Mercurial > code > home > repos > light9
changeset 361:ff914126f3ea
fix CC selection bindings
author | Drew Perttula <drewp@bigasterisk.com> |
---|---|
date | Fri, 15 Jun 2007 04:29:44 +0000 |
parents | 415c206f7534 |
children | fc87327e29c4 |
files | bin/curvecalc light9/curve.py |
diffstat | 2 files changed, 33 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/bin/curvecalc Wed Jun 13 07:23:54 2007 +0000 +++ b/bin/curvecalc Fri Jun 15 04:29:44 2007 +0000 @@ -414,7 +414,7 @@ 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')
--- a/light9/curve.py Wed Jun 13 07:23:54 2007 +0000 +++ b/light9/curve.py Fri Jun 15 04:29:44 2007 +0000 @@ -181,15 +181,21 @@ self.bind("<Shift-ButtonRelease-1>", 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("<Alt-Key>", self.select_press) + self.bind("<ButtonPress-1>",#"<Alt-Key>", + self.select_press) self.bind("<Motion>", self.select_motion, add=True) - self.bind("<Alt-KeyRelease>", self.select_release) + self.bind("<ButtonRelease-1>", #"<Alt-KeyRelease>", + self.select_release) self.bind("<ButtonPress-1>", 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 @@ 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 @@ 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 @@ 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 @@ 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: