mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-23 23:17:46 +01:00
clever fixes to make keyboard-driven trimming work nicely
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@2856 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
9c88023faf
commit
2c3f54250d
4 changed files with 69 additions and 23 deletions
|
|
@ -317,8 +317,8 @@
|
|||
(gtk_accel_path "<Actions>/Editor/set-fade-out-length" "backslash")
|
||||
(gtk_accel_path "<Actions>/Editor/trim-from-start" "<%TERTIARY%>braceleft")
|
||||
(gtk_accel_path "<Actions>/Editor/trim-to-end" "<%TERTIARY%>braceright")
|
||||
;(gtk_accel_path "<Actions>/Editor/trim-front" "a")
|
||||
;(gtk_accel_path "<Actions>/Editor/trim-back" "s")
|
||||
(gtk_accel_path "<Actions>/Editor/trim-front" "j")
|
||||
(gtk_accel_path "<Actions>/Editor/trim-back" "k")
|
||||
(gtk_accel_path "<Actions>/Editor/goto-mark-1" "KP_1")
|
||||
(gtk_accel_path "<Actions>/Editor/goto-mark-2" "KP_2")
|
||||
(gtk_accel_path "<Actions>/Editor/goto-mark-3" "KP_3")
|
||||
|
|
|
|||
|
|
@ -1966,6 +1966,18 @@ class Editor : public PublicEditor
|
|||
|
||||
TimeAxisView* entered_track;
|
||||
RegionView* entered_regionview;
|
||||
|
||||
class ExclusiveRegionSelection {
|
||||
public:
|
||||
ExclusiveRegionSelection (Editor&, RegionView*);
|
||||
~ExclusiveRegionSelection ();
|
||||
|
||||
private:
|
||||
Editor& editor;
|
||||
RegionView* regionview;
|
||||
bool remove;
|
||||
};
|
||||
|
||||
void ensure_entered_region_selected (bool op_acts_on_objects = false);
|
||||
void ensure_entered_track_selected (bool op_acts_on_objects = false);
|
||||
bool clear_entered_track;
|
||||
|
|
|
|||
|
|
@ -3171,7 +3171,7 @@ Editor::trim_region_to_punch ()
|
|||
void
|
||||
Editor::trim_region_to_location (const Location& loc, const char* str)
|
||||
{
|
||||
ensure_entered_region_selected ();
|
||||
ExclusiveRegionSelection ers (*this, entered_regionview);
|
||||
|
||||
RegionSelection& rs (get_regions_for_action ());
|
||||
|
||||
|
|
@ -3222,6 +3222,8 @@ Editor::trim_region_to_location (const Location& loc, const char* str)
|
|||
void
|
||||
Editor::trim_region_to_edit_point ()
|
||||
{
|
||||
ExclusiveRegionSelection ers (*this, entered_regionview);
|
||||
|
||||
RegionSelection& rs (get_regions_for_action ());
|
||||
nframes64_t where = get_preferred_edit_position();
|
||||
|
||||
|
|
@ -3264,6 +3266,8 @@ Editor::trim_region_to_edit_point ()
|
|||
void
|
||||
Editor::trim_region_from_edit_point ()
|
||||
{
|
||||
ExclusiveRegionSelection ers (*this, entered_regionview);
|
||||
|
||||
RegionSelection& rs (get_regions_for_action ());
|
||||
nframes64_t where = get_preferred_edit_position();
|
||||
|
||||
|
|
@ -4609,27 +4613,29 @@ Editor::ensure_entered_track_selected (bool op_really_wants_one_track_if_none_ar
|
|||
void
|
||||
Editor::ensure_entered_region_selected (bool op_really_wants_one_region_if_none_are_selected)
|
||||
{
|
||||
if (entered_regionview && mouse_mode == MouseObject) {
|
||||
if (!entered_regionview || mouse_mode != MouseObject) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* heuristic:
|
||||
|
||||
- if there is no existing selection, don't change it. the operation will thus apply to "all"
|
||||
|
||||
- if there is an existing selection, but the entered regionview isn't in it, add it. this
|
||||
avoids key-mouse ops on unselected regions from interfering with an existing selection,
|
||||
but also means that the operation will apply to the pointed-at region.
|
||||
*/
|
||||
|
||||
if (!selection->regions.empty()) {
|
||||
if (find (selection->regions.begin(), selection->regions.end(), entered_regionview) != selection->regions.end()) {
|
||||
selection->add (entered_regionview);
|
||||
}
|
||||
} else {
|
||||
/* there is no selection, but this operation requires/prefers selected objects */
|
||||
|
||||
if (op_really_wants_one_region_if_none_are_selected) {
|
||||
selection->set (entered_regionview, false);
|
||||
}
|
||||
|
||||
/* heuristic:
|
||||
|
||||
- if there is no existing selection, don't change it. the operation will thus apply to "all"
|
||||
|
||||
- if there is an existing selection, but the entered regionview isn't in it, add it. this
|
||||
avoids key-mouse ops on unselected regions from interfering with an existing selection,
|
||||
but also means that the operation will apply to the pointed-at region.
|
||||
*/
|
||||
|
||||
if (!selection->regions.empty()) {
|
||||
if (!selection->selected (entered_regionview)) {
|
||||
selection->add (entered_regionview);
|
||||
}
|
||||
} else {
|
||||
/* there is no selection, but this operation requires/prefers selected objects */
|
||||
|
||||
if (op_really_wants_one_region_if_none_are_selected) {
|
||||
selection->set (entered_regionview, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -4649,6 +4655,8 @@ Editor::trim_region_back ()
|
|||
void
|
||||
Editor::trim_region (bool front)
|
||||
{
|
||||
ExclusiveRegionSelection ers (*this, entered_regionview);
|
||||
|
||||
nframes64_t where = get_preferred_edit_position();
|
||||
RegionSelection& rs = get_regions_for_action ();
|
||||
|
||||
|
|
@ -4671,6 +4679,7 @@ Editor::trim_region (bool front)
|
|||
session->add_command(new MementoCommand<Playlist>(*pl.get(), &before, &after));
|
||||
}
|
||||
}
|
||||
|
||||
commit_reversible_command ();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1325,3 +1325,28 @@ Editor::deselect_all ()
|
|||
{
|
||||
selection->clear ();
|
||||
}
|
||||
|
||||
Editor::ExclusiveRegionSelection::ExclusiveRegionSelection (Editor& ed, RegionView* rv)
|
||||
: editor (ed),
|
||||
regionview (rv)
|
||||
{
|
||||
|
||||
if (!rv || ed.current_mouse_mode() != Editing::MouseObject) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (ed.get_selection().regions.empty() && !ed.get_selection().selected (rv)) {
|
||||
ed.get_selection().set (rv, false);
|
||||
remove = true;
|
||||
} else {
|
||||
remove = false;
|
||||
}
|
||||
}
|
||||
|
||||
Editor::ExclusiveRegionSelection::~ExclusiveRegionSelection ()
|
||||
{
|
||||
if (remove) {
|
||||
editor.get_selection().remove (regionview);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue