Переглянути джерело

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 роки тому
джерело
коміт
0ba9a44ab3

+ 19
- 2
src/com/dmdirc/addons/osd/OsdManager.java Переглянути файл

@@ -91,7 +91,6 @@ public class OsdManager {
91 91
         OsdWindow currentWindow = new OsdWindow(message, false,
92 92
                 IdentityManager.getGlobalConfig().getOptionInt(plugin.getDomain(),
93 93
                 "locationX"), getYPosition(), plugin, this);
94
-
95 94
         windowList.add(currentWindow);
96 95
     }
97 96
 
@@ -102,9 +101,27 @@ public class OsdManager {
102 101
      * @param window The window that we are destroying.
103 102
      */
104 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 109
         windowList.remove(window);
106 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 125
         displayWindows();
109 126
     }
110 127
 
@@ -141,7 +158,7 @@ public class OsdManager {
141 158
      *
142 159
      * @return the Y position for the next window.
143 160
      */
144
-    public int getYPosition() {
161
+    private int getYPosition() {
145 162
         final String policy = IdentityManager.getGlobalConfig().getOption(
146 163
                 plugin.getDomain(), "newbehaviour");
147 164
         int y = IdentityManager.getGlobalConfig().getOptionInt(plugin.getDomain(),

+ 0
- 2
src/com/dmdirc/addons/osd/OsdWindow.java Переглянути файл

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

Завантаження…
Відмінити
Зберегти