diff options
-rw-r--r-- | gtk2_ardour/editor.cc | 2 | ||||
-rw-r--r-- | gtk2_ardour/time_info_box.cc | 40 | ||||
-rw-r--r-- | libs/gtkmm2ext/actions.cc | 12 | ||||
-rw-r--r-- | libs/gtkmm2ext/gtkmm2ext/actions.h | 1 |
4 files changed, 48 insertions, 7 deletions
diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index 01777f54a3..8a00a3e501 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -2263,7 +2263,7 @@ Editor::set_state (const XMLNode& node, int /*version*/) } if ((prop = node.property ("join-object-range"))) { - join_object_range_button.set_active (string_is_affirmative (prop->value ())); + ActionManager::set_toggle_action ("MouseMode", "set-mouse-mode-object-range", string_is_affirmative (prop->value ())); } if ((prop = node.property ("edit-point"))) { diff --git a/gtk2_ardour/time_info_box.cc b/gtk2_ardour/time_info_box.cc index 515d49f72b..00b760952c 100644 --- a/gtk2_ardour/time_info_box.cc +++ b/gtk2_ardour/time_info_box.cc @@ -247,9 +247,22 @@ TimeInfoBox::selection_changed () } else { if (selection.regions.empty()) { if (selection.points.empty()) { - selection_start->set_off (true); - selection_end->set_off (true); - selection_length->set_off (true); + Glib::RefPtr<Action> act = ActionManager::get_action ("MouseMode", "set-mouse-mode-object-range"); + Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic (act); + + if (tact && tact->get_active() && !selection.time.empty()) { + /* show selected range */ + selection_start->set_off (false); + selection_end->set_off (false); + selection_length->set_off (false); + selection_start->set (selection.time.start()); + selection_end->set (selection.time.end_frame()); + selection_length->set (selection.time.length()); + } else { + selection_start->set_off (true); + selection_end->set_off (true); + selection_length->set_off (true); + } } else { s = max_framepos; e = 0; @@ -279,9 +292,24 @@ TimeInfoBox::selection_changed () case Editing::MouseRange: if (selection.time.empty()) { - selection_start->set_off (true); - selection_end->set_off (true); - selection_length->set_off (true); + Glib::RefPtr<Action> act = ActionManager::get_action ("MouseMode", "set-mouse-mode-object-range"); + Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic (act); + + if (tact && tact->get_active() && !selection.regions.empty()) { + /* show selected regions */ + s = selection.regions.start(); + e = selection.regions.end_frame(); + selection_start->set_off (false); + selection_end->set_off (false); + selection_length->set_off (false); + selection_start->set (s); + selection_end->set (e); + selection_length->set (e - s + 1); + } else { + selection_start->set_off (true); + selection_end->set_off (true); + selection_length->set_off (true); + } } else { selection_start->set_off (false); selection_end->set_off (false); diff --git a/libs/gtkmm2ext/actions.cc b/libs/gtkmm2ext/actions.cc index c9aae4568b..02e99f23e9 100644 --- a/libs/gtkmm2ext/actions.cc +++ b/libs/gtkmm2ext/actions.cc @@ -353,3 +353,15 @@ ActionManager::do_action (const char* group, const char*action) } } +void +ActionManager::set_toggle_action (const char* group, const char*action, bool yn) +{ + Glib::RefPtr<Gtk::Action> act = ActionManager::get_action (group, action); + if (act) { + Glib::RefPtr<Gtk::ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic (act); + if (tact) { + tact->set_active (yn); + } + } +} + diff --git a/libs/gtkmm2ext/gtkmm2ext/actions.h b/libs/gtkmm2ext/gtkmm2ext/actions.h index d9082ffbff..0c53e9c10d 100644 --- a/libs/gtkmm2ext/gtkmm2ext/actions.h +++ b/libs/gtkmm2ext/gtkmm2ext/actions.h @@ -44,6 +44,7 @@ namespace ActionManager { extern Glib::RefPtr<Gtk::Action> get_action (const char* group, const char* name); extern Glib::RefPtr<Gtk::Action> get_action (const char* path); extern void do_action (const char* group, const char* name); + extern void set_toggle_action (const char* group, const char* name, bool); extern void add_action_group (Glib::RefPtr<Gtk::ActionGroup>); |