Skip to content

Commit

Permalink
gui.linemode: move line ends when pressing ctrl+shift
Browse files Browse the repository at this point in the history
In addition to changing the curve points, the line ends can now
also be moved when pressing ctrl+shift (or to be precise, toggling
both to the opposite state they were in when the line was drawn).

Updates the toolbar message string to reflect this change.
  • Loading branch information
gwojcik authored and jplloyd committed Aug 16, 2020
1 parent 9e81378 commit 91500a7
Showing 1 changed file with 30 additions and 6 deletions.
36 changes: 30 additions & 6 deletions gui/linemode.py
Expand Up @@ -382,7 +382,7 @@ def start_command(self, modifier):
self.ellipse_vec = None
return
# If not Ellipse, command must be Straight Line or Sequence
# First check if the user intends to Curve an existing Line
# First check if the user intends to Curve or move an existing Line
if shift:
last_line = self.last_line_data
last_stroke = layer.get_last_stroke_info()
Expand All @@ -397,7 +397,9 @@ def start_command(self, modifier):
self.flip = length_a > length_b
if self.flip:
self.kx, self.ky = last_line[6], last_line[7]
self.k2x, self.k2y = last_line[8], last_line[9]
else:
self.k2x, self.k2y = last_line[6], last_line[7]
self.kx, self.ky = last_line[8], last_line[9]
self.model.undo()
self.process_line()
Expand All @@ -421,6 +423,14 @@ def stop_command(self):
self.record_last_stroke(cmd, x, y)

def record_last_stroke(self, cmd, x, y):
""" Store last stroke data
Stroke data is used for redraws and modifications of the line.
:param str cmd: name of the last command
:param int x: last cursor x-coordinate
:param int y: last cursor y-coordinate
"""
last_line = None
self.tdw.last_painting_pos = x, y
# FIXME: should probably not set that from here
Expand All @@ -444,14 +454,14 @@ def record_last_stroke(self, cmd, x, y):
cmd, last_stroke,
sx, sy,
self.ex, self.ey,
self.kx, self.ky, x, y,
self.kx, self.ky, self.k2x, self.k2y,
]
else:
last_line = [
cmd, last_stroke,
sx, sy,
self.ex, self.ey,
x, y, self.kx, self.ky,
self.k2x, self.k2y, self.kx, self.ky,
]
self.tdw.last_painting_pos = self.ex, self.ey

Expand Down Expand Up @@ -493,10 +503,22 @@ def process_line(self):
elif self.mode == "CurveLine2":
ex, ey = self.ex, self.ey
kx, ky = self.kx, self.ky
if not self.flip:
self.dynamic_curve_2(x, y, sx, sy, ex, ey, kx, ky)
k2x, k2y = self.k2x, self.k2y
if shift and ctrl:
# moved line end
if not self.flip:
self.dynamic_curve_2(k2x, k2y, x, y, ex, ey, kx, ky)
self.sx, self.sy = x, y
else:
self.dynamic_curve_2(kx, ky, sx, sy, x, y, k2x, k2y)
self.ex, self.ey = x, y
else:
self.dynamic_curve_2(kx, ky, sx, sy, ex, ey, x, y)
# changed curve shape
self.k2x, self.k2y = x, y
if not self.flip:
self.dynamic_curve_2(x, y, sx, sy, ex, ey, kx, ky)
else:
self.dynamic_curve_2(kx, ky, sx, sy, ex, ey, x, y)

elif self.mode == "EllipseMode":
constrain = False
Expand Down Expand Up @@ -755,6 +777,7 @@ def redraw_line_cb(self):
if command == "CurveLine2":
x, y = last_line[6], last_line[7]
self.kx, self.ky = last_line[8], last_line[9]
self.k2x, self.k2y = x, y
if (x, y) == (self.kx, self.ky):
self.dynamic_curve_1(x, y, self.sx, self.sy,
self.ex, self.ey)
Expand All @@ -778,6 +801,7 @@ def get_name(cls):

def get_usage(self):
return _(u"Draw straight lines; Shift adds curves, "
"Shift + Ctrl moves line ends, "
"Ctrl constrains angle")


Expand Down

0 comments on commit 91500a7

Please sign in to comment.