Browse Source

OSD Space recycling fix - no longer spazzes out when user clicks an osd closed. Also re-added Stylized to remove control codes

Change-Id: I44dc5a45eef0577f1d83d522beb61848f5d09dc3
Reviewed-on: http://gerrit.dmdirc.com/639
Reviewed-by: Shane Mc Cormack <shane@dmdirc.com>
Automatic-Compile: Shane Mc Cormack <shane@dmdirc.com>
tags/0.6.3
Simon Mott 14 years ago
parent
commit
d76be99686
2 changed files with 21 additions and 18 deletions
  1. 2
    1
      src/com/dmdirc/addons/osd/OsdCommand.java
  2. 19
    17
      src/com/dmdirc/addons/osd/OsdManager.java

+ 2
- 1
src/com/dmdirc/addons/osd/OsdCommand.java View File

@@ -29,6 +29,7 @@ import com.dmdirc.commandparser.commands.IntelligentCommand;
29 29
 import com.dmdirc.ui.input.AdditionalTabTargets;
30 30
 import com.dmdirc.ui.interfaces.InputWindow;
31 31
 
32
+import com.dmdirc.ui.messages.Styliser;
32 33
 import java.util.List;
33 34
 
34 35
 /**
@@ -65,7 +66,7 @@ public final class OsdCommand extends GlobalCommand implements IntelligentComman
65 66
      * @return True if the notification was shown.
66 67
      */
67 68
     public boolean showOSD(final String title, final String message) {
68
-        osdManager.showWindow(message);
69
+        osdManager.showWindow(Styliser.stipControlCodes(message));
69 70
         return true;
70 71
     }
71 72
 

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

@@ -109,27 +109,30 @@ public class OsdManager {
109 109
     public void closeWindow(final OsdWindow window) {
110 110
         final String policy = IdentityManager.getGlobalConfig().getOption(
111 111
                 plugin.getDomain(), "newbehaviour");
112
-        final int startY = IdentityManager.getGlobalConfig().getOptionInt(plugin.
113
-                getDomain(), "locationY");
114 112
 
115 113
         synchronized (OsdManager.this) {
116 114
             UIUtilities.invokeAndWait(new Runnable() {
117 115
                 /** {@inheritDoc} */
118 116
                 @Override
119 117
                 public void run() {
118
+                    int oldY = window.getY();
119
+                    final int closedIndex = windowList.indexOf(window);
120
+
121
+                    if (closedIndex == -1) {
122
+                        return;
123
+                    }
124
+
120 125
                     windowList.remove(window);
121 126
                     window.dispose();
122
-                    for (OsdWindow otherWindow : getWindowList()) {
123
-                        if (otherWindow.isVisible()) {
124
-                            if ("down".equals(policy)) {
125
-                                otherWindow.setLocation(otherWindow.getX(), Math.
126
-                                        max(startY, otherWindow.getY()
127
-                                        - otherWindow.getHeight() - WINDOW_GAP));
128
-                            } else if ("up".equals(policy)) {
129
-                                otherWindow.setLocation(otherWindow.getX(), Math.
130
-                                        min(startY, otherWindow.getY()
131
-                                        + otherWindow.getHeight() + WINDOW_GAP));
132
-                            }
127
+
128
+                    final List<OsdWindow> newList = getWindowList();
129
+
130
+                    for (OsdWindow otherWindow : newList.subList(closedIndex, newList.size())) {
131
+                        final int currentY = otherWindow.getY();
132
+
133
+                        if ("down".equals(policy) || "up".equals(policy)) {
134
+                                otherWindow.setLocation(otherWindow.getX(), oldY);
135
+                                oldY = currentY;
133 136
                         }
134 137
                     }
135 138
                 }
@@ -142,8 +145,7 @@ public class OsdManager {
142 145
      * Destroy all OSD Windows.
143 146
      */
144 147
     public void closeAll() {
145
-        for (OsdWindow window : new ArrayList<OsdWindow>(windowList)) {
146
-            window.setVisible(false);
148
+        for (OsdWindow window : getWindowList()) {
147 149
             closeWindow(window);
148 150
         }
149 151
     }
@@ -179,14 +181,14 @@ public class OsdManager {
179 181
 
180 182
         if ("down".equals(policy)) {
181 183
             // Place our new window below old windows
182
-            for (OsdWindow window : new ArrayList<OsdWindow>(getWindowList())) {
184
+            for (OsdWindow window : getWindowList()) {
183 185
                 if (window.isVisible()) {
184 186
                     y = Math.max(y, window.getY() + window.getHeight() + WINDOW_GAP);
185 187
                 }
186 188
             }
187 189
         } else if ("up".equals(policy)) {
188 190
             // Place our new window above old windows
189
-            for (OsdWindow window : new ArrayList<OsdWindow>(getWindowList())) {
191
+            for (OsdWindow window : getWindowList()) {
190 192
                 if (window.isVisible()) {
191 193
                     y = Math.min(y, window.getY() - window.getHeight() - WINDOW_GAP);
192 194
                 }

Loading…
Cancel
Save