mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-22 22:56:32 +01:00
[Summary]: ProgressDialog for Tracks creation and removal
This commit is contained in:
parent
7274155288
commit
dbb0a6385b
12 changed files with 115 additions and 27 deletions
|
|
@ -66,6 +66,7 @@
|
|||
|
||||
#include "ardour/ardour.h"
|
||||
#include "ardour/audio_backend.h"
|
||||
#include "ardour/audio_track.h"
|
||||
#include "ardour/audioengine.h"
|
||||
#include "ardour/audiofilesource.h"
|
||||
#include "ardour/automation_watch.h"
|
||||
|
|
@ -2972,13 +2973,9 @@ ARDOUR_UI::close_session()
|
|||
int
|
||||
ARDOUR_UI::load_session (const std::string& path, const std::string& snap_name, std::string mix_template)
|
||||
{
|
||||
ProgressDialog::instance()->set_top_label ("Loading session: "+path);
|
||||
ProgressDialog::instance()->set_top_label ("Loading session: "+snap_name);
|
||||
ProgressDialog::instance()->update_info (0.0, NULL, NULL, "Loading audio...");
|
||||
ProgressDialog::instance()->show ();
|
||||
/* Make sure the progress dialog is drawn */
|
||||
while (Glib::MainContext::get_default()->iteration (false)) {
|
||||
/* do nothing */
|
||||
}
|
||||
|
||||
Session *new_session;
|
||||
int unload_status;
|
||||
|
|
@ -3473,7 +3470,7 @@ ARDOUR_UI::add_route (Gtk::Window* float_window)
|
|||
setup_order_hint();
|
||||
|
||||
ChanCount input_chan = _add_tracks_dialog->input_channels ();
|
||||
DisplaySuspender ds;
|
||||
//DisplaySuspender ds;
|
||||
ChanCount output_chan;
|
||||
|
||||
// NP: output_channels amount will be validated and changed accordingly to Master BUS config in Session::reconnect_existing_routes
|
||||
|
|
@ -3484,15 +3481,41 @@ ARDOUR_UI::add_route (Gtk::Window* float_window)
|
|||
} else */ {
|
||||
output_chan = input_chan;
|
||||
}
|
||||
|
||||
ProgressDialog::instance()->set_top_label ("Adding tracks...");
|
||||
ProgressDialog::instance()->set_num_of_steps (_add_tracks_dialog->count () * 2);
|
||||
ProgressDialog::instance()->show ();
|
||||
|
||||
session_add_audio_track (input_chan.n_audio(), output_chan.n_audio(), ARDOUR::Normal, NULL, _add_tracks_dialog->count(), "");
|
||||
session_add_audio_route (true, input_chan.n_audio(), output_chan.n_audio(), ARDOUR::Normal, NULL, _add_tracks_dialog->count(), "");
|
||||
ProgressDialog::instance()->hide ();
|
||||
}
|
||||
|
||||
void
|
||||
ARDOUR_UI::delete_selected_tracks()
|
||||
{
|
||||
DisplaySuspender ds;
|
||||
|
||||
TrackSelection& track_selection = ARDOUR_UI::instance()->the_editor().get_selection().tracks;
|
||||
track_selection.foreach_route_ui (boost::bind (&RouteUI::remove_this_route, _1, false));
|
||||
boost::shared_ptr<RouteList> routes_to_remove(new RouteList);
|
||||
for (list<TimeAxisView*>::iterator i = track_selection.begin(); i != track_selection.end(); ++i) {
|
||||
RouteUI* t = dynamic_cast<RouteUI*> (*i);
|
||||
if (t) {
|
||||
if ( t->route()->is_master() || t->route()->is_monitor() )
|
||||
continue;
|
||||
|
||||
AudioTrack* audio_track = dynamic_cast<AudioTrack*>( t->route().get() );
|
||||
if ( audio_track && audio_track->is_master_track() )
|
||||
continue;
|
||||
|
||||
routes_to_remove->push_back(t->route() );
|
||||
}
|
||||
}
|
||||
ProgressDialog::instance()->set_top_label ("Removing tracks...");
|
||||
ProgressDialog::instance()->set_num_of_steps (routes_to_remove->size ());
|
||||
ProgressDialog::instance()->show ();
|
||||
|
||||
ARDOUR_UI::instance()->the_session()->remove_routes (routes_to_remove);
|
||||
ProgressDialog::instance()->hide ();
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -1487,6 +1487,9 @@ Editor::set_session (Session *t)
|
|||
// if new tracks is added, they must effect on Global Record button and Master Mute button
|
||||
_session->RouteAdded.connect (_session_connections, invalidator (*this), boost::bind (&Editor::connect_routes_and_update_global_rec_button, this, _1), gui_context());
|
||||
|
||||
// one route was removed/added
|
||||
_session->RouteAddedOrRemoved.connect (_session_connections, invalidator (*this), boost::bind (&Editor::update_progress_dialog_of_changing_tracks, this, _1), gui_context());
|
||||
|
||||
// connect existing tracks to Global Record button
|
||||
connect_routes_and_update_global_rec_button( *(_session->get_tracks().get()) );
|
||||
|
||||
|
|
@ -5034,6 +5037,7 @@ Editor::add_routes (RouteList& routes)
|
|||
|
||||
rtv->view()->RegionViewAdded.connect (sigc::mem_fun (*this, &Editor::region_view_added));
|
||||
rtv->view()->RegionViewRemoved.connect (sigc::mem_fun (*this, &Editor::region_view_removed));
|
||||
ProgressDialog::instance()->add_progress_step ();
|
||||
}
|
||||
|
||||
if (new_views.size() > 0) {
|
||||
|
|
@ -5944,3 +5948,10 @@ Editor::port_connection_handler (boost::weak_ptr<Port> wa, std::string, boost::w
|
|||
|
||||
// add actions here
|
||||
}
|
||||
|
||||
|
||||
void // true - track was added, false - track was removed
|
||||
Editor::update_progress_dialog_of_changing_tracks (bool operation)
|
||||
{
|
||||
ProgressDialog::instance()->add_progress_step ();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2166,6 +2166,8 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
|
|||
void port_connection_handler (boost::weak_ptr<ARDOUR::Port> wa, std::string, boost::weak_ptr<ARDOUR::Port> wb, std::string, bool connected);
|
||||
|
||||
PBD::ScopedConnectionList port_state_connection_list;
|
||||
|
||||
void update_progress_dialog_of_changing_tracks (bool);
|
||||
|
||||
/* members and methods associated with MIDI + markers */
|
||||
|
||||
|
|
|
|||
|
|
@ -564,6 +564,7 @@ EditorRoutes::redisplay ()
|
|||
*/
|
||||
_editor->vertical_adjustment.set_value (_editor->_full_canvas_height - _editor->_visible_canvas_height);
|
||||
}
|
||||
ProgressDialog::instance()->add_progress_step ();
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -33,6 +33,9 @@ ProgressDialog::ProgressDialog (const std::string& title,
|
|||
, _top_label ( get_label ("top_label") )
|
||||
, _bottom_label ( get_label ("bottom_label") )
|
||||
, _progress_bar (get_progressbar ("progress_bar"))
|
||||
, num_of_steps (0)
|
||||
, cur_step (0)
|
||||
, hide_automatically(false)
|
||||
{
|
||||
init (title, top_message, progress_message, bottom_message);
|
||||
}
|
||||
|
|
@ -53,8 +56,6 @@ ProgressDialog::init (const std::string& title,
|
|||
set_modal (true);
|
||||
set_resizable (false);
|
||||
set_position (Gtk::WIN_POS_CENTER_ALWAYS);
|
||||
set_type_hint (Gdk::WINDOW_TYPE_HINT_NORMAL);
|
||||
|
||||
|
||||
set_title (title);
|
||||
set_top_label (top_message);
|
||||
|
|
@ -92,6 +93,45 @@ ProgressDialog::update_info (double new_progress, const char* top_message, const
|
|||
set_bottom_label (bottom_message);
|
||||
}
|
||||
|
||||
void
|
||||
ProgressDialog::set_num_of_steps (unsigned int n, bool hide_automatically)
|
||||
{
|
||||
num_of_steps = n;
|
||||
cur_step = 0;
|
||||
this->hide_automatically = hide_automatically;
|
||||
_progress_bar.set_fraction (0.0);
|
||||
set_bottom_label("0 %");
|
||||
}
|
||||
void
|
||||
ProgressDialog::add_progress_step ()
|
||||
{
|
||||
unsigned int this_thread_cur_step;
|
||||
{ //thread unsafe, so
|
||||
std::lock_guard <std::mutex> lock (_m);
|
||||
if (cur_step == num_of_steps)
|
||||
return;
|
||||
|
||||
++cur_step;
|
||||
this_thread_cur_step = cur_step;
|
||||
}
|
||||
set_bottom_label (string_compose ("%1 %", int ( ( float (cur_step) / (num_of_steps)) * 100)));
|
||||
set_progress (float (this_thread_cur_step) / (num_of_steps));
|
||||
|
||||
if (hide_automatically && this_thread_cur_step == num_of_steps){
|
||||
hide ();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ProgressDialog::show ()
|
||||
{
|
||||
WavesDialog::show ();
|
||||
/* Make sure the progress dialog is drawn */
|
||||
while (Glib::MainContext::get_default()->iteration (false)) {
|
||||
/* do nothing */
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ProgressDialog::update_progress_gui (float p)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -34,7 +34,13 @@ public:
|
|||
void set_top_label (std::string message);
|
||||
void set_progress_label (std::string message);
|
||||
void set_bottom_label (std::string message);
|
||||
// initialize num of processing steps (thread-unsafe method)
|
||||
void set_num_of_steps (unsigned int, bool hide_automatically = false);
|
||||
// increment cur_step of progress process (thread-safe method)
|
||||
// it's expected that set_num_of_steps () was called previously
|
||||
void add_progress_step ();
|
||||
void update_info (double new_progress, const char* top_message, const char* progress_message, const char* bottom_message);
|
||||
void show ();
|
||||
|
||||
private:
|
||||
ProgressDialog (const std::string& title="",
|
||||
|
|
@ -48,10 +54,13 @@ private:
|
|||
const std::string& progress_message,
|
||||
const std::string& bottom_message);
|
||||
|
||||
|
||||
mutable std::mutex _m;
|
||||
Gtk::Label& _top_label;
|
||||
Gtk::Label& _bottom_label;
|
||||
Gtk::ProgressBar& _progress_bar;
|
||||
unsigned int num_of_steps;
|
||||
unsigned int cur_step;
|
||||
bool hide_automatically;
|
||||
};
|
||||
|
||||
#endif /* __progress_dialog_h__ */
|
||||
|
|
@ -56,6 +56,7 @@
|
|||
|
||||
#include "canvas/debug.h"
|
||||
|
||||
#include "actions.h"
|
||||
#include "ardour_ui.h"
|
||||
#include "ardour_button.h"
|
||||
#include "debug.h"
|
||||
|
|
@ -436,10 +437,12 @@ RouteTimeAxisView::build_display_menu ()
|
|||
items.push_back (SeparatorElem());
|
||||
|
||||
if (!Profile->get_sae()) {
|
||||
items.push_back (MenuElem (_("Remove"), sigc::bind (sigc::mem_fun(*this, &RouteUI::remove_this_route), true)));
|
||||
items.push_back (*manage (ActionManager::get_action_from_name ("DeleteSelectedTracks")->create_menu_item ()));
|
||||
items.back().set_label ("Remove");
|
||||
} else {
|
||||
items.push_front (SeparatorElem());
|
||||
items.push_front (MenuElem (_("Delete"), sigc::bind (sigc::mem_fun(*this, &RouteUI::remove_this_route), true)));
|
||||
items.push_back (*manage (ActionManager::get_action_from_name ("DeleteSelectedTracks")->create_menu_item ()));
|
||||
items.back().set_label ("Delete");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -727,11 +730,12 @@ RouteTimeAxisView::build_display_menu ()
|
|||
items.push_back (SeparatorElem());
|
||||
items.push_back (MenuElem (_("Hide"), sigc::bind (sigc::mem_fun(_editor, &PublicEditor::hide_track_in_display), this, true)));
|
||||
if (!Profile->get_sae()) {
|
||||
items.push_back (MenuElem (_("Remove"), sigc::bind (sigc::mem_fun(*this, &RouteUI::remove_this_route), true)));
|
||||
items.push_back (*manage (ActionManager::get_action_from_name ("DeleteSelectedTracks")->create_menu_item ()));
|
||||
items.back().set_label ("Remove");
|
||||
} else {
|
||||
items.push_front (SeparatorElem());
|
||||
items.push_front (MenuElem (_("Delete"), sigc::bind (sigc::mem_fun(*this, &RouteUI::remove_this_route), true)));
|
||||
}
|
||||
items.push_back (*manage (ActionManager::get_action_from_name ("DeleteSelectedTracks")->create_menu_item ()));
|
||||
items.back().set_label ("Delete"); }
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -1407,7 +1407,8 @@ RouteUI::remove_this_route (bool apply_to_selection)
|
|||
routes_to_remove->push_back(this->route() );
|
||||
}
|
||||
|
||||
Glib::signal_idle().connect (sigc::bind (sigc::ptr_fun (&RouteUI::idle_remove_routes), ARDOUR_UI::instance()->the_session(), routes_to_remove) );
|
||||
ARDOUR_UI::instance()->the_session()->remove_routes (routes_to_remove);
|
||||
ProgressDialog::instance()->hide ();
|
||||
}
|
||||
|
||||
gint
|
||||
|
|
@ -1417,12 +1418,6 @@ RouteUI::idle_remove_this_route (RouteUI *rui)
|
|||
return false;
|
||||
}
|
||||
|
||||
gint
|
||||
RouteUI::idle_remove_routes (Session* sess, boost::shared_ptr<RouteList>& rlist)
|
||||
{
|
||||
sess->remove_routes (rlist);
|
||||
return false;
|
||||
}
|
||||
|
||||
/** @return true if this name should be used for the route, otherwise false */
|
||||
bool
|
||||
|
|
|
|||
|
|
@ -217,7 +217,6 @@ class RouteUI : public Gtk::EventBox, public WavesUI, public virtual AxisView
|
|||
|
||||
void remove_this_route (bool apply_to_selection = false);
|
||||
static gint idle_remove_this_route (RouteUI *);
|
||||
static gint idle_remove_routes (ARDOUR::Session*, boost::shared_ptr<ARDOUR::RouteList> &);
|
||||
|
||||
void route_rename();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Dialog title=""
|
||||
resizeable="False"
|
||||
winfont ="Arial Bold 12"
|
||||
macfont ="Helvetica Bold 12"
|
||||
fgnormal="#6D6E72"
|
||||
|
|
@ -14,12 +13,13 @@
|
|||
/>
|
||||
|
||||
<EventBox bgnormal="#EDECE8">
|
||||
<VBox width="320">
|
||||
<VBox width="320" borderwidth="5">
|
||||
<Label id="top_label"
|
||||
style="generic_control"
|
||||
vertalignment="center"
|
||||
text="---"
|
||||
height="28"/>
|
||||
height="28"
|
||||
ellipsize="end"/>
|
||||
<VBox height="4"/>
|
||||
<HBox width="320">
|
||||
<VBox width="13"/>
|
||||
|
|
|
|||
|
|
@ -186,6 +186,8 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop
|
|||
bool reconnection_in_progress() const { return _reconnecting_routes_in_progress; }
|
||||
bool routes_deletion_in_progress() const { return _route_deletion_in_progress; }
|
||||
PBD::Signal0<void> DirtyChanged;
|
||||
|
||||
PBD::Signal1<void, bool> RouteAddedOrRemoved;
|
||||
|
||||
const SessionDirectory& session_directory () const { return *(_session_dir.get()); }
|
||||
|
||||
|
|
|
|||
|
|
@ -2620,6 +2620,7 @@ Session::new_audio_track (int input_channels, int output_channels, TrackMode mod
|
|||
|
||||
new_routes.push_back (track);
|
||||
ret.push_back (track);
|
||||
RouteAddedOrRemoved (true); /* EMIT SIGNAL */
|
||||
}
|
||||
|
||||
catch (failed_constructor &err) {
|
||||
|
|
@ -3235,6 +3236,7 @@ Session::remove_routes (boost::shared_ptr<RouteList> routes_to_remove)
|
|||
}
|
||||
}
|
||||
|
||||
RouteAddedOrRemoved (false); /* EMIT SIGNAL */
|
||||
}
|
||||
|
||||
/* writer goes out of scope, forces route list update */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue