annotate clients/editor/plugins/LayerTool.py @ 377:fe6fb0e0ed23

Adding freebsd8 build support. Thanks to varnie.
author prock@33b003aa-7bff-0310-803a-e67f0ece8222
date Wed, 09 Dec 2009 17:01:52 +0000
parents 598547404022
children
rev   line source
358
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
1 # -*- coding: utf-8 -*-
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
2
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
3 # ####################################################################
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
4 # Copyright (C) 2005-2009 by the FIFE team
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
5 # http://www.fifengine.de
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
6 # This file is part of FIFE.
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
7 #
358
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
8 # FIFE is free software; you can redistribute it and/or
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
9 # modify it under the terms of the GNU Lesser General Public
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
10 # License as published by the Free Software Foundation; either
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
11 # version 2.1 of the License, or (at your option) any later version.
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
12 #
358
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
13 # This library is distributed in the hope that it will be useful,
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
16 # Lesser General Public License for more details.
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
17 #
358
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
18 # You should have received a copy of the GNU Lesser General Public
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
19 # License along with this library; if not, write to the
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
20 # Free Software Foundation, Inc.,
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
21 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
22 # ####################################################################
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
23
358
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
24 """ A layer tool for FIFedit """
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
25
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
26 import fife
358
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
27 import pychan
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
28 import pychan.widgets as widgets
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
29 from pychan.tools import callbackWithArguments as cbwa
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
30
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
31 import scripts.plugin as plugin
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
32 import scripts.editor
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
33 from scripts.events import *
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
34 from scripts.gui.action import Action
343
8e71629c4c43 Several changes to layer, camera and map dialogs:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 340
diff changeset
35 from scripts.gui.layerdialog import LayerDialog
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
36
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
37 class LayerTool(plugin.Plugin):
322
3853f8659598 - small changes to code layout to make it more readable
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 321
diff changeset
38 """ The B{LayerTool} allows to select and show / hide layers of a loaded
3853f8659598 - small changes to code layout to make it more readable
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 321
diff changeset
39 map as well as creating new layers or edit layer properties
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
40 """
358
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
41
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
42 # default should be pychan default, highlight can be choosen (format: r,g,b)
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
43 DEFAULT_BACKGROUND_COLOR = pychan.internal.DEFAULT_STYLE['default']['base_color']
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
44 HIGHLIGHT_BACKGROUND_COLOR = pychan.internal.DEFAULT_STYLE['default']['selection_color']
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
45
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
46 # the dynamicly created widgets have the name scheme prefix + layerid
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
47 LABEL_NAME_PREFIX = "select_"
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
48
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
49 def __init__(self):
358
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
50 # Editor instance
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
51 self._editor = None
358
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
52
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
53 # Plugin variables
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
54 self._enabled = False
358
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
55
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
56 # Current mapview
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
57 self._mapview = None
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
58
358
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
59 # Toolbar button to display LayerTool
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
60 self._action_show = None
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
61
358
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
62 # GUI
319
62ec3b530cc6 * Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 316
diff changeset
63 self._layer_wizard = None
358
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
64 self._container = None
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
65 self._wrapper = None
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
66 self._remove_layer_button = None
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
67 self._create_layer_button = None
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
68 self._edit_layer_button = None
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
69
358
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
70 #--- Plugin functions ---#
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
71 def enable(self):
358
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
72 """ Enable plugin """
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
73 if self._enabled is True:
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
74 return
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
75
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
76 # Fifedit plugin data
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
77 self._editor = scripts.editor.getEditor()
358
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
78 self._action_show = Action(u"LayerTool", checkable=True)
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
79 scripts.gui.action.activated.connect(self.toggle, sender=self._action_show)
359
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 358
diff changeset
80 self._editor._tools_menu.addAction(self._action_show)
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
81
358
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
82 self._createGui()
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
83
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
84 self.toggle()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
85
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
86 events.postMapShown.connect(self.update)
367
598547404022 * Initial support for closing maps:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 359
diff changeset
87 events.preMapClosed.connect(self._mapClosed)
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
88
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
89 def disable(self):
358
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
90 """ Disable plugin """
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
91 if self._enabled is False:
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
92 return
358
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
93 self._container.setDocked(False)
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
94 self._container.hide()
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
95
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
96 events.postMapShown.disconnect(self.update)
367
598547404022 * Initial support for closing maps:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 359
diff changeset
97 events.preMapClosed.disconnect(self._mapClosed)
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
98
359
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 358
diff changeset
99 self._editor._tools_menu.removeAction(self._action_show)
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
100
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
101 def isEnabled(self):
358
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
102 """ Returns True if plugin is enabled """
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
103 return self._enabled;
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
104
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
105 def getName(self):
358
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
106 """ Return plugin name """
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
107 return u"Layertool"
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
108
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
109 #--- End plugin functions ---#
367
598547404022 * Initial support for closing maps:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 359
diff changeset
110 def _mapClosed(self):
598547404022 * Initial support for closing maps:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 359
diff changeset
111 self.update(mapview=None)
598547404022 * Initial support for closing maps:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 359
diff changeset
112
598547404022 * Initial support for closing maps:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 359
diff changeset
113
358
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
114 def showLayerWizard(self):
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
115 """ Show layer wizard """
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
116 if not self._mapview: return
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
117
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
118 if self._layer_wizard: self._layer_wizard._widget.hide()
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
119 self._layer_wizard = LayerDialog(self._editor.getEngine(), self._mapview.getMap(), callback=self._layerCreated)
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
120
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
121 def showEditDialog(self):
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
122 """ Show layerdialog for active layer """
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
123 if not self._mapview: return
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
124 layer = self.getActiveLayer()
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
125 if not layer: return
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
126
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
127 if self._layer_wizard: self._layer_wizard._widget.hide()
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
128 self._layer_wizard = LayerDialog(self._editor.getEngine(), self._mapview.getMap(), layer=layer, callback=cbwa(self.update, self._mapview))
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
129
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
130 def clear(self):
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
131 """ Remove all subwrappers """
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
132 self._wrapper.removeAllChildren()
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
133
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
134 def update(self, mapview):
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
135 """ Update layertool with information from mapview
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
136
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
137 We group one ToggleButton and one Label into a HBox, the main wrapper
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
138 itself is a VBox and we also capture both the Button and the Label to listen
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
139 for mouse actions
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
140
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
141 @type event: object
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
142 @param event: pychan mouse event
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
143 """
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
144 layers = []
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
145 self._mapview = mapview
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
146 if self._mapview is not None:
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
147 layers = self._mapview.getMap().getLayers()
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
148
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
149 self.clear()
323
b64ce990abb1 LayerTool:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 322
diff changeset
150
358
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
151 if len(layers) <= 0:
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
152 if not self._mapview:
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
153 layerid = "No map is open"
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
154 else:
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
155 layerid = "No layers"
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
156 subwrapper = pychan.widgets.HBox()
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
157
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
158 layerLabel = pychan.widgets.Label()
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
159 layerLabel.text = unicode(layerid)
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
160 layerLabel.name = LayerTool.LABEL_NAME_PREFIX + layerid
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
161 subwrapper.addChild(layerLabel)
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
162
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
163 self._wrapper.addChild(subwrapper)
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
164
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
165 active_layer = self.getActiveLayer()
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
166 if active_layer:
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
167 active_layer = active_layer.getId()
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
168 for layer in reversed(layers):
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
169 layerid = layer.getId()
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
170 subwrapper = pychan.widgets.HBox()
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
171
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
172 toggleVisibleButton = pychan.widgets.ToggleButton(hexpand=0, up_image="gui/icons/is_visible.png", down_image="gui/icons/is_visible.png", hover_image="gui/icons/is_visible.png")
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
173 toggleVisibleButton.name = "toggle_" + layerid
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
174 if layer.areInstancesVisible():
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
175 toggleVisibleButton.toggled = True
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
176 toggleVisibleButton.capture(self.toggleLayerVisibility)
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
177
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
178 layerLabel = pychan.widgets.Label()
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
179 layerLabel.text = unicode(layerid)
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
180 layerLabel.name = LayerTool.LABEL_NAME_PREFIX + layerid
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
181 layerLabel.capture(self.selectLayer,"mousePressed")
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
182
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
183 if active_layer == layerid:
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
184 layerLabel.background_color = LayerTool.HIGHLIGHT_BACKGROUND_COLOR
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
185 layerLabel.foreground_color = LayerTool.HIGHLIGHT_BACKGROUND_COLOR
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
186 layerLabel.base_color = LayerTool.HIGHLIGHT_BACKGROUND_COLOR
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
187
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
188 subwrapper.addChild(toggleVisibleButton)
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
189 subwrapper.addChild(layerLabel)
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
190
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
191 self._wrapper.addChild(subwrapper)
323
b64ce990abb1 LayerTool:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 322
diff changeset
192
358
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
193 self._container.adaptLayout()
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
194
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
195 def toggleLayerVisibility(self, event, widget):
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
196 """ Callback for ToggleButtons
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
197
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
198 Toggle the chosen layer visible / invisible. If the active layer is hidden,
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
199 it will be deselected.
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
200
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
201 @type event: object
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
202 @param event: pychan mouse event
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
203 @type widget: object
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
204 @param widget: the pychan widget where the event occurs, transports the layer id in it's name
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
205 """
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
206
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
207 layerid = widget.name[len(LayerTool.LABEL_NAME_PREFIX):]
323
b64ce990abb1 LayerTool:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 322
diff changeset
208
358
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
209 layer = self._mapview.getMap().getLayer(layerid)
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
210 active_layer = self.getActiveLayer()
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
211 if active_layer:
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
212 active_layer = active_layer.getId()
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
213
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
214 if layer.areInstancesVisible():
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
215 layer.setInstancesVisible(False)
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
216 else:
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
217 layer.setInstancesVisible(True)
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
218
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
219 if active_layer == layerid:
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
220 self.resetSelection()
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
221
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
222 def getActiveLayer(self):
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
223 """ Returns the active layer """
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
224 if self._mapview:
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
225 return self._mapview.getController()._layer
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
226
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
227 def selectLayer(self, event, widget=None, layerid=None):
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
228 """ Callback for Labels
323
b64ce990abb1 LayerTool:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 322
diff changeset
229
358
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
230 We hand the layerid over to the mapeditor module to select a
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
231 new active layer
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
232
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
233 Additionally, we mark the active layer widget (changing base color) and reseting the previous one
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
234
358
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
235 @type event: object
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
236 @param event: pychan mouse event
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
237 @type widget: object
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
238 @param widget: the pychan widget where the event occurs, transports the layer id in it's name
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
239 @type layerid: string
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
240 @param layerid: the layer id
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
241 """
358
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
242
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
243 if not widget and not layerid:
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
244 print "No layer ID or widget passed to LayerTool.selectLayer"
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
245 return
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
246
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
247 if widget is not None:
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
248 layerid = widget.name[len(LayerTool.LABEL_NAME_PREFIX):]
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
249
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
250 self.resetSelection()
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
251
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
252 widget.background_color = LayerTool.HIGHLIGHT_BACKGROUND_COLOR
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
253 widget.foreground_color = LayerTool.HIGHLIGHT_BACKGROUND_COLOR
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
254 widget.base_color = LayerTool.HIGHLIGHT_BACKGROUND_COLOR
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
255
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
256 self._mapview.getController().selectLayer(layerid)
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
257
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
258 def resetSelection(self):
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
259 """ Deselects selected layer """
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
260 previous_active_layer = self.getActiveLayer()
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
261 if previous_active_layer is not None:
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
262 previous_layer_id = previous_active_layer.getId()
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
263 previous_active_widget = self._container.findChild(name=LayerTool.LABEL_NAME_PREFIX + previous_layer_id)
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
264 previous_active_widget.background_color = LayerTool.DEFAULT_BACKGROUND_COLOR
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
265 previous_active_widget.foreground_color = LayerTool.DEFAULT_BACKGROUND_COLOR
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
266 previous_active_widget.base_color = LayerTool.DEFAULT_BACKGROUND_COLOR
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
267 previous_active_widget.text = unicode(previous_layer_id)
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
268
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
269 self._mapview.getController().selectLayer(None)
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
270
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
271
319
62ec3b530cc6 * Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 316
diff changeset
272 def removeSelectedLayer(self):
358
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
273 """ Deletes the selected layer """
319
62ec3b530cc6 * Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 316
diff changeset
274 if not self._mapview: return
62ec3b530cc6 * Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 316
diff changeset
275
321
7ddec4ce99b3 Fixed a crash when removing the layer which the editor camera uses
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 319
diff changeset
276 if self._mapview.getMap().getNumLayers() <= 1:
7ddec4ce99b3 Fixed a crash when removing the layer which the editor camera uses
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 319
diff changeset
277 print "Can't remove the last layer"
7ddec4ce99b3 Fixed a crash when removing the layer which the editor camera uses
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 319
diff changeset
278 return
7ddec4ce99b3 Fixed a crash when removing the layer which the editor camera uses
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 319
diff changeset
279
319
62ec3b530cc6 * Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 316
diff changeset
280 layer = self.getActiveLayer()
62ec3b530cc6 * Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 316
diff changeset
281 if not layer: return
62ec3b530cc6 * Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 316
diff changeset
282
358
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
283 self.resetSelection()
319
62ec3b530cc6 * Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 316
diff changeset
284
321
7ddec4ce99b3 Fixed a crash when removing the layer which the editor camera uses
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 319
diff changeset
285 map = self._mapview.getMap()
7ddec4ce99b3 Fixed a crash when removing the layer which the editor camera uses
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 319
diff changeset
286
7ddec4ce99b3 Fixed a crash when removing the layer which the editor camera uses
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 319
diff changeset
287 # FIFE will crash if we try to delete the layer which is in use by a camera
7ddec4ce99b3 Fixed a crash when removing the layer which the editor camera uses
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 319
diff changeset
288 # so we will set the camera to another layer instead
7ddec4ce99b3 Fixed a crash when removing the layer which the editor camera uses
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 319
diff changeset
289 for cam in self._editor.getEngine().getView().getCameras():
322
3853f8659598 - small changes to code layout to make it more readable
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 321
diff changeset
290 if cam.getLocationRef().getMap().getId() != map.getId():
3853f8659598 - small changes to code layout to make it more readable
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 321
diff changeset
291 continue
3853f8659598 - small changes to code layout to make it more readable
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 321
diff changeset
292
3853f8659598 - small changes to code layout to make it more readable
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 321
diff changeset
293 if cam.getLocation().getLayer().getId() != layer.getId():
3853f8659598 - small changes to code layout to make it more readable
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 321
diff changeset
294 continue
3853f8659598 - small changes to code layout to make it more readable
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 321
diff changeset
295
3853f8659598 - small changes to code layout to make it more readable
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 321
diff changeset
296 for l in map.getLayers():
3853f8659598 - small changes to code layout to make it more readable
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 321
diff changeset
297 if l.getId() == layer.getId():
3853f8659598 - small changes to code layout to make it more readable
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 321
diff changeset
298 continue
3853f8659598 - small changes to code layout to make it more readable
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 321
diff changeset
299
3853f8659598 - small changes to code layout to make it more readable
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 321
diff changeset
300 cam.getLocationRef().setLayer(l)
3853f8659598 - small changes to code layout to make it more readable
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 321
diff changeset
301 break
321
7ddec4ce99b3 Fixed a crash when removing the layer which the editor camera uses
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 319
diff changeset
302
319
62ec3b530cc6 * Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 316
diff changeset
303 map.deleteLayer(layer)
62ec3b530cc6 * Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 316
diff changeset
304 self.update(self._mapview)
358
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
305
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
306 def toggle(self):
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
307 """ Toggles the layertool visible / invisible and sets
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
308 dock status
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
309 """
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
310 if self._container.isVisible() or self._container.isDocked():
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
311 self._container.setDocked(False)
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
312 self._container.hide()
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
313
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
314 self._action_show.setChecked(False)
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
315 else:
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
316 self._container.show()
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
317 self._action_show.setChecked(True)
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
318 self._adjustPosition()
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
319
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
320 def _createGui(self):
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
321 """ Create the basic gui container """
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
322 self._container = pychan.loadXML('gui/layertool.xml')
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
323 self._wrapper = self._container.findChild(name="layers_wrapper")
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
324 self._remove_layer_button = self._container.findChild(name="remove_layer_button")
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
325 self._create_layer_button = self._container.findChild(name="add_layer_button")
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
326 self._edit_layer_button = self._container.findChild(name="edit_layer_button")
319
62ec3b530cc6 * Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 316
diff changeset
327
358
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
328 self._remove_layer_button.capture(self.removeSelectedLayer)
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
329 self._remove_layer_button.capture(cbwa(self._editor.getStatusBar().showTooltip, self._remove_layer_button.helptext), 'mouseEntered')
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
330 self._remove_layer_button.capture(self._editor.getStatusBar().hideTooltip, 'mouseExited')
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
331
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
332 self._create_layer_button.capture(self.showLayerWizard)
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
333 self._create_layer_button.capture(cbwa(self._editor.getStatusBar().showTooltip, self._create_layer_button.helptext), 'mouseEntered')
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
334 self._create_layer_button.capture(self._editor.getStatusBar().hideTooltip, 'mouseExited')
323
b64ce990abb1 LayerTool:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 322
diff changeset
335
358
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
336 self._edit_layer_button.capture(self.showEditDialog)
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
337 self._edit_layer_button.capture(cbwa(self._editor.getStatusBar().showTooltip, self._edit_layer_button.helptext), 'mouseEntered')
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
338 self._edit_layer_button.capture(self._editor.getStatusBar().hideTooltip, 'mouseExited')
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
339
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
340 self.update(None)
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
341
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
342 def _adjustPosition(self):
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
343 """ Adjusts the position of the container - we don't want to
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
344 let the window appear at the center of the screen.
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
345 (new default position: left, beneath the tools window)
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
346 """
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
347 self._container.position = (50, 200)
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
348
323
b64ce990abb1 LayerTool:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 322
diff changeset
349 def _layerCreated(self, layer):
b64ce990abb1 LayerTool:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 322
diff changeset
350 self.update(self._mapview)
358
8f64a9d1e7ab * Cleaned up LayerTool so it follows the new python coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 343
diff changeset
351 self.selectLayer(None, self._wrapper.findChild(name=LayerTool.LABEL_NAME_PREFIX + layer.getId()))
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
352
319
62ec3b530cc6 * Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 316
diff changeset
353
62ec3b530cc6 * Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 316
diff changeset
354