Browse Source

OSD windows reuse space depending on policy.

Fixes issue 3619

Change-Id: Ieafb0fee528b8e43ccbbdc71c1a615d14d50ac4a
Reviewed-on: http://gerrit.dmdirc.com/629
Automatic-Compile: Chris Smith <chris@dmdirc.com>
Reviewed-by: Chris Smith <chris@dmdirc.com>
tags/0.6.3
Simon Mott 14 years ago
parent
commit
0ba9a44ab3

+ 19
- 2
src/com/dmdirc/addons/osd/OsdManager.java View File

91
         OsdWindow currentWindow = new OsdWindow(message, false,
91
         OsdWindow currentWindow = new OsdWindow(message, false,
92
                 IdentityManager.getGlobalConfig().getOptionInt(plugin.getDomain(),
92
                 IdentityManager.getGlobalConfig().getOptionInt(plugin.getDomain(),
93
                 "locationX"), getYPosition(), plugin, this);
93
                 "locationX"), getYPosition(), plugin, this);
94
-
95
         windowList.add(currentWindow);
94
         windowList.add(currentWindow);
96
     }
95
     }
97
 
96
 
102
      * @param window The window that we are destroying.
101
      * @param window The window that we are destroying.
103
      */
102
      */
104
     public void closeWindow(final OsdWindow window) {
103
     public void closeWindow(final OsdWindow window) {
104
+        final String policy = IdentityManager.getGlobalConfig().getOption(
105
+                plugin.getDomain(), "newbehaviour");
106
+        final int startY = IdentityManager.getGlobalConfig().getOptionInt(plugin.getDomain(),
107
+                "locationY");
108
+
105
         windowList.remove(window);
109
         windowList.remove(window);
106
         window.dispose();
110
         window.dispose();
107
 
111
 
112
+        synchronized (this) {
113
+            for (OsdWindow otherWindow : getWindowList()) {
114
+                if (otherWindow.isVisible()) {
115
+                    if ("down".equals(policy)) {
116
+                        otherWindow.setLocation(otherWindow.getX(), Math.max(startY,
117
+                                otherWindow.getY() - otherWindow.getHeight() - WINDOW_GAP));
118
+                    } else if ("up".equals(policy)) {
119
+                        otherWindow.setLocation(otherWindow.getX(), Math.min(startY,
120
+                                otherWindow.getY() + otherWindow.getHeight() + WINDOW_GAP));
121
+                    }
122
+                }
123
+            }
124
+        }
108
         displayWindows();
125
         displayWindows();
109
     }
126
     }
110
 
127
 
141
      *
158
      *
142
      * @return the Y position for the next window.
159
      * @return the Y position for the next window.
143
      */
160
      */
144
-    public int getYPosition() {
161
+    private int getYPosition() {
145
         final String policy = IdentityManager.getGlobalConfig().getOption(
162
         final String policy = IdentityManager.getGlobalConfig().getOption(
146
                 plugin.getDomain(), "newbehaviour");
163
                 plugin.getDomain(), "newbehaviour");
147
         int y = IdentityManager.getGlobalConfig().getOptionInt(plugin.getDomain(),
164
         int y = IdentityManager.getGlobalConfig().getOptionInt(plugin.getDomain(),

+ 0
- 2
src/com/dmdirc/addons/osd/OsdWindow.java View File

133
                 /** {@inheritDoc} */
133
                 /** {@inheritDoc} */
134
                 @Override
134
                 @Override
135
                 public void run() {
135
                 public void run() {
136
-                    setVisible(false);
137
                     osdManager.closeWindow(OsdWindow.this);
136
                     osdManager.closeWindow(OsdWindow.this);
138
                 }
137
                 }
139
             }, IdentityManager.getGlobalConfig().getOptionInt(plugin.getDomain(),
138
             }, IdentityManager.getGlobalConfig().getOptionInt(plugin.getDomain(),
150
     @Override
149
     @Override
151
     public void mouseClicked(final MouseEvent e) {
150
     public void mouseClicked(final MouseEvent e) {
152
         if (!config) {
151
         if (!config) {
153
-            setVisible(false);
154
             osdManager.closeWindow(this);
152
             osdManager.closeWindow(this);
155
         }
153
         }
156
     }
154
     }

Loading…
Cancel
Save