summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Schwarz <michi.schwarz@gmail.com>2015-09-30 18:09:55 +0200
committerMichael Schwarz <michi.schwarz@gmail.com>2015-09-30 18:09:55 +0200
commit9f3e7bf14de8b5a45c8e4a6b86b6af0f787aa5ad (patch)
treed48d51eacba84018c07ebca08d34561b1dfbad55
parent5c055707309d0a94a344a291ef222862efead960 (diff)
downloadpogojig-9f3e7bf14de8b5a45c8e4a6b86b6af0f787aa5ad.tar.gz
pogojig-9f3e7bf14de8b5a45c8e4a6b86b6af0f787aa5ad.tar.bz2
pogojig-9f3e7bf14de8b5a45c8e4a6b86b6af0f787aa5ad.zip
Workaround for LayerMoveToPrev/Next not selecting correct layer.
Inkscape does not reliably select the previous or next layer when using LayerMoveToPrev or LayerMoveToNext.
-rw-r--r--support/inkscape/inkscape.py19
1 files changed, 12 insertions, 7 deletions
diff --git a/support/inkscape/inkscape.py b/support/inkscape/inkscape.py
index d395992..21634d2 100644
--- a/support/inkscape/inkscape.py
+++ b/support/inkscape/inkscape.py
@@ -78,15 +78,20 @@ class InkscapeCommandLine(object):
target_index = self._layers.index(layer)
- while True:
- if self._current_layer_index < target_index:
+ if self._current_layer_index < target_index:
+ for _ in range(target_index - self._current_layer_index):
self.apply_to_document('LayerMoveToNext' if with_selection else 'LayerNext')
- self._current_layer_index += 1
- elif self._current_layer_index > target_index:
+ elif self._current_layer_index > target_index:
+ for _ in range(self._current_layer_index - target_index):
self.apply_to_document('LayerMoveToPrev' if with_selection else 'LayerPrev')
- self._current_layer_index -= 1
- else:
- break
+ else:
+ return
+
+ if with_selection:
+ # When using LayerMoveToNext and LayerMoveToPrev, inkscape does not reliably select the next/previous layer.
+ self._current_layer_index = None
+ else:
+ self._current_layer_index = target_index
def duplicate_layer(self, layer):
self.apply_to_layer(layer, 'LayerDuplicate')