Search in sources :

Example 1 with VisualPaddingProvider

use of com.github.weisj.swingdsl.visualpadding.VisualPaddingProvider in project darklaf by weisJ.

the class ThemeSettingsPanel method createMonitorSettings.

private Component createMonitorSettings(final GroupLayout.Alignment alignment, final Insets insets) {
    TristateCheckBox enabledSystemPreferences = settingsUI.getSystemPreferencesTristateCheckBox();
    Insets ins = new Insets(insets.top, insets.left, insets.bottom, insets.right);
    if (alignment == GroupLayout.Alignment.LEADING) {
        Insets padding = ((VisualPaddingProvider) enabledSystemPreferences.getBorder()).getVisualPaddings(enabledSystemPreferences);
        ins = DarkUIUtil.addInsets(ins, DarkUIUtil.invert(padding));
    }
    JPanel panel = DynamicUI.withDynamic(new JPanel(new BorderLayout()), c -> c.setBorder(BorderFactory.createTitledBorder(UIManager.getString(ThemeSettingsUI.MONITORING_LABEL_KEY, getLocale()))));
    JComponent c = LayoutHelper.createTwoColumnPanel(new JComponent[] { enabledSystemPreferences, settingsUI.getThemeFollowsSystemCheckBox(), settingsUI.getAccentColorFollowsSystemCheckBox() }, new JComponent[] { new JLabel(), settingsUI.getFontSizeFollowsSystemCheckBox(), settingsUI.getSelectionColorFollowsSystemCheckBox() }, GroupLayout.Alignment.LEADING, GroupLayout.Alignment.LEADING);
    c.setBorder(LayoutHelper.createEmptyBorder(ins));
    panel.add(c);
    return panel;
}
Also used : TristateCheckBox(com.github.weisj.darklaf.components.tristate.TristateCheckBox) VisualPaddingProvider(com.github.weisj.swingdsl.visualpadding.VisualPaddingProvider)

Example 2 with VisualPaddingProvider

use of com.github.weisj.swingdsl.visualpadding.VisualPaddingProvider in project darklaf by weisJ.

the class DarkSliderUI method getBaseline.

@Override
public int getBaseline(JComponent c, int width, int height) {
    if (isHorizontal() && PropertyUtil.getBooleanProperty(c, KEY_USE_TRACK_AS_BASELINE)) {
        int thumbY = focusInsets.top + trackBuffer;
        if (isPlainThumb()) {
            Dimension thumbSize = getThumbSize();
            return thumbY + thumbSize.height - focusBorderSize;
        } else {
            Icon icon = getThumbIcon();
            int baseline = thumbY + icon.getIconHeight();
            if (icon instanceof RotatableIcon) {
                icon = ((RotatableIcon) icon).getIcon();
            }
            if (icon instanceof VisualPaddingProvider) {
                baseline -= ((VisualPaddingProvider) icon).getVisualPaddings(slider).bottom;
            }
            return baseline;
        }
    } else {
        return super.getBaseline(c, width, height);
    }
}
Also used : VisualPaddingProvider(com.github.weisj.swingdsl.visualpadding.VisualPaddingProvider) RotatableIcon(com.github.weisj.darklaf.properties.icons.RotatableIcon) RotatableIcon(com.github.weisj.darklaf.properties.icons.RotatableIcon)

Aggregations

VisualPaddingProvider (com.github.weisj.swingdsl.visualpadding.VisualPaddingProvider)2 TristateCheckBox (com.github.weisj.darklaf.components.tristate.TristateCheckBox)1 RotatableIcon (com.github.weisj.darklaf.properties.icons.RotatableIcon)1