Browse Source

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 years ago
parent
commit
4cd224fcd7

+ 28
- 26
src/com/dmdirc/addons/ui_swing/framemanager/tree/NodeLabel.java View File

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

+ 13
- 8
src/com/dmdirc/addons/ui_swing/framemanager/tree/TreeViewTreeCellRenderer.java View File

101
             return new JLabel("Label == null");
101
             return new JLabel("Label == null");
102
         }
102
         }
103
 
103
 
104
+        label.setOpaque(false);
104
         label.setBackground(tree.getBackground());
105
         label.setBackground(tree.getBackground());
105
         label.setForeground(tree.getForeground());
106
         label.setForeground(tree.getForeground());
106
 
107
 
107
         if (label.isRollover()) {
108
         if (label.isRollover()) {
109
+            label.setOpaque(true);
108
             label.setBackground(rolloverColour);
110
             label.setBackground(rolloverColour);
109
         }
111
         }
110
 
112
 
119
             } else {
121
             } else {
120
                 label.setFont(label.getFont().deriveFont(Font.PLAIN));
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
             label.setForeground(activeForeground);
128
             label.setForeground(activeForeground);
124
         } else {
129
         } else {
125
             label.setFont(label.getFont().deriveFont(Font.PLAIN));
130
             label.setFont(label.getFont().deriveFont(Font.PLAIN));
150
     /** {@inheritDoc} */
155
     /** {@inheritDoc} */
151
     @Override
156
     @Override
152
     public void configChanged(final String domain, final String key) {
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
             setColours();
165
             setColours();
161
         }
166
         }
162
     }
167
     }

Loading…
Cancel
Save