enable use of arrow keys, fix hscroller issues, start work on smoother auto-scroll

git-svn-id: svn://localhost/trunk/ardour2@490 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2006-05-02 01:08:34 +00:00
parent 433c518dc7
commit 979b95a56e
8 changed files with 81 additions and 88 deletions

View file

@ -53,8 +53,10 @@
(gtk_accel_path "<Actions>/Editor/scroll-tracks-down" "Page_Down") (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/scroll-tracks-up" "Page_Up")
(gtk_accel_path "<Actions>/Editor/step-tracks-down" "Down") (gtk_accel_path "<Actions>/Editor/scroll-backward" "leftarrow")
(gtk_accel_path "<Actions>/Editor/step-tracks-up" "Up") (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/playhead-to-edit" "Return")
(gtk_accel_path "<Actions>/Editor/edit-to-playhead" "<Alt>Return") (gtk_accel_path "<Actions>/Editor/edit-to-playhead" "<Alt>Return")

View file

@ -159,6 +159,9 @@
<menuitem action='step-tracks-up'/> <menuitem action='step-tracks-up'/>
<menuitem action='step-tracks-down'/> <menuitem action='step-tracks-down'/>
<separator/> <separator/>
<menuitem action='scroll-forward'/>
<menuitem action='scroll-backward'/>
<separator/>
<menuitem action='ToggleWaveformVisibility'/> <menuitem action='ToggleWaveformVisibility'/>
<menuitem action='ToggleWaveformsWhileRecording'/> <menuitem action='ToggleWaveformsWhileRecording'/>
<menuitem action='ToggleMeasureVisibility'/> <menuitem action='ToggleMeasureVisibility'/>

View file

@ -930,6 +930,14 @@ Editor::reposition_x_origin (jack_nframes_t frame)
{ {
if (frame != leftmost_frame) { if (frame != leftmost_frame) {
leftmost_frame = 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); 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 void
Editor::start_scrolling () Editor::start_scrolling ()
{ {
@ -1163,12 +1153,16 @@ Editor::center_screen_internal (jack_nframes_t frame, float page)
void void
Editor::handle_new_duration () Editor::handle_new_duration ()
{ {
reset_scrolling_region (); ENSURE_GUI_THREAD (mem_fun (*this, &Editor::handle_new_duration));
if (session) { jack_nframes_t new_end = session->get_maximum_extent() + (jack_nframes_t) floorf (current_page_frames() * 0.10f);
cerr << "Set upper #2 to " << horizontal_adjustment.get_upper () << endl;
horizontal_adjustment.set_value (leftmost_frame/frames_per_unit); if (new_end > last_canvas_frame) {
last_canvas_frame = new_end;
reset_scrolling_region ();
} }
horizontal_adjustment.set_value (leftmost_frame/frames_per_unit);
} }
void 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->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->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->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->AudioRegionAdded.connect (mem_fun(*this, &Editor::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->AudioRegionRemoved.connect (mem_fun(*this, &Editor::handle_audio_region_removed)));
session_connections.push_back (session->DurationChanged.connect (mem_fun(*this, &Editor::fake_handle_new_duration))); 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_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->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))); 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_crossfade_model ();
update_layering_model (); update_layering_model ();
reset_scrolling_region (); handle_new_duration ();
redisplay_regions (); redisplay_regions ();
redisplay_named_selections (); redisplay_named_selections ();
@ -2880,28 +2874,20 @@ Editor::autoscroll_canvas ()
/* connect the timeout so that we get called repeatedly */ /* connect the timeout so that we get called repeatedly */
autoscroll_timeout_tag = gtk_timeout_add (100, _autoscroll_canvas, this); autoscroll_timeout_tag = gtk_timeout_add (40, _autoscroll_canvas, this);
keep_calling = false;
} else if (autoscroll_cnt > 10 && autoscroll_cnt < 20) { } else if (autoscroll_cnt > 10 && autoscroll_cnt < 20) {
/* after about a while, speed up a bit by changing the timeout interval */ /* after about a while, speed up a bit by changing the timeout interval */
autoscroll_timeout_tag = gtk_timeout_add (50, _autoscroll_canvas, this); autoscroll_timeout_tag = gtk_timeout_add (20, _autoscroll_canvas, this);
keep_calling = false;
} 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) { } 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 = (jack_nframes_t) floor (0.5 * current_page_frames());
autoscroll_distance = 10 * (jack_nframes_t) floor (canvas_width * frames_per_unit);
} }
return keep_calling; return keep_calling;
@ -2917,7 +2903,7 @@ Editor::start_canvas_autoscroll (int dir)
stop_canvas_autoscroll (); stop_canvas_autoscroll ();
autoscroll_direction = dir; 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; autoscroll_cnt = 0;
/* do it right now, which will start the repeated callbacks */ /* do it right now, which will start the repeated callbacks */

View file

@ -700,6 +700,7 @@ class Editor : public PublicEditor
double canvas_width; double canvas_width;
double canvas_height; double canvas_height;
jack_nframes_t last_canvas_frame;
bool track_canvas_map_handler (GdkEventAny*); bool track_canvas_map_handler (GdkEventAny*);
bool time_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); int ensure_cursor (jack_nframes_t* pos);
void fake_handle_new_audio_region (ARDOUR::AudioRegion *);
void 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 handle_audio_region_removed (ARDOUR::AudioRegion *);
void add_audio_region_to_region_display (ARDOUR::AudioRegion *); void add_audio_region_to_region_display (ARDOUR::AudioRegion *);
void region_hidden (ARDOUR::Region*); void region_hidden (ARDOUR::Region*);
@ -1215,7 +1214,6 @@ class Editor : public PublicEditor
void kbd_do_brush (GdkEvent*); void kbd_do_brush (GdkEvent*);
void kbd_do_audition (GdkEvent*); void kbd_do_audition (GdkEvent*);
void fake_handle_new_duration ();
void handle_new_duration (); void handle_new_duration ();
void initialize_canvas (); void initialize_canvas ();
void reset_scrolling_region (Gtk::Allocation* alloc = 0); void reset_scrolling_region (Gtk::Allocation* alloc = 0);

View file

@ -275,38 +275,6 @@ Editor::track_canvas_allocate (Gtk::Allocation alloc)
canvas_width = alloc.get_width(); canvas_width = alloc.get_width();
canvas_height = alloc.get_height(); 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))); zoom_range_clock.set ((jack_nframes_t) floor ((canvas_width * frames_per_unit)));
edit_cursor->set_position (edit_cursor->current_frame); edit_cursor->set_position (edit_cursor->current_frame);
playhead_cursor->set_position (playhead_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 = last_canvas_frame / 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;
}
track_canvas.set_scroll_region (0.0, 0.0, max (last_canvas_unit, canvas_width), pos); 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(); edit_controls_vbox.check_resize();
req->width = max (edit_controls_vbox.get_width(), controls_layout.get_width()); 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)); req->height = min ((gint) pos, (screen->get_height() - 400));
/* this one is important: it determines how big the layout thinks it really is, as /* this one is important: it determines how big the layout thinks it really is, as

View file

@ -256,6 +256,7 @@ Editor::session_going_away ()
last_update_frame = 0; last_update_frame = 0;
drag_info.item = 0; drag_info.item = 0;
last_audition_region = 0; last_audition_region = 0;
last_canvas_frame = 0;
/* hide all tracks */ /* hide all tracks */

View file

@ -46,14 +46,17 @@ using namespace Glib;
using namespace Editing; using namespace Editing;
void 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 (); redisplay_regions ();
} }
void void
Editor::handle_new_audio_region (AudioRegion *region) 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 /* don't copy region - the one we are being notified
about belongs to the session, and so it will about belongs to the session, and so it will
never be edited. never be edited.

View file

@ -396,6 +396,42 @@ key_press_focus_accelerator_handler (Gtk::Window& window, GdkEventKey* ev)
all "normal text" accelerators. 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 || if (!special_handling_of_unmodified_accelerators ||
ev->state & (Gdk::MOD1_MASK| ev->state & (Gdk::MOD1_MASK|
Gdk::MOD2_MASK| Gdk::MOD2_MASK|