2 Copyright (C) 2000-2007 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.
23 #include "fix_carbon.h"
25 #include "pbd/gstdio_compat.h"
27 #include <gtkmm/settings.h>
29 #include "gtkmm2ext/gtk_ui.h"
30 #include "gtkmm2ext/utils.h"
32 #include "pbd/compose.h"
34 #include "ardour/profile.h"
36 #include "canvas/wave_view.h"
38 #include "ardour_button.h"
39 #include "ardour_dialog.h"
40 #include "theme_manager.h"
41 #include "ui_config.h"
49 using namespace ARDOUR;
50 using namespace ARDOUR_UI_UTILS;
52 ThemeManager::ThemeManager()
53 : flat_buttons (_("Draw \"flat\" buttons"))
54 , blink_rec_button (_("Blink Rec-Arm buttons"))
55 , region_color_button (_("Color regions using their track's color"))
56 , show_clipping_button (_("Show waveform clipping"))
57 , waveform_gradient_depth (0, 1.0, 0.05)
58 , waveform_gradient_depth_label (_("Waveforms color gradient depth"))
59 , timeline_item_gradient_depth (0, 1.0, 0.05)
60 , timeline_item_gradient_depth_label (_("Timeline item gradient depth"))
61 , all_dialogs (_("All floating windows are dialogs"))
62 , transients_follow_front (_("Transient windows follow front window."))
63 , floating_monitor_section (_("Float detached monitor-section window"))
64 , icon_set_label (_("Icon Set"))
70 set_homogeneous (false);
74 pack_start (all_dialogs, PACK_SHRINK);
75 pack_start (transients_follow_front, PACK_SHRINK);
77 if (!Profile->get_mixbus()) {
78 pack_start (floating_monitor_section, PACK_SHRINK);
80 pack_start (flat_buttons, PACK_SHRINK);
81 pack_start (blink_rec_button, PACK_SHRINK);
82 pack_start (region_color_button, PACK_SHRINK);
83 pack_start (show_clipping_button, PACK_SHRINK);
85 vector<string> icon_sets = ::get_icon_sets ();
87 if (icon_sets.size() > 1) {
88 Gtkmm2ext::set_popdown_strings (icon_set_dropdown, icon_sets);
89 icon_set_dropdown.set_active_text (UIConfiguration::instance().get_icon_set());
91 hbox = Gtk::manage (new Gtk::HBox());
92 hbox->set_spacing (6);
93 Gtk::Alignment* align = Gtk::manage (new Gtk::Alignment);
95 align->add (icon_set_dropdown);
96 hbox->pack_start (icon_set_label, false, false);
97 hbox->pack_start (*align, true, true);
98 pack_start (*hbox, PACK_SHRINK);
101 hbox = Gtk::manage (new Gtk::HBox());
102 hbox->set_spacing (6);
103 hbox->pack_start (waveform_gradient_depth, true, true);
104 hbox->pack_start (waveform_gradient_depth_label, false, false);
105 pack_start (*hbox, PACK_SHRINK);
107 hbox = Gtk::manage (new Gtk::HBox());
108 hbox->set_spacing (6);
109 hbox->pack_start (timeline_item_gradient_depth, true, true);
110 hbox->pack_start (timeline_item_gradient_depth_label, false, false);
111 pack_start (*hbox, PACK_SHRINK);
115 waveform_gradient_depth.set_update_policy (Gtk::UPDATE_DELAYED);
116 timeline_item_gradient_depth.set_update_policy (Gtk::UPDATE_DELAYED);
120 flat_buttons.signal_toggled().connect (sigc::mem_fun (*this, &ThemeManager::on_flat_buttons_toggled));
121 blink_rec_button.signal_toggled().connect (sigc::mem_fun (*this, &ThemeManager::on_blink_rec_arm_toggled));
122 region_color_button.signal_toggled().connect (sigc::mem_fun (*this, &ThemeManager::on_region_color_toggled));
123 show_clipping_button.signal_toggled().connect (sigc::mem_fun (*this, &ThemeManager::on_show_clip_toggled));
124 waveform_gradient_depth.signal_value_changed().connect (sigc::mem_fun (*this, &ThemeManager::on_waveform_gradient_depth_change));
125 timeline_item_gradient_depth.signal_value_changed().connect (sigc::mem_fun (*this, &ThemeManager::on_timeline_item_gradient_depth_change));
126 all_dialogs.signal_toggled().connect (sigc::mem_fun (*this, &ThemeManager::on_all_dialogs_toggled));
127 transients_follow_front.signal_toggled().connect (sigc::mem_fun (*this, &ThemeManager::on_transients_follow_front_toggled));
128 floating_monitor_section.signal_toggled().connect (sigc::mem_fun (*this, &ThemeManager::on_floating_monitor_section_toggled));
129 icon_set_dropdown.signal_changed().connect (sigc::mem_fun (*this, &ThemeManager::on_icon_set_changed));
131 Gtkmm2ext::UI::instance()->set_tip (all_dialogs,
132 string_compose (_("Mark all floating windows to be type \"Dialog\" rather than using \"Utility\" for some.\n"
133 "This may help with some window managers. This requires a restart of %1 to take effect"),
135 Gtkmm2ext::UI::instance()->set_tip (transients_follow_front,
136 string_compose (_("Make transient windows follow the front window when toggling between the editor and mixer.\n"
137 "This requires a restart of %1 to take effect"), PROGRAM_NAME));
138 Gtkmm2ext::UI::instance()->set_tip (floating_monitor_section,
139 string_compose (_("When detaching the monitoring section, mark it as \"Utility\" window to stay in front.\n"
140 "This requires a restart of %1 to take effect"), PROGRAM_NAME));
145 ThemeManager::on_flat_buttons_toggled ()
147 UIConfiguration::instance().set_flat_buttons (flat_buttons.get_active());
148 ArdourButton::set_flat_buttons (flat_buttons.get_active());
150 gtk_rc_reset_styles (gtk_settings_get_default());
154 ThemeManager::on_blink_rec_arm_toggled ()
156 UIConfiguration::instance().set_blink_rec_arm (blink_rec_button.get_active());
157 UIConfiguration::instance().ParameterChanged("blink-rec-arm");
161 ThemeManager::on_region_color_toggled ()
163 UIConfiguration::instance().set_color_regions_using_track_color (region_color_button.get_active());
167 ThemeManager::on_show_clip_toggled ()
169 UIConfiguration::instance().set_show_waveform_clipping (show_clipping_button.get_active());
170 // "show-waveform-clipping" was a session config key
171 ArdourCanvas::WaveView::set_global_show_waveform_clipping (UIConfiguration::instance().get_show_waveform_clipping());
175 ThemeManager::on_all_dialogs_toggled ()
177 UIConfiguration::instance().set_all_floating_windows_are_dialogs (all_dialogs.get_active());
181 ThemeManager::on_transients_follow_front_toggled ()
183 UIConfiguration::instance().set_transients_follow_front (transients_follow_front.get_active());
187 ThemeManager::on_floating_monitor_section_toggled ()
189 UIConfiguration::instance().set_floating_monitor_section (floating_monitor_section.get_active());
193 ThemeManager::on_waveform_gradient_depth_change ()
195 double v = waveform_gradient_depth.get_value();
197 UIConfiguration::instance().set_waveform_gradient_depth (v);
198 ArdourCanvas::WaveView::set_global_gradient_depth (v);
202 ThemeManager::on_timeline_item_gradient_depth_change ()
204 double v = timeline_item_gradient_depth.get_value();
206 UIConfiguration::instance().set_timeline_item_gradient_depth (v);
210 ThemeManager::on_icon_set_changed ()
212 string new_set = icon_set_dropdown.get_active_text();
213 UIConfiguration::instance().set_icon_set (new_set);
217 ThemeManager::set_ui_to_state()
219 /* there is no need to block signal handlers, here,
220 * all elements check if the value has changed and ignore NOOPs
222 all_dialogs.set_active (UIConfiguration::instance().get_all_floating_windows_are_dialogs());
223 transients_follow_front.set_active (UIConfiguration::instance().get_transients_follow_front());
224 floating_monitor_section.set_active (UIConfiguration::instance().get_floating_monitor_section());
225 flat_buttons.set_active (UIConfiguration::instance().get_flat_buttons());
226 blink_rec_button.set_active (UIConfiguration::instance().get_blink_rec_arm());
227 region_color_button.set_active (UIConfiguration::instance().get_color_regions_using_track_color());
228 show_clipping_button.set_active (UIConfiguration::instance().get_show_waveform_clipping());
229 waveform_gradient_depth.set_value(UIConfiguration::instance().get_waveform_gradient_depth());
230 timeline_item_gradient_depth.set_value(UIConfiguration::instance().get_timeline_item_gradient_depth());