Changeset 1242

Show
Ignore:
Timestamp:
06/09/08 08:54:13 (3 months ago)
Author:
drobilla
Message:

Scroll canvas with arrow keys.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • flowcanvas/src/Canvas.cpp

    r1206 r1242  
    675675Canvas::canvas_event(GdkEvent* event) 
    676676{ 
    677 #if 0 
     677        static const int scroll_increment = 10; 
     678        int scroll_x, scroll_y; 
     679        get_scroll_offsets(scroll_x, scroll_y); 
     680 
    678681        switch (event->type) { 
    679                 case GDK_BUTTON_PRESS: 
    680                 cerr << "FC BUTTON PRESS!\n" << endl; 
     682        case GDK_KEY_PRESS: 
     683                switch (event->key.keyval) { 
     684                case GDK_Up: 
     685                        scroll_y += scroll_increment; 
     686                        break; 
     687                case GDK_Down: 
     688                        scroll_y -= scroll_increment; 
     689                        break; 
     690                case GDK_Left: 
     691                        scroll_x += scroll_increment; 
     692                        break; 
     693                case GDK_Right: 
     694                        scroll_x -= scroll_increment; 
     695                default: break; 
     696                } 
     697                scroll_to(scroll_x, scroll_y); 
    681698                return true; 
    682  
    683                 case GDK_SCROLL: 
    684                 cerr << "FC SCROLL!\n" << endl; 
    685                 return true; 
    686         } 
    687  
    688         if (event->type == GDK_KEY_PRESS) { 
    689                 cerr << "CANVAS KEY PRESS" << endl; 
    690         } else if (event->type == GDK_KEY_RELEASE) { 
    691                 cerr << "CANVAS KEY RELEASE" << endl; 
    692         } 
    693 #endif 
    694  
    695         return false; 
     699        default: 
     700                return false; 
     701        } 
    696702} 
    697703 
     
    804810                _drag_state = NOT_DRAGGING; 
    805811                return true; 
    806         } else if (event->type == GDK_KEY_PRESS) { 
    807                 canvas_event(event); 
    808812        } 
    809813        return false; 
  • patchage/src/Patchage.cpp

    r1172 r1242  
    163163        _main_scrolledwin->property_vadjustment().get_value()->set_step_increment(10); 
    164164 
     165        _main_scrolledwin->signal_scroll_event().connect( 
     166                        sigc::mem_fun(this, &Patchage::on_scroll)); 
     167 
    165168        _buffer_size_combo->signal_changed().connect( 
    166169                        sigc::mem_fun(this, &Patchage::buffer_size_changed)); 
     
    252255        update_state(); 
    253256 
     257        _canvas->grab_focus(); 
     258 
    254259        // Idle callback, check if we need to refresh 
    255260        Glib::signal_timeout().connect( 
     
    664669} 
    665670 
     671         
     672bool 
     673Patchage::on_scroll(GdkEventScroll* ev)  
     674{ 
     675        cout << "ON SCROLL" << endl; 
     676        return false; 
     677} 
     678 
    666679 
    667680void 
  • patchage/src/patchage.glade

    r1167 r1242  
    487487              </widget> 
    488488              <packing> 
     489                <property name="expand">False</property> 
    489490                <property name="homogeneous">False</property> 
    490491              </packing> 
     
    497498              <packing> 
    498499                <property name="expand">False</property> 
     500                <property name="homogeneous">False</property> 
    499501              </packing> 
    500502            </child> 
     
    530532            <property name="can_focus">True</property> 
    531533            <property name="has_focus">True</property> 
     534            <property name="is_focus">True</property> 
    532535            <property name="can_default">True</property> 
    533536            <property name="has_default">True</property> 
     537            <property name="receives_default">True</property> 
    534538            <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property> 
    535539            <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property> 
     
    596600    <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property> 
    597601    <child internal-child="vbox"> 
    598       <widget class="GtkVBox" id="dialog-vbox1"> 
     602      <widget class="GtkVBox" id="dialog-vbox2"> 
    599603        <property name="visible">True</property> 
    600604        <child> 
     
    664668        </child> 
    665669        <child internal-child="action_area"> 
    666           <widget class="GtkHButtonBox" id="dialog-action_area1"> 
     670          <widget class="GtkHButtonBox" id="dialog-action_area2"> 
    667671            <property name="visible">True</property> 
    668672            <property name="layout_style">GTK_BUTTONBOX_END</property> 
  • patchage/src/Patchage.hpp

    r1168 r1242  
    7474        void on_store_positions(); 
    7575        void on_view_toolbar(); 
     76        bool on_scroll(GdkEventScroll* ev); 
    7677 
    7778        void zoom(double z); 
  • patchage/src/PatchageCanvas.cpp

    r1191 r1242  
    3232 
    3333PatchageCanvas::PatchageCanvas(Patchage* app, int width, int height) 
    34 : FlowCanvas::Canvas(width, height), 
    35   _app(app) 
     34        : FlowCanvas::Canvas(width, height) 
     35       , _app(app) 
    3636{ 
    3737}