Search in sources :

Example 6 with Alignment

use of com.github.weisj.darklaf.util.Alignment in project darklaf by weisJ.

the class DarkPanelPopupUI method updateBorder.

protected void updateBorder(final boolean notifyPeer) {
    if (popupComponent.getTabFrame() != null) {
        JTabFrame tabFrame = popupComponent.getTabFrame();
        boolean[] status = tabFrame.getContentPane().getStatus();
        Alignment alignment = popupComponent.getAlignment();
        Insets insets = getBorderSize(tabFrame, alignment, status);
        applyBorderInsets(insets);
        Component component = popupComponent.getComponent();
        popupComponent.doLayout();
        popupComponent.repaint();
        if (component != null && component != popupComponent) {
            component.doLayout();
            component.repaint();
        }
        if (header != null) {
            Component headerParent = header.getParent();
            if (headerParent != null) {
                headerParent.doLayout();
                headerParent.repaint();
            }
        }
        if (notifyPeer) {
            try {
                Component peer = tabFrame.getPopupComponentAt(tabFrame.getPeer(popupComponent.getAlignment()));
                peer.firePropertyChange(TabFramePopup.KEY_PEER_INSETS, 0, 1);
            } catch (final IndexOutOfBoundsException ignored) {
            /* may happen during transfer */
            }
        }
    }
}
Also used : Alignment(com.github.weisj.darklaf.util.Alignment) JTabFrame(com.github.weisj.darklaf.components.tabframe.JTabFrame)

Example 7 with Alignment

use of com.github.weisj.darklaf.util.Alignment in project darklaf by weisJ.

the class ToolTipDemo method createComponent.

@Override
public JComponent createComponent() {
    JButton button = new JButton("Demo Button", DemoResources.FOLDER_ICON);
    DemoPanel panel = new DemoPanel(button);
    ToolTipContext context = new ToolTipContext(button).setAlignment(Alignment.CENTER).setCenterAlignment(Alignment.SOUTH);
    ToolTipContext.setDefaultContext(context);
    button.setToolTipText(StringUtil.toHtml("<p style=\"color:red;\">This is the ToolTip demo text!\n" + "<p style=\"color:blue;\">This is the ToolTip demo text!\n" + "<p style=\"color:green;\">This is the ToolTip demo text!\n"));
    button.putClientProperty(DarkToolTipUI.KEY_STYLE, DarkToolTipUI.VARIANT_BALLOON);
    button.putClientProperty(DarkToolTipUI.KEY_CONTEXT, context);
    JPanel controlPanel = panel.addControls(3);
    controlPanel.add(new JCheckBox("Align inside") {

        {
            setSelected(context.isAlignInside());
            addActionListener(e -> context.setAlignInside(isSelected()));
        }
    });
    controlPanel.add(new JCheckBox("Ignore Border") {

        {
            setSelected(context.isIgnoreBorder());
            addActionListener(e -> context.setIgnoreBorder(isSelected()));
        }
    });
    controlPanel.add(new JCheckBox("Use best fit") {

        {
            setSelected(context.isBestFit());
            addActionListener(e -> context.setUseBestFit(isSelected()));
        }
    });
    controlPanel = panel.addControls();
    controlPanel.add(new JLabel("Tooltip Style:", JLabel.RIGHT));
    controlPanel.add(new JComboBox<ToolTipStyle>(ToolTipStyle.values()) {

        {
            setSelectedItem(ToolTipStyle.BALLOON);
            addItemListener(e -> button.putClientProperty(DarkToolTipUI.KEY_STYLE, e.getItem()));
        }
    }, "sgx");
    controlPanel.add(new JLabel("Alignment:", JLabel.RIGHT));
    controlPanel.add(new JComboBox<Alignment>(Alignment.values()) {

        {
            setSelectedItem(context.getAlignment());
            addItemListener(e -> context.setAlignment((Alignment) e.getItem()));
        }
    }, "sgx");
    controlPanel.add(new JLabel("Center Alignment:", JLabel.RIGHT));
    controlPanel.add(new JComboBox<Alignment>(Alignment.values()) {

        {
            setSelectedItem(context.getCenterAlignment());
            addItemListener(e -> context.setCenterAlignment((Alignment) e.getItem()));
        }
    }, "sgx");
    controlPanel.add(new JLabel("Alignment Strategy:", JLabel.RIGHT));
    controlPanel.add(new JComboBox<AlignmentStrategy>(AlignmentStrategy.values()) {

        {
            setSelectedItem(context.getAlignmentStrategy());
            addItemListener(e -> context.setAlignmentStrategy((AlignmentStrategy) e.getItem()));
        }
    }, "sgx");
    return panel;
}
Also used : DemoExecutor(com.github.weisj.darklaf.ui.demo.DemoExecutor) BaseComponentDemo(com.github.weisj.darklaf.ui.demo.BaseComponentDemo) Alignment(com.github.weisj.darklaf.util.Alignment) AlignmentStrategy(com.github.weisj.darklaf.components.alignment.AlignmentStrategy) ToolTipContext(com.github.weisj.darklaf.components.tooltip.ToolTipContext) ToolTipStyle(com.github.weisj.darklaf.components.tooltip.ToolTipStyle) DemoPanel(com.github.weisj.darklaf.ui.DemoPanel) StringUtil(com.github.weisj.darklaf.util.StringUtil) DemoResources(com.github.weisj.darklaf.ui.DemoResources) javax.swing(javax.swing) DarkToolTipUI(com.github.weisj.darklaf.ui.tooltip.DarkToolTipUI) DemoPanel(com.github.weisj.darklaf.ui.DemoPanel) ToolTipStyle(com.github.weisj.darklaf.components.tooltip.ToolTipStyle) Alignment(com.github.weisj.darklaf.util.Alignment) ToolTipContext(com.github.weisj.darklaf.components.tooltip.ToolTipContext) AlignmentStrategy(com.github.weisj.darklaf.components.alignment.AlignmentStrategy)

Example 8 with Alignment

use of com.github.weisj.darklaf.util.Alignment in project darklaf by weisJ.

the class JTabFrame method notifySelectionChange.

/**
 * Notify the tabFrame that a selection has changed.
 *
 * @param tabComponent the tab at which the selection has changed.
 */
public void notifySelectionChange(final TabFrameTab tabComponent) {
    if (tabComponent == null) {
        return;
    }
    Alignment a = tabComponent.getOrientation();
    selectedIndices[a.ordinal()] = tabComponent.isSelected() ? tabComponent.getIndex() : -1;
    if (tabComponent.isSelected()) {
        for (TabFrameTab tc : tabsForAlignment(a)) {
            if (tc != null && tc != tabComponent) {
                tc.setSelected(false);
            }
        }
    }
}
Also used : Alignment(com.github.weisj.darklaf.util.Alignment)

Example 9 with Alignment

use of com.github.weisj.darklaf.util.Alignment in project darklaf by weisJ.

the class JTabFrame method setPopupVisibility.

/*
     * Set the visibility of the popup.
     */
private void setPopupVisibility(final TabFrameTab tabComponent, final boolean selected) {
    Alignment a = tabComponent.getOrientation();
    TabFramePopup c = compsForAlignment(a).get(tabComponent.getIndex());
    c.setEnabled(selected);
    content.setComponentAt(a, c.getComponent());
    content.setEnabled(a, selected);
    doLayout();
}
Also used : Alignment(com.github.weisj.darklaf.util.Alignment)

Example 10 with Alignment

use of com.github.weisj.darklaf.util.Alignment in project darklaf by weisJ.

the class JTabFrame method moveTab.

/**
 * Move a tab to a new position.
 *
 * @param tabComp the tab to move.
 * @param a the new alignment position.{@link TabFramePosition#getAlignment()}
 */
public void moveTab(final TabFrameTab tabComp, final Alignment a) {
    if (a == tabComp.getOrientation()) {
        return;
    }
    boolean oldSelected = tabComp.isSelected();
    Alignment oldAlign = tabComp.getOrientation();
    int oldIndex = tabComp.getIndex();
    closeTab(oldAlign, oldIndex);
    TabFramePopup comp = compsForAlignment(oldAlign).get(oldIndex);
    removeTab(oldAlign, oldIndex);
    addTab(comp, tabComp, a);
    if (oldSelected) {
        openTab(a, tabComp.getIndex());
    }
    doLayout();
    getTabContainer(a).repaint();
}
Also used : Alignment(com.github.weisj.darklaf.util.Alignment)

Aggregations

Alignment (com.github.weisj.darklaf.util.Alignment)26 JTabFrame (com.github.weisj.darklaf.components.tabframe.JTabFrame)6 TabFrameUI (com.github.weisj.darklaf.components.tabframe.TabFrameUI)3 ToolTipContext (com.github.weisj.darklaf.components.tooltip.ToolTipContext)2 DemoPanel (com.github.weisj.darklaf.ui.DemoPanel)2 OverlayScrollPane (com.github.weisj.darklaf.components.OverlayScrollPane)1 AlignmentStrategy (com.github.weisj.darklaf.components.alignment.AlignmentStrategy)1 TabFrameTab (com.github.weisj.darklaf.components.tabframe.TabFrameTab)1 TabbedPopup (com.github.weisj.darklaf.components.tabframe.TabbedPopup)1 ToolTipStyle (com.github.weisj.darklaf.components.tooltip.ToolTipStyle)1 DarkSVGIcon (com.github.weisj.darklaf.properties.icons.DarkSVGIcon)1 RotatableIcon (com.github.weisj.darklaf.properties.icons.RotatableIcon)1 DemoResources (com.github.weisj.darklaf.ui.DemoResources)1 BaseComponentDemo (com.github.weisj.darklaf.ui.demo.BaseComponentDemo)1 DemoExecutor (com.github.weisj.darklaf.ui.demo.DemoExecutor)1 AlignableTooltipBorder (com.github.weisj.darklaf.ui.tooltip.AlignableTooltipBorder)1 DarkToolTipUI (com.github.weisj.darklaf.ui.tooltip.DarkToolTipUI)1 Pair (com.github.weisj.darklaf.util.Pair)1 StringUtil (com.github.weisj.darklaf.util.StringUtil)1 UnsupportedFlavorException (java.awt.datatransfer.UnsupportedFlavorException)1