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>
 
            <property name="can_focus">False</property>
 
            <child>
 
              <object class="GtkMenuItem" id="menuitem1">
 
                <property name="use_action_appearance">False</property>
 
                <property name="visible">True</property>
 
                <property name="can_focus">False</property>
 
                <property name="label" translatable="yes">_Curvecalc</property>
 
                <property name="use_underline">True</property>
 
                <child type="submenu">
 
                  <object class="GtkMenu" id="menu1">
 
                    <property name="visible">True</property>
 
                    <property name="can_focus">False</property>
 
                    <child>
 
                      <object class="GtkImageMenuItem" id="imagemenuitem2">
 
                        <property name="label">gtk-save</property>
 
                        <property name="use_action_appearance">False</property>
 
                        <property name="visible">True</property>
 
                        <property name="can_focus">False</property>
 
                        <property name="use_underline">True</property>
 
                        <property name="use_stock">True</property>
 
                        <signal name="activate" handler="onSave" swapped="no"/>
 
                        <accelerator key="s" signal="activate" modifiers="GDK_CONTROL_MASK"/>
 
                      </object>
 
                    </child>
 
                    <child>
 
                      <object class="GtkImageMenuItem" id="imagemenuitem5">
 
                        <property name="label">gtk-quit</property>
 
                        <property name="use_action_appearance">False</property>
 
                        <property name="visible">True</property>
 
                        <property name="can_focus">False</property>
 
                        <property name="use_underline">True</property>
 
                        <property name="use_stock">True</property>
 
                        <signal name="activate" handler="onQuit" swapped="no"/>
 
                        <accelerator key="q" signal="activate" modifiers="GDK_CONTROL_MASK"/>
 
                      </object>
 
                    </child>
 
                  </object>
 
                </child>
 
              </object>
 
            </child>
 
            <child>
 
              <object class="GtkMenuItem" id="menuitem7">
 
                <property name="use_action_appearance">False</property>
 
                <property name="visible">True</property>
 
                <property name="can_focus">False</property>
 
                <property name="label" translatable="yes">_Edit</property>
 
                <property name="use_underline">True</property>
 
                <child type="submenu">
 
                  <object class="GtkMenu" id="menu5">
 
                    <property name="visible">True</property>
 
                    <property name="can_focus">False</property>
 
                    <child>
 
                      <object class="GtkImageMenuItem" id="imagemenuitem1">
 
                        <property name="label">gtk-cut</property>
 
                        <property name="use_action_appearance">False</property>
 
                        <property name="visible">True</property>
 
                        <property name="can_focus">False</property>
 
                        <property name="use_underline">True</property>
 
                        <property name="use_stock">True</property>
 
                      </object>
 
                    </child>
 
                    <child>
 
                      <object class="GtkImageMenuItem" id="imagemenuitem3">
 
                        <property name="label">gtk-copy</property>
 
                        <property name="use_action_appearance">False</property>
 
                        <property name="visible">True</property>
 
                        <property name="can_focus">False</property>
 
                        <property name="use_underline">True</property>
 
                        <property name="use_stock">True</property>
 
                      </object>
 
                    </child>
 
                    <child>
 
                      <object class="GtkImageMenuItem" id="imagemenuitem4">
 
                        <property name="label">gtk-paste</property>
 
                        <property name="use_action_appearance">False</property>
 
                        <property name="visible">True</property>
 
                        <property name="can_focus">False</property>
 
                        <property name="use_underline">True</property>
 
                        <property name="use_stock">True</property>
 
                      </object>
 
                    </child>
 
                    <child>
 
                      <object class="GtkImageMenuItem" id="imagemenuitem6">
 
                        <property name="label">gtk-delete</property>
 
@@ -342,499 +345,487 @@ Available in functions: nsin/ncos period
 
                <property name="xalign">1</property>
 
                <property name="label" translatable="yes">Player is on song </property>
 
                <property name="justify">right</property>
 
              </object>
 
              <packing>
 
                <property name="expand">False</property>
 
                <property name="fill">False</property>
 
                <property name="position">1</property>
 
              </packing>
 
            </child>
 
            <child>
 
              <object class="GtkLinkButton" id="playerSong">
 
                <property name="label" translatable="yes">(song)</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>
 
                <property name="has_tooltip">True</property>
 
                <property name="relief">none</property>
 
                <property name="xalign">0</property>
 
                <property name="uri">http://glade.gnome.org</property>
 
              </object>
 
              <packing>
 
                <property name="expand">False</property>
 
                <property name="fill">False</property>
 
                <property name="position">2</property>
 
              </packing>
 
            </child>
 
            <child>
 
              <object class="GtkCheckButton" id="followPlayerSongChoice">
 
                <property name="label" translatable="yes">follow player song choice</property>
 
                <property name="use_action_appearance">False</property>
 
                <property name="visible">True</property>
 
                <property name="can_focus">True</property>
 
                <property name="receives_default">False</property>
 
                <property name="xalign">0.5</property>
 
                <property name="draw_indicator">True</property>
 
              </object>
 
              <packing>
 
                <property name="expand">False</property>
 
                <property name="fill">False</property>
 
                <property name="padding">15</property>
 
                <property name="position">3</property>
 
              </packing>
 
            </child>
 
            <child>
 
              <placeholder/>
 
            </child>
 
          </object>
 
          <packing>
 
            <property name="expand">False</property>
 
            <property name="fill">False</property>
 
            <property name="position">1</property>
 
          </packing>
 
        </child>
 
        <child>
 
          <object class="GtkPaned" id="paned1">
 
            <property name="height_request">600</property>
 
            <property name="visible">True</property>
 
            <property name="can_focus">True</property>
 
            <property name="orientation">vertical</property>
 
            <property name="position">600</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="GtkBox" id="vbox4">
 
                    <property name="height_request">100</property>
 
                    <property name="visible">True</property>
 
                    <property name="can_focus">False</property>
 
                    <property name="orientation">vertical</property>
 
                    <child>
 
                      <object class="GtkBox" id="curveTools">
 
                        <property name="visible">True</property>
 
                        <property name="can_focus">False</property>
 
                        <property name="spacing">7</property>
 
                        <child>
 
                          <object class="GtkButton" id="button22">
 
                            <property name="label">gtk-add</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>
 
                            <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>
 
                        <property name="expand">False</property>
 
                        <property name="fill">False</property>
 
                        <property name="position">0</property>
 
                      </packing>
 
                    </child>
 
                    <child>
 
                      <object class="GtkBox" id="zoomControlBox">
 
                        <property name="visible">True</property>
 
                        <property name="can_focus">False</property>
 
                        <property name="orientation">vertical</property>
 
                        <child>
 
                          <object class="GtkLabel" id="zoomControl">
 
                            <property name="visible">True</property>
 
                            <property name="can_focus">False</property>
 
                            <property name="label" translatable="yes">[zoom control]</property>
 
                          </object>
 
                          <packing>
 
                            <property name="expand">False</property>
 
                            <property name="fill">True</property>
 
                            <property name="position">0</property>
 
                          </packing>
 
                        </child>
 
                      </object>
 
                      <packing>
 
                        <property name="expand">False</property>
 
                        <property name="fill">True</property>
 
                        <property name="position">1</property>
 
                      </packing>
 
                    </child>
 
                    <child>
 
                      <object class="GtkScrolledWindow" id="scrolledwindowCurves">
 
                        <property name="visible">True</property>
 
                        <property name="can_focus">True</property>
 
                        <property name="hscrollbar_policy">never</property>
 
                        <child>
 
                          <object class="GtkViewport" id="viewport2">
 
                            <property name="visible">True</property>
 
                            <property name="can_focus">False</property>
 
                            <child>
 
                              <object class="GtkEventBox" id="eventbox1">
 
                                <property name="visible">True</property>
 
                                <property name="can_focus">True</property>
 
                                <child>
 
                                  <object class="GtkBox" id="curves">
 
                                    <property name="visible">True</property>
 
                                    <property name="can_focus">False</property>
 
                                    <property name="orientation">vertical</property>
 
                                    <child>
 
                                      <placeholder/>
 
                                    </child>
 
                                    <child>
 
                                      <placeholder/>
 
                                    </child>
 
                                    <child>
 
                                      <placeholder/>
 
                                    </child>
 
                                  </object>
 
                                </child>
 
                              </object>
 
                            </child>
 
                          </object>
 
                        </child>
 
                      </object>
 
                      <packing>
 
                        <property name="expand">True</property>
 
                        <property name="fill">True</property>
 
                        <property name="position">2</property>
 
                      </packing>
 
                    </child>
 
                  </object>
 
                </child>
 
                <child type="label">
 
                  <object class="GtkLabel" id="label10">
 
                    <property name="visible">True</property>
 
                    <property name="can_focus">False</property>
 
                    <property name="label" translatable="yes">Curves</property>
 
                  </object>
 
                </child>
 
              </object>
 
              <packing>
 
                <property name="resize">True</property>
 
                <property name="shrink">False</property>
 
              </packing>
 
            </child>
 
            <child>
 
              <object class="GtkExpander" id="expander1">
 
                <property name="visible">True</property>
 
                <property name="can_focus">True</property>
 
                <child>
 
                  <object class="GtkBox" id="box1">
 
                    <property name="visible">True</property>
 
                    <property name="can_focus">False</property>
 
                    <property name="orientation">vertical</property>
 
                    <child>
 
                      <object class="GtkScrolledWindow" id="scrolledwindow2">
 
                        <property name="visible">True</property>
 
                        <property name="can_focus">True</property>
 
                        <property name="vadjustment">adjustment1</property>
 
                        <property name="hscrollbar_policy">never</property>
 
                        <child>
 
                          <object class="GtkViewport" id="viewport1">
 
                            <property name="visible">True</property>
 
                            <property name="can_focus">False</property>
 
                            <property name="vadjustment">adjustment1</property>
 
                            <property name="shadow_type">none</property>
 
                            <child>
 
                              <object class="GtkTable" id="subterms">
 
                                <property name="visible">True</property>
 
                                <property name="can_focus">False</property>
 
                                <property name="n_columns">2</property>
 
                                <signal name="add" handler="onSubtermChildAdded" swapped="no"/>
 
                                <signal name="map" handler="onSubtermsMap" swapped="no"/>
 
                                <child>
 
                                  <placeholder/>
 
                                </child>
 
                                <child>
 
                                  <placeholder/>
 
                                </child>
 
                                <child>
 
                                  <placeholder/>
 
                                </child>
 
                                <child>
 
                                  <placeholder/>
 
                                </child>
 
                                <child>
 
                                  <placeholder/>
 
                                </child>
 
                                <child>
 
                                  <placeholder/>
 
                                </child>
 
                                <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>
 
                      <object class="GtkLabel" id="newSubZone">
 
                        <property name="visible">True</property>
 
                        <property name="can_focus">False</property>
 
                        <property name="ypad">18</property>
 
                        <property name="label" translatable="yes">Drop new sub here</property>
 
                        <signal name="drag-data-received" handler="onDragDataInNewSubZone" swapped="no"/>
 
                      </object>
 
                      <packing>
 
                        <property name="expand">False</property>
 
                        <property name="fill">True</property>
 
                        <property name="position">1</property>
 
                      </packing>
 
                    </child>
 
                    <child>
 
                      <object class="GtkBox" id="box2">
 
                        <property name="visible">True</property>
 
                        <property name="can_focus">False</property>
 
                        <child>
 
                          <placeholder/>
 
                        </child>
 
                        <child>
 
                          <object class="GtkButton" id="button2">
 
                            <property name="label">gtk-add</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>
 
                            <property name="use_stock">True</property>
 
                            <signal name="clicked" handler="onNewSubterm" swapped="no"/>
 
                          </object>
 
                          <packing>
 
                            <property name="expand">False</property>
 
                            <property name="fill">False</property>
 
                            <property name="position">1</property>
 
                          </packing>
 
                        </child>
 
                        <child>
 
                          <placeholder/>
 
                        </child>
 
                      </object>
 
                      <packing>
 
                        <property name="expand">False</property>
 
                        <property name="fill">False</property>
 
                        <property name="position">2</property>
 
                      </packing>
 
                    </child>
 
                  </object>
 
                </child>
 
                <child type="label">
 
                  <object class="GtkLabel" id="subtermsLabel">
 
                    <property name="visible">True</property>
 
                    <property name="can_focus">False</property>
 
                    <property name="label" translatable="yes">Subterms</property>
 
                  </object>
 
                </child>
 
              </object>
 
              <packing>
 
                <property name="resize">False</property>
 
                <property name="shrink">False</property>
 
              </packing>
 
            </child>
 
          </object>
 
          <packing>
 
            <property name="expand">True</property>
 
            <property name="fill">True</property>
 
            <property name="position">2</property>
 
          </packing>
 
        </child>
 
        <child>
 
          <object class="GtkBox" id="statusRow">
 
            <property name="visible">True</property>
 
            <property name="can_focus">False</property>
 
            <child>
 
              <object class="GtkFrame" id="frame2">
 
                <property name="visible">True</property>
 
                <property name="can_focus">False</property>
 
                <property name="label_xalign">0</property>
 
                <property name="shadow_type">none</property>
 
                <child>
 
                  <object class="GtkTable" id="status">
 
                    <property name="visible">True</property>
 
                    <property name="can_focus">False</property>
 
                    <property name="n_columns">2</property>
 
                    <child>
 
                      <placeholder/>
 
                    </child>
 
                    <child>
 
                      <placeholder/>
 
                    </child>
 
                    <child>
 
                      <placeholder/>
 
                    </child>
 
                    <child>
 
                      <placeholder/>
 
                    </child>
 
                    <child>
 
                      <placeholder/>
 
                    </child>
 
                    <child>
 
                      <placeholder/>
 
                    </child>
 
                    <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>
 
                <property name="expand">True</property>
 
                <property name="fill">True</property>
 
                <property name="position">0</property>
 
              </packing>
 
            </child>
 
            <child>
 
              <object class="GtkTextView" id="textview1">
 
                <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">True</property>
 
                <property name="fill">True</property>
 
                <property name="position">1</property>
 
              </packing>
 
            </child>
 
          </object>
 
          <packing>
 
            <property name="expand">False</property>
 
            <property name="fill">False</property>
 
            <property name="padding">5</property>
 
            <property name="position">3</property>
 
          </packing>
 
        </child>
 
      </object>
 
    </child>
 
  </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="newSubterm">
 
    <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="GtkBox" id="dialog-vbox3">
 
        <property name="visible">True</property>
 
        <property name="can_focus">False</property>
 
        <property name="spacing">2</property>
 
        <child internal-child="action_area">
 
          <object class="GtkButtonBox" id="dialog-action_area3">
 
            <property name="visible">True</property>
 
            <property name="can_focus">False</property>
 
            <property name="layout_style">end</property>
 
            <child>
 
              <object class="GtkButton" id="button12">
 
                <property name="label">gtk-cancel</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>
 
                <property name="use_stock">True</property>
 
              </object>
 
              <packing>
 
                <property name="expand">False</property>
 
                <property name="fill">False</property>
 
                <property name="position">0</property>
 
              </packing>
 
            </child>
 
            <child>
 
              <object class="GtkButton" id="button3">
 
                <property name="label">gtk-add</property>
 
                <property name="use_action_appearance">False</property>
 
                <property name="visible">True</property>
 
                <property name="can_focus">True</property>
 
                <property name="can_default">True</property>
 
                <property name="has_default">True</property>
 
                <property name="receives_default">True</property>
 
                <property name="use_stock">True</property>
 
              </object>
 
              <packing>
 
                <property name="expand">False</property>
 
                <property name="fill">False</property>
 
                <property name="position">1</property>
light9/curvecalc/curveview.py
Show inline comments
 
@@ -291,194 +291,195 @@ class SelectManip(object):
 
    def destroy(self):
 
        self.grp.remove()
 

	
 
class Curveview(object):
 
    """
 
    graphical curve widget only. Please pack .widget
 

	
 
    <caller's parent>
 
     -> self.widget <caller packs this>
 
       -> EventBox
 
         -> Box vertical, for border
 
           -> self.canvas GooCanvas
 
             -> root CanvasItem
 
               ..various groups and items..
 

	
 
    The canvas x1/x2/y1/y2 coords are updated to match self.widget.
 
    
 
    """
 
    def __init__(self, curve, markers, knobEnabled=False, isMusic=False,
 
                 zoomControl=None):
 
        """knobEnabled=True highlights the previous key and ties it to a
 
        hardware knob"""
 
        self.curve = curve
 
        self.markers = markers
 
        self.knobEnabled = knobEnabled
 
        self._isMusic = isMusic
 
        self.zoomControl = zoomControl
 
        
 
        self.redrawsEnabled = False
 

	
 
        box = self.createOuterWidgets()
 
        self.canvas = self.createCanvasWidget(box)
 
        self.trackWidgetSize()
 
        self.update_curve()
 
        
 
        self._time = -999
 
        self.last_mouse_world = None
 
        self.entered = False # is the mouse currently over this widget
 
        self.selected_points=[] # idx of points being dragged
 
        self.dots = {}
 
        # 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")
 
        dispatcher.connect(self.acls, "all curves lose selection")
 
        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))
 
      
 
        # this binds on c-a-b1, etc
 
        if 0: # unported
 
            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
 

	
 
    def acls(self, butNot=None):
 
        if butNot is self:
 
            return
 
        self.unselect()
 

	
 
    def createOuterWidgets(self):
 
        self.timelineLine = self.curveGroup = self.selectManip = None
 
        self.widget = Gtk.EventBox()
 
        self.widget.set_can_focus(True)
 
        self.widget.add_events(Gdk.EventMask.KEY_PRESS_MASK |
 
                               Gdk.EventMask.FOCUS_CHANGE_MASK)
 
        self.onFocusOut()
 

	
 
        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
 
                reactor.callLater(0, self.update_curve)
 
            return False
 
            
 
        #self.widget.connect('size-allocate', sizeEvent) # see docstring
 

	
 
        def visEvent(w, alloc):
 
            p = self.canvas.props
 
            w = self.widget.get_allocated_width()
 
            h = self.widget.get_allocated_height()
 
            if (w, h) != (p.x2, p.y2):
 
                p.x1, p.x2 = 0, w
 
                p.y1, p.y2 = 0, h
 
                self.update_curve()
 
            return False
 
        self.widget.add_events(Gdk.EventMask.VISIBILITY_NOTIFY_MASK)
 
        self.widget.connect('visibility-notify-event', visEvent)
 
        
 
    def createCanvasWidget(self, parent):
 
        # this is only separate from createOuterWidgets because in the
 
        # past, i worked around display bugs by recreating the whole
 
        # canvas widget. If that's not necessary, this could be more
 
        # clearly combined with createOuterWidgets since there's no
 
        # time you'd want that one but not this one.
 
        canvas = GooCanvas.Canvas()
 
        parent.pack_start(canvas, expand=True, fill=True, padding=0)
 
        canvas.show()
 

	
 
        p = canvas.props
 
        p.background_color = 'black'
 
        root = canvas.get_root_item()
 

	
 
        canvas.connect("leave-notify-event", self.onLeave)
 
        canvas.connect("enter-notify-event", self.onEnter)
 
        canvas.connect("motion-notify-event", self.onMotion)
 
        canvas.connect("scroll-event", self.onScroll)
 
        canvas.connect("button-release-event", self.onRelease)
 
        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)
 
        return canvas
 

	
 
    def onAny(self, w, event):
 
        print "   %s on %s" % (event, w)
 
        
 
    def onFocusIn(self, *args):
 
        dispatcher.send('curve row focus change')     
 
        dispatcher.send("all curves lose selection", butNot=self)
 

	
 
        self.widget.modify_bg(Gtk.StateFlags.NORMAL, Gdk.color_parse("red"))
 

	
 
    def onFocusOut(self, widget=None, event=None):
 
        dispatcher.send('curve row focus change')                  
 
        self.widget.modify_bg(Gtk.StateFlags.NORMAL, Gdk.color_parse("gray30"))
 

	
 
        # you'd think i'm unselecting when we lose focus, but we also
 
        # lose focus when the user moves off the toplevel window, and
 
        # that's not a time to forget the selection. See the 'all
 
        # curves lose selection' signal for the fix.
 

	
 
    def onKeyPress(self, widget, event):
 
        if event.string in list('12345'):
 
            x = int(event.string)
 
            self.add_point((self.current_time(), (x - 1) / 4.0))
 
        if event.string in list('qwerty'):
 
            self.add_marker((self.current_time(), event.string))
 

	
 
    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
 

	
 
        self.widget.grab_focus()
 

	
 
@@ -1061,293 +1062,277 @@ class Curveview(object):
 

	
 
        if event.state & Gdk.ModifierType.SHIFT_MASK: # relese-B1
 
            self.sketch_release(event)
 
            return
 

	
 
        self.select_release(event)
 
 
 
        if not self.dragging_dots:
 
            return
 
        self.last_mouse_world = None
 
        self.dragging_dots = False
 

	
 
class CurveRow(object):
 
    """
 
    one of the repeating curve rows (including widgets on the left)
 

	
 
    i wish these were in a list-style TreeView so i could set_reorderable on it
 

	
 
    please pack self.box
 
    """
 
    def __init__(self, graph, name, curve, markers, slider, knobEnabled, zoomControl):
 
        self.graph = graph
 
        self.name = name
 
        self.box = Gtk.Box.new(Gtk.Orientation.VERTICAL, 0)
 
        self.box.set_border_width(1)
 

	
 
        self.cols = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 0)
 
        self.box.add(self.cols)
 
        
 
        controls = Gtk.Frame()
 
        controls.set_size_request(160, -1)
 
        controls.set_shadow_type(Gtk.ShadowType.OUT)
 
        self.cols.pack_start(controls, expand=False, fill=True, padding=0)
 
        self.setupControls(controls, name, curve, slider)
 

	
 
        self.curveView = Curveview(curve, markers, knobEnabled=knobEnabled,
 
                                   isMusic=name in ['music', 'smooth_music'],
 
                                   zoomControl=zoomControl)
 
        
 
        self.initCurveView()
 
        dispatcher.connect(self.rebuild, "all curves rebuild")
 

	
 
    def isFocus(self):
 
        return self.curveView.widget.is_focus()
 
        
 
    def rebuild(self):
 
        raise NotImplementedError('obsolete, if curves are drawing right')
 
        self.curveView.rebuild()
 
        self.initCurveView()
 
        self.update_ui_to_collapsed_state()
 

	
 
    def destroy(self):
 
        self.curveView.entered = False  # help suppress bad position events
 
        del self.curveView
 
        self.box.destroy()
 
        
 
    def initCurveView(self):
 
        self.curveView.widget.show()
 
        self.setHeight(100)
 
        self.cols.pack_start(self.curveView.widget, expand=True, fill=True, padding=0)       
 

	
 
    def setHeight(self, h):
 
        self.curveView.widget.set_size_request(-1, h)
 
        # the event watcher wasn't catching these
 
        reactor.callLater(.5, self.curveView.update_curve)
 
        
 
    def setupControls(self, controls, name, curve, slider):
 
        box = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 0)
 
        controls.add(box)
 

	
 
        curve_name_label = Gtk.LinkButton()
 
        def update_label():
 
            # todo: abort if we don't still exist...
 
            p = curve_name_label.props
 
            p.uri = curve.uri
 
            p.label = self.graph.label(curve.uri)
 
        self.graph.addHandler(update_label)
 
        
 

	
 
        self.muted = Gtk.CheckButton("M")
 
        self.muted.connect("toggled", self.sync_mute_to_curve)
 
        dispatcher.connect(self.mute_changed, 'mute changed', sender=curve)
 

	
 
        self.sliderLabel = None
 
        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:
 
            new_bg = 'normal'
 

	
 
        for widget in self.widgets:
 
            widget['bg'] = new_bg
 

	
 
    def mute_changed(self):
 
        """call this if curve.muted changed"""
 
        self.muted.set_active(self.curveView.curve.muted)
 
        #self.update_mute_look()
 

	
 

	
 
class Curvesetview(object):
 
    """
 
    
 
    """
 
    def __init__(self, graph, curvesVBox, zoomControlBox, curveset):
 
        self.graph = graph
 
        self.live = True
 
        self.curvesVBox = curvesVBox
 
        self.curveset = curveset
 
        self.allCurveRows = set()
 
        self.visibleHeight = 1000
 

	
 
        self.zoomControl = self.initZoomControl(zoomControlBox)
 
        self.zoomControl.redrawzoom()
 
        
 
        for c in curveset.curveNamesInOrder():
 
            self.add_curve(c) 
 

	
 
        dispatcher.connect(self.clear_curves, "clear_curves")
 
        dispatcher.connect(self.add_curve, "add_curve", sender=self.curveset)
 
        dispatcher.connect(self.set_featured_curves, "set_featured_curves")
 
        dispatcher.connect(self.song_has_changed, "song_has_changed")
 
        
 
        self.newcurvename = Gtk.EntryBuffer.new("", 0)
 

	
 
        eventBox = self.curvesVBox.get_parent()
 
        eventBox.connect("key-press-event", self.onKeyPress)
 
        eventBox.connect("button-press-event", self.takeFocus)
 

	
 
        self.watchCurveAreaHeight()
 

	
 
    def __del__(self):
 
        print "del curvesetview", id(self) 
 

	
 
    def initZoomControl(self, zoomControlBox):
 
        import light9.curvecalc.zoomcontrol
 
        reload(light9.curvecalc.zoomcontrol)
 
        zoomControl = light9.curvecalc.zoomcontrol.ZoomControl()
 
        zoomControlBox.add(zoomControl.widget)
 
        zoomControl.widget.show_all()
 
        return zoomControl
 
        
 
    def clear_curves(self):
 
        """curveset is about to re-add all new curves"""
 
        while self.allCurveRows:
 
            self.allCurveRows.pop().destroy()
 

	
 
    def song_has_changed(self):
 
        self.zoomControl.redrawzoom()
 
        
 
    def takeFocus(self, *args):
 
        """the whole curveset's eventbox is what gets the focus, currently, so
 
        keys like 'c' can work in it"""
 
        dispatcher.send("all curves lose selection")
 
        self.curvesVBox.get_parent().grab_focus()
 

	
 
    def curveRow_from_name(self, name):
 
        for cr in self.allCurveRows:
 
            if cr.name == name:
 
                return cr
 
        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):
 
            name = str(name)
 
        curve = self.curveset.curves[name]
 
        f = CurveRow(self.graph, name, curve, self.curveset.markers,
 
                     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
 
        anyFocus = any(r.isFocus() for r in self.allCurveRows)
 

	
 
        evenHeight = max(14, self.visibleHeight // nRows) - 3
 
        if anyFocus:
 
            focusHeight = max(100, evenHeight)
 
            if nRows > 1:
 
                otherHeight = max(14,
 
                                  (self.visibleHeight - focusHeight) //
 
                                  (nRows - 1)) - 3
 
        else:
 
            otherHeight = evenHeight
 
        for row in self.allCurveRows:
 
            row.setHeight(focusHeight if row.isFocus() else otherHeight)
 
            
 
    def row(self, name):
 
        if isinstance(name, Literal):
 
            name = str(name)
 
        matches = [r for r in self.allCurveRows if r.name == name]
 
        if not matches:
 
            raise ValueError("no curveRow named %r. only %s" %
 
                             (name, [r.name for r in self.allCurveRows]))
 
        return matches[0]
 

	
 
    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)