diff --git a/bin/curvecalc b/bin/curvecalc --- a/bin/curvecalc +++ b/bin/curvecalc @@ -414,7 +414,7 @@ root.bind("", lambda evt: create_status_lines(root) for helpline in ["Bindings: C-s save subterms; Esc see current time; S-Esc see curtime to end; Mousewheel zoom; C-p play/pause music at mouse", - "Curve point bindings: B1 drag point; C-B1 curve add point; S-B1 sketch points; Del selected points; 1..5 add point at time; Alt-Shift-B1 drag select points", + "Curve point bindings: B1 drag point; C-B1 curve add point; S-B1 sketch points; Del selected points; 1..5 add point at time; B1 drag select points", "Available in functions: nsin/ncos period=amp=1; within(a,b) bef(x) aft(x) compare to time; smoove(x) cubic smoothstep; curvename(t) eval curve"]: tk.Label(root,text=helpline, font="Helvetica -12 italic", anchor='w').pack(side='top',fill='x') diff --git a/light9/curve.py b/light9/curve.py --- a/light9/curve.py +++ b/light9/curve.py @@ -181,15 +181,21 @@ class Curveview(tk.Canvas): self.bind("", self.sketch_release) - # hold alt-shift to select, since i had a hard time detecting - # other combos right + self.dragging_dots = False self.selecting = False - self.bind("", self.select_press) + self.bind("",#"", + self.select_press) self.bind("", self.select_motion, add=True) - self.bind("", self.select_release) + self.bind("", #"", + self.select_release) self.bind("", self.check_deselect, add=True) + def print_state(self, msg=""): + if 0: + print "%s: dragging_dots=%s selecting=%s" % ( + msg, self.dragging_dots, self.selecting) + def check_deselect(self,ev): try: self.find_index_near(ev.x, ev.y) @@ -198,6 +204,9 @@ class Curveview(tk.Canvas): self.highlight_selected_dots() def select_press(self,ev): + self.print_state("select_press") + if self.dragging_dots: + return if not self.selecting: self.selecting = True self.select_start = self.world_from_screen(ev.x,0)[0] @@ -206,14 +215,22 @@ class Curveview(tk.Canvas): def select_motion(self,ev): if not self.selecting: return + start = self.select_start + cur = self.world_from_screen(ev.x, 0)[0] + self.select_between(start, cur) def select_release(self,ev): + self.print_state("select_release") + + # dotrelease never gets called, but I can clear that state here + self.dragging_dots = False + if not self.selecting: return cursors.pop(self) self.selecting = False - s,e = (self.select_start, self.world_from_screen(ev.x,0)[0]) - self.select_between(min(s,e), max(s,e)) + self.select_between(self.select_start, + self.world_from_screen(ev.x,0)[0]) def sketch_press(self,ev): self.sketch = Sketch(self,ev) @@ -415,16 +432,22 @@ class Curveview(tk.Canvas): self.itemconfigure(d,fill='blue') def dotpress(self,ev,dotidx): + self.print_state("dotpress") if dotidx not in self.selected_points: self.selected_points=[dotidx] self.highlight_selected_dots() self.last_mouse_world = self.world_from_screen(ev.x, ev.y) + self.dragging_dots = True def select_between(self,start,end): + if start > end: + start, end = end, start self.selected_points = self.curve.indices_between(start,end) self.highlight_selected_dots() def dotmotion(self,ev): + if not self.dragging_dots: + return if not ev.state & 256: return # not lmb-down cp = self.curve.points @@ -458,6 +481,9 @@ class Curveview(tk.Canvas): self.highlight_selected_dots() def dotrelease(self,ev): + self.print_state("dotrelease") + if not self.dragging_dots: + return self.last_mouse_world = None class Curveset: