mirror of
https://github.com/Ardour/ardour.git
synced 2026-01-02 03:47:42 +01:00
more key-mouse selection guesswork, plus make duplicate work without the "times" dialog by default (dialog accessible via Alt-d now)
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@2685 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
11ee29c574
commit
1ef6511c76
6 changed files with 80 additions and 83 deletions
|
|
@ -133,6 +133,7 @@
|
|||
<menu name='Regions' action='Regions'>
|
||||
<menuitem action='crop'/>
|
||||
<menuitem action='duplicate-region'/>
|
||||
<menuitem action='multi-duplicate-region'/>
|
||||
<menuitem action='insert-region'/>
|
||||
<menuitem action='normalize-region'/>
|
||||
<separator/>
|
||||
|
|
|
|||
|
|
@ -1840,7 +1840,8 @@ Editor::add_region_context_items (AudioStreamView* sv, boost::shared_ptr<Region>
|
|||
items.push_back (MenuElem (_("Make mono regions"), (mem_fun(*this, &Editor::split_multichannel_region))));
|
||||
region_edit_menu_split_multichannel_item = &items.back();
|
||||
|
||||
items.push_back (MenuElem (_("Duplicate"), (bind (mem_fun(*this, &Editor::duplicate_dialog), true))));
|
||||
items.push_back (MenuElem (_("Duplicate"), (bind (mem_fun(*this, &Editor::duplicate_dialog), false))));
|
||||
items.push_back (MenuElem (_("Multi-Duplicate"), (bind (mem_fun(*this, &Editor::duplicate_dialog), true))));
|
||||
items.push_back (MenuElem (_("Fill Track"), (mem_fun(*this, &Editor::region_fill_track))));
|
||||
items.push_back (SeparatorElem());
|
||||
items.push_back (MenuElem (_("Remove"), mem_fun(*this, &Editor::remove_clicked_region)));
|
||||
|
|
@ -2999,50 +3000,67 @@ Editor::history_changed ()
|
|||
}
|
||||
|
||||
void
|
||||
Editor::duplicate_dialog (bool dup_region)
|
||||
Editor::duplicate_dialog (bool with_dialog)
|
||||
{
|
||||
if (selection->regions.empty() && (selection->time.length() == 0)) {
|
||||
return;
|
||||
float times = 1.0f;
|
||||
|
||||
if (mouse_mode == MouseRange) {
|
||||
if (selection->time.length() == 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ArdourDialog win ("duplicate dialog");
|
||||
Label label (_("Duplicate how many times?"));
|
||||
Adjustment adjustment (1.0, 1.0, 1000000.0, 1.0, 5.0);
|
||||
SpinButton spinner (adjustment);
|
||||
|
||||
if (mouse_mode != MouseRange) {
|
||||
|
||||
win.get_vbox()->set_spacing (12);
|
||||
win.get_vbox()->pack_start (label);
|
||||
ensure_entered_selected (true);
|
||||
|
||||
/* dialogs have ::add_action_widget() but that puts the spinner in the wrong
|
||||
place, visually. so do this by hand.
|
||||
*/
|
||||
|
||||
win.get_vbox()->pack_start (spinner);
|
||||
spinner.signal_activate().connect (sigc::bind (mem_fun (win, &ArdourDialog::response), RESPONSE_ACCEPT));
|
||||
|
||||
label.show ();
|
||||
spinner.show ();
|
||||
|
||||
win.add_button (Stock::OK, RESPONSE_ACCEPT);
|
||||
win.add_button (Stock::CANCEL, RESPONSE_CANCEL);
|
||||
|
||||
win.set_position (WIN_POS_MOUSE);
|
||||
|
||||
spinner.grab_focus ();
|
||||
|
||||
switch (win.run ()) {
|
||||
case RESPONSE_ACCEPT:
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
if (selection->regions.empty()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
float times = adjustment.get_value();
|
||||
if (with_dialog) {
|
||||
|
||||
if (!selection->regions.empty()) {
|
||||
duplicate_some_regions (selection->regions, times);
|
||||
} else {
|
||||
ArdourDialog win ("duplicate dialog");
|
||||
Label label (_("Duplicate how many times?"));
|
||||
Adjustment adjustment (1.0, 1.0, 1000000.0, 1.0, 5.0);
|
||||
SpinButton spinner (adjustment);
|
||||
|
||||
win.get_vbox()->set_spacing (12);
|
||||
win.get_vbox()->pack_start (label);
|
||||
|
||||
/* dialogs have ::add_action_widget() but that puts the spinner in the wrong
|
||||
place, visually. so do this by hand.
|
||||
*/
|
||||
|
||||
win.get_vbox()->pack_start (spinner);
|
||||
spinner.signal_activate().connect (sigc::bind (mem_fun (win, &ArdourDialog::response), RESPONSE_ACCEPT));
|
||||
|
||||
label.show ();
|
||||
spinner.show ();
|
||||
|
||||
win.add_button (Stock::OK, RESPONSE_ACCEPT);
|
||||
win.add_button (Stock::CANCEL, RESPONSE_CANCEL);
|
||||
|
||||
win.set_position (WIN_POS_MOUSE);
|
||||
|
||||
spinner.grab_focus ();
|
||||
|
||||
switch (win.run ()) {
|
||||
case RESPONSE_ACCEPT:
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
times = adjustment.get_value();
|
||||
}
|
||||
|
||||
if (mouse_mode == MouseRange) {
|
||||
duplicate_selection (times);
|
||||
} else {
|
||||
duplicate_some_regions (selection->regions, times);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -953,8 +953,6 @@ class Editor : public PublicEditor
|
|||
int get_prefix (float&, bool&);
|
||||
|
||||
void keyboard_paste ();
|
||||
void keyboard_duplicate_region ();
|
||||
void keyboard_duplicate_selection ();
|
||||
void keyboard_insert_region_list_selection ();
|
||||
|
||||
void region_from_selection ();
|
||||
|
|
@ -1744,7 +1742,7 @@ class Editor : public PublicEditor
|
|||
|
||||
/* duplication */
|
||||
|
||||
void duplicate_dialog (bool for_region);
|
||||
void duplicate_dialog (bool with_dialog);
|
||||
|
||||
nframes64_t event_frame (GdkEvent*, double* px = 0, double* py = 0) const;
|
||||
|
||||
|
|
@ -1887,7 +1885,7 @@ class Editor : public PublicEditor
|
|||
|
||||
TimeAxisView* entered_track;
|
||||
RegionView* entered_regionview;
|
||||
void ensure_entered_selected ();
|
||||
void ensure_entered_selected (bool op_acts_on_objects = false);
|
||||
bool clear_entered_track;
|
||||
gint left_track_canvas (GdkEventCrossing*);
|
||||
void set_entered_track (TimeAxisView*);
|
||||
|
|
|
|||
|
|
@ -267,9 +267,11 @@ Editor::register_actions ()
|
|||
ActionManager::session_sensitive_actions.push_back (act);
|
||||
act = ActionManager::register_action (editor_actions, "editor-paste", _("Paste"), mem_fun(*this, &Editor::keyboard_paste));
|
||||
ActionManager::session_sensitive_actions.push_back (act);
|
||||
act = ActionManager::register_action (editor_actions, "duplicate-region", _("Duplicate Region"), mem_fun(*this, &Editor::keyboard_duplicate_region));
|
||||
act = ActionManager::register_action (editor_actions, "duplicate-region", _("Duplicate Region"), bind (mem_fun(*this, &Editor::duplicate_dialog), false));
|
||||
ActionManager::session_sensitive_actions.push_back (act);
|
||||
act = ActionManager::register_action (editor_actions, "duplicate-range", _("Duplicate Range"), mem_fun(*this, &Editor::keyboard_duplicate_selection));
|
||||
act = ActionManager::register_action (editor_actions, "multi-duplicate-region", _("Multi-Duplicate Region"), bind (mem_fun(*this, &Editor::duplicate_dialog), true));
|
||||
ActionManager::session_sensitive_actions.push_back (act);
|
||||
act = ActionManager::register_action (editor_actions, "duplicate-range", _("Duplicate Range"), bind (mem_fun(*this, &Editor::duplicate_dialog), false));
|
||||
ActionManager::session_sensitive_actions.push_back (act);
|
||||
act = ActionManager::register_action (editor_actions, "insert-region", _("Insert Region"), mem_fun(*this, &Editor::keyboard_insert_region_list_selection));
|
||||
ActionManager::session_sensitive_actions.push_back (act);
|
||||
|
|
|
|||
|
|
@ -86,36 +86,6 @@ Editor::keyboard_selection_begin ()
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
Editor::keyboard_duplicate_region ()
|
||||
{
|
||||
if (selection->regions.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
float prefix = 0;
|
||||
bool was_floating;
|
||||
|
||||
if (get_prefix (prefix, was_floating) == 0) {
|
||||
duplicate_some_regions (selection->regions, prefix);
|
||||
} else {
|
||||
duplicate_some_regions (selection->regions, 1);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Editor::keyboard_duplicate_selection ()
|
||||
{
|
||||
float prefix = 0;
|
||||
bool was_floating;
|
||||
|
||||
if (get_prefix (prefix, was_floating) == 0) {
|
||||
duplicate_selection (prefix);
|
||||
} else {
|
||||
duplicate_selection (1);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Editor::keyboard_paste ()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2357,7 +2357,7 @@ Editor::separate_regions_using_location (Location& loc)
|
|||
void
|
||||
Editor::crop_region_to_selection ()
|
||||
{
|
||||
ensure_entered_selected ();
|
||||
ensure_entered_selected (true);
|
||||
|
||||
if (!selection->time.empty()) {
|
||||
|
||||
|
|
@ -2382,8 +2382,6 @@ Editor::crop_region_to (nframes_t start, nframes_t end)
|
|||
boost::shared_ptr<Playlist> playlist;
|
||||
TrackSelection* ts;
|
||||
|
||||
ensure_entered_selected ();
|
||||
|
||||
if (selection->tracks.empty()) {
|
||||
ts = &track_views;
|
||||
} else {
|
||||
|
|
@ -3439,8 +3437,9 @@ void
|
|||
Editor::duplicate_some_regions (RegionSelection& regions, float times)
|
||||
{
|
||||
boost::shared_ptr<Playlist> playlist;
|
||||
RegionSelection sel = regions; // clear (below) will clear the argument list
|
||||
|
||||
RegionSelection sel = regions; // clear (below) may clear the argument list if its the current region selection
|
||||
RegionSelection foo;
|
||||
|
||||
begin_reversible_command (_("duplicate region"));
|
||||
|
||||
selection->clear_regions ();
|
||||
|
|
@ -3451,6 +3450,8 @@ Editor::duplicate_some_regions (RegionSelection& regions, float times)
|
|||
|
||||
TimeAxisView& tv = (*i)->get_time_axis_view();
|
||||
AudioTimeAxisView* atv = dynamic_cast<AudioTimeAxisView*> (&tv);
|
||||
|
||||
latest_regionviews.clear ();
|
||||
sigc::connection c = atv->view()->RegionViewAdded.connect (mem_fun(*this, &Editor::collect_new_region_view));
|
||||
|
||||
playlist = (*i)->region()->playlist();
|
||||
|
|
@ -3459,14 +3460,15 @@ Editor::duplicate_some_regions (RegionSelection& regions, float times)
|
|||
session->add_command(new MementoCommand<Playlist>(*playlist, &before, &playlist->get_state()));
|
||||
|
||||
c.disconnect ();
|
||||
|
||||
if (!latest_regionviews.empty()) {
|
||||
selection->add (latest_regionviews);
|
||||
}
|
||||
}
|
||||
|
||||
foo.insert (foo.end(), latest_regionviews.begin(), latest_regionviews.end());
|
||||
}
|
||||
|
||||
commit_reversible_command ();
|
||||
|
||||
if (!foo.empty()) {
|
||||
selection->set (foo);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -4124,7 +4126,7 @@ Editor::split ()
|
|||
}
|
||||
|
||||
void
|
||||
Editor::ensure_entered_selected ()
|
||||
Editor::ensure_entered_selected (bool op_really_wants_one_region_if_none_are_selected)
|
||||
{
|
||||
if (entered_regionview && mouse_mode == MouseObject) {
|
||||
|
||||
|
|
@ -4141,6 +4143,12 @@ Editor::ensure_entered_selected ()
|
|||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue