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.
20 #include <glibmm/miscutils.h>
21 #include <gtkmm2ext/utils.h>
22 #include <gtkmm2ext/window_title.h>
24 #include "pbd/enumwriter.h"
27 #include "mixer_strip.h"
28 #include "ardour_ui.h"
29 #include "selection.h"
30 #include "audio_time_axis.h"
32 #include "editor_routes.h"
33 #include "editor_route_groups.h"
34 #include "editor_regions.h"
35 #include "gui_thread.h"
40 using namespace Gtkmm2ext
;
44 Editor::editor_mixer_button_toggled ()
46 Glib::RefPtr
<Gtk::Action
> act
= ActionManager::get_action (X_("Editor"), X_("show-editor-mixer"));
48 Glib::RefPtr
<Gtk::ToggleAction
> tact
= Glib::RefPtr
<Gtk::ToggleAction
>::cast_dynamic(act
);
49 show_editor_mixer (tact
->get_active());
54 Editor::editor_list_button_toggled ()
56 Glib::RefPtr
<Gtk::Action
> act
= ActionManager::get_action (X_("Editor"), X_("show-editor-list"));
58 Glib::RefPtr
<Gtk::ToggleAction
> tact
= Glib::RefPtr
<Gtk::ToggleAction
>::cast_dynamic(act
);
59 show_editor_list (tact
->get_active());
64 Editor::show_editor_mixer (bool yn
)
66 boost::shared_ptr
<ARDOUR::Route
> r
;
68 show_editor_mixer_when_tracks_arrive
= false;
71 show_editor_mixer_when_tracks_arrive
= yn
;
77 if (selection
->tracks
.empty()) {
79 if (track_views
.empty()) {
80 show_editor_mixer_when_tracks_arrive
= true;
84 for (TrackViewList::iterator i
= track_views
.begin(); i
!= track_views
.end(); ++i
) {
85 RouteTimeAxisView
* atv
;
87 if ((atv
= dynamic_cast<RouteTimeAxisView
*> (*i
)) != 0) {
94 sort_track_selection ();
96 for (TrackSelection::iterator i
= selection
->tracks
.begin(); i
!= selection
->tracks
.end(); ++i
) {
97 RouteTimeAxisView
* atv
;
99 if ((atv
= dynamic_cast<RouteTimeAxisView
*> (*i
)) != 0) {
107 if (current_mixer_strip
== 0) {
108 create_editor_mixer ();
111 current_mixer_strip
->set_route (r
);
112 current_mixer_strip
->set_width_enum (editor_mixer_strip_width
, (void*) this);
115 if (current_mixer_strip
->get_parent() == 0) {
116 global_hpacker
.pack_start (*current_mixer_strip
, Gtk::PACK_SHRINK
);
117 global_hpacker
.reorder_child (*current_mixer_strip
, 0);
118 current_mixer_strip
->show_all ();
123 if (current_mixer_strip
) {
124 if (current_mixer_strip
->get_parent() != 0) {
125 global_hpacker
.remove (*current_mixer_strip
);
131 /* XXX gtk problem here */
132 ensure_all_elements_drawn();
138 Editor::ensure_all_elements_drawn ()
140 controls_layout
.queue_draw ();
141 ruler_label_event_box
.queue_draw ();
142 time_button_event_box
.queue_draw ();
147 Editor::create_editor_mixer ()
149 current_mixer_strip
= new MixerStrip (*ARDOUR_UI::instance()->the_mixer(),
152 current_mixer_strip
->Hiding
.connect (sigc::mem_fun(*this, &Editor::current_mixer_strip_hidden
));
155 current_mixer_strip
->WidthChanged
.connect (sigc::mem_fun(*this, &Editor::ensure_all_elements_drawn
));
157 current_mixer_strip
->set_embedded (true);
161 Editor::set_selected_mixer_strip (TimeAxisView
& view
)
163 RouteTimeAxisView
* at
;
165 if (!_session
|| (at
= dynamic_cast<RouteTimeAxisView
*>(&view
)) == 0) {
169 Glib::RefPtr
<Gtk::Action
> act
= ActionManager::get_action (X_("Editor"), X_("show-editor-mixer"));
172 Glib::RefPtr
<Gtk::ToggleAction
> tact
= Glib::RefPtr
<Gtk::ToggleAction
>::cast_dynamic(act
);
173 if (!tact
|| !tact
->get_active()) {
174 /* not showing mixer strip presently */
179 if (current_mixer_strip
== 0) {
180 create_editor_mixer ();
183 /* might be nothing to do */
185 if (current_mixer_strip
->route() == at
->route()) {
189 current_mixer_strip
->set_route (at
->route());
190 current_mixer_strip
->set_width_enum (editor_mixer_strip_width
, (void*) this);
194 Editor::current_mixer_strip_hidden ()
196 for (TrackViewList::iterator i
= track_views
.begin(); i
!= track_views
.end(); ++i
) {
198 RouteTimeAxisView
* tmp
;
200 if ((tmp
= dynamic_cast<RouteTimeAxisView
*>(*i
)) != 0) {
201 if (tmp
->route() == current_mixer_strip
->route()) {
202 (*i
)->set_selected (false);
208 Glib::RefPtr
<Gtk::Action
> act
= ActionManager::get_action (X_("Editor"), X_("show-editor-mixer"));
210 Glib::RefPtr
<Gtk::ToggleAction
> tact
= Glib::RefPtr
<Gtk::ToggleAction
>::cast_dynamic(act
);
211 tact
->set_active (false);
216 Editor::maybe_add_mixer_strip_width (XMLNode
& node
)
218 if (current_mixer_strip
) {
219 node
.add_property ("mixer-width", enum_2_string (current_mixer_strip
->get_width_enum()));