Changeset - 35a234c7e6ff
[Not reviewed]
default
0 2 0
Drew Perttula - 11 years ago 2014-06-03 06:31:24
drewp@bigasterisk.com
remove some more 'collapsed' curve code
Ignore-this: 609c9b2f898a5fa89be8719258e82f27
2 files changed with 28 insertions and 52 deletions:
0 comments (0 inline, 0 general)
light9/curvecalc/curvecalc.glade
Show inline comments
 
<?xml version="1.0" encoding="UTF-8"?>
 
<!-- Generated with glade 3.16.1 -->
 
<interface>
 
  <requires lib="gtk+" version="3.10"/>
 
  <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
 
Keys in a selected curve: 1..5 add point at time cursor
 
Keys in any curve: q,w,e,r,t,y set marker at time cursor
 
Curve point bindings: B1 drag point; C-B1 curve add point; S-B1 sketch points; B1 drag select points
 

	
 
Old subterm system may still work:
 
Drag sub into curve area for new curve+subterm
 
Keys in a selected curve: C to collapse; R to rebuild broken canvas widget; 1..5 add point at time cursor; q,w,e,r,t,y set marker at time cursor
 
Curve point bindings: B1 drag point; C-B1 curve add point; S-B1 sketch points; 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="GtkWindow" id="MainWindow">
 
    <property name="can_focus">False</property>
 
    <child>
 
      <object class="GtkBox" id="vbox1">
 
        <property name="visible">True</property>
 
        <property name="can_focus">False</property>
 
        <property name="orientation">vertical</property>
 
        <child>
 
          <object class="GtkMenuBar" id="menubar1">
 
            <property name="visible">True</property>
 
@@ -426,52 +429,28 @@ Available in functions: nsin/ncos period
 
                            <property name="can_focus">True</property>
 
                            <property name="receives_default">True</property>
 
                            <property name="use_stock">True</property>
 
                            <signal name="clicked" handler="onNewCurve" swapped="no"/>
 
                          </object>
 
                          <packing>
 
                            <property name="expand">False</property>
 
                            <property name="fill">False</property>
 
                            <property name="position">0</property>
 
                          </packing>
 
                        </child>
 
                        <child>
 
                          <object class="GtkButton" id="button7">
 
                            <property name="label" translatable="yes">Collapse all</property>
 
                            <property name="use_action_appearance">False</property>
 
                            <property name="visible">True</property>
 
                            <property name="can_focus">True</property>
 
                            <property name="receives_default">True</property>
 
                            <signal name="clicked" handler="onCollapseAll" swapped="no"/>
 
                          </object>
 
                          <packing>
 
                            <property name="expand">False</property>
 
                            <property name="fill">True</property>
 
                            <property name="position">1</property>
 
                          </packing>
 
                          <placeholder/>
 
                        </child>
 
                        <child>
 
                          <object class="GtkButton" id="button6">
 
                            <property name="label" translatable="yes">Collapse none	</property>
 
                            <property name="use_action_appearance">False</property>
 
                            <property name="visible">True</property>
 
                            <property name="can_focus">True</property>
 
                            <property name="receives_default">True</property>
 
                            <signal name="clicked" handler="onCollapseNone" swapped="no"/>
 
                          </object>
 
                          <packing>
 
                            <property name="expand">False</property>
 
                            <property name="fill">True</property>
 
                            <property name="position">2</property>
 
                          </packing>
 
                          <placeholder/>
 
                        </child>
 
                        <child>
 
                          <placeholder/>
 
                        </child>
 
                        <child>
 
                          <placeholder/>
 
                        </child>
 
                        <child>
 
                          <placeholder/>
 
                        </child>
 
                      </object>
 
                      <packing>
 
@@ -608,24 +587,30 @@ Available in functions: nsin/ncos period
 
                                <child>
 
                                  <placeholder/>
 
                                </child>
 
                                <child>
 
                                  <placeholder/>
 
                                </child>
 
                                <child>
 
                                  <placeholder/>
 
                                </child>
 
                                <child>
 
                                  <placeholder/>
 
                                </child>
 
                                <child>
 
                                  <placeholder/>
 
                                </child>
 
                                <child>
 
                                  <placeholder/>
 
                                </child>
 
                              </object>
 
                            </child>
 
                          </object>
 
                        </child>
 
                      </object>
 
                      <packing>
 
                        <property name="expand">True</property>
 
                        <property name="fill">True</property>
 
                        <property name="position">0</property>
 
                      </packing>
 
                    </child>
 
                    <child>
 
@@ -733,24 +718,30 @@ Available in functions: nsin/ncos period
 
                    <child>
 
                      <placeholder/>
 
                    </child>
 
                    <child>
 
                      <placeholder/>
 
                    </child>
 
                    <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>
 
                    <property name="label" translatable="yes">Status</property>
 
                    <property name="use_markup">True</property>
 
                  </object>
 
                </child>
 
              </object>
 
              <packing>
light9/curvecalc/curveview.py
Show inline comments
 
@@ -375,26 +375,27 @@ class Curveview(object):
 
        box = Gtk.Box.new(Gtk.Orientation.VERTICAL, 0)
 
        box.set_border_width(1)
 
        self.widget.add(box)
 
        box.show()
 
        return box
 

	
 
    def trackWidgetSize(self):
 
        """
 
        Also tried:
 

	
 
            visibility-notify-event
 
            (Gdk.EventMask.VISIBILITY_NOTIFY_MASK) fires on some
 
            resizes but maybe not all. Could be doing the right thing,
 
            though
 
            resizes but definitely not all. During window resizes,
 
            sometimes I have to 'shake' the window size to get all
 
            curves to update.
 
        
 
            configure-event seems to never fire.
 

	
 
            size-allocate seems right but i get into infinite bounces
 
            between two sizes
 
        """
 
        def sizeEvent(w, alloc):
 
            p = self.canvas.props
 
            if (alloc.width, alloc.height) != (p.x2, p.y2):
 
                p.x1, p.x2 = 0, alloc.width
 
                p.y1, p.y2 = 0, alloc.height
 
                # calling update_curve in this event usually doesn't work
 
@@ -1145,32 +1146,24 @@ class CurveRow(object):
 
        if slider is not None:
 
            # slider should have a checkbutton, defaults to off for
 
            # music tracks
 
            self.sliderLabel = Gtk.Label("Slider %s" % slider)
 
            box.pack_start(self.sliderLabel, expand=True, fill=True, padding=0)
 

	
 
        box.pack_start(curve_name_label, expand=True, fill=True, padding=0)
 
        box.pack_start(self.muted, expand=True, fill=True, padding=0)
 

	
 
    def onDelete(self):
 
        self.curveView.onDelete()
 
        
 
    def update_ui_to_collapsed_state(self, *args):
 
        if self.collapsed.get_active():
 
            self.curveView.widget.set_size_request(-1, 25)
 
            [w.hide() for w in self.hideWhenCollapsed]
 
        else:
 
            self.curveView.widget.set_size_request(-1, 100)
 
            [w.show() for w in self.hideWhenCollapsed]
 

	
 
    def sync_mute_to_curve(self, *args):
 
        """send value from CheckButton to the master attribute inside Curve"""
 
        new_mute = self.muted.get_active()
 
        self.curveView.curve.muted = new_mute
 

	
 
    def update_mute_look(self):
 
        """set colors on the widgets in the row according to self.muted.get()"""
 
        # not yet ported for gtk
 
        return
 
        if self.curveView.curve.muted:
 
            new_bg = 'grey20'
 
        else:
 
@@ -1248,35 +1241,34 @@ class Curvesetview(object):
 
        raise ValueError("couldn't find curveRow named %r" % name)
 

	
 
    def set_featured_curves(self, curveNames):
 
        """bring these curves to the top of the stack"""
 
        for n in curveNames[::-1]:
 
            self.curvesVBox.reorder_child(self.curveRow_from_name(n).box,
 
                                          Gtk.PACK_START)
 
        
 
    def onKeyPress(self, widget, event):
 
        if not self.live: # workaround for old instances living past reload()
 
            return
 

	
 
        if event.string == 'c':
 
            r = self.row_under_mouse()
 
            # calling toggled() had no effect; don't know why
 
            r.collapsed.set_active(not r.collapsed.get_active())
 
        r = self.row_under_mouse()
 
        key = event.string
 
        pass # no handlers right now
 
 
 
    def row_under_mouse(self):
 
        x, y = self.curvesVBox.get_pointer()
 
        for r in self.allCurveRows:
 
            inRowX, inRowY = self.curvesVBox.translate_coordinates(r.box, x, y)
 
            _, _, w, h = r.box.get_allocation()
 
            if 0 <= inRowX < w and 0 <= inRowY < h:
 
            alloc = r.box.get_allocation()
 
            if 0 <= inRowX < alloc.width and 0 <= inRowY < alloc.height:
 
                return r
 
        raise ValueError("no curveRow is under the mouse")
 

	
 
    def focus_entry(self):
 
        self.entry.focus()
 

	
 
    def new_curve(self, event):
 
        self.curveset.new_curve(self.newcurvename.get())
 
        self.newcurvename.set('')
 
        
 
    def add_curve(self, name, slider=None, knobEnabled=False):
 
        if isinstance(name, Literal):
 
@@ -1286,25 +1278,25 @@ class Curvesetview(object):
 
                     slider, knobEnabled, self.zoomControl)
 
        self.curvesVBox.pack_start(f.box, expand=True, fill=True, padding=0)
 
        f.box.show_all()
 
        self.allCurveRows.add(f)
 
        self.setRowHeights()
 
        f.curveView.goLive()
 

	
 
    def watchCurveAreaHeight(self):
 
        def sizeEvent(w, size):
 
            # this is firing really often
 
            if self.visibleHeight == size.height:
 
                return
 
            print "size.height is new", size.height
 
            log.debug("size.height is new: %s", size.height)
 
            self.visibleHeight = size.height
 
            self.setRowHeights()
 

	
 
        visibleArea = self.curvesVBox.get_parent().get_parent()
 
        visibleArea.connect('size-allocate', sizeEvent)
 

	
 
        dispatcher.connect(self.setRowHeights, "curve row focus change")
 
        
 
    def setRowHeights(self):
 
        nRows = len(self.allCurveRows)
 
        if not nRows:
 
            return
 
@@ -1333,21 +1325,14 @@ class Curvesetview(object):
 

	
 
    def goLive(self):
 
        """for startup performance, none of the curves redraw
 
        themselves until this is called once (and then they're normal)"""
 
        
 
        for cr in self.allCurveRows:
 
            cr.curveView.goLive()
 

	
 
    def onDelete(self):
 
        for r in self.allCurveRows:
 
            r.onDelete()
 

	
 
    def collapseAll(self):
 
        for r in self.allCurveRows:
 
            r.collapsed.set_active(True)
 

	
 
    def collapseNone(self):
 
        for r in self.allCurveRows:
 
            r.collapsed.set_active(False)
 

	
 
        
0 comments (0 inline, 0 general)