use leave/enter from track canvas to be the primary driver of region action sensitivity
This works for context menus also, because GTK sends us leave/enter notify events when they appear.
This commit is contained in:
parent
0a41daa932
commit
3d3f2a79f6
|
@ -1466,30 +1466,11 @@ Editor::set_session (Session *t)
|
|||
_session->register_with_memento_command_factory(id(), this);
|
||||
_session->register_with_memento_command_factory(_selection_memento->id(), _selection_memento);
|
||||
|
||||
ActionManager::ui_manager->signal_pre_activate().connect (sigc::mem_fun (*this, &Editor::action_pre_activated));
|
||||
|
||||
LuaInstance::instance()->set_session(_session);
|
||||
|
||||
start_updating_meters ();
|
||||
}
|
||||
|
||||
void
|
||||
Editor::action_pre_activated (Glib::RefPtr<Action> const & a)
|
||||
{
|
||||
if (a->get_name() == "RegionMenu") {
|
||||
/* When the main menu's region menu is opened, we setup the actions so that they look right
|
||||
in the menu. I can't find a way of getting a signal when this menu is subsequently closed,
|
||||
so we resensitize all region actions when the entered regionview or the region selection
|
||||
changes. HOWEVER we can't always resensitize on entered_regionview change because that
|
||||
happens after the region context menu is opened. So we set a flag here, too.
|
||||
|
||||
What a carry on :(
|
||||
*/
|
||||
sensitize_the_right_region_actions (false, !within_track_canvas);
|
||||
_last_region_menu_was_main = true;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Editor::fill_xfade_menu (Menu_Helpers::MenuList& items, bool start)
|
||||
{
|
||||
|
@ -4738,8 +4719,6 @@ Editor::get_preferred_edit_position (EditIgnoreOption ignore, bool from_context_
|
|||
framepos_t where = 0;
|
||||
EditPoint ep = _edit_point;
|
||||
|
||||
cerr << "ig " << ignore << " fcm " << from_context_menu << " foc " << from_outside_canvas << endl;
|
||||
|
||||
if (Profile->get_mixbus()) {
|
||||
if (ep == EditAtSelectedMarker) {
|
||||
ep = EditAtPlayhead;
|
||||
|
@ -4767,8 +4746,6 @@ Editor::get_preferred_edit_position (EditIgnoreOption ignore, bool from_context_
|
|||
|
||||
MusicFrame snap_mf (0, 0);
|
||||
|
||||
cerr << "Using EP " << enum_2_string (ep) << endl;
|
||||
|
||||
switch (ep) {
|
||||
case EditAtPlayhead:
|
||||
if (_dragging_playhead) {
|
||||
|
@ -4970,7 +4947,7 @@ Editor::get_regions_from_selection_and_edit_point (EditIgnoreOption ignore, bool
|
|||
/* no region selected or entered, but some selected tracks:
|
||||
* act on all regions on the selected tracks at the edit point
|
||||
*/
|
||||
framepos_t const where = get_preferred_edit_position (ignore, from_outside_canvas, from_outside_canvas);
|
||||
framepos_t const where = get_preferred_edit_position (ignore, from_context_menu, from_outside_canvas);
|
||||
get_regions_at(regions, where, tracks);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -808,22 +808,46 @@ Editor::get_enter_context(ItemType type)
|
|||
}
|
||||
|
||||
bool
|
||||
Editor::left_track_canvas (GdkEventCrossing */*ev*/)
|
||||
Editor::left_track_canvas (GdkEventCrossing* ev)
|
||||
{
|
||||
const bool was_within = within_track_canvas;
|
||||
DropDownKeys ();
|
||||
within_track_canvas = false;
|
||||
set_entered_track (0);
|
||||
set_entered_regionview (0);
|
||||
reset_canvas_action_sensitivity (false);
|
||||
|
||||
if (was_within) {
|
||||
if (ev->detail == GDK_NOTIFY_NONLINEAR ||
|
||||
ev->detail == GDK_NOTIFY_NONLINEAR_VIRTUAL) {
|
||||
/* context menu or something similar */
|
||||
sensitize_the_right_region_actions (true, false);
|
||||
} else {
|
||||
sensitize_the_right_region_actions (false, true);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
Editor::entered_track_canvas (GdkEventCrossing */*ev*/)
|
||||
Editor::entered_track_canvas (GdkEventCrossing* ev)
|
||||
{
|
||||
const bool was_within = within_track_canvas;
|
||||
within_track_canvas = true;
|
||||
reset_canvas_action_sensitivity (true);
|
||||
return FALSE;
|
||||
|
||||
if (!was_within) {
|
||||
if (ev->detail == GDK_NOTIFY_NONLINEAR ||
|
||||
ev->detail == GDK_NOTIFY_NONLINEAR_VIRTUAL) {
|
||||
/* context menu or something similar */
|
||||
sensitize_the_right_region_actions (true, false);
|
||||
} else {
|
||||
sensitize_the_right_region_actions (false, true);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -892,6 +892,7 @@ Editor::build_marker_menu (Location* loc)
|
|||
using namespace Menu_Helpers;
|
||||
|
||||
marker_menu = new Menu;
|
||||
|
||||
MenuList& items = marker_menu->items();
|
||||
marker_menu->set_name ("ArdourContextMenu");
|
||||
|
||||
|
@ -931,7 +932,8 @@ Editor::build_range_marker_menu (Location* loc, bool loop_or_punch, bool session
|
|||
|
||||
bool const loop_or_punch_or_session = loop_or_punch || session;
|
||||
|
||||
Menu *markerMenu = new Menu;
|
||||
Menu* markerMenu = new Menu;
|
||||
|
||||
if (loop_or_punch_or_session) {
|
||||
transport_marker_menu = markerMenu;
|
||||
} else {
|
||||
|
@ -985,6 +987,7 @@ Editor::build_tempo_marker_menu (TempoMarker* loc, bool can_remove)
|
|||
using namespace Menu_Helpers;
|
||||
|
||||
tempo_marker_menu = new Menu;
|
||||
|
||||
MenuList& items = tempo_marker_menu->items();
|
||||
tempo_marker_menu->set_name ("ArdourContextMenu");
|
||||
|
||||
|
@ -1011,6 +1014,7 @@ Editor::build_meter_marker_menu (MeterMarker* loc, bool can_remove)
|
|||
using namespace Menu_Helpers;
|
||||
|
||||
meter_marker_menu = new Menu;
|
||||
|
||||
MenuList& items = meter_marker_menu->items();
|
||||
meter_marker_menu->set_name ("ArdourContextMenu");
|
||||
|
||||
|
@ -1032,6 +1036,7 @@ Editor::build_new_transport_marker_menu ()
|
|||
using namespace Menu_Helpers;
|
||||
|
||||
new_transport_marker_menu = new Menu;
|
||||
|
||||
MenuList& items = new_transport_marker_menu->items();
|
||||
new_transport_marker_menu->set_name ("ArdourContextMenu");
|
||||
|
||||
|
|
|
@ -1086,17 +1086,14 @@ Editor::sensitize_all_region_actions (bool s)
|
|||
_all_region_actions_sensitized = s;
|
||||
}
|
||||
|
||||
/** Sensitize region-based actions based on the selection ONLY, ignoring the entered_regionview.
|
||||
* This method is called from three places:
|
||||
/** Sensitize region-based actions.
|
||||
*
|
||||
* 1. just before the top level Region menu is shown
|
||||
* 2. whenever the region selection changes
|
||||
* 3. just before popping up a track context menu
|
||||
*
|
||||
* This method also sets up toggle action state as appropriate.
|
||||
* This method is called from whenever we leave the canvas, either by moving
|
||||
* the pointer out of it, or by popping up a context menu. See
|
||||
* Editor::{entered,left}_track_canvas() for details there.
|
||||
*/
|
||||
void
|
||||
Editor::sensitize_the_right_region_actions (bool from_context_menu, bool from_outside_canvas)
|
||||
Editor::sensitize_the_right_region_actions (bool from_context_menu, bool from_canvas_crossing)
|
||||
{
|
||||
bool have_selection = false;
|
||||
bool have_entered = false;
|
||||
|
@ -1113,9 +1110,18 @@ Editor::sensitize_the_right_region_actions (bool from_context_menu, bool from_ou
|
|||
rs.add (entered_regionview);
|
||||
}
|
||||
|
||||
if (!selection->tracks.empty()) {
|
||||
if (rs.empty() && !selection->tracks.empty()) {
|
||||
|
||||
/* no selected regions, but some selected tracks. what we do
|
||||
* here depends on the context in which we are called
|
||||
*/
|
||||
|
||||
if (from_canvas_crossing) {
|
||||
if (!within_track_canvas && _edit_point == EditAtMouse) {
|
||||
have_edit_point = false;
|
||||
} else {
|
||||
RegionSelection at_edit_point;
|
||||
framepos_t const where = get_preferred_edit_position (Editing::EDIT_IGNORE_NONE, from_context_menu, from_outside_canvas);
|
||||
framepos_t const where = get_preferred_edit_position (Editing::EDIT_IGNORE_NONE, false, !within_track_canvas);
|
||||
get_regions_at (at_edit_point, where, selection->tracks);
|
||||
if (!at_edit_point.empty()) {
|
||||
have_edit_point = true;
|
||||
|
@ -1124,6 +1130,10 @@ Editor::sensitize_the_right_region_actions (bool from_context_menu, bool from_ou
|
|||
rs.insert (rs.end(), at_edit_point.begin(), at_edit_point.end());
|
||||
}
|
||||
}
|
||||
} else if (from_context_menu) {
|
||||
/* we have a context click event */
|
||||
}
|
||||
}
|
||||
|
||||
typedef std::map<std::string,RegionAction> RegionActionMap;
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user