package Common.UI.Menus_2023;
import Common.Current;
import Common.UI.Themes.VisualiserFonts;
import Common.Utils.Utils;
import Visual_DVM_2021.Passes.PassCode_2021;
import Visual_DVM_2021.Passes.Pass_2021;

import javax.swing.*;
import java.awt.*;
//https://java-online.ru/swing-menu.xhtml
public class VisualiserMenuBar extends JToolBar {
    public VisualiserMenuBar() {
        setFloatable(false);
        setSizeLimits();
    }
    public void addPasses(PassCode_2021... codes) {
        //- кнопки. связать их с проходами. (!)
        for (PassCode_2021 code : codes)
            add(Pass_2021.passes.get(code).createButton());
    }
    public JMenuBar addMenus(JMenu... menus) {
        JMenuBar bar = new JMenuBar() {
            {
                for (JMenu menu : menus)
                    add(menu);
            }
        };
        add(bar);
        return bar;
    }
    public JLabel addLabel(String text_in) {
        return addLabel(text_in, null);
    }
    public JLabel addLabel(String text_in, String icon_path_in) {
        JLabel res = new JLabel(text_in) {
            {
                setFont(Current.getTheme().Fonts.get(VisualiserFonts.TreeItalic));
                if (icon_path_in != null) {
                    setIcon(Utils.getIcon(icon_path_in));
                }
            }
        };
        add(res);
        return res;
    }
    public void setSizeLimits() {
        setPreferredSize(new Dimension(0, 30));
    }
}
