8152968: JTree Collapse Buttons Clipped Off Under GTK
authorssadetsky
Fri, 08 Jul 2016 20:28:28 +0300
changeset 39845 9a6e55dd0aeb
parent 39844 a3cc7e551a48
child 39846 9b585e2c52de
8152968: JTree Collapse Buttons Clipped Off Under GTK Reviewed-by: alexsch
jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKPainter.java
jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKStyle.java
jdk/src/java.desktop/unix/native/libawt_xawt/awt/gtk3_interface.c
--- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKPainter.java	Fri Jul 08 18:43:12 2016 +0300
+++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKPainter.java	Fri Jul 08 20:28:28 2016 +0300
@@ -1339,14 +1339,14 @@
             Graphics g, int state, int x, int y, int w, int h) {
         ENGINE.paintExpander(g, context, Region.TREE,
                 GTKLookAndFeel.synthStateToGTKState(context.getRegion(), state),
-                ExpanderStyle.EXPANDED, "treeview", x, y, w, h);
+                ExpanderStyle.EXPANDED, "expander", x, y, w, h);
     }
 
     public void paintTreeCollapsedIcon(SynthContext context,
             Graphics g, int state, int x, int y, int w, int h) {
         ENGINE.paintExpander(g, context, Region.TREE,
                 GTKLookAndFeel.synthStateToGTKState(context.getRegion(), state),
-                ExpanderStyle.COLLAPSED, "treeview", x, y, w, h);
+                ExpanderStyle.COLLAPSED, "expander", x, y, w, h);
     }
 
     public void paintCheckBoxIcon(SynthContext context,
--- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKStyle.java	Fri Jul 08 18:43:12 2016 +0300
+++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKStyle.java	Fri Jul 08 20:28:28 2016 +0300
@@ -854,6 +854,12 @@
             return indicatorSpacing + focusSize + focusPad;
         } else if (GTKLookAndFeel.is3() && "ComboBox.forceOpaque".equals(key)) {
             return true;
+        } else if ("Tree.expanderSize".equals(key)) {
+            Object value = getClassSpecificValue("expander-size");
+            if (value instanceof Integer) {
+                return (Integer)value + 4;
+            }
+            return null;
         }
 
         // Is it a stock icon ?
@@ -1136,7 +1142,6 @@
         CLASS_SPECIFIC_MAP.put("Slider.thumbWidth", "slider-length");
         CLASS_SPECIFIC_MAP.put("Slider.trackBorder", "trough-border");
         CLASS_SPECIFIC_MAP.put("SplitPane.size", "handle-size");
-        CLASS_SPECIFIC_MAP.put("Tree.expanderSize", "expander-size");
         CLASS_SPECIFIC_MAP.put("ScrollBar.thumbHeight", "slider-width");
         CLASS_SPECIFIC_MAP.put("ScrollBar.width", "slider-width");
         CLASS_SPECIFIC_MAP.put("TextArea.caretForeground", "cursor-color");
--- a/jdk/src/java.desktop/unix/native/libawt_xawt/awt/gtk3_interface.c	Fri Jul 08 18:43:12 2016 +0300
+++ b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/gtk3_interface.c	Fri Jul 08 20:28:28 2016 +0300
@@ -1586,13 +1586,17 @@
     fp_gtk_style_context_save (context);
 
     GtkStateFlags flags = get_gtk_flags(state_type);
+    if (expander_style == GTK_EXPANDER_EXPANDED) {
+        flags |= GTK_STATE_FLAG_ACTIVE;
+    }
+
     fp_gtk_style_context_set_state(context, flags);
 
     if (detail != 0) {
         transform_detail_string(detail, context);
     }
 
-    fp_gtk_render_expander (context, cr, x, y, width, height);
+    fp_gtk_render_expander (context, cr, x + 2, y + 2, width - 4, height - 4);
 
     fp_gtk_style_context_restore (context);
 }