CottonMC / LibGui

Buttons & Co
MIT License
291 stars 47 forks source link

Potential WTabPanel bug #211

Closed Type-32 closed 1 year ago

Type-32 commented 1 year ago

Describe the bug The WTabPanel renders tabs' the background as a panel.

Code

package cn.crtlprototypestudios.controlui.gui;
import io.github.cottonmc.cotton.gui.client.LightweightGuiDescription;
import io.github.cottonmc.cotton.gui.widget.WGridPanel;
import io.github.cottonmc.cotton.gui.widget.WLabel;
import io.github.cottonmc.cotton.gui.widget.WTabPanel;
import io.github.cottonmc.cotton.gui.widget.WText;
import io.github.cottonmc.cotton.gui.widget.data.HorizontalAlignment;
import io.github.cottonmc.cotton.gui.widget.data.Insets;
import io.github.cottonmc.cotton.gui.widget.data.VerticalAlignment;
import net.minecraft.text.Text;

import javax.swing.*;

public class MainGUI extends LightweightGuiDescription {
    public MainGUI() {
        // Root
        WTabPanel tabs = new WTabPanel();
//        tabs.setSize(300,200);
        setRootPanel(tabs);

        // Main Menu
        WGridPanel menu = new WGridPanel();
        menu.setSize(300,200);

        WLabel menuTitle = new WLabel(Text.translatable("gui.control_ui.menus.main.title"));
        menu.add(menuTitle, 0, 0, 4, 1);
        menuTitle.setHorizontalAlignment(HorizontalAlignment.CENTER).setVerticalAlignment(VerticalAlignment.TOP);

        // Mine Menu
        WGridPanel mine = new WGridPanel();
        mine.setSize(300,200);

        WLabel mineTitle = new WLabel(Text.translatable("gui.control_ui.menus.mine.title"));
        mine.add(mineTitle, 0, 0, 4, 1);
        mineTitle.setHorizontalAlignment(HorizontalAlignment.CENTER).setVerticalAlignment(VerticalAlignment.TOP);

        // Add tabs
        tabs.add(menu, tab -> tab.title(Text.translatable("gui.control_ui.tabs.main")));
        tabs.add(mine, tab -> tab.title(Text.translatable("gui.control_ui.tabs.mine")));
        tabs.add(new WGridPanel(), tab -> tab.title(Text.translatable("gui.control_ui.tabs.goal")));
        tabs.add(new WGridPanel(), tab -> tab.title(Text.translatable("gui.control_ui.tabs.waypoint")));
        tabs.add(new WGridPanel(), tab -> tab.title(Text.translatable("gui.control_ui.tabs.settings")));

        tabs.validate(this);
    }
}

Expected behavior Optional The WTabPanel shouldn't render a Panel background behind the tabs.

Screenshots Optional

Screenshot 2023-08-24 at 08 10 19

Version of the (please complete the following information):

Additional context Optional Is this an intended effect?

Type-32 commented 1 year ago

Also there are some pages in the documentation I can't access. It just shows red and clicking on it brings me back to the main page.

Juuxel commented 1 year ago

That is the background drawn by the default background painter used for all root panels in LibGui.

You can disable it by overriding GuiDescription.addPainters to do nothing.