2 Copyright (C) 2000-2016 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 #ifndef __ardour_gtk_color_manager_h__
21 #define __ardour_gtk_color_manager_h__
23 #include <gtkmm/treeview.h>
24 #include <gtkmm/treestore.h>
25 #include <gtkmm/scrolledwindow.h>
26 #include <gtkmm/colorselection.h>
27 #include <gtkmm/button.h>
29 #include "canvas/types.h"
30 #include "canvas/canvas.h"
32 #include "option_editor.h"
33 #include "ui_config.h"
35 namespace ArdourCanvas {
42 class ColorThemeManager : public OptionEditorMiniPage
48 void reset_canvas_colors();
49 void on_color_theme_changed ();
51 /** Called when a configuration parameter's value has changed.
52 * @param p parameter name
54 void parameter_changed (std::string const & p);
56 /** Called to instruct the object to set its UI state from the configuration */
57 void set_state_from_config ();
59 void set_note (std::string const &);
61 void add_to_page (OptionEditorPage*);
63 Gtk::Widget& tip_widget();
66 Gtk::Button reset_button;
67 Gtk::Notebook notebook;
69 /* handls response from color dialog when it is used to
72 void palette_color_response (int, std::string);
74 Gtk::ScrolledWindow palette_scroller;
75 ArdourCanvas::GtkCanvasViewport palette_viewport;
76 ArdourCanvas::Container* palette_group;
78 /* these methods create and manage a canvas for use in either the
79 palette tab or in a separate dialog. Different behaviour is
80 accomplished by changing the event handler passed into the
81 allocation handler. We do it there because we have to rebuild
82 the canvas on allocation events, and during the rebuild, connect
83 each rectangle to the event handler.
85 the alternative is one event handler for the canvas and a map
86 of where each color rectangle is. nothing wrong with this
87 but the per-rect event setup is simpler and avoids building
88 and looking up the map information.
90 ArdourCanvas::Container* initialize_palette_canvas (ArdourCanvas::Canvas& canvas);
91 void build_palette_canvas (ArdourCanvas::Canvas&, ArdourCanvas::Container&, sigc::slot<bool,GdkEvent*,std::string> event_handler);
92 void palette_canvas_allocated (Gtk::Allocation& alloc, ArdourCanvas::Container* group, ArdourCanvas::Canvas* canvas, sigc::slot<bool,GdkEvent*,std::string> event_handler);
93 void palette_size_request (Gtk::Requisition*);
95 /* handles events from a palette canvas inside the palette (derived
98 bool palette_event (GdkEvent*, std::string name);
99 /* allows user to edit a named color (e.g. "color 3") after clicking
100 on it inside the palette tab.
102 void edit_palette_color (std::string);
104 struct ColorAliasModelColumns : public Gtk::TreeModel::ColumnRecord {
105 ColorAliasModelColumns() {
112 Gtk::TreeModelColumn<std::string> name;
113 Gtk::TreeModelColumn<std::string> alias;
114 Gtk::TreeModelColumn<Gdk::Color> color;
115 Gtk::TreeModelColumn<std::string> key;
118 ColorAliasModelColumns alias_columns;
119 Gtk::TreeView alias_display;
120 Glib::RefPtr<Gtk::TreeStore> alias_list;
121 Gtk::ScrolledWindow alias_scroller;
123 bool alias_button_press_event (GdkEventButton*);
125 ArdourDialog* palette_window;
126 sigc::connection palette_response_connection;
128 void choose_color_from_palette (std::string const &target_name);
130 bool alias_palette_event (GdkEvent*, std::string, std::string);
131 void alias_palette_response (int, std::string, std::string);
133 void setup_aliases ();
134 void setup_palette ();
136 Gtk::ScrolledWindow modifier_scroller;
137 Gtk::VBox modifier_vbox;
139 void setup_modifiers ();
140 void modifier_edited (Gtk::Range*, std::string);
142 Gtk::ColorSelectionDialog color_dialog;
143 sigc::connection color_dialog_connection;
145 void colors_changed ();
146 void set_ui_to_state ();
149 struct ColorThemeModelColumns : public Gtk::TreeModel::ColumnRecord {
150 ColorThemeModelColumns() {
155 Gtk::TreeModelColumn<std::string> name;
156 Gtk::TreeModelColumn<std::string> path;
159 ColorThemeModelColumns color_theme_columns;
160 Glib::RefPtr<Gtk::TreeStore> theme_list;
162 Gtk::Label color_theme_label;
163 Gtk::ComboBox color_theme_dropdown;
167 #endif /* __ardour_gtk_color_manager_h__ */