factor out "new route insertion point" enums so they can be shared by relevant dialogs

This commit is contained in:
Paul Davis
2016-08-22 08:40:12 -04:00
parent b339cde446
commit 36f232d558
5 changed files with 46 additions and 13 deletions

View File

@@ -614,9 +614,11 @@ AddRouteDialog::new_group_dialog_finished (int r, RouteGroupDialog* d)
delete_when_idle (d);
}
AddRouteDialog::InsertAt
RouteDialogs::InsertAt
AddRouteDialog::insert_at ()
{
using namespace RouteDialogs;
std::string str = insert_at_combo.get_active_text();
if (str == _("First")) {

View File

@@ -40,6 +40,7 @@
#include "ardour_dialog.h"
#include "instrument_selector.h"
#include "route_dialogs.h"
class Editor;
class RouteGroupDialog;
@@ -70,13 +71,8 @@ class AddRouteDialog : public ArdourDialog
ARDOUR::TrackMode mode();
ARDOUR::RouteGroup* route_group ();
enum InsertAt {
BeforeSelection,
AfterSelection,
First,
Last
};
InsertAt insert_at();
RouteDialogs::InsertAt insert_at();
bool use_strict_io();
private:

View File

@@ -3971,7 +3971,7 @@ ARDOUR_UI::cleanup_peakfiles ()
}
PresentationInfo::order_t
ARDOUR_UI::translate_order (AddRouteDialog::InsertAt place)
ARDOUR_UI::translate_order (RouteDialogs::InsertAt place)
{
if (editor->get_selection().tracks.empty()) {
return PresentationInfo::max_order;
@@ -3984,18 +3984,18 @@ ARDOUR_UI::translate_order (AddRouteDialog::InsertAt place)
the highest order key in the selection + 1 (if available).
*/
if (place == AddRouteDialog::AfterSelection) {
if (place == RouteDialogs::AfterSelection) {
RouteTimeAxisView *rtav = dynamic_cast<RouteTimeAxisView*> (editor->get_selection().tracks.back());
if (rtav) {
order_hint = rtav->route()->presentation_info().order();
order_hint++;
}
} else if (place == AddRouteDialog::BeforeSelection) {
} else if (place == RouteDialogs::BeforeSelection) {
RouteTimeAxisView *rtav = dynamic_cast<RouteTimeAxisView*> (editor->get_selection().tracks.front());
if (rtav) {
order_hint = rtav->route()->presentation_info().order();
}
} else if (place == AddRouteDialog::First) {
} else if (place == RouteDialogs::First) {
order_hint = 0;
} else {
/* leave order_hint at max_order */

View File

@@ -91,6 +91,7 @@
#include "location_ui.h"
#include "lua_script_manager.h"
#include "rc_option_editor.h"
#include "route_dialogs.h"
#include "route_params_ui.h"
#include "session_option_editor.h"
#include "speaker_dialog.h"
@@ -680,7 +681,7 @@ private:
bool save_as_progress_update (float fraction, int64_t cnt, int64_t total, Gtk::Label* label, Gtk::ProgressBar* bar);
void save_session_as ();
void rename_session ();
ARDOUR::PresentationInfo::order_t translate_order (AddRouteDialog::InsertAt);
ARDOUR::PresentationInfo::order_t translate_order (RouteDialogs::InsertAt);
int create_mixer ();
int create_editor ();

View File

@@ -0,0 +1,34 @@
/*
Copyright (C) 2016 Paul Davis
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __gtk_ardour_route_dialogs_h__
#define __gtk_ardour_route_dialogs_h__
namespace RouteDialogs {
enum InsertAt {
BeforeSelection,
AfterSelection,
First,
Last
};
}
#endif /* __gtk_ardour_route_dialogs_h__ */