From 69f52c8abd7f14ad028f499b51a9c3ef30a097ad Mon Sep 17 00:00:00 2001 From: Karl Tauber Date: Sat, 27 Mar 2021 17:48:58 +0100 Subject: [PATCH] JIDE: JideTabbedPane: scale tab gripper --- .../flatlaf/jideoss/ui/FlatJidePainter.java | 18 ++++++++++++++++++ .../jideoss/ui/FlatJideTabbedPaneUI.java | 1 + .../jideoss/FlatJideOssContainerTest.java | 14 ++++++++++++++ .../jideoss/FlatJideOssContainerTest.jfd | 10 ++++++++++ 4 files changed, 43 insertions(+) diff --git a/flatlaf-jide-oss/src/main/java/com/formdev/flatlaf/jideoss/ui/FlatJidePainter.java b/flatlaf-jide-oss/src/main/java/com/formdev/flatlaf/jideoss/ui/FlatJidePainter.java index 56f8fb1e..9930c1e1 100644 --- a/flatlaf-jide-oss/src/main/java/com/formdev/flatlaf/jideoss/ui/FlatJidePainter.java +++ b/flatlaf-jide-oss/src/main/java/com/formdev/flatlaf/jideoss/ui/FlatJidePainter.java @@ -107,4 +107,22 @@ public class FlatJidePainter } else super.paintBackground( c, g, rect, borderColor, background, orientation ); } + + @Override + public void paintGripper( JComponent c, Graphics g, Rectangle rect, int orientation, int state ) { + float userScaleFactor = UIScale.getUserScaleFactor(); + if( userScaleFactor > 1 ) { + // scale gripper + Graphics2D g2 = (Graphics2D) g.create(); + try { + g2.translate( rect.x, rect.y ); + g2.scale( userScaleFactor, userScaleFactor ); + Rectangle rect2 = new Rectangle( 0, 0, UIScale.unscale( rect.width ), UIScale.unscale( rect.height ) ); + super.paintGripper( c, g2, rect2, orientation, state ); + } finally { + g2.dispose(); + } + } else + super.paintGripper( c, g, rect, orientation, state ); + } } diff --git a/flatlaf-jide-oss/src/main/java/com/formdev/flatlaf/jideoss/ui/FlatJideTabbedPaneUI.java b/flatlaf-jide-oss/src/main/java/com/formdev/flatlaf/jideoss/ui/FlatJideTabbedPaneUI.java index 14a94add..02bba2a9 100644 --- a/flatlaf-jide-oss/src/main/java/com/formdev/flatlaf/jideoss/ui/FlatJideTabbedPaneUI.java +++ b/flatlaf-jide-oss/src/main/java/com/formdev/flatlaf/jideoss/ui/FlatJideTabbedPaneUI.java @@ -151,6 +151,7 @@ public class FlatJideTabbedPaneUI case JideTabbedPane.PROPERTY_TAB_AREA_INSETS: case JideTabbedPane.PROPERTY_TAB_INSETS: + case JideTabbedPane.GRIPPER_PROPERTY: case TABBED_PANE_SHOW_TAB_SEPARATORS: case TABBED_PANE_HAS_FULL_BORDER: _tabPane.revalidate(); diff --git a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/jideoss/FlatJideOssContainerTest.java b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/jideoss/FlatJideOssContainerTest.java index a8cbd3a4..6b185cb1 100644 --- a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/jideoss/FlatJideOssContainerTest.java +++ b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/jideoss/FlatJideOssContainerTest.java @@ -369,6 +369,13 @@ public class FlatJideOssContainerTest tabbedPane.setShowTabButtons( showTabButtons ); } + private void showGripperChanged() { + boolean showGripper = showGripperCheckBox.isSelected(); + + for( JideTabbedPane tabbedPane : allTabbedPanes ) + tabbedPane.setShowGripper( showGripper ); + } + private void initComponents() { // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents JPanel panel9 = new JPanel(); @@ -405,6 +412,7 @@ public class FlatJideOssContainerTest boldActiveTabCheckBox = new JCheckBox(); showTabButtonsCheckBox = new JCheckBox(); smallerInsetsCheckBox = new JCheckBox(); + showGripperCheckBox = new JCheckBox(); showTabSeparatorsCheckBox = new JCheckBox(); hideTabAreaWithOneTabCheckBox = new JCheckBox(); CellConstraints cc = new CellConstraints(); @@ -600,6 +608,11 @@ public class FlatJideOssContainerTest smallerInsetsCheckBox.addActionListener(e -> smallerInsetsChanged()); tabbedPaneControlPanel.add(smallerInsetsCheckBox, "cell 2 8"); + //---- showGripperCheckBox ---- + showGripperCheckBox.setText("Show gripper"); + showGripperCheckBox.addActionListener(e -> showGripperChanged()); + tabbedPaneControlPanel.add(showGripperCheckBox, "cell 0 9"); + //---- showTabSeparatorsCheckBox ---- showTabSeparatorsCheckBox.setText("Show tab separators"); showTabSeparatorsCheckBox.addActionListener(e -> showTabSeparatorsChanged()); @@ -646,6 +659,7 @@ public class FlatJideOssContainerTest private JCheckBox boldActiveTabCheckBox; private JCheckBox showTabButtonsCheckBox; private JCheckBox smallerInsetsCheckBox; + private JCheckBox showGripperCheckBox; private JCheckBox showTabSeparatorsCheckBox; private JCheckBox hideTabAreaWithOneTabCheckBox; // JFormDesigner - End of variables declaration //GEN-END:variables diff --git a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/jideoss/FlatJideOssContainerTest.jfd b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/jideoss/FlatJideOssContainerTest.jfd index 680e3e72..d305280e 100644 --- a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/jideoss/FlatJideOssContainerTest.jfd +++ b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/jideoss/FlatJideOssContainerTest.jfd @@ -337,6 +337,16 @@ new FormModel { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 2 8" } ) + add( new FormComponent( "javax.swing.JCheckBox" ) { + name: "showGripperCheckBox" + "text": "Show gripper" + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } + addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "showGripperChanged", false ) ) + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 9" + } ) add( new FormComponent( "javax.swing.JCheckBox" ) { name: "showTabSeparatorsCheckBox" "text": "Show tab separators"