use of mcjty.lib.gui.layout.PositionalLayout in project XNet by McJty.
the class GuiController method initEditPanels.
private void initEditPanels() {
channelEditPanel = new Panel(mc, this).setLayout(new PositionalLayout()).setFilledRectThickness(-1).setFilledBackground(StyleConfig.colorListBackground).setLayoutHint(new PositionalLayout.PositionalHint(171, 5, 161, 37));
connectorEditPanel = new Panel(mc, this).setLayout(new PositionalLayout()).setFilledRectThickness(-1).setFilledBackground(StyleConfig.colorListBackground).setLayoutHint(new PositionalLayout.PositionalHint(171, 45, 161, 108));
}
use of mcjty.lib.gui.layout.PositionalLayout in project XNet by McJty.
the class GuiRouter method makeChannelLine.
private Panel makeChannelLine(ControllerChannelClientInfo channel, boolean local) {
String name = channel.getChannelName();
String publishedName = channel.getPublishedName();
BlockPos controllerPos = channel.getPos();
IChannelType type = channel.getChannelType();
int index = channel.getIndex();
Panel panel = new Panel(mc, this).setLayout(new PositionalLayout()).setDesiredHeight(30);
Panel panel1 = new Panel(mc, this).setLayout(new HorizontalLayout().setHorizontalMargin(0).setSpacing(0)).setLayoutHint(new PositionalLayout.PositionalHint(0, 0, 160, 13));
panel1.addChild(new Label<>(mc, this).setText("Ch").setColor(0xff2244aa));
panel1.addChild(new Label<>(mc, this).setText(name));
panel1.addChild(new Label<>(mc, this).setText(">").setColor(0xff2244aa));
if (local) {
TextField pubName = new TextField(mc, this).setText(publishedName).setDesiredWidth(50).setDesiredHeight(13).addTextEvent((parent, newText) -> updatePublish(controllerPos, index, newText));
panel1.addChild(pubName);
} else {
panel1.addChild(new Label<>(mc, this).setText(publishedName).setColor(0xff33ff00));
}
Panel panel2 = new Panel(mc, this).setLayout(new HorizontalLayout().setHorizontalMargin(0).setSpacing(0)).setLayoutHint(new PositionalLayout.PositionalHint(0, 13, 160, 13));
panel2.addChild(new Label<>(mc, this).setText("Pos").setColor(0xff2244aa));
panel2.addChild(new Label<>(mc, this).setText(BlockPosTools.toString(controllerPos)));
Panel panel3 = new Panel(mc, this).setLayout(new HorizontalLayout().setHorizontalMargin(0).setSpacing(0)).setLayoutHint(new PositionalLayout.PositionalHint(0, 26, 160, 13));
panel3.addChild(new Label<>(mc, this).setText("Index").setColor(0xff2244aa));
panel3.addChild(new Label<>(mc, this).setText(index + " (" + type.getName() + ")"));
panel.addChild(panel1).addChild(panel2).addChild(panel3);
return panel;
}
use of mcjty.lib.gui.layout.PositionalLayout in project RFToolsControl by McJty.
the class GuiProgrammer method initGui.
@Override
public void initGui() {
super.initGui();
// --- Main window ---
Panel editorPanel = setupEditorPanel();
Panel controlPanel = setupControlPanel();
Panel gridPanel = setupGridPanel();
Panel toplevel = new Panel(mc, this).setLayout(new PositionalLayout()).setBackground(mainBackground).addChild(editorPanel).addChild(controlPanel).addChild(gridPanel);
toplevel.setBounds(new Rectangle(guiLeft, guiTop, xSize, ySize));
window = new Window(this, toplevel).addFocusEvent((parent, focused) -> selectIcon(parent, focused));
// --- Side window ---
Panel listPanel = setupListPanel();
Panel sidePanel = new Panel(mc, this).setLayout(new PositionalLayout()).setBackground(sideBackground).addChild(listPanel);
sidePanel.setBounds(new Rectangle(guiLeft - SIDEWIDTH, guiTop, SIDEWIDTH, ySize));
sideWindow = new Window(this, sidePanel);
loadProgram(ProgrammerContainer.SLOT_DUMMY);
clearCategoryLabels();
}
use of mcjty.lib.gui.layout.PositionalLayout in project RFToolsControl by McJty.
the class GuiProgrammer method setupGridPanel.
private Panel setupGridPanel() {
Panel panel = new Panel(mc, this).setLayout(new PositionalLayout()).setLayoutHint(new PositionalLayout.PositionalHint(5, 5, 246, 130));
gridList = new WidgetList(mc, this).setLayoutHint(new PositionalLayout.PositionalHint(0, 0, 236, 130)).setPropagateEventsToChildren(true).setInvisibleSelection(true).setDrawHorizontalLines(false).setRowheight(ICONSIZE + 1);
Slider slider = new Slider(mc, this).setVertical().setScrollable(gridList).setLayoutHint(new PositionalLayout.PositionalHint(237, 0, 9, 130));
for (int y = 0; y < GRID_HEIGHT; y++) {
Panel rowPanel = new Panel(mc, this).setLayout(new HorizontalLayout().setSpacing(-1).setHorizontalMargin(0).setVerticalMargin(0));
for (int x = 0; x < GRID_WIDTH; x++) {
int finalX = x;
int finalY = y;
IconHolder holder = new IconHolder(mc, this) {
@Override
public List<String> getTooltips() {
return getGridIconTooltips(finalX, finalY);
}
}.setDesiredWidth(ICONSIZE + 2).setDesiredHeight(ICONSIZE + 2).setBorder(1).setBorderColor(0xff777777).setSelectable(true).setUserObject(new GridPos(finalX, finalY)).addIconHoverEvent(((iconHolder, iIcon, dx, dy) -> {
handleConnectorHighlight(finalX, finalY, iIcon, dx, dy);
})).addIconLeavesEvent(((parent, icon) -> {
iconLeavesFromX = finalX;
iconLeavesFromY = finalY;
return true;
})).addIconArrivesEvent(((parent, icon) -> {
if (icon != null && !loading) {
handleNewIconOverlay(icon, finalX, finalY);
}
return true;
})).addIconClickedEvent((parent, icon, dx, dy) -> {
gridIconClicked(icon, finalX, finalY, dx, dy);
return true;
});
rowPanel.addChild(holder);
}
gridList.addChild(rowPanel);
}
panel.addChild(gridList).addChild(slider);
return panel;
}
use of mcjty.lib.gui.layout.PositionalLayout in project RFToolsControl by McJty.
the class GuiProgrammer method openValueEditor.
private void openValueEditor(IIcon icon, IconHolder iconHolder, ParameterDescription parameter, TextField field, boolean constantOnly) {
ParameterEditor editor = ParameterEditors.getEditor(parameter.getType());
Panel editPanel;
if (editor != null) {
editPanel = new Panel(mc, this).setLayout(new PositionalLayout()).setFilledRectThickness(1);
Map<String, Object> data = icon.getData() == null ? Collections.emptyMap() : icon.getData();
editor.build(mc, this, editPanel, o -> {
icon.addData(parameter.getName(), o);
field.setText(ParameterTypeTools.stringRepresentation(parameter.getType(), o));
});
editor.writeValue((ParameterValue) data.get(parameter.getName()));
if (constantOnly) {
editor.constantOnly();
}
} else {
return;
}
Panel panel = new Panel(mc, this).setLayout(new VerticalLayout()).setFilledBackground(0xff666666, 0xffaaaaaa).setFilledRectThickness(1);
panel.setBounds(new Rectangle(50, 25, 200, 60 + editor.getHeight()));
Window modalWindow = getWindowManager().createModalWindow(panel);
panel.addChild(new Label(mc, this).setText(StringUtils.capitalize(parameter.getName()) + ":"));
panel.addChild(editPanel);
panel.addChild(new Button(mc, this).addButtonEvent(w -> {
getWindowManager().closeWindow(modalWindow);
window.setTextFocus(iconHolder);
}).setText("Close"));
editor.initialFocus(modalWindow);
editor.setOnClose(() -> window.setTextFocus(iconHolder));
}
Aggregations