Search in sources :

Example 11 with PositionalLayout

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));
}
Also used : Panel(mcjty.lib.gui.widgets.Panel) PositionalLayout(mcjty.lib.gui.layout.PositionalLayout)

Example 12 with PositionalLayout

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;
}
Also used : Panel(mcjty.lib.gui.widgets.Panel) PositionalLayout(mcjty.lib.gui.layout.PositionalLayout) Label(mcjty.lib.gui.widgets.Label) TextField(mcjty.lib.gui.widgets.TextField) BlockPos(net.minecraft.util.math.BlockPos) IChannelType(mcjty.xnet.api.channels.IChannelType) HorizontalLayout(mcjty.lib.gui.layout.HorizontalLayout)

Example 13 with PositionalLayout

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();
}
Also used : Window(mcjty.lib.gui.Window) GenericGuiContainer(mcjty.lib.container.GenericGuiContainer) ProgramCardInstance(mcjty.rftoolscontrol.logic.grid.ProgramCardInstance) GeneralConfiguration(mcjty.rftoolscontrol.config.GeneralConfiguration) OpcodeCategory(mcjty.rftoolscontrol.api.code.OpcodeCategory) Opcode(mcjty.rftoolscontrol.api.code.Opcode) ParameterDescription(mcjty.rftoolscontrol.api.parameters.ParameterDescription) ParameterEditors(mcjty.rftoolscontrol.logic.editors.ParameterEditors) Keyboard(org.lwjgl.input.Keyboard) StringUtils(org.apache.commons.lang3.StringUtils) StyleConfig(mcjty.lib.base.StyleConfig) Panel(mcjty.lib.gui.widgets.Panel) Pair(org.apache.commons.lang3.tuple.Pair) PositionalLayout(mcjty.lib.gui.layout.PositionalLayout) ParameterEditor(mcjty.rftoolscontrol.logic.editors.ParameterEditor) Clipboard(java.awt.datatransfer.Clipboard) UnsupportedFlavorException(java.awt.datatransfer.UnsupportedFlavorException) ParameterTypeTools(mcjty.rftoolscontrol.logic.registry.ParameterTypeTools) VerticalLayout(mcjty.lib.gui.layout.VerticalLayout) List(java.util.List) Button(mcjty.lib.gui.widgets.Button) IIcon(mcjty.lib.gui.icons.IIcon) Connection(mcjty.rftoolscontrol.logic.Connection) TextField(mcjty.lib.gui.widgets.TextField) java.util(java.util) mcjty.lib.gui.widgets(mcjty.lib.gui.widgets) ParameterValue(mcjty.rftoolscontrol.api.parameters.ParameterValue) DataFlavor(java.awt.datatransfer.DataFlavor) HorizontalAlignment(mcjty.lib.gui.layout.HorizontalAlignment) OpcodeOutput(mcjty.rftoolscontrol.api.code.OpcodeOutput) Label(mcjty.lib.gui.widgets.Label) Window(mcjty.lib.gui.Window) GridInstance(mcjty.rftoolscontrol.logic.grid.GridInstance) ItemStack(net.minecraft.item.ItemStack) HorizontalLayout(mcjty.lib.gui.layout.HorizontalLayout) ProgramValidator(mcjty.rftoolscontrol.logic.compiled.ProgramValidator) GuiTools(mcjty.rftoolscontrol.gui.GuiTools) Logging(mcjty.lib.varia.Logging) ProgramCardItem(mcjty.rftoolscontrol.items.ProgramCardItem) StringSelection(java.awt.datatransfer.StringSelection) RFToolsControl(mcjty.rftoolscontrol.RFToolsControl) Parameter(mcjty.rftoolscontrol.api.parameters.Parameter) RFToolsCtrlMessages(mcjty.rftoolscontrol.network.RFToolsCtrlMessages) GridPos(mcjty.rftoolscontrol.logic.grid.GridPos) SelectionEvent(mcjty.lib.gui.events.SelectionEvent) Opcodes(mcjty.rftoolscontrol.logic.registry.Opcodes) TextFormatting(net.minecraft.util.text.TextFormatting) IOException(java.io.IOException) WindowManager(mcjty.lib.gui.WindowManager) java.awt(java.awt) Slot(net.minecraft.inventory.Slot) ResourceLocation(net.minecraft.util.ResourceLocation) ImageIcon(mcjty.lib.gui.icons.ImageIcon) ClickType(net.minecraft.inventory.ClickType) Panel(mcjty.lib.gui.widgets.Panel) PositionalLayout(mcjty.lib.gui.layout.PositionalLayout)

Example 14 with PositionalLayout

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;
}
Also used : GenericGuiContainer(mcjty.lib.container.GenericGuiContainer) ProgramCardInstance(mcjty.rftoolscontrol.logic.grid.ProgramCardInstance) GeneralConfiguration(mcjty.rftoolscontrol.config.GeneralConfiguration) OpcodeCategory(mcjty.rftoolscontrol.api.code.OpcodeCategory) Opcode(mcjty.rftoolscontrol.api.code.Opcode) ParameterDescription(mcjty.rftoolscontrol.api.parameters.ParameterDescription) ParameterEditors(mcjty.rftoolscontrol.logic.editors.ParameterEditors) Keyboard(org.lwjgl.input.Keyboard) StringUtils(org.apache.commons.lang3.StringUtils) StyleConfig(mcjty.lib.base.StyleConfig) Panel(mcjty.lib.gui.widgets.Panel) Pair(org.apache.commons.lang3.tuple.Pair) PositionalLayout(mcjty.lib.gui.layout.PositionalLayout) ParameterEditor(mcjty.rftoolscontrol.logic.editors.ParameterEditor) Clipboard(java.awt.datatransfer.Clipboard) UnsupportedFlavorException(java.awt.datatransfer.UnsupportedFlavorException) ParameterTypeTools(mcjty.rftoolscontrol.logic.registry.ParameterTypeTools) VerticalLayout(mcjty.lib.gui.layout.VerticalLayout) List(java.util.List) Button(mcjty.lib.gui.widgets.Button) IIcon(mcjty.lib.gui.icons.IIcon) Connection(mcjty.rftoolscontrol.logic.Connection) TextField(mcjty.lib.gui.widgets.TextField) java.util(java.util) mcjty.lib.gui.widgets(mcjty.lib.gui.widgets) ParameterValue(mcjty.rftoolscontrol.api.parameters.ParameterValue) DataFlavor(java.awt.datatransfer.DataFlavor) HorizontalAlignment(mcjty.lib.gui.layout.HorizontalAlignment) OpcodeOutput(mcjty.rftoolscontrol.api.code.OpcodeOutput) Label(mcjty.lib.gui.widgets.Label) Window(mcjty.lib.gui.Window) GridInstance(mcjty.rftoolscontrol.logic.grid.GridInstance) ItemStack(net.minecraft.item.ItemStack) HorizontalLayout(mcjty.lib.gui.layout.HorizontalLayout) ProgramValidator(mcjty.rftoolscontrol.logic.compiled.ProgramValidator) GuiTools(mcjty.rftoolscontrol.gui.GuiTools) Logging(mcjty.lib.varia.Logging) ProgramCardItem(mcjty.rftoolscontrol.items.ProgramCardItem) StringSelection(java.awt.datatransfer.StringSelection) RFToolsControl(mcjty.rftoolscontrol.RFToolsControl) Parameter(mcjty.rftoolscontrol.api.parameters.Parameter) RFToolsCtrlMessages(mcjty.rftoolscontrol.network.RFToolsCtrlMessages) GridPos(mcjty.rftoolscontrol.logic.grid.GridPos) SelectionEvent(mcjty.lib.gui.events.SelectionEvent) Opcodes(mcjty.rftoolscontrol.logic.registry.Opcodes) TextFormatting(net.minecraft.util.text.TextFormatting) IOException(java.io.IOException) WindowManager(mcjty.lib.gui.WindowManager) java.awt(java.awt) Slot(net.minecraft.inventory.Slot) ResourceLocation(net.minecraft.util.ResourceLocation) ImageIcon(mcjty.lib.gui.icons.ImageIcon) ClickType(net.minecraft.inventory.ClickType) Panel(mcjty.lib.gui.widgets.Panel) GridPos(mcjty.rftoolscontrol.logic.grid.GridPos) PositionalLayout(mcjty.lib.gui.layout.PositionalLayout) HorizontalLayout(mcjty.lib.gui.layout.HorizontalLayout)

Example 15 with PositionalLayout

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));
}
Also used : Window(mcjty.lib.gui.Window) Panel(mcjty.lib.gui.widgets.Panel) Button(mcjty.lib.gui.widgets.Button) PositionalLayout(mcjty.lib.gui.layout.PositionalLayout) Label(mcjty.lib.gui.widgets.Label) VerticalLayout(mcjty.lib.gui.layout.VerticalLayout) ParameterEditor(mcjty.rftoolscontrol.logic.editors.ParameterEditor)

Aggregations

PositionalLayout (mcjty.lib.gui.layout.PositionalLayout)62 Window (mcjty.lib.gui.Window)53 Panel (mcjty.lib.gui.widgets.Panel)47 Label (mcjty.lib.gui.widgets.Label)25 Argument (mcjty.lib.network.Argument)19 GenericGuiContainer (mcjty.lib.container.GenericGuiContainer)18 ResourceLocation (net.minecraft.util.ResourceLocation)18 mcjty.lib.gui.widgets (mcjty.lib.gui.widgets)16 HorizontalAlignment (mcjty.lib.gui.layout.HorizontalAlignment)15 Button (mcjty.lib.gui.widgets.Button)15 RFToolsMessages (mcjty.rftools.network.RFToolsMessages)15 ItemStack (net.minecraft.item.ItemStack)15 Rectangle (java.awt.Rectangle)14 StyleConfig (mcjty.lib.base.StyleConfig)14 RFTools (mcjty.rftools.RFTools)14 java.awt (java.awt)13 TextField (mcjty.lib.gui.widgets.TextField)13 HorizontalLayout (mcjty.lib.gui.layout.HorizontalLayout)11 List (java.util.List)9 Slot (net.minecraft.inventory.Slot)9