lots more color work, closer and closer to being ready for ... being taken apart...
[ardour.git] / gtk2_ardour / theme_manager.h
1 /*
2     Copyright (C) 2000-2007 Paul Davis
3
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.
8
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.
13
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.
17
18 */
19
20 #ifndef __ardour_gtk_color_manager_h__
21 #define __ardour_gtk_color_manager_h__
22
23 #include <gtkmm/treeview.h>
24 #include <gtkmm/treestore.h>
25 #include <gtkmm/scrolledwindow.h>
26 #include <gtkmm/colorselection.h>
27 #include <gtkmm/radiobutton.h>
28 #include <gtkmm/button.h>
29 #include <gtkmm/scale.h>
30 #include <gtkmm/rc.h>
31
32 #include "canvas/types.h"
33 #include "canvas/canvas.h"
34
35 #include "ardour_window.h"
36
37 #include "ui_config.h"
38
39 namespace ArdourCanvas {
40         class Container;
41         class ScrollGroup;
42 }
43
44 class ArdourDialog;
45
46 class ThemeManager : public ArdourWindow
47 {
48   public:
49         ThemeManager();
50         ~ThemeManager();
51
52         int save (std::string path);
53         void setup_basic_color_display ();
54         void reset_canvas_colors();
55
56         void on_dark_theme_button_toggled ();
57         void on_light_theme_button_toggled ();
58         void on_flat_buttons_toggled ();
59         void on_blink_rec_arm_toggled ();
60         void on_region_color_toggled ();
61         void on_show_clip_toggled ();
62         void on_waveform_gradient_depth_change ();
63         void on_timeline_item_gradient_depth_change ();
64         void on_all_dialogs_toggled ();
65         void on_icon_set_changed ();
66
67   private:
68         Gtk::Notebook notebook;
69         
70         struct BasicColorDisplayModelColumns : public Gtk::TreeModel::ColumnRecord {
71                 BasicColorDisplayModelColumns() {
72                         add (name);
73                         add (gdkcolor);
74                         add (color_variable);
75                 }
76                 
77                 Gtk::TreeModelColumn<std::string>  name;
78                 Gtk::TreeModelColumn<Gdk::Color>   gdkcolor;
79                 Gtk::TreeModelColumn<ColorVariable<ArdourCanvas::Color> *> color_variable;
80         };
81         
82         BasicColorDisplayModelColumns basic_color_columns;
83         Gtk::TreeView basic_color_display;
84         Glib::RefPtr<Gtk::TreeStore> basic_color_list;
85
86         bool basic_color_button_press_event (GdkEventButton*);
87
88         Gtk::ColorSelectionDialog color_dialog;
89         sigc::connection color_dialog_connection;
90         
91         Gtk::ScrolledWindow scroller;
92         Gtk::HBox theme_selection_hbox;
93         Gtk::RadioButton dark_button;
94         Gtk::RadioButton light_button;
95         Gtk::Button reset_button;
96         Gtk::CheckButton flat_buttons;
97         Gtk::CheckButton blink_rec_button;
98         Gtk::CheckButton region_color_button;
99         Gtk::CheckButton show_clipping_button;
100         Gtk::HScale waveform_gradient_depth;
101         Gtk::Label waveform_gradient_depth_label;
102         Gtk::HScale timeline_item_gradient_depth;
103         Gtk::Label timeline_item_gradient_depth_label;
104         Gtk::CheckButton all_dialogs;
105         Gtk::CheckButton gradient_waveforms;
106         Gtk::Label icon_set_label;
107         Gtk::ComboBoxText icon_set_dropdown;
108
109         /* handles response from color dialog when it used to 
110            edit a basic color
111         */
112         void basic_color_response (int, ColorVariable<ArdourCanvas::Color>*);
113
114         /* handls response from color dialog when it is used to
115            edit a derived color.
116         */
117         void palette_color_response (int, std::string);
118
119         Gtk::ScrolledWindow palette_scroller;
120         ArdourCanvas::GtkCanvasViewport palette_viewport;
121         ArdourCanvas::Container* palette_group;
122         
123         /* these methods create and manage a canvas for use in either the
124            palette tab or in a separate dialog. Different behaviour is
125            accomplished by changing the event handler passed into the 
126            allocation handler. We do it there because we have to rebuild
127            the canvas on allocation events, and during the rebuild, connect
128            each rectangle to the event handler.
129
130            the alternative is one event handler for the canvas and a map
131            of where each color rectangle is. nothing wrong with this
132            but the per-rect event setup is simpler and avoids building
133            and looking up the map information.
134         */
135         ArdourCanvas::Container* initialize_palette_canvas (ArdourCanvas::Canvas& canvas);
136         void build_palette_canvas (ArdourCanvas::Canvas&, ArdourCanvas::Container&, sigc::slot<bool,GdkEvent*,std::string> event_handler);
137         void palette_canvas_allocated (Gtk::Allocation& alloc, ArdourCanvas::Container* group, ArdourCanvas::Canvas* canvas, sigc::slot<bool,GdkEvent*,std::string> event_handler);
138         void palette_size_request (Gtk::Requisition*);
139
140         /* handles events from a palette canvas inside the palette (derived
141            colors) tab
142         */
143         bool palette_event (GdkEvent*, std::string name);
144         /* allows user to edit a named color (e.g. "color 3") after clicking
145            on it inside the palette tab.
146         */
147         void edit_palette_color (std::string);
148         
149         struct ColorAliasModelColumns : public Gtk::TreeModel::ColumnRecord {
150                 ColorAliasModelColumns() {
151                         add (name);
152                         add (alias);
153                         add (color);
154                 }
155                 
156                 Gtk::TreeModelColumn<std::string>  name;
157                 Gtk::TreeModelColumn<std::string>  alias;
158                 Gtk::TreeModelColumn<Gdk::Color>   color;
159         };
160
161         ColorAliasModelColumns       alias_columns;
162         Gtk::TreeView                alias_display;
163         Glib::RefPtr<Gtk::TreeStore> alias_list;
164         Gtk::ScrolledWindow          alias_scroller;
165
166         bool alias_button_press_event (GdkEventButton*);
167
168         ArdourDialog* palette_window;
169         sigc::connection palette_response_connection;
170         
171         void choose_color_from_palette (std::string const &target_name);
172         
173         bool alias_palette_event (GdkEvent*, std::string, std::string);
174         void alias_palette_response (int, std::string, std::string);
175
176         void setup_aliases ();
177         void setup_palette ();
178 };
179
180 #endif /* __ardour_gtk_color_manager_h__ */
181