Преглед изворни кода

Make tree nodes transparent as required.

Fixes issue CLIENT-30

Change-Id: I7b2aefe95c9e1e1ad8aa5a4301f8a8638344a913
Reviewed-on: http://gerrit.dmdirc.com/1636
Automatic-Compile: DMDirc Local Commits <dmdirc@googlemail.com>
Reviewed-by: Chris Smith <chris@dmdirc.com>
tags/0.6.5
Greg Holmes пре 13 година
родитељ
комит
4cd224fcd7

+ 28
- 26
src/com/dmdirc/addons/ui_swing/framemanager/tree/NodeLabel.java Прегледај датотеку

@@ -1,16 +1,16 @@
1 1
 /*
2 2
  * Copyright (c) 2006-2010 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
- * 
3
+ *
4 4
  * Permission is hereby granted, free of charge, to any person obtaining a copy
5 5
  * of this software and associated documentation files (the "Software"), to deal
6 6
  * in the Software without restriction, including without limitation the rights
7 7
  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 8
  * copies of the Software, and to permit persons to whom the Software is
9 9
  * furnished to do so, subject to the following conditions:
10
- * 
10
+ *
11 11
  * The above copyright notice and this permission notice shall be included in
12 12
  * all copies or substantial portions of the Software.
13
- * 
13
+ *
14 14
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 15
  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 16
  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -47,25 +47,25 @@ public class NodeLabel extends JLabel implements SelectionListener,
47 47
      * objects being unserialized with the new class).
48 48
      */
49 49
     private static final long serialVersionUID = 1;
50
-    /** Node window. */
50
+    /** The window this node represents in the tree. */
51 51
     private final FrameContainer<?> window;
52
-    /** Rollover colours. */
52
+    /** Colour used to show if the mouse is over this node. */
53 53
     private boolean rollover;
54
-    /** notification colour */
54
+    /** Colour used to show if this node has an active notification. */
55 55
     private Color notificationColour;
56
-    /** Selected. */
56
+    /** Are we the selected window? */
57 57
     private boolean selected;
58 58
 
59
-    /** 
59
+    /**
60 60
      * Instantiates a new node label.
61
-     * 
61
+     *
62 62
      * @param window Window for this node
63 63
      */
64 64
     public NodeLabel(final FrameContainer<?> window) {
65 65
         super();
66 66
 
67 67
         this.window = window;
68
-        
68
+
69 69
         init();
70 70
     }
71 71
 
@@ -79,13 +79,13 @@ public class NodeLabel extends JLabel implements SelectionListener,
79 79
 
80 80
         setText(window.toString());
81 81
 
82
-        setOpaque(true);
82
+
83 83
         setToolTipText(null);
84 84
         setIcon(IconManager.getIconManager().getIcon(window.getIcon()));
85 85
         setBorder(BorderFactory.createEmptyBorder(1, 0, 2, 0));
86 86
 
87
-        setPreferredSize(new Dimension(100000, getFont().getSize() +
88
-                (int) PlatformDefaults.getUnitValueX("related").
87
+        setPreferredSize(new Dimension(100000, getFont().getSize()
88
+                + (int) PlatformDefaults.getUnitValueX("related").
89 89
                 getValue()));
90 90
         notificationColour = null;
91 91
         selected = false;
@@ -103,7 +103,8 @@ public class NodeLabel extends JLabel implements SelectionListener,
103 103
 
104 104
     /** {@inheritDoc} */
105 105
     @Override
106
-    public void notificationSet(final FrameContainer<?> window, final Color colour) {
106
+    public void notificationSet(final FrameContainer<?> window,
107
+            final Color colour) {
107 108
         if (equals(window)) {
108 109
             notificationColour = colour;
109 110
         }
@@ -135,53 +136,54 @@ public class NodeLabel extends JLabel implements SelectionListener,
135 136
 
136 137
     /** {@inheritDoc} */
137 138
     @Override
138
-    public void titleChanged(final FrameContainer<?> window, final String title) {
139
+    public void titleChanged(final FrameContainer<?> window,
140
+            final String title) {
139 141
         // Do nothing
140 142
     }
141 143
 
142
-    /** 
144
+    /**
143 145
      * Sets the rollover state for the node.
144
-     * 
146
+     *
145 147
      * @param rollover rollover state
146 148
      */
147 149
     public void setRollover(final boolean rollover) {
148 150
         this.rollover = rollover;
149 151
     }
150
-    
152
+
151 153
     /**
152 154
      * Is this node a rollover node?
153
-     * 
155
+     *
154 156
      * @return true iff this node is a rollover node
155 157
      */
156 158
     public boolean isRollover() {
157 159
         return rollover;
158 160
     }
159
-    
161
+
160 162
     /**
161 163
      * Is this node a selected node?
162
-     * 
164
+     *
163 165
      * @return true iff this node is a selected node
164 166
      */
165 167
     public boolean isSelected() {
166 168
         return selected;
167 169
     }
168
-    
170
+
169 171
     /**
170 172
      * Returns the notification colour for this node.
171
-     * 
173
+     *
172 174
      * @return notification colour or null if non set
173 175
      */
174 176
     public Color getNotificationColour() {
175 177
         return notificationColour;
176 178
     }
177
-    
179
+
178 180
     /** {@inheritDoc} */
179 181
     @Override
180 182
     public boolean equals(final Object obj) {
181 183
         if (window == null) {
182 184
             return false;
183 185
         }
184
-        
186
+
185 187
         return window.equals(obj);
186 188
     }
187 189
 
@@ -191,7 +193,7 @@ public class NodeLabel extends JLabel implements SelectionListener,
191 193
         if (window == null) {
192 194
             return super.hashCode();
193 195
         }
194
-        
196
+
195 197
         return window.hashCode();
196 198
     }
197 199
 

+ 13
- 8
src/com/dmdirc/addons/ui_swing/framemanager/tree/TreeViewTreeCellRenderer.java Прегледај датотеку

@@ -101,10 +101,12 @@ public class TreeViewTreeCellRenderer implements TreeCellRenderer,
101 101
             return new JLabel("Label == null");
102 102
         }
103 103
 
104
+        label.setOpaque(false);
104 105
         label.setBackground(tree.getBackground());
105 106
         label.setForeground(tree.getForeground());
106 107
 
107 108
         if (label.isRollover()) {
109
+            label.setOpaque(true);
108 110
             label.setBackground(rolloverColour);
109 111
         }
110 112
 
@@ -119,7 +121,10 @@ public class TreeViewTreeCellRenderer implements TreeCellRenderer,
119 121
             } else {
120 122
                 label.setFont(label.getFont().deriveFont(Font.PLAIN));
121 123
             }
122
-            label.setBackground(activeBackground);
124
+            if (!tree.getBackground().equals(activeBackground)) {
125
+                label.setOpaque(true);
126
+                label.setBackground(activeBackground);
127
+            }
123 128
             label.setForeground(activeForeground);
124 129
         } else {
125 130
             label.setFont(label.getFont().deriveFont(Font.PLAIN));
@@ -150,13 +155,13 @@ public class TreeViewTreeCellRenderer implements TreeCellRenderer,
150 155
     /** {@inheritDoc} */
151 156
     @Override
152 157
     public void configChanged(final String domain, final String key) {
153
-        if (("ui".equals(domain) || "treeview".equals(domain)) &&
154
-                ("treeviewRolloverColour".equals(key) ||
155
-                "treeviewActiveBackground".equals(key) ||
156
-                "treeviewActiveForeground".equals(key) ||
157
-                "treeviewActiveBold".equals(key) ||
158
-                "backgroundcolour".equals(key) ||
159
-                "foregroundcolour".equals(key))) {
158
+        if (("ui".equals(domain) || "treeview".equals(domain))
159
+                && ("treeviewRolloverColour".equals(key)
160
+                || "treeviewActiveBackground".equals(key)
161
+                || "treeviewActiveForeground".equals(key)
162
+                || "treeviewActiveBold".equals(key)
163
+                || "backgroundcolour".equals(key)
164
+                || "foregroundcolour".equals(key))) {
160 165
             setColours();
161 166
         }
162 167
     }

Loading…
Откажи
Сачувај