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 32 insertions and 16 deletions:
0 comments (0 inline, 0 general)
light9/curvecalc/curvecalc.glade
Show inline comments
 
@@ -670,49 +670,49 @@
 
            <property name="visible">True</property>
 
            <property name="can_focus">True</property>
 
            <property name="editable">False</property>
 
            <property name="wrap_mode">word</property>
 
            <property name="buffer">help</property>
 
          </object>
 
          <packing>
 
            <property name="expand">False</property>
 
            <property name="fill">False</property>
 
            <property name="position">3</property>
 
          </packing>
 
        </child>
 
      </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>
 
    <property name="title" translatable="yes">New curve</property>
 
    <property name="modal">True</property>
 
    <property name="window_position">mouse</property>
 
    <property name="type_hint">normal</property>
 
    <child internal-child="vbox">
 
      <object class="GtkVBox" id="dialog-vbox1">
 
        <property name="visible">True</property>
 
        <property name="can_focus">False</property>
 
        <property name="spacing">2</property>
 
        <child internal-child="action_area">
 
          <object class="GtkHButtonBox" id="dialog-action_area1">
 
            <property name="visible">True</property>
light9/curvecalc/curveview.py
Show inline comments
 
@@ -91,164 +91,161 @@ class Curveview(object):
 
        self.last_mouse_world = None
 
        self.culled = False # have we been putting off updates?
 
        self.entered = False # is the mouse currently over this widget
 
        self.selected_points=[] # idx of points being dragged
 
        # self.bind("<Enter>",self.focus)
 
        dispatcher.connect(self.playPause, "onPlayPause")
 
        dispatcher.connect(self.input_time, "input time")
 
        dispatcher.connect(self.update_curve, "zoom changed")
 
        dispatcher.connect(self.update_curve, "points changed",
 
                           sender=self.curve)
 
        dispatcher.connect(self.update_curve, "mute changed", 
 
                           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>",
 
                      self.select_press, add=True)
 
            self.bind("<Motion>", self.select_motion, add=True)
 
            self.bind("<ButtonRelease-1>", #"<Alt-KeyRelease>",
 
                      self.select_release, add=True)
 

	
 
            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)
 
        box.show()
 
        
 
        self.canvas = goocanvas.Canvas()
 
        box.pack_start(self.canvas)
 
        self.canvas.show()
 
        
 
        self.canvas.set_property("background-color", "black")
 
        self.size = self.canvas.get_allocation()
 
        self.root = self.canvas.get_root_item()
 

	
 
        self.canvas.connect("size-allocate", self.update_curve)
 
        self.canvas.connect("expose-event", self.onExpose)
 

	
 
        self.canvas.connect("leave-notify-event", self.onLeave)
 
        self.canvas.connect("enter-notify-event", self.onEnter)
 
        self.canvas.connect("motion-notify-event", self.onMotion)
 
        self.canvas.connect("scroll-event", self.onScroll)
 
        self.canvas.connect("button-release-event", self.onRelease)
 
        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
 
        # the close one and add a point to that. Binding to the line
 
        # itself is probably too hard to hit. Maybe a background-color
 
        # really thick line would be a nice way to allow a sloppier
 
        # click
 

	
 
        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
 
        if self.entered:
 
            t = self.world_from_screen(self.lastMouseX, 0)[0]
 
            return t
 
        return None
 

	
 
    def goLive(self):
 
        """this is for startup performance only, since the curves were
 
        getting redrawn many times. """
 
        self.redrawsEnabled = True
 
        self.update_curve()
 

	
 
    def knob_in(self, curve, value):
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
 

	
 
add vidref on mousemove. separate process? yes
 

	
 
sub autocomplete
 

	
 
drop grids with keystrokes. grid all the beats that way? different
 
keys make different grid colors. do the beats from various songs with
 
different colors.
 

	
 
be able to select grid lines to delete them. maybe grid is on a
 
special curve row
 

	
 
hotter reloading of subs and values. from KC, drag a new sub into CC
0 comments (0 inline, 0 general)