Reenable the correct sort column and type when redisplaying regions
[ardour.git] / gtk2_ardour / return_ui.cc
1 /*
2  * Copyright (C) 2009-2010 Carl Hetherington <carl@carlh.net>
3  * Copyright (C) 2009-2012 David Robillard <d@drobilla.net>
4  * Copyright (C) 2009-2016 Paul Davis <paul@linuxaudiosystems.com>
5  * Copyright (C) 2013-2014 Robin Gareus <robin@gareus.org>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with this program; if not, write to the Free Software Foundation, Inc.,
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20  */
21
22 #include <gtkmm2ext/doi.h>
23
24 #include "ardour/io.h"
25 #include "ardour/rc_configuration.h"
26 #include "ardour/return.h"
27
28 #include "return_ui.h"
29 #include "io_selector.h"
30 #include "gui_thread.h"
31 #include "timers.h"
32
33 #include "pbd/i18n.h"
34
35 using namespace std;
36 using namespace ARDOUR;
37 using namespace PBD;
38
39 ReturnUI::ReturnUI (Gtk::Window* parent, boost::shared_ptr<Return> r, Session* session)
40         :_return (r)
41         , _gpm (session, 250)
42 {
43         _gpm.set_controls (boost::shared_ptr<Route>(), r->meter(), r->amp(), r->gain_control());
44
45         _hbox.pack_start (_gpm, true, true);
46         set_name (X_("ReturnUIFrame"));
47
48         _vbox.set_spacing (5);
49         _vbox.set_border_width (5);
50
51         _vbox.pack_start (_hbox, false, false, false);
52
53         io = Gtk::manage (new IOSelector (parent, session, r->output()));
54
55         pack_start (_vbox, false, false);
56
57         pack_start (*io, true, true);
58
59         show_all ();
60
61         _return->set_metering (true);
62         _return->input()->changed.connect (input_change_connection, invalidator (*this), boost::bind (&ReturnUI::ins_changed, this, _1, _2), gui_context());
63
64         _gpm.setup_meters ();
65         _gpm.set_fader_name (X_("ReturnUIFader"));
66
67         // screen_update_connection = Timers::rapid_connect (sigc::mem_fun (*this, &ReturnUI::update));
68         fast_screen_update_connection = Timers::super_rapid_connect (sigc::mem_fun (*this, &ReturnUI::fast_update));
69 }
70
71 ReturnUI::~ReturnUI ()
72 {
73         _return->set_metering (false);
74
75         /* XXX not clear that we need to do this */
76
77         screen_update_connection.disconnect();
78         fast_screen_update_connection.disconnect();
79 }
80
81 void
82 ReturnUI::ins_changed (IOChange change, void* /*ignored*/)
83 {
84         ENSURE_GUI_THREAD (*this, &ReturnUI::ins_changed, change, ignored)
85         if (change.type & IOChange::ConfigurationChanged) {
86                 _gpm.setup_meters ();
87         }
88 }
89
90 void
91 ReturnUI::update ()
92 {
93 }
94
95 void
96 ReturnUI::fast_update ()
97 {
98         if (Config->get_meter_falloff() > 0.0f) {
99                 _gpm.update_meters ();
100         }
101 }
102
103 ReturnUIWindow::ReturnUIWindow (boost::shared_ptr<Return> r, ARDOUR::Session* s)
104         : ArdourWindow (string(_("Return ")) + r->name())
105 {
106         ui = new ReturnUI (this, r, s);
107
108         hpacker.pack_start (*ui, true, true);
109
110         add (hpacker);
111
112         set_name ("ReturnUIWindow");
113
114 }
115
116 ReturnUIWindow::~ReturnUIWindow ()
117 {
118         delete ui;
119 }