Mercurial > fife-parpg
comparison clients/editor/plugins/LayerTool.py @ 303:a33576d94f32
- eliminated magic number
- updated some doc strings
author | chewie@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Sat, 11 Jul 2009 07:17:24 +0000 |
parents | 07709bffab8f |
children | 6add14ebe9f5 |
comparison
equal
deleted
inserted
replaced
302:94470d79576f | 303:a33576d94f32 |
---|---|
60 | 60 |
61 self.subwrappers = [] | 61 self.subwrappers = [] |
62 | 62 |
63 #--- Plugin function ---# | 63 #--- Plugin function ---# |
64 def enable(self): | 64 def enable(self): |
65 """ """ | |
65 if self._enabled is True: | 66 if self._enabled is True: |
66 return | 67 return |
67 | 68 |
68 # Fifedit plugin data | 69 # Fifedit plugin data |
69 self._editor = scripts.editor.getEditor() | 70 self._editor = scripts.editor.getEditor() |
76 self.toggle() | 77 self.toggle() |
77 | 78 |
78 events.postMapShown.connect(self.update) | 79 events.postMapShown.connect(self.update) |
79 | 80 |
80 def disable(self): | 81 def disable(self): |
82 """ """ | |
81 if self._enabled is False: | 83 if self._enabled is False: |
82 return | 84 return |
83 self.container.setDocked(False) | 85 self.container.setDocked(False) |
84 self.container.hide() | 86 self.container.hide() |
85 self.removeAllChildren() | 87 self.removeAllChildren() |
87 events.postMapShown.disconnect(self.update) | 89 events.postMapShown.disconnect(self.update) |
88 | 90 |
89 self._editor._toolsMenu.removeAction(self._showAction) | 91 self._editor._toolsMenu.removeAction(self._showAction) |
90 | 92 |
91 def isEnabled(self): | 93 def isEnabled(self): |
94 """ """ | |
92 return self._enabled; | 95 return self._enabled; |
93 | 96 |
94 def getName(self): | 97 def getName(self): |
98 """ """ | |
95 return u"Layertool" | 99 return u"Layertool" |
96 | 100 |
97 #--- End plugin functions ---# | 101 #--- End plugin functions ---# |
98 | 102 |
99 def __create_gui(self): | 103 def __create_gui(self): |
204 if active_layer == layerid: | 208 if active_layer == layerid: |
205 self.select_no_layer() | 209 self.select_no_layer() |
206 | 210 |
207 | 211 |
208 def select_no_layer(self): | 212 def select_no_layer(self): |
209 """ the exception approach - as soon as the user hides a layer, the mapedit module should stop to use this | 213 """ Resets the current active layer (widget + editor) """ |
210 one, too. | |
211 | |
212 A bunch of exceptions is the result (each click on the map will result in a exception as no layer is set etc...) | |
213 """ | |
214 previous_active_layer = self.getActiveLayer() | 214 previous_active_layer = self.getActiveLayer() |
215 if previous_active_layer is not None: | 215 if previous_active_layer is not None: |
216 previous_layer_id = previous_active_layer.getId() | 216 previous_layer_id = previous_active_layer.getId() |
217 previous_active_widget = self.container.findChild(name=_LABEL_NAME_PREFIX + previous_layer_id) | 217 previous_active_widget = self.container.findChild(name=_LABEL_NAME_PREFIX + previous_layer_id) |
218 previous_active_widget.background_color = _DEFAULT_BACKGROUND_COLOR | 218 previous_active_widget.background_color = _DEFAULT_BACKGROUND_COLOR |
241 @param widget: the pychan widget where the event occurs, transports the layer id in it's name | 241 @param widget: the pychan widget where the event occurs, transports the layer id in it's name |
242 """ | 242 """ |
243 | 243 |
244 self.select_no_layer() | 244 self.select_no_layer() |
245 | 245 |
246 layerid = widget.name[7:] | 246 layerid = widget.name[len(_LABEL_NAME_PREFIX):] |
247 | 247 |
248 widget.background_color = _HIGHLIGHT_BACKGROUND_COLOR | 248 widget.background_color = _HIGHLIGHT_BACKGROUND_COLOR |
249 widget.foreground_color = _HIGHLIGHT_BACKGROUND_COLOR | 249 widget.foreground_color = _HIGHLIGHT_BACKGROUND_COLOR |
250 widget.base_color = _HIGHLIGHT_BACKGROUND_COLOR | 250 widget.base_color = _HIGHLIGHT_BACKGROUND_COLOR |
251 self.container.adaptLayout() | 251 self.container.adaptLayout() |
252 | 252 |
253 self._mapview.getController().selectLayer(layerid) | 253 self._mapview.getController().selectLayer(layerid) |
254 | 254 |
255 def toggle(self): | 255 def toggle(self): |
256 """ toggles the layertool visible / invisible and sets | |
257 dock status | |
258 """ | |
256 if self.container.isVisible() or self.container.isDocked(): | 259 if self.container.isVisible() or self.container.isDocked(): |
257 self.container.setDocked(False) | 260 self.container.setDocked(False) |
258 self.container.hide() | 261 self.container.hide() |
259 | 262 |
260 self._showAction.setChecked(False) | 263 self._showAction.setChecked(False) |