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 2019/12/11 21:25:39 UTC

[GitHub] [netbeans] svenreimers commented on a change in pull request #1771: [NETBEANS-3428] FlatLaf: UI delegates for editor and view tabs in main window

svenreimers commented on a change in pull request #1771: [NETBEANS-3428] FlatLaf: UI delegates for editor and view tabs in main window
URL: https://github.com/apache/netbeans/pull/1771#discussion_r356842361
 
 

 ##########
 File path: platform/o.n.swing.laf.flatlaf/src/org/netbeans/swing/laf/flatlaf/ui/FlatTabControlIcon.java
 ##########
 @@ -0,0 +1,270 @@
+/*
+ * 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 com.formdev.flatlaf.ui.FlatUIUtils;
+import com.formdev.flatlaf.util.UIScale;
+import org.openide.util.VectorIcon;
+import java.awt.BasicStroke;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Graphics2D;
+import java.awt.Stroke;
+import java.awt.geom.Area;
+import java.awt.geom.Line2D;
+import java.awt.geom.Path2D;
+import java.awt.geom.Rectangle2D;
+import java.util.AbstractMap.SimpleEntry;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+import javax.swing.Icon;
+import javax.swing.UIManager;
+import org.netbeans.swing.tabcontrol.plaf.TabControlButton;
+
+/**
+ * Scalable vector icons for the FlatLaf tab control L&amp;F, for use with HiDPI screens. These
+ * icons look good at all of the standard scaling factors available on Windows (see superclass
+ * Javadoc).
+ *
+ * This is a copy of Windows8VectorTabControlIcon with modifications:
+ * - use "close" icon from AquaVectorTabControlIcon
+ * - arrow icons changed to match arrows in FlatLaf (chevron or triangle)
+ * - minimize, maximize and restore icons changed
+ * - increased size from 14x14 to 16x16
+ * - scales in Java 8 and Linux
+ *
+ * @author Eirik Bakke
+ */
+@SuppressWarnings("serial")
+final class FlatTabControlIcon extends VectorIcon {
+    private static final boolean chevron = "chevron".equals(UIManager.getString("Component.arrowType")); // NOI18N
+    private static final int arc = UIManager.getInt("TabControlIcon.arc"); // NOI18N
+    private static final Color foreground = UIManager.getColor("TabControlIcon.foreground"); // NOI18N
+    private static final Color disabledForeground = UIManager.getColor("TabControlIcon.disabledForeground"); // NOI18N
+    private static final Color rolloverBackground = UIManager.getColor("TabControlIcon.rolloverBackground"); // NOI18N
+    private static final Color pressedBackground = UIManager.getColor("TabControlIcon.pressedBackground"); // NOI18N
+    private static final Color closeRolloverBackground = UIManager.getColor("TabControlIcon.close.rolloverBackground"); // NOI18N
+    private static final Color closeRolloverForeground = UIManager.getColor("TabControlIcon.close.rolloverForeground"); // NOI18N
+
+    private static final Map<Entry<Integer,Integer>,Icon> INSTANCES = populateInstances();
+    private final int buttonId;
+    private final int buttonState;
+    private final float userScaleFactor; // for Java 8 and Linux
+
+    private static void populateOne(
+            Map<Entry<Integer,Integer>,Icon> toMap, int buttonId, int buttonState)
+    {
+        toMap.put(new SimpleEntry<Integer,Integer>(buttonId, buttonState),
+                new FlatTabControlIcon(buttonId, buttonState));
+    }
+
+    private static Map<Entry<Integer,Integer>,Icon> populateInstances() {
+        // The string keys of these maps aren't currently used, but are useful for debugging.
+        Map<String, Integer> buttonIDs = new LinkedHashMap<String, Integer>();
+        // ViewTabDisplayerUI
+        buttonIDs.put("close", TabControlButton.ID_CLOSE_BUTTON);
+        // These don't seem to be in use anymore.
+        //buttonIDs.put("slide_right", TabControlButton.ID_SLIDE_RIGHT_BUTTON);
+        //buttonIDs.put("slide_left", TabControlButton.ID_SLIDE_LEFT_BUTTON);
+        //buttonIDs.put("slide_down", TabControlButton.ID_SLIDE_DOWN_BUTTON);
+        buttonIDs.put("pin", TabControlButton.ID_PIN_BUTTON);
+        buttonIDs.put("restore_group", TabControlButton.ID_RESTORE_GROUP_BUTTON);
+        buttonIDs.put("slide_group", TabControlButton.ID_SLIDE_GROUP_BUTTON);
+        // EditorTabDisplayerUI
+        buttonIDs.put("scroll_left", TabControlButton.ID_SCROLL_LEFT_BUTTON);
+        buttonIDs.put("scroll_right", TabControlButton.ID_SCROLL_RIGHT_BUTTON);
+        buttonIDs.put("drop_down", TabControlButton.ID_DROP_DOWN_BUTTON);
+        buttonIDs.put("maximize", TabControlButton.ID_MAXIMIZE_BUTTON);
+        buttonIDs.put("restore", TabControlButton.ID_RESTORE_BUTTON);
+        Map<String, Integer> buttonStates = new LinkedHashMap<String, Integer>();
+        buttonStates.put("default", TabControlButton.STATE_DEFAULT);
+        buttonStates.put("pressed", TabControlButton.STATE_PRESSED);
+        buttonStates.put("disabled", TabControlButton.STATE_DISABLED);
+        buttonStates.put("rollover", TabControlButton.STATE_ROLLOVER);
 
 Review comment:
   I think if you use the Internationalization tooling in NetBeans across multiple files it will skip strings found on line with //NOI18N. So it may indeed be useful.

----------------------------------------------------------------
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