Changeset - 0b8fc64a896c
[Not reviewed]
default
0 3 0
Drew Perttula - 13 years ago 2012-06-08 07:54:32
drewp@bigasterisk.com
goocanvas drawing a little
Ignore-this: aae191151f454a98caa671b65d080029
3 files changed with 29 insertions and 15 deletions:
0 comments (0 inline, 0 general)
bin/curvecalc
Show inline comments
 
@@ -54,20 +54,20 @@ class Main(object):
 
        mainwin.connect("destroy", gtk.main_quit)
 
        wtree.connect_signals(self)
 
        mainwin.show_all()
 

	
 
        mainwin.connect("delete-event", lambda *args: reactor.crash())
 
        mainwin.set_title("curvecalc - %s" % graph.label(song))
 
        mainwin.parse_geometry("1000x1000")
 
        
 
        self.add_subterms_for_song(song, curveset, subterms,
 
                                   wtree.get_object("subterms")
 
                                   )
 

	
 

	
 
        curvesetView = Curvesetview(wtree.get_object("curves"), curveset)
 
        self.curvesetView = curvesetView # mem problem; don't let this get lost
 

	
 
        # curvesetview must already exist, since this makes 'add_curve'
 
        # signals for all the initial curves
 
        curveset.load(basename=os.path.join(
 
            showconfig.curvesDir(),
 
            showconfig.songFilenameFromURI(song)),
light9/curvecalc/curvecalc.glade
Show inline comments
 
<?xml version="1.0" encoding="UTF-8"?>
 
<interface>
 
  <!-- interface-requires gtk+ 3.0 -->
 
  <object class="GtkWindow" id="MainWindow">
 
    <property name="width_request">530</property>
 
    <property name="height_request">380</property>
 
    <property name="can_focus">False</property>
 
    <child>
 
      <object class="GtkVBox" id="vbox1">
 
        <property name="visible">True</property>
 
        <property name="can_focus">False</property>
 
        <child>
 
@@ -207,17 +205,18 @@
 
            <property name="fill">True</property>
 
            <property name="position">0</property>
 
          </packing>
 
        </child>
 
        <child>
 
          <object class="GtkVPaned" id="paned1">
 
            <property name="height_request">200</property>
 
            <property name="height_request">600</property>
 
            <property name="visible">True</property>
 
            <property name="can_focus">True</property>
 
            <child>
 
              <object class="GtkExpander" id="expander2">
 
                <property name="height_request">400</property>
 
                <property name="visible">True</property>
 
                <property name="can_focus">True</property>
 
                <property name="expanded">True</property>
 
                <child>
 
                  <object class="GtkVBox" id="vbox4">
 
                    <property name="height_request">100</property>
 
@@ -308,12 +307,13 @@
 
                <property name="resize">False</property>
 
                <property name="shrink">True</property>
 
              </packing>
 
            </child>
 
            <child>
 
              <object class="GtkExpander" id="expander1">
 
                <property name="height_request">120</property>
 
                <property name="visible">True</property>
 
                <property name="can_focus">True</property>
 
                <property name="expanded">True</property>
 
                <child>
 
                  <object class="GtkVBox" id="box1">
 
                    <property name="visible">True</property>
 
@@ -368,12 +368,18 @@
 
                                <child>
 
                                  <placeholder/>
 
                                </child>
 
                                <child>
 
                                  <placeholder/>
 
                                </child>
 
                                <child>
 
                                  <placeholder/>
 
                                </child>
 
                                <child>
 
                                  <placeholder/>
 
                                </child>
 
                              </object>
 
                            </child>
 
                          </object>
 
                        </child>
 
                      </object>
 
                      <packing>
 
@@ -487,12 +493,18 @@
 
                    <child>
 
                      <placeholder/>
 
                    </child>
 
                    <child>
 
                      <placeholder/>
 
                    </child>
 
                    <child>
 
                      <placeholder/>
 
                    </child>
 
                    <child>
 
                      <placeholder/>
 
                    </child>
 
                  </object>
 
                </child>
 
                <child type="label">
 
                  <object class="GtkLabel" id="label1">
 
                    <property name="visible">True</property>
 
                    <property name="can_focus">False</property>
light9/curvecalc/curveview.py
Show inline comments
 
@@ -72,12 +72,14 @@ class Curveview(object):
 
    graphical curve widget only. Please pack .widget
 
    """
 
    def __init__(self, curve, knobEnabled=False, isMusic=False, **kw):
 
        """knobEnabled=True highlights the previous key and ties it to a
 
        hardware knob"""
 
        self.widget = goocanvas.Canvas()
 
        self.widget.set_property("background-color", "black")
 
        self.widget.set_size_request(-1, 130)
 
        self.root = self.widget.get_root_item()
 

	
 
        self.redrawsEnabled = False
 
        self.curve = curve
 
        self.knobEnabled = knobEnabled
 
        self._isMusic = isMusic
 
@@ -92,13 +94,13 @@ class Curveview(object):
 
        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")
 
        print "setup alloc", self.__dict__
 

	
 
        self.widget.connect("size-allocate", self.update_curve)
 
        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))
 
@@ -280,14 +282,13 @@ class Curveview(object):
 
                                 pos[0] + 8, pos[1] + 8,
 
                                 outline='#800000',
 
                                 tags=('knob',))
 
                dispatcher.send("knob out", value=prevKey[1], curve=self.curve)
 
        
 
    def update_curve(self, _widget=None, _rect=None):
 
        print "update curve on", self, id(self), self.__dict__
 
        if not getattr(self, 'redrawsEnabled', False):
 
        if not self.redrawsEnabled:
 
            return
 
        self.size = self.widget.get_allocation()
 

	
 
        self.zoom = 0, 3#dispatcher.send("zoom area")[0][1]
 
        cp = self.curve.points
 

	
 
@@ -355,13 +356,12 @@ class Curveview(object):
 

	
 
    def _draw_gradient_slice(self, x1, x2, color):
 
        self.create_rectangle(x1, 0, x2, 40,
 
                              fill=color, width=0, tags='curve')        
 

	
 
    def _draw_markers(self,visible_x):
 
        return
 
        mark = self._draw_one_marker
 

	
 
        mark(0,"0")
 
        t1,t2=visible_x
 
        if t2-t1<30:
 
            for t in range(int(t1),int(t2)+1):
 
@@ -377,18 +377,20 @@ class Curveview(object):
 
    def _draw_one_marker(self,t,label):
 
        x = self.screen_from_world((t,0))[0]
 
        ht = self.size.height
 
        if not 0 <= x < self.size.width:
 
            return
 
        x = max(5, x) # cheat left-edge stuff onscreen
 
        self.create_line(x, ht,
 
        goocanvas.polyline_new_line(self.curveGroup,
 
                                    x, ht,
 
                         x, ht - 20,
 
                         fill='white', tags=('curve',))
 
        self.create_text(x, ht-20, text=label, anchor='s', fill='white',
 
                         font="arial 7", tags=('curve',))
 

	
 
                                    stroke_color='white')
 
        goocanvas.Text(parent=self.curveGroup,
 
                       fill_color="white",
 
                       x=x, y=ht-20,
 
                       text=label)
 

	
 
    def _draw_line(self,visible_points):
 
        linepts=[]
 
        step=1
 
        linewidth=2
 
        # 800? maybe this should be related to self.width
 
@@ -401,13 +403,13 @@ class Curveview(object):
 
            return
 
        if self.curve.muted:
 
            fill = 'grey34'
 
        else:
 
            fill = 'white'
 

	
 
        goocanvas.Polyline(parent=self.curveGroup,
 
        self.pl = goocanvas.Polyline(parent=self.curveGroup,
 
                           points=goocanvas.Points(linepts),
 
                           width=linewidth,
 
                           stroke_color=fill,
 
                           )
 
            
 
        # canvas doesnt have keyboard focus, so i can't easily change the
 
@@ -694,13 +696,13 @@ class Curvesetview(object):
 
    def add_curve(self, name, slider=None, knobEnabled=False):
 
        curve = self.curveset.curves[name]
 
        f = CurveRow(name, curve, slider, knobEnabled)
 
        self.curvesVBox.pack_end(f.box)
 
        f.box.show_all()
 
        self.allCurveRows.add(f)
 
        f.curveView.goLive()
 
        #f.curveView.goLive()
 

	
 

	
 
    def goLive(self):
 
        """for startup performance, none of the curves redraw
 
        themselves until this is called once (and then they're normal)"""
 
        
0 comments (0 inline, 0 general)