Changeset - 8169d88d4eb4
[Not reviewed]
default
0 3 0
Drew Perttula - 13 years ago 2012-06-13 06:07:27
drewp@bigasterisk.com
fix 1..5 keys. add more readme
Ignore-this: a5491a5e6de3facfda724a8b7d730ef8
3 files changed with 33 insertions and 17 deletions:
0 comments (0 inline, 0 general)
light9/curvecalc/curvecalc.glade
Show inline comments
 
@@ -682,25 +682,25 @@
 
      </object>
 
    </child>
 
  </object>
 
  <object class="GtkAccelGroup" id="accelgroup1"/>
 
  <object class="GtkAdjustment" id="adjustment1">
 
    <property name="upper">100</property>
 
    <property name="step_increment">1</property>
 
    <property name="page_increment">10</property>
 
  </object>
 
  <object class="GtkTextBuffer" id="help">
 
    <property name="text">Mousewheel zoom; C-p play/pause music at mouse
 
Over a curve: C to collapse; R to rebuild canvas widget
 
Curve point bindings: B1 drag point; C-B1 curve add point; S-B1 sketch points; 1..5 add point at time; B1 drag select points
 
Curve point bindings: B1 drag point; C-B1 curve add point; S-B1 sketch points; 1..5 add point at time cursor; 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; chan(name); curvename(t) eval curve</property>
 
  </object>
 
  <object class="GtkImage" id="image2">
 
    <property name="visible">True</property>
 
    <property name="can_focus">False</property>
 
    <property name="stock">gtk-refresh</property>
 
  </object>
 
  <object class="GtkListStore" id="liststore1"/>
 
  <object class="GtkDialog" id="newCurve">
 
    <property name="can_focus">False</property>
 
    <property name="border_width">5</property>
 
    <property name="type">popup</property>
light9/curvecalc/curveview.py
Show inline comments
 
@@ -102,32 +102,25 @@ class Curveview(object):
 
                           sender=self.curve)
 
        dispatcher.connect(self.select_between, "select between")
 
        if self.knobEnabled:
 
            dispatcher.connect(self.knob_in, "knob in")
 
            dispatcher.connect(self.slider_in, "set key")
 

	
 

	
 
        # todo: hold control to get a [+] cursor
 
        #        def curs(ev):
 
        #            print ev.state
 
        #        self.bind("<KeyPress>",curs)
 
        #        self.bind("<KeyRelease-Control_L>",lambda ev: curs(0))
 
        
 
        if 0:
 
            for x in range(1, 6):
 
                def add_kb_marker_point(evt, x=x):
 
                    self.add_point((self.current_time(), (x - 1) / 4.0))
 

	
 
                self.bind("<Key-%s>" % x, add_kb_marker_point)
 

	
 
      
 
        # this binds on c-a-b1, etc
 
        if 0:
 
            self.regionzoom = RegionZoom(self, self.world_from_screen,
 
                                         self.screen_from_world)
 

	
 
        self.sketch = None # an in-progress sketch
 

	
 
        self.dragging_dots = False
 
        self.selecting = False
 
        
 
        if 0:
 
            self.bind("<ButtonPress-1>",#"<Alt-Key>",
 
@@ -139,24 +132,25 @@ class Curveview(object):
 
            self.bind("<ButtonPress-1>", self.check_deselect, add=True)
 

	
 
            self.bind("<Key-m>", lambda *args: self.curve.toggleMute())
 

	
 
    def rebuild(self):
 
        """
 
        sometimes after windows get resized, canvas gets stuck with a
 
        weird offset. I can't find where it is, so for now we support
 
        rebuilding the canvas widget
 
        """
 
        if hasattr(self, 'widget'):
 
            self.widget.destroy()
 
            self._time = -999
 
            print "rebuilding canvas"
 

	
 
        self.timelineLine = self.curveGroup = None
 
        self.widget = gtk.EventBox()
 
        self.widget.set_can_focus(True)
 
        self.widget.add_events(gtk.gdk.KEY_PRESS_MASK |
 
                               gtk.gdk.FOCUS_CHANGE_MASK)
 
        self.onFocusOut()
 

	
 
        box = gtk.VBox()
 
        box.set_border_width(1)
 
        self.widget.add(box)
 
@@ -181,34 +175,34 @@ class Curveview(object):
 
        self.root.connect("button-press-event", self.onCanvasPress)
 

	
 
        self.widget.connect("key-press-event", self.onKeyPress)
 

	
 
        self.widget.connect("focus-in-event", self.onFocusIn)
 
        self.widget.connect("focus-out-event", self.onFocusOut)
 
        self.widget.connect("event", self.onAny)
 

	
 
    def onAny(self, w, event):
 
        print "   %s on %s" % (event, w)
 
        
 
    def onFocusIn(self, *args):
 
        print "focusin", args
 
        self.widget.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("red"))
 

	
 
    def onFocusOut(self, widget=None, event=None):
 
        #if event:
 
        #    import pdb;pdb.set_trace()
 
        print "focusout now", event.get_state() if event else 0
 
        self.widget.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("gray30"))
 

	
 
    def onKeyPress(self, *args):
 
        print "canvas key", args
 
    def onKeyPress(self, widget, event):
 
        print "canvas key", event
 
        if event.string in '12345':
 
            x = int(event.string)
 
            self.add_point((self.current_time(), (x - 1) / 4.0))
 

	
 
    def onExpose(self, *args):
 
        if self.culled:
 
            self.update_curve()
 

	
 
    def onDelete(self):
 
        if self.selected_points:
 
            self.remove_point_idx(*self.selected_points)
 
        
 
            
 
    def onCanvasPress(self, item, target_item, event):
 
        # when we support multiple curves per canvas, this should find
 
@@ -219,24 +213,27 @@ class Curveview(object):
 

	
 
        print "focus on", self.widget
 
        self.widget.grab_focus()
 
        print "done grab"
 
        
 
        if event.get_state() & gtk.gdk.CONTROL_MASK:
 
            self.new_point_at_mouse(event)
 
        elif event.get_state() & gtk.gdk.SHIFT_MASK:
 
            self.sketch_press(event)
 
        else:
 
            self.select_press(event)
 

	
 
        # this stops some other handler that wants to unfocus 
 
        return True
 

	
 
    def playPause(self):
 
        """
 
        user has pressed ctrl-p over a curve view, possibly this
 
        one. Returns the time under the mouse if we know it, or else
 
        None
 

	
 
        todo: there should be a faint timecursor line under the mouse
 
        so it's more obvious that we use that time for some
 
        events. Rt-click should include Ctrl+P as 'play/pause from
 
        here'
 
        """
 
        # maybe self.canvas.get_pointer would be ok for this? i didn't try it
readme
Show inline comments
 
on dash:
 
Mini instructions:
 

	
 
% buildout2.7
 

	
 
% export LIGHT9_SHOW=path/to/light9/show/dance2011
 

	
 
Edit $LIGHT9_SHOW/config.n3 to set :musicRoot and the values under sh:netHome 
 

	
 
% bin/dmxserver --dummy
 
(leave that shell)
 

	
 
dash(pts/35):/my/dl/modified/mpd% src/mpd --no-daemon --verbose
 
% bin/ascoltami2
 
(leave that shell)
 

	
 
Browse to http://localhost:8040/ to see the music player.
 

	
 
% bin/curvecalc --reload http://light9.bigasterisk.com/show/dance2011/song16
 
(gui opens)
 

	
 
See bin/listsongs for a way to make zsh autocomplete on the last
 
argument to bin/curvecalc
 

	
 

	
 

	
 
--------------------------------
 

	
 
curvecalc upgrades:
 

	
 
1..5 keys
 

	
 
fix fader UIs
 

	
 
draw handles for moving and resizing a fade with various anchor points
 

	
0 comments (0 inline, 0 general)