2 Copyright (C) 2003-2004 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #include "gtk2ardour-config.h"
24 #include <glibmm/miscutils.h>
25 #include <gtkmm2ext/utils.h>
26 #include <gtkmm2ext/window_title.h>
28 #include "pbd/enumwriter.h"
31 #include "ardour_ui.h"
32 #include "audio_time_axis.h"
33 #include "automation_time_axis.h"
35 #include "editor_routes.h"
36 #include "editor_route_groups.h"
37 #include "editor_regions.h"
38 #include "gui_thread.h"
39 #include "midi_time_axis.h"
40 #include "mixer_strip.h"
41 #include "selection.h"
46 using namespace Gtkmm2ext
;
50 Editor::editor_mixer_button_toggled ()
52 Glib::RefPtr
<Gtk::Action
> act
= ActionManager::get_action (X_("Editor"), X_("show-editor-mixer"));
54 Glib::RefPtr
<Gtk::ToggleAction
> tact
= Glib::RefPtr
<Gtk::ToggleAction
>::cast_dynamic(act
);
55 show_editor_mixer (tact
->get_active());
60 Editor::editor_list_button_toggled ()
62 Glib::RefPtr
<Gtk::Action
> act
= ActionManager::get_action (X_("Editor"), X_("show-editor-list"));
64 Glib::RefPtr
<Gtk::ToggleAction
> tact
= Glib::RefPtr
<Gtk::ToggleAction
>::cast_dynamic(act
);
65 show_editor_list (tact
->get_active());
70 Editor::show_editor_mixer (bool yn
)
72 boost::shared_ptr
<ARDOUR::Route
> r
;
74 show_editor_mixer_when_tracks_arrive
= false;
77 show_editor_mixer_when_tracks_arrive
= yn
;
83 if (selection
->tracks
.empty()) {
85 if (track_views
.empty()) {
86 show_editor_mixer_when_tracks_arrive
= true;
90 for (TrackViewList::iterator i
= track_views
.begin(); i
!= track_views
.end(); ++i
) {
91 RouteTimeAxisView
* atv
;
93 if ((atv
= dynamic_cast<RouteTimeAxisView
*> (*i
)) != 0) {
100 sort_track_selection ();
102 for (TrackSelection::iterator i
= selection
->tracks
.begin(); i
!= selection
->tracks
.end(); ++i
) {
103 RouteTimeAxisView
* atv
;
105 if ((atv
= dynamic_cast<RouteTimeAxisView
*> (*i
)) != 0) {
113 if (current_mixer_strip
== 0) {
114 create_editor_mixer ();
117 current_mixer_strip
->set_route (r
);
118 current_mixer_strip
->set_width_enum (editor_mixer_strip_width
, (void*) this);
121 if (current_mixer_strip
->get_parent() == 0) {
122 global_hpacker
.pack_start (*current_mixer_strip
, Gtk::PACK_SHRINK
);
123 global_hpacker
.reorder_child (*current_mixer_strip
, 0);
124 current_mixer_strip
->show_all ();
129 if (current_mixer_strip
) {
130 if (current_mixer_strip
->get_parent() != 0) {
131 global_hpacker
.remove (*current_mixer_strip
);
137 /* XXX gtk problem here */
138 ensure_all_elements_drawn();
144 Editor::ensure_all_elements_drawn ()
146 controls_layout
.queue_draw ();
147 ruler_label_event_box
.queue_draw ();
148 time_button_event_box
.queue_draw ();
153 Editor::create_editor_mixer ()
155 current_mixer_strip
= new MixerStrip (*ARDOUR_UI::instance()->the_mixer(),
158 current_mixer_strip
->Hiding
.connect (sigc::mem_fun(*this, &Editor::current_mixer_strip_hidden
));
161 current_mixer_strip
->WidthChanged
.connect (sigc::mem_fun(*this, &Editor::ensure_all_elements_drawn
));
163 current_mixer_strip
->set_embedded (true);
167 Editor::set_selected_mixer_strip (TimeAxisView
& view
)
173 Glib::RefPtr
<Gtk::Action
> act
= ActionManager::get_action (X_("Editor"), X_("show-editor-mixer"));
176 Glib::RefPtr
<Gtk::ToggleAction
> tact
= Glib::RefPtr
<Gtk::ToggleAction
>::cast_dynamic(act
);
177 if (!tact
|| !tact
->get_active()) {
178 /* not showing mixer strip presently */
183 if (current_mixer_strip
== 0) {
184 create_editor_mixer ();
188 // if this is an automation track, then we shold the mixer strip should
191 boost::shared_ptr
<ARDOUR::Route
> route
;
192 AutomationTimeAxisView
* atv
;
194 if ((atv
= dynamic_cast<AutomationTimeAxisView
*>(&view
)) != 0) {
196 AudioTimeAxisView
*parent
= dynamic_cast<AudioTimeAxisView
*>(view
.get_parent());
199 route
= parent
->route ();
204 AudioTimeAxisView
* at
= dynamic_cast<AudioTimeAxisView
*> (&view
);
209 MidiTimeAxisView
* mt
= dynamic_cast<MidiTimeAxisView
*> (&view
);
216 if (current_mixer_strip
->route() == route
) {
221 current_mixer_strip
->set_route (route
);
222 current_mixer_strip
->set_width_enum (editor_mixer_strip_width
, (void*) this);
227 Editor::current_mixer_strip_hidden ()
229 Glib::RefPtr
<Gtk::Action
> act
= ActionManager::get_action (X_("Editor"), X_("show-editor-mixer"));
231 Glib::RefPtr
<Gtk::ToggleAction
> tact
= Glib::RefPtr
<Gtk::ToggleAction
>::cast_dynamic(act
);
232 tact
->set_active (false);
237 Editor::maybe_add_mixer_strip_width (XMLNode
& node
)
239 if (current_mixer_strip
) {
240 node
.add_property ("mixer-width", enum_2_string (current_mixer_strip
->get_width_enum()));