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.
25 #include "fix_carbon.h"
27 #include <gtkmm/stock.h>
28 #include <gtkmm/settings.h>
30 #include "gtkmm2ext/gtk_ui.h"
31 #include "gtkmm2ext/cell_renderer_color_selector.h"
32 #include "gtkmm2ext/utils.h"
34 #include "pbd/file_utils.h"
35 #include "pbd/compose.h"
37 #include "ardour/filesystem_paths.h"
39 #include "canvas/container.h"
40 #include "canvas/rectangle.h"
41 #include "canvas/scroll_group.h"
42 #include "canvas/wave_view.h"
44 #include "ardour_button.h"
45 #include "theme_manager.h"
46 #include "rgb_macros.h"
47 #include "ardour_ui.h"
48 #include "global_signals.h"
56 using namespace ARDOUR;
57 using namespace ARDOUR_UI_UTILS;
59 namespace ARDOUR_UI_UTILS {
60 sigc::signal<void> ColorsChanged;
61 sigc::signal<void,uint32_t> ColorChanged;
64 ThemeManager::ThemeManager()
65 : ArdourWindow (_("Theme Manager"))
66 , dark_button (_("Dark Theme"))
67 , light_button (_("Light Theme"))
68 , reset_button (_("Restore Defaults"))
69 , flat_buttons (_("Draw \"flat\" buttons"))
70 , blink_rec_button (_("Blink Rec-Arm buttons"))
71 , region_color_button (_("Color regions using their track's color"))
72 , show_clipping_button (_("Show waveform clipping"))
73 , waveform_gradient_depth (0, 1.0, 0.05)
74 , waveform_gradient_depth_label (_("Waveforms color gradient depth"))
75 , timeline_item_gradient_depth (0, 1.0, 0.05)
76 , timeline_item_gradient_depth_label (_("Timeline item gradient depth"))
77 , all_dialogs (_("All floating windows are dialogs"))
78 , icon_set_label (_("Icon Set"))
79 , base_color_viewport (*base_color_scroller.get_hadjustment(), *base_color_scroller.get_vadjustment())
80 , base_color_group (0)
83 set_title (_("Theme Manager"));
85 /* Basic color list */
87 color_list = TreeStore::create (columns);
88 color_display.set_model (color_list);
89 color_display.append_column (_("Object"), columns.name);
91 Gtkmm2ext::CellRendererColorSelector* color_renderer = manage (new Gtkmm2ext::CellRendererColorSelector);
92 TreeViewColumn* color_column = manage (new TreeViewColumn (_("Color"), *color_renderer));
93 color_column->add_attribute (color_renderer->property_color(), columns.gdkcolor);
95 color_display.append_column (*color_column);
97 color_display.get_column (0)->set_data (X_("colnum"), GUINT_TO_POINTER(0));
98 color_display.get_column (0)->set_expand (true);
99 color_display.get_column (1)->set_data (X_("colnum"), GUINT_TO_POINTER(1));
100 color_display.get_column (1)->set_expand (false);
101 color_display.set_reorderable (false);
102 color_display.get_selection()->set_mode (SELECTION_NONE);
103 color_display.set_headers_visible (true);
105 color_display.signal_button_press_event().connect (sigc::mem_fun (*this, &ThemeManager::button_press_event), false);
107 scroller.add (color_display);
108 scroller.set_policy (POLICY_NEVER, POLICY_AUTOMATIC);
110 /* Now the alias list */
112 alias_list = TreeStore::create (alias_columns);
113 alias_display.set_model (alias_list);
114 alias_display.append_column (_("Object"), columns.name);
116 color_renderer = manage (new Gtkmm2ext::CellRendererColorSelector);
117 color_column = manage (new TreeViewColumn (_("Color"), *color_renderer));
118 color_column->add_attribute (color_renderer->property_color(), alias_columns.color);
120 alias_display.append_column (*color_column);
122 alias_display.get_column (0)->set_data (X_("colnum"), GUINT_TO_POINTER(0));
123 alias_display.get_column (0)->set_expand (true);
124 alias_display.get_column (1)->set_data (X_("colnum"), GUINT_TO_POINTER(1));
125 alias_display.get_column (1)->set_expand (false);
126 alias_display.set_reorderable (false);
127 alias_display.get_selection()->set_mode (SELECTION_NONE);
128 alias_display.set_headers_visible (true);
130 alias_display.signal_button_press_event().connect (sigc::mem_fun (*this, &ThemeManager::alias_button_press_event), false);
132 alias_scroller.add (alias_display);
134 /* various buttons */
136 RadioButton::Group group = dark_button.get_group();
137 light_button.set_group(group);
138 theme_selection_hbox.set_homogeneous(false);
139 theme_selection_hbox.pack_start (dark_button);
140 theme_selection_hbox.pack_start (light_button);
142 Gtk::VBox* vbox = Gtk::manage (new Gtk::VBox ());
143 vbox->set_homogeneous (false);
144 vbox->pack_start (theme_selection_hbox, PACK_SHRINK);
145 vbox->pack_start (reset_button, PACK_SHRINK);
147 vbox->pack_start (all_dialogs, PACK_SHRINK);
149 vbox->pack_start (flat_buttons, PACK_SHRINK);
150 vbox->pack_start (blink_rec_button, PACK_SHRINK);
151 vbox->pack_start (region_color_button, PACK_SHRINK);
152 vbox->pack_start (show_clipping_button, PACK_SHRINK);
156 vector<string> icon_sets = ::get_icon_sets ();
158 if (icon_sets.size() > 1) {
159 Gtkmm2ext::set_popdown_strings (icon_set_dropdown, icon_sets);
160 icon_set_dropdown.set_active_text (ARDOUR_UI::config()->get_icon_set());
162 hbox = Gtk::manage (new Gtk::HBox());
163 hbox->set_spacing (6);
164 hbox->pack_start (icon_set_label, false, false);
165 hbox->pack_start (icon_set_dropdown, true, true);
166 vbox->pack_start (*hbox, PACK_SHRINK);
170 hbox = Gtk::manage (new Gtk::HBox());
171 hbox->set_spacing (6);
172 hbox->pack_start (waveform_gradient_depth, true, true);
173 hbox->pack_start (waveform_gradient_depth_label, false, false);
174 vbox->pack_start (*hbox, PACK_SHRINK);
176 hbox = Gtk::manage (new Gtk::HBox());
177 hbox->set_spacing (6);
178 hbox->pack_start (timeline_item_gradient_depth, true, true);
179 hbox->pack_start (timeline_item_gradient_depth_label, false, false);
180 vbox->pack_start (*hbox, PACK_SHRINK);
182 base_color_viewport.signal_size_allocate().connect (sigc::mem_fun (*this, &ThemeManager::base_color_viewport_allocated));
183 base_color_scroller.add (base_color_viewport);
185 notebook.append_page (scroller, _("Palette"));
186 notebook.append_page (base_color_scroller, _("Base Colors"));
187 notebook.append_page (alias_scroller, _("Items"));
189 vbox->pack_start (notebook);
195 waveform_gradient_depth.set_update_policy (Gtk::UPDATE_DELAYED);
196 timeline_item_gradient_depth.set_update_policy (Gtk::UPDATE_DELAYED);
198 color_dialog.get_colorsel()->set_has_opacity_control (true);
199 color_dialog.get_colorsel()->set_has_palette (true);
201 flat_buttons.set_active (ARDOUR_UI::config()->get_flat_buttons());
202 blink_rec_button.set_active (ARDOUR_UI::config()->get_blink_rec_arm());
203 region_color_button.set_active (ARDOUR_UI::config()->get_color_regions_using_track_color());
204 show_clipping_button.set_active (ARDOUR_UI::config()->get_show_waveform_clipping());
206 color_dialog.get_ok_button()->signal_clicked().connect (sigc::bind (sigc::mem_fun (color_dialog, &Gtk::Dialog::response), RESPONSE_ACCEPT));
207 color_dialog.get_cancel_button()->signal_clicked().connect (sigc::bind (sigc::mem_fun (color_dialog, &Gtk::Dialog::response), RESPONSE_CANCEL));
208 dark_button.signal_toggled().connect (sigc::mem_fun (*this, &ThemeManager::on_dark_theme_button_toggled));
209 light_button.signal_toggled().connect (sigc::mem_fun (*this, &ThemeManager::on_light_theme_button_toggled));
210 reset_button.signal_clicked().connect (sigc::mem_fun (*this, &ThemeManager::reset_canvas_colors));
211 flat_buttons.signal_toggled().connect (sigc::mem_fun (*this, &ThemeManager::on_flat_buttons_toggled));
212 blink_rec_button.signal_toggled().connect (sigc::mem_fun (*this, &ThemeManager::on_blink_rec_arm_toggled));
213 region_color_button.signal_toggled().connect (sigc::mem_fun (*this, &ThemeManager::on_region_color_toggled));
214 show_clipping_button.signal_toggled().connect (sigc::mem_fun (*this, &ThemeManager::on_show_clip_toggled));
215 waveform_gradient_depth.signal_value_changed().connect (sigc::mem_fun (*this, &ThemeManager::on_waveform_gradient_depth_change));
216 timeline_item_gradient_depth.signal_value_changed().connect (sigc::mem_fun (*this, &ThemeManager::on_timeline_item_gradient_depth_change));
217 all_dialogs.signal_toggled().connect (sigc::mem_fun (*this, &ThemeManager::on_all_dialogs_toggled));
218 icon_set_dropdown.signal_changed().connect (sigc::mem_fun (*this, &ThemeManager::on_icon_set_changed));
220 Gtkmm2ext::UI::instance()->set_tip (all_dialogs,
221 string_compose (_("Mark all floating windows to be type \"Dialog\" rather than using \"Utility\" for some.\n"
222 "This may help with some window managers. This requires a restart of %1 to take effect"),
225 set_size_request (-1, 400);
230 ThemeManager::~ThemeManager()
235 ThemeManager::save (string /*path*/)
241 ThemeManager::button_press_event (GdkEventButton* ev)
244 TreeModel::Path path;
245 TreeViewColumn* column;
249 if (!color_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
253 switch (GPOINTER_TO_UINT (column->get_data (X_("colnum")))) {
255 /* allow normal processing to occur */
259 if ((iter = color_list->get_iter (path))) {
261 ColorVariable<uint32_t>* var = (*iter)[columns.pVar];
263 /* parent row, do nothing */
268 uint32_t rgba = (*iter)[columns.rgba];
271 UINT_TO_RGBA (rgba, &r, &g, &b, &a);
272 color.set_rgb_p (r / 255.0, g / 255.0, b / 255.0);
273 color_dialog.get_colorsel()->set_previous_color (color);
274 color_dialog.get_colorsel()->set_current_color (color);
275 color_dialog.get_colorsel()->set_previous_alpha ((guint16) (a * 256));
276 color_dialog.get_colorsel()->set_current_alpha ((guint16) (a * 256));
278 color_dialog_connection.disconnect ();
279 color_dialog_connection = color_dialog.signal_response().connect (sigc::mem_fun (*this, &ThemeManager::foobar_response));
280 color_dialog.present ();
288 ThemeManager::foobar_response (int result)
290 // ColorVariable<uint32_t> *ccvar;
295 color_dialog_connection.disconnect ();
298 case RESPONSE_CANCEL:
300 case RESPONSE_ACCEPT:
301 color = color_dialog.get_colorsel()->get_current_color();
302 a = color_dialog.get_colorsel()->get_current_alpha();
303 r = (int) floor (color.get_red_p() * 255.0);
304 g = (int) floor (color.get_green_p() * 255.0);
305 b = (int) floor (color.get_blue_p() * 255.0);
307 rgba = RGBA_TO_UINT(r,g,b,a>>8);
308 // (*iter)[columns.rgba] = rgba;
309 // (*iter)[columns.gdkcolor] = color;
311 // ccvar = (*iter)[columns.pVar];
314 ARDOUR_UI::config()->set_dirty ();
315 /* but save it immediately */
316 ARDOUR_UI::config()->save_state ();
318 ColorsChanged(); //EMIT SIGNAL
326 color_dialog.hide ();
330 load_rc_file (const string& filename, bool themechange)
332 std::string rc_file_path;
334 if (!find_file (ardour_config_search_path(), filename, rc_file_path)) {
335 warning << string_compose (_("Unable to find UI style file %1 in search path %2. %3 will look strange"),
336 filename, ardour_config_search_path().to_string(), PROGRAM_NAME)
341 info << "Loading ui configuration file " << rc_file_path << endmsg;
343 Gtkmm2ext::UI::instance()->load_rcfile (rc_file_path, themechange);
347 ThemeManager::on_flat_buttons_toggled ()
349 ARDOUR_UI::config()->set_flat_buttons (flat_buttons.get_active());
350 ARDOUR_UI::config()->set_dirty ();
351 ArdourButton::set_flat_buttons (flat_buttons.get_active());
353 gtk_rc_reset_styles (gtk_settings_get_default());
357 ThemeManager::on_blink_rec_arm_toggled ()
359 ARDOUR_UI::config()->set_blink_rec_arm (blink_rec_button.get_active());
360 ARDOUR_UI::config()->set_dirty ();
361 ARDOUR::Config->ParameterChanged("blink-rec-arm");
365 ThemeManager::on_region_color_toggled ()
367 ARDOUR_UI::config()->set_color_regions_using_track_color (region_color_button.get_active());
368 ARDOUR_UI::config()->set_dirty ();
372 ThemeManager::on_show_clip_toggled ()
374 ARDOUR_UI::config()->set_show_waveform_clipping (show_clipping_button.get_active());
375 ARDOUR_UI::config()->set_dirty ();
379 ThemeManager::on_all_dialogs_toggled ()
381 ARDOUR_UI::config()->set_all_floating_windows_are_dialogs (all_dialogs.get_active());
382 ARDOUR_UI::config()->set_dirty ();
386 ThemeManager::on_waveform_gradient_depth_change ()
388 double v = waveform_gradient_depth.get_value();
390 ARDOUR_UI::config()->set_waveform_gradient_depth (v);
391 ARDOUR_UI::config()->set_dirty ();
392 ArdourCanvas::WaveView::set_global_gradient_depth (v);
396 ThemeManager::on_timeline_item_gradient_depth_change ()
398 double v = timeline_item_gradient_depth.get_value();
400 ARDOUR_UI::config()->set_timeline_item_gradient_depth (v);
401 ARDOUR_UI::config()->set_dirty ();
405 ThemeManager::on_icon_set_changed ()
407 string new_set = icon_set_dropdown.get_active_text();
408 ARDOUR_UI::config()->set_icon_set (new_set);
412 ThemeManager::on_dark_theme_button_toggled()
414 if (!dark_button.get_active()) return;
416 ARDOUR_UI::config()->set_ui_rc_file("ui_dark.rc");
417 ARDOUR_UI::config()->set_dirty ();
419 load_rc_file (ARDOUR_UI::config()->get_ui_rc_file(), true);
423 ThemeManager::on_light_theme_button_toggled()
425 if (!light_button.get_active()) return;
427 ARDOUR_UI::config()->set_ui_rc_file("ui_light.rc");
428 load_rc_file (ARDOUR_UI::config()->get_ui_rc_file(), true);
432 ThemeManager::setup_theme ()
438 for (std::map<std::string,ColorVariable<uint32_t> *>::iterator i = ARDOUR_UI::config()->configurable_colors.begin(); i != ARDOUR_UI::config()->configurable_colors.end(); i++) {
441 ColorVariable<uint32_t>* var = i->second;
443 TreeModel::Children rows = color_list->children();
445 string::size_type colon;
447 if ((colon = var->name().find (':')) != string::npos) {
449 /* this is supposed to be a child node, so find the
453 string parent = var->name().substr (0, colon);
454 TreeModel::iterator ri;
456 for (ri = rows.begin(); ri != rows.end(); ++ri) {
457 string s = (*ri)[columns.name];
463 if (ri == rows.end()) {
464 /* not found, add the parent as new top level row */
465 row = *(color_list->append());
466 row[columns.name] = parent;
467 row[columns.pVar] = 0;
469 /* now add the child as a child of this one */
471 row = *(color_list->insert (row->children().end()));
472 row[columns.name] = var->name().substr (colon+1);
474 row = *(color_list->insert ((*ri)->children().end()));
475 row[columns.name] = var->name().substr (colon+1);
480 row = *(color_list->append());
481 row[columns.name] = var->name();
485 uint32_t rgba = var->get();
486 UINT_TO_RGBA (rgba, &r, &g, &b, &a);
487 //cerr << (*i)->name() << " == " << hex << rgba << ": " << hex << r << " " << hex << g << " " << hex << b << endl;
488 col.set_rgb_p (r / 255.0, g / 255.0, b / 255.0);
490 row[columns.pVar] = var;
491 row[columns.rgba] = rgba;
492 row[columns.gdkcolor] = col;
495 ColorsChanged.emit();
497 bool env_defined = false;
498 string rcfile = Glib::getenv("ARDOUR3_UI_RC", env_defined);
501 rcfile = ARDOUR_UI::config()->get_ui_rc_file();
504 if (rcfile == "ui_dark.rc") {
505 dark_button.set_active();
506 } else if (rcfile == "ui_light.rc") {
507 light_button.set_active();
510 flat_buttons.set_active (ARDOUR_UI::config()->get_flat_buttons());
511 blink_rec_button.set_active (ARDOUR_UI::config()->get_blink_rec_arm());
512 waveform_gradient_depth.set_value (ARDOUR_UI::config()->get_waveform_gradient_depth());
513 timeline_item_gradient_depth.set_value (ARDOUR_UI::config()->get_timeline_item_gradient_depth());
514 all_dialogs.set_active (ARDOUR_UI::config()->get_all_floating_windows_are_dialogs());
516 load_rc_file(rcfile, false);
520 ThemeManager::reset_canvas_colors()
522 ARDOUR_UI::config()->load_defaults();
525 ARDOUR_UI::config()->set_dirty ();
526 /* but save it immediately */
527 ARDOUR_UI::config()->save_state ();
532 ArdourCanvas::HSV color;
533 NamedColor (string s, ArdourCanvas::HSV c) : name (s), color (c) {}
537 bool operator() (NamedColor const & a, NamedColor const & b) {
538 using namespace ArdourCanvas;
539 const HSV black (0, 0, 0);
540 if (a.color.is_gray() || b.color.is_gray()) {
541 return black.distance (a.color) < black.distance (b.color);
543 return a.color.h < b.color.h;
544 // const HSV red (rgba_to_color (1.0, 0.0, 0.0, 1.0));
545 // return red.distance (a.color) < red.distance (b.color);
550 ArdourCanvas::Container*
551 ThemeManager::initialize_canvas (ArdourCanvas::Canvas& canvas)
553 using namespace ArdourCanvas;
555 /* hide background */
556 canvas.set_background_color (rgba_to_color (0.0, 0.0, 1.0, 0.0));
558 ScrollGroup* base_color_scroll_group = new ScrollGroup (canvas.root(), ScrollGroup::ScrollSensitivity (ScrollGroup::ScrollsVertically|ScrollGroup::ScrollsHorizontally));
559 canvas.add_scroller (*base_color_scroll_group);
560 return new ArdourCanvas::Container (base_color_scroll_group);
564 ThemeManager::build_base_color_canvas (ArdourCanvas::Container& group, bool (ThemeManager::*event_handler)(GdkEvent*,std::string), double width, double height)
566 using namespace ArdourCanvas;
568 /* we want the colors sorted by hue, with their name */
570 UIConfiguration::RelativeColors& relatives (ARDOUR_UI::instance()->config()->relative_colors);
571 vector<NamedColor> nc;
572 for (UIConfiguration::RelativeColors::const_iterator x = relatives.begin(); x != relatives.end(); ++x) {
573 nc.push_back (NamedColor (x->first, x->second.get()));
576 sort (nc.begin(), nc.end(), sorter);
578 const uint32_t color_limit = nc.size();
579 const double box_size = 20.0;
581 uint32_t color_num = 0;
583 /* clear existing rects and delete them */
587 for (uint32_t y = 0; y < height - box_size && color_num < color_limit; y += box_size) {
588 for (uint32_t x = 0; x < width - box_size && color_num < color_limit; x += box_size) {
589 ArdourCanvas::Rectangle* r = new ArdourCanvas::Rectangle (&group, ArdourCanvas::Rect (x, y, x + box_size, y + box_size));
591 string name = nc[color_num++].name;
593 UIConfiguration::RelativeColors::iterator c = relatives.find (name);
595 if (c != relatives.end()) {
596 Color color = c->second.get().color ();
597 r->set_fill_color (color);
598 r->set_outline_color (rgba_to_color (0.0, 0.0, 0.0, 1.0));
599 r->set_tooltip (name);
600 r->Event.connect (sigc::bind (sigc::mem_fun (*this, event_handler), name));
607 ThemeManager::base_color_viewport_allocated (Gtk::Allocation&)
609 if (!base_color_group) {
610 base_color_group = initialize_canvas (*base_color_viewport.canvas());
613 build_base_color_canvas (*base_color_group, &ThemeManager::base_color_event,
614 base_color_viewport.canvas()->width(),
615 base_color_viewport.canvas()->height());
620 ThemeManager::base_color_event (GdkEvent*ev, string name)
623 case GDK_BUTTON_RELEASE:
624 edit_named_color (name);
634 ThemeManager::edit_named_color (std::string name)
636 using namespace ArdourCanvas;
638 UIConfiguration* uic (ARDOUR_UI::instance()->config());
639 ArdourCanvas::Color c = uic->color (name);
642 color_to_rgba (c, r, g, b, a);
644 gdkcolor.set_rgb_p (r, g, b);
645 color_dialog.get_colorsel()->set_previous_color (gdkcolor);
646 color_dialog.get_colorsel()->set_current_color (gdkcolor);
647 color_dialog.get_colorsel()->set_previous_alpha ((guint16) (a * 65535));
648 color_dialog.get_colorsel()->set_current_alpha ((guint16) (a * 65535));
650 base_color_edit_name = name;
652 color_dialog_connection.disconnect ();
653 color_dialog_connection = color_dialog.signal_response().connect (sigc::mem_fun (*this, &ThemeManager::base_color_dialog_done));
654 color_dialog.present();
658 ThemeManager::base_color_dialog_done (int result)
660 using namespace ArdourCanvas;
662 cerr << "Done, using [" << base_color_edit_name << "] res = " << result << endl;
664 if (base_color_edit_name.empty()) {
665 color_dialog.hide ();
669 UIConfiguration* uic (ARDOUR_UI::instance()->config());
670 UIConfiguration::RelativeHSV rhsv ("", HSV());
675 case RESPONSE_ACCEPT:
677 cerr << "Accepting\n";
678 gdkcolor = color_dialog.get_colorsel()->get_current_color();
679 a = color_dialog.get_colorsel()->get_current_alpha() / 65535.0;
680 r = gdkcolor.get_red_p();
681 g = gdkcolor.get_green_p();
682 b = gdkcolor.get_blue_p();
684 rhsv = uic->color_as_relative_hsv (rgba_to_color (r, g, b, a));
685 uic->reset_relative (base_color_edit_name, rhsv);
689 build_base_color_canvas (*base_color_group, &ThemeManager::base_color_event,
690 base_color_viewport.canvas()->width(),
691 base_color_viewport.canvas()->height());
693 ColorsChanged(); //EMIT SIGNAL
700 color_dialog.hide ();
701 base_color_edit_name = "";
705 ThemeManager::palette_canvas_allocated (Gtk::Allocation& alloc, ArdourCanvas::Container* group, bool (ThemeManager::*event_handler)(GdkEvent*,std::string))
707 build_base_color_canvas (*group, event_handler, alloc.get_width(), alloc.get_height());
711 ThemeManager::palette_chosen (GdkEvent* ev, string name)
714 case GDK_BUTTON_RELEASE:
721 UIConfiguration* uic (ARDOUR_UI::instance()->config());
722 uic->set_alias (palette_edit_name, name);
724 (void) palette_done ((GdkEventAny*) 0);
726 /* rebuild alias list with new color: inefficient but simple */
734 ThemeManager::palette_done (GdkEventAny*)
736 palette_edit_name = "";
737 palette_window->hide ();
742 ThemeManager::choose_color_from_palette (string const & name)
744 if (!palette_window) {
745 palette_window = new Gtk::Window (WINDOW_TOPLEVEL);
746 ArdourCanvas::GtkCanvas* canvas = new ArdourCanvas::GtkCanvas ();
747 ArdourCanvas::Container* group = initialize_canvas (*canvas);
749 canvas->signal_size_allocate().connect (sigc::bind (sigc::mem_fun (*this, &ThemeManager::palette_canvas_allocated), group, &ThemeManager::palette_chosen));
750 palette_window->signal_delete_event().connect (sigc::mem_fun (*this, &ThemeManager::palette_done));
752 palette_window->add (*canvas);
756 palette_edit_name = name;
758 palette_window->set_position (WIN_POS_MOUSE);
759 palette_window->present ();
763 ThemeManager::setup_aliases ()
765 using namespace ArdourCanvas;
767 UIConfiguration* uic (ARDOUR_UI::instance()->config());
768 UIConfiguration::ColorAliases& aliases (uic->color_aliases);
770 alias_list->clear ();
772 for (UIConfiguration::ColorAliases::iterator i = aliases.begin(); i != aliases.end(); ++i) {
775 row = *(alias_list->append());
776 row[alias_columns.name] = i->first;
777 row[alias_columns.alias] = i->second;
779 Color c = uic->color (i->second);
781 /* Gdk colors don't support alpha */
784 color_to_rgba (c, r, g, b, a);
786 gcolor.set_rgb_p (r, g, b);
788 row[alias_columns.color] = gcolor;
793 ThemeManager::alias_button_press_event (GdkEventButton* ev)
796 TreeModel::Path path;
797 TreeViewColumn* column;
801 if (!alias_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
805 guint32 colnum = GPOINTER_TO_UINT (column->get_data (X_("colnum")));
809 /* allow normal processing to occur */
813 if ((iter = alias_list->get_iter (path))) {
814 choose_color_from_palette ((*iter)[alias_columns.name]);