enable use of arrow keys, fix hscroller issues, start work on smoother auto-scroll
authorPaul Davis <paul@linuxaudiosystems.com>
Tue, 2 May 2006 01:08:34 +0000 (01:08 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Tue, 2 May 2006 01:08:34 +0000 (01:08 +0000)
git-svn-id: svn://localhost/trunk/ardour2@490 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/ardour.bindings
gtk2_ardour/ardour.menus
gtk2_ardour/editor.cc
gtk2_ardour/editor.h
gtk2_ardour/editor_canvas.cc
gtk2_ardour/editor_mixer.cc
gtk2_ardour/editor_region_list.cc
gtk2_ardour/utils.cc

index 7215bb6d6f587a2af53994bec8a04ab569512b6b..244e21436c653661954336fceddf80e9c117a197 100644 (file)
 
 (gtk_accel_path "<Actions>/Editor/scroll-tracks-down" "Page_Down")
 (gtk_accel_path "<Actions>/Editor/scroll-tracks-up" "Page_Up")
-(gtk_accel_path "<Actions>/Editor/step-tracks-down" "Down")
-(gtk_accel_path "<Actions>/Editor/step-tracks-up" "Up")
+(gtk_accel_path "<Actions>/Editor/scroll-backward" "leftarrow")
+(gtk_accel_path "<Actions>/Editor/scroll-forward" "rightarrow")
+(gtk_accel_path "<Actions>/Editor/step-tracks-down" "downarrow")
+(gtk_accel_path "<Actions>/Editor/step-tracks-up" "uparrow")
 (gtk_accel_path "<Actions>/Editor/playhead-to-edit" "Return")
 (gtk_accel_path "<Actions>/Editor/edit-to-playhead" "<Alt>Return")
 
index 3abb0d4219f495106803676a9158cc558a6058ca..cbe4d3098517112966d5e2747981a095d9ca61e9 100644 (file)
                <menuitem action='step-tracks-up'/>
                <menuitem action='step-tracks-down'/>
               <separator/>
+               <menuitem action='scroll-forward'/>
+               <menuitem action='scroll-backward'/>
+              <separator/>
                <menuitem action='ToggleWaveformVisibility'/>
                <menuitem action='ToggleWaveformsWhileRecording'/>
                <menuitem action='ToggleMeasureVisibility'/>
index a3a73bc9362464a8ba476a6a0f0fee10a5cb76a3..2c6e981bd7c6104885adff8d9e1a85bcfdd44af2 100644 (file)
@@ -930,6 +930,14 @@ Editor::reposition_x_origin (jack_nframes_t frame)
 {
        if (frame != leftmost_frame) {
                leftmost_frame = frame;
+               
+               jack_nframes_t rightmost_frame = leftmost_frame + current_page_frames ();
+
+               if (rightmost_frame > last_canvas_frame) {
+                       last_canvas_frame = rightmost_frame;
+                       reset_scrolling_region ();
+               }
+
                horizontal_adjustment.set_value (frame/frames_per_unit);
        }
 }
@@ -1088,24 +1096,6 @@ Editor::session_control_changed (Session::ControlType t)
        }
 }
 
-void
-Editor::fake_handle_new_audio_region (AudioRegion *region)
-{
-       Gtkmm2ext::UI::instance()->call_slot (bind (mem_fun(*this, &Editor::handle_new_audio_region), region));
-}
-
-void
-Editor::fake_handle_audio_region_removed (AudioRegion *region)
-{
-       Gtkmm2ext::UI::instance()->call_slot (bind (mem_fun(*this, &Editor::handle_audio_region_removed), region));
-}
-
-void
-Editor::fake_handle_new_duration ()
-{
-       Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &Editor::handle_new_duration));
-}
-
 void
 Editor::start_scrolling ()
 {
@@ -1163,12 +1153,16 @@ Editor::center_screen_internal (jack_nframes_t frame, float page)
 void
 Editor::handle_new_duration ()
 {
-       reset_scrolling_region ();
+       ENSURE_GUI_THREAD (mem_fun (*this, &Editor::handle_new_duration));
 
-       if (session) {
-               cerr << "Set upper #2 to " << horizontal_adjustment.get_upper () << endl;
-               horizontal_adjustment.set_value (leftmost_frame/frames_per_unit);
+       jack_nframes_t new_end = session->get_maximum_extent() + (jack_nframes_t) floorf (current_page_frames() * 0.10f);
+                                 
+       if (new_end > last_canvas_frame) {
+               last_canvas_frame = new_end;
+               reset_scrolling_region ();
        }
+
+       horizontal_adjustment.set_value (leftmost_frame/frames_per_unit);
 }
 
 void
@@ -1229,9 +1223,9 @@ Editor::connect_to_session (Session *t)
        session_connections.push_back (session->TransportStateChange.connect (mem_fun(*this, &Editor::map_transport_state)));
        session_connections.push_back (session->PositionChanged.connect (mem_fun(*this, &Editor::map_position_change)));
        session_connections.push_back (session->RouteAdded.connect (mem_fun(*this, &Editor::handle_new_route_p)));
-       session_connections.push_back (session->AudioRegionAdded.connect (mem_fun(*this, &Editor::fake_handle_new_audio_region)));
-       session_connections.push_back (session->AudioRegionRemoved.connect (mem_fun(*this, &Editor::fake_handle_audio_region_removed)));
-       session_connections.push_back (session->DurationChanged.connect (mem_fun(*this, &Editor::fake_handle_new_duration)));
+       session_connections.push_back (session->AudioRegionAdded.connect (mem_fun(*this, &Editor::handle_new_audio_region)));
+       session_connections.push_back (session->AudioRegionRemoved.connect (mem_fun(*this, &Editor::handle_audio_region_removed)));
+       session_connections.push_back (session->DurationChanged.connect (mem_fun(*this, &Editor::handle_new_duration)));
        session_connections.push_back (session->edit_group_added.connect (mem_fun(*this, &Editor::add_edit_group)));
        session_connections.push_back (session->edit_group_removed.connect (mem_fun(*this, &Editor::edit_groups_changed)));
        session_connections.push_back (session->NamedSelectionAdded.connect (mem_fun(*this, &Editor::handle_new_named_selection)));
@@ -1337,7 +1331,7 @@ Editor::connect_to_session (Session *t)
        update_crossfade_model ();
        update_layering_model ();
 
-       reset_scrolling_region ();
+       handle_new_duration ();
 
        redisplay_regions ();
        redisplay_named_selections ();
@@ -2880,29 +2874,21 @@ Editor::autoscroll_canvas ()
 
                /* connect the timeout so that we get called repeatedly */
                
-               autoscroll_timeout_tag = gtk_timeout_add (100, _autoscroll_canvas, this);
-               keep_calling = false;
+               autoscroll_timeout_tag = gtk_timeout_add (40, _autoscroll_canvas, this);
 
        } else if (autoscroll_cnt > 10 && autoscroll_cnt < 20) {
                
                /* after about a while, speed up a bit by changing the timeout interval */
 
-               autoscroll_timeout_tag = gtk_timeout_add (50, _autoscroll_canvas, this);
-               keep_calling = false;
+               autoscroll_timeout_tag = gtk_timeout_add (20, _autoscroll_canvas, this);
                
-       } else if (autoscroll_cnt >= 20 && autoscroll_cnt < 30) {
-
-               /* after about another while, speed up some more */
-
-               autoscroll_timeout_tag = gtk_timeout_add (25, _autoscroll_canvas, this);
-               keep_calling = false;
-
        } else if (autoscroll_cnt >= 30) {
 
-               /* we've been scrolling for a while ... crank it up */
+               /* after about another while, speed up by increasing the shift per callback */
 
-               autoscroll_distance = 10 * (jack_nframes_t) floor (canvas_width * frames_per_unit);
-       }
+               autoscroll_distance =  (jack_nframes_t) floor (0.5 * current_page_frames());
+
+       } 
 
        return keep_calling;
 }
@@ -2917,7 +2903,7 @@ Editor::start_canvas_autoscroll (int dir)
        stop_canvas_autoscroll ();
 
        autoscroll_direction = dir;
-       autoscroll_distance = (jack_nframes_t) floor ((canvas_width * frames_per_unit)/10.0);
+       autoscroll_distance = (jack_nframes_t) floor ((canvas_width * frames_per_unit)/50.0);
        autoscroll_cnt = 0;
        
        /* do it right now, which will start the repeated callbacks */
index 3e080415c06ed82987fef850fb5e59ed8b2cb799..8770c6c93f179126ffae905b9da2e33bf0f5cefb 100644 (file)
@@ -700,6 +700,7 @@ class Editor : public PublicEditor
 
        double canvas_width;
        double canvas_height;
+       jack_nframes_t last_canvas_frame;
 
        bool track_canvas_map_handler (GdkEventAny*);
        bool time_canvas_map_handler (GdkEventAny*);
@@ -870,9 +871,7 @@ class Editor : public PublicEditor
 
        int ensure_cursor (jack_nframes_t* pos);
 
-       void fake_handle_new_audio_region (ARDOUR::AudioRegion *);
        void handle_new_audio_region (ARDOUR::AudioRegion *);
-       void fake_handle_audio_region_removed (ARDOUR::AudioRegion *);
        void handle_audio_region_removed (ARDOUR::AudioRegion *);
        void add_audio_region_to_region_display (ARDOUR::AudioRegion *);
        void region_hidden (ARDOUR::Region*);
@@ -1215,7 +1214,6 @@ class Editor : public PublicEditor
        void kbd_do_brush (GdkEvent*);
        void kbd_do_audition (GdkEvent*);
 
-       void fake_handle_new_duration ();
        void handle_new_duration ();
        void initialize_canvas ();
        void reset_scrolling_region (Gtk::Allocation* alloc = 0);
index 744de49c9424a7d4ee14586268e16e2b56ef9c86..b636fccc9cf4ac82d430a9299bbe59c5e7da53da 100644 (file)
@@ -275,38 +275,6 @@ Editor::track_canvas_allocate (Gtk::Allocation alloc)
        canvas_width = alloc.get_width();
        canvas_height = alloc.get_height();
 
-       if (session == 0 && !ARDOUR_UI::instance()->will_create_new_session_automatically()) {
-
-               /* this mess of code is here to find out how wide this text is and
-                  position the message in the center of the editor window.
-               */
-               
-               ustring msg = string_compose ("<span face=\"sans\" style=\"normal\" weight=\"bold\" size=\"x-large\">%1%2</span>",
-                                          _("Start a new session\n"), _("via Session menu"));
-
-               RefPtr<Pango::Layout> layout = create_pango_layout (msg);
-               Pango::FontDescription font = get_font_for_style (N_("FirstActionMessage"));
-               int width, height;
-               get_ink_pixel_size (layout, width, height);
-                       
-               if (first_action_message == 0) {
-                       
-                       first_action_message = new ArdourCanvas::Text (*track_canvas.root());
-                       first_action_message->property_font_desc() = font;
-                       first_action_message->property_fill_color_rgba() = color_map[cFirstActionMessage];
-                       first_action_message->property_x() = (canvas_width - width) / 2.0;
-                       first_action_message->property_y() = (canvas_height/2.0) - height;
-                       first_action_message->property_anchor() = ANCHOR_NORTH_WEST;
-                       first_action_message->property_markup() = msg;
-                       
-               } else {
-
-                       /* center it */
-                       first_action_message->property_x() = (canvas_width - width) / 2.0;
-                       first_action_message->property_y() = (canvas_height/2.0) - height;
-               }
-       }
-
        zoom_range_clock.set ((jack_nframes_t) floor ((canvas_width * frames_per_unit)));
        edit_cursor->set_position (edit_cursor->current_frame);
        playhead_cursor->set_position (playhead_cursor->current_frame);
@@ -374,15 +342,7 @@ Editor::reset_scrolling_region (Gtk::Allocation* alloc)
                }
        }
 
-       // old: ceil ((double) max_frames / frames_per_unit);
-       
-       double last_canvas_unit;
-
-       if (session) {
-               last_canvas_unit =  (session->get_maximum_extent() + (current_page_frames() * 0.10f)) / frames_per_unit;
-       } else {
-               last_canvas_unit = 0;
-       }
+       double last_canvas_unit =  last_canvas_frame / frames_per_unit;
 
        track_canvas.set_scroll_region (0.0, 0.0, max (last_canvas_unit, canvas_width), pos);
 
@@ -418,6 +378,10 @@ Editor::controls_layout_size_request (Requisition* req)
        edit_controls_vbox.check_resize();
 
        req->width = max (edit_controls_vbox.get_width(),  controls_layout.get_width());
+       
+       /* don't get too big. the fudge factors here are just guesses */
+       
+       req->width = min (req->width, screen->get_width() - 300);
        req->height = min ((gint) pos, (screen->get_height() - 400));
 
        /* this one is important: it determines how big the layout thinks it really is, as 
index f6fe3b66c9dbfce16c87af17076942dd20a57653..a55b6f2066c1b4a1887cc8c37c2c9e3cf79ea464 100644 (file)
@@ -256,6 +256,7 @@ Editor::session_going_away ()
        last_update_frame = 0;
        drag_info.item = 0;
        last_audition_region = 0;
+       last_canvas_frame = 0;
 
        /* hide all tracks */
 
index 4506b69b5e00f33a8d4fc6fcf98613d582a21432..bbcfb09a2902f2121aada484b5a531827c46d78b 100644 (file)
@@ -46,14 +46,17 @@ using namespace Glib;
 using namespace Editing;
 
 void
-Editor::handle_audio_region_removed (AudioRegion* ignored)
+Editor::handle_audio_region_removed (AudioRegion* region)
 {
+       ENSURE_GUI_THREAD (bind (mem_fun (*this, &Editor::handle_audio_region_removed), region));
        redisplay_regions ();
 }
 
 void
 Editor::handle_new_audio_region (AudioRegion *region)
 {
+       ENSURE_GUI_THREAD (bind (mem_fun (*this, &Editor::handle_new_audio_region), region));
+
        /* don't copy region - the one we are being notified
           about belongs to the session, and so it will
           never be edited.
index fde9d545bbf77149996093ace177dc2c09f8b120..c1ad4f6ca7fd0bde94fbe210f8dec032c698ed22 100644 (file)
@@ -396,6 +396,42 @@ key_press_focus_accelerator_handler (Gtk::Window& window, GdkEventKey* ev)
           all "normal text" accelerators.
        */
 
+
+       if (!special_handling_of_unmodified_accelerators) {
+
+               /* pretend that certain key events that GTK does not allow
+                  to be used as accelerators are actually something that
+                  it does allow.
+               */
+
+               int ret = false;
+
+               switch (ev->keyval) {
+               case GDK_Up:
+                       ret = gtk_accel_groups_activate(G_OBJECT(win), GDK_uparrow, GdkModifierType(ev->state));
+                       break;
+
+               case GDK_Down:
+                       ret = gtk_accel_groups_activate(G_OBJECT(win), GDK_downarrow, GdkModifierType(ev->state));
+                       break;
+
+               case GDK_Right:
+                       ret = gtk_accel_groups_activate(G_OBJECT(win), GDK_rightarrow, GdkModifierType(ev->state));
+                       break;
+
+               case GDK_Left:
+                       ret = gtk_accel_groups_activate(G_OBJECT(win), GDK_leftarrow, GdkModifierType(ev->state));
+                       break;
+
+               default:
+                       break;
+               }
+
+               if (ret) {
+                       return true;
+               }
+       }
+               
        if (!special_handling_of_unmodified_accelerators ||
            ev->state & (Gdk::MOD1_MASK|
                         Gdk::MOD2_MASK|