瀏覽代碼

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 年之前
父節點
當前提交
d76be99686
共有 2 個文件被更改,包括 21 次插入18 次删除
  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 查看文件

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

+ 19
- 17
src/com/dmdirc/addons/osd/OsdManager.java 查看文件

109
     public void closeWindow(final OsdWindow window) {
109
     public void closeWindow(final OsdWindow window) {
110
         final String policy = IdentityManager.getGlobalConfig().getOption(
110
         final String policy = IdentityManager.getGlobalConfig().getOption(
111
                 plugin.getDomain(), "newbehaviour");
111
                 plugin.getDomain(), "newbehaviour");
112
-        final int startY = IdentityManager.getGlobalConfig().getOptionInt(plugin.
113
-                getDomain(), "locationY");
114
 
112
 
115
         synchronized (OsdManager.this) {
113
         synchronized (OsdManager.this) {
116
             UIUtilities.invokeAndWait(new Runnable() {
114
             UIUtilities.invokeAndWait(new Runnable() {
117
                 /** {@inheritDoc} */
115
                 /** {@inheritDoc} */
118
                 @Override
116
                 @Override
119
                 public void run() {
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
                     windowList.remove(window);
125
                     windowList.remove(window);
121
                     window.dispose();
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
      * Destroy all OSD Windows.
145
      * Destroy all OSD Windows.
143
      */
146
      */
144
     public void closeAll() {
147
     public void closeAll() {
145
-        for (OsdWindow window : new ArrayList<OsdWindow>(windowList)) {
146
-            window.setVisible(false);
148
+        for (OsdWindow window : getWindowList()) {
147
             closeWindow(window);
149
             closeWindow(window);
148
         }
150
         }
149
     }
151
     }
179
 
181
 
180
         if ("down".equals(policy)) {
182
         if ("down".equals(policy)) {
181
             // Place our new window below old windows
183
             // Place our new window below old windows
182
-            for (OsdWindow window : new ArrayList<OsdWindow>(getWindowList())) {
184
+            for (OsdWindow window : getWindowList()) {
183
                 if (window.isVisible()) {
185
                 if (window.isVisible()) {
184
                     y = Math.max(y, window.getY() + window.getHeight() + WINDOW_GAP);
186
                     y = Math.max(y, window.getY() + window.getHeight() + WINDOW_GAP);
185
                 }
187
                 }
186
             }
188
             }
187
         } else if ("up".equals(policy)) {
189
         } else if ("up".equals(policy)) {
188
             // Place our new window above old windows
190
             // Place our new window above old windows
189
-            for (OsdWindow window : new ArrayList<OsdWindow>(getWindowList())) {
191
+            for (OsdWindow window : getWindowList()) {
190
                 if (window.isVisible()) {
192
                 if (window.isVisible()) {
191
                     y = Math.min(y, window.getY() - window.getHeight() - WINDOW_GAP);
193
                     y = Math.min(y, window.getY() - window.getHeight() - WINDOW_GAP);
192
                 }
194
                 }

Loading…
取消
儲存