changeset 216:2a80f7d9aede

- changed autoselection once a layer is toggled invisible, now an exception is thrown because we also deselect the layer in the mapedit module
author chewie@33b003aa-7bff-0310-803a-e67f0ece8222
date Tue, 17 Mar 2009 23:47:56 +0000
parents 5f5f8ca6db93
children 68ae8f4234ca
files clients/editor/plugins/layertool.py
diffstat 1 files changed, 22 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/clients/editor/plugins/layertool.py	Tue Mar 17 23:18:11 2009 +0000
+++ b/clients/editor/plugins/layertool.py	Tue Mar 17 23:47:56 2009 +0000
@@ -58,6 +58,7 @@
 		self.menu_items = { 'LayerTool' : self.toggle }
 		self._mapedit = mapedit
 		self.data = False
+		self.previous_active_layer = None
 		
 		# "register" at mapeditor module 
 		self._mapedit.layertool = self
@@ -148,15 +149,27 @@
 		
 		if layer.areInstancesVisible():
 			layer.setInstancesVisible(False)
-			self.select_different_active_layer(layerid)
+			self.select_no_layer()
+#			self.select_different_active_layer(layerid)
 		else:
 			layer.setInstancesVisible(True)
 			
+			
+	def select_no_layer(self):
+		""" the exception approach - as soon as the user hides a layer, the mapedit module should stop to use this
+		one, too.
+		
+		A bunch of exceptions is the result (each click on the map will result in a exception as no layer is set etc...)	
+		"""
+		self._mapedit._editLayer(None)
 		
 	def select_different_active_layer(self, layerid):
 		""" a helper method to pick either the previous or next layer in the layerlist
 		by using the given layerid as pivot element
 		
+		NOTE:
+			- dropped for now, we set self.mapedit._layer to None if a layer gets invisible
+		
 		FIXME:
 			- either drop this feature or find a solution for boderline cases:
 				- user hides all layers (which one should be active?)
@@ -199,12 +212,13 @@
 		"""
 		if not self.data: return
 		
-		previous_active_layer = self._mapedit._layer.getId()
-		previous_active_widget = self.container.findChild(name="select_" + str(previous_active_layer))
-		previous_active_widget._setBackgroundColor(_DEFAULT_BACKGROUND_COLOR)
-		previous_active_widget._setForegroundColor(_DEFAULT_BACKGROUND_COLOR)
-		previous_active_widget._setBaseColor(_DEFAULT_BACKGROUND_COLOR)		
-		previous_active_widget.text = str(previous_active_layer)
+		if self.previous_active_layer is not None:
+			previous_layer_id = str(self.previous_active_layer)
+			previous_active_widget = self.container.findChild(name="select_" + previous_layer_id)
+			previous_active_widget._setBackgroundColor(_DEFAULT_BACKGROUND_COLOR)
+			previous_active_widget._setForegroundColor(_DEFAULT_BACKGROUND_COLOR)
+			previous_active_widget._setBaseColor(_DEFAULT_BACKGROUND_COLOR)		
+			previous_active_widget.text = previous_layer_id
 		
 		layerid = widget.name[7:]	
 		
@@ -212,6 +226,7 @@
 		widget._setForegroundColor(_HIGHLIGHT_BACKGROUND_COLOR)
 		widget._setBaseColor(_HIGHLIGHT_BACKGROUND_COLOR)
 		widget.text = widget.text + " *"
+		self.previous_active_layer = layerid
 		self.container.adaptLayout()
 		
 		self._mapedit._editLayer(layerid)