You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by GitBox <gi...@apache.org> on 2020/02/06 18:01:31 UTC

[GitHub] [netbeans] eirikbakke commented on a change in pull request #1928: FlatLaf toolbar grips

eirikbakke commented on a change in pull request #1928: FlatLaf toolbar grips
URL: https://github.com/apache/netbeans/pull/1928#discussion_r375993571
 
 

 ##########
 File path: platform/o.n.swing.laf.flatlaf/src/org/netbeans/swing/laf/flatlaf/ui/FlatToolbarDragger.java
 ##########
 @@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.swing.laf.flatlaf.ui;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import javax.swing.JPanel;
+import javax.swing.UIManager;
+import com.formdev.flatlaf.util.UIScale;
+
+/**
+ * Toolbar grip consistent with FlatLaf style.
+ * Paint code is modeled after {@code com.formdev.flatlaf.ui.FlatToolBarBorder}.
+ */
+public class FlatToolbarDragger extends JPanel {
+	private static final int DOT_COUNT = 4;
+	private static final int DOT_SIZE = 2;
+	private static final int GRIP_WIDTH = DOT_SIZE * 3;
+    /** Minimum size. */
+    private final Dimension min;
+    /** Maximum size. */
+    private final Dimension max;
+    protected final Color gripColor = UIManager.getColor( "ToolBar.gripColor" );
+
+    public FlatToolbarDragger() {
+        min = new Dimension(GRIP_WIDTH, GRIP_WIDTH);
+        max = new Dimension(GRIP_WIDTH, Integer.MAX_VALUE);
+    }
+
+    @Override
+    public void paint (Graphics g) {
+        Graphics2D g2 = (Graphics2D)g.create();
+        try {
+            Utils.setRenderingHints(g2);
+            g2.setColor(gripColor);
+            int dotSize = UIScale.scale(DOT_SIZE);
+            int gapSize = dotSize;
+            int gripSize = (dotSize * DOT_COUNT) + ((gapSize * (DOT_COUNT - 1)));
+            // paint dots
+            int y = Math.round((getHeight() - gripSize) / 2f);
+            for(int i = 0; i < DOT_COUNT; i++) {
+                g2.fillOval(DOT_SIZE, y, dotSize, dotSize);
+                y += dotSize + gapSize;
+            }
+        } finally {
+            g2.dispose();
+        }
+    }
+
+    @Override
+    public Dimension getMinimumSize () {
+        return min;
 
 Review comment:
   Could you explain why this is needed? Is this to support scaling on Java 8?
   
   On Java 9 and above I would expect getMinimumSize to return the same logical pixel value regardless of HiDPI scaling setting. Is this correct?
   
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists