You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by sk...@apache.org on 2020/02/06 23:13:00 UTC
[netbeans] branch master updated: FlatLaf toolbar grips
This is an automated email from the ASF dual-hosted git repository.
skygo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/netbeans.git
The following commit(s) were added to refs/heads/master by this push:
new 47b6617 FlatLaf toolbar grips
new 35597ec Merge pull request #1928 from AlexFalappa/fix-toolbar-grips
47b6617 is described below
commit 47b66172a357c66db097af5c057076b38cf7cdf2
Author: Alex <no...@nohost.com>
AuthorDate: Thu Feb 6 16:48:34 2020 +0100
FlatLaf toolbar grips
Implementation of toolbar grippers (or dragger) following FlatLaf design.
---
.../netbeans/swing/laf/flatlaf/FlatLaf.properties | 4 ++
.../swing/laf/flatlaf/ui/FlatToolbarDragger.java | 81 ++++++++++++++++++++++
2 files changed, 85 insertions(+)
diff --git a/platform/o.n.swing.laf.flatlaf/src/org/netbeans/swing/laf/flatlaf/FlatLaf.properties b/platform/o.n.swing.laf.flatlaf/src/org/netbeans/swing/laf/flatlaf/FlatLaf.properties
index 2adc6bd..0a5d803 100644
--- a/platform/o.n.swing.laf.flatlaf/src/org/netbeans/swing/laf/flatlaf/FlatLaf.properties
+++ b/platform/o.n.swing.laf.flatlaf/src/org/netbeans/swing/laf/flatlaf/FlatLaf.properties
@@ -128,3 +128,7 @@ nb.popupswitcher.border=1,1,1,1,$PopupMenu.borderColor
# Windows file chooser places bar (at left side; class sun.swing.WindowsPlacesBar)
[win]ToolBar.shadow=@background
+
+
+#---- Main Toolbar ----
+Nb.MainWindow.Toolbar.Dragger=org.netbeans.swing.laf.flatlaf.ui.FlatToolbarDragger
\ No newline at end of file
diff --git a/platform/o.n.swing.laf.flatlaf/src/org/netbeans/swing/laf/flatlaf/ui/FlatToolbarDragger.java b/platform/o.n.swing.laf.flatlaf/src/org/netbeans/swing/laf/flatlaf/ui/FlatToolbarDragger.java
new file mode 100644
index 0000000..7119c61
--- /dev/null
+++ b/platform/o.n.swing.laf.flatlaf/src/org/netbeans/swing/laf/flatlaf/ui/FlatToolbarDragger.java
@@ -0,0 +1,81 @@
+/*
+ * 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;
+ private final Dimension min;
+ private final Dimension max;
+ protected final Color gripColor = UIManager.getColor("ToolBar.gripColor"); //NOI18N
+
+ 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(dotSize, y, dotSize, dotSize);
+ y += dotSize + gapSize;
+ }
+ } finally {
+ g2.dispose();
+ }
+ }
+
+ @Override
+ public Dimension getMinimumSize () {
+ return UIScale.scale(min);
+ }
+
+ @Override
+ public Dimension getPreferredSize () {
+ return this.getMinimumSize ();
+ }
+
+ @Override
+ public Dimension getMaximumSize () {
+ return UIScale.scale(max);
+ }
+
+}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@netbeans.apache.org
For additional commands, e-mail: commits-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists