366fc8aad8701cb01253e6cd3c48e7b081ec32c6
[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 "ui_config.h"
36
37 namespace ArdourCanvas {
38         class Container;
39         class ScrollGroup;
40 }
41
42 class ArdourDialog;
43
44 class ThemeManager : public Gtk::VBox
45 {
46   public:
47         ThemeManager();
48         ~ThemeManager();
49
50         int save (std::string path);
51         void reset_canvas_colors();
52
53         void on_dark_theme_button_toggled ();
54         void on_light_theme_button_toggled ();
55         void on_flat_buttons_toggled ();
56         void on_blink_rec_arm_toggled ();
57         void on_region_color_toggled ();
58         void on_show_clip_toggled ();
59         void on_waveform_gradient_depth_change ();
60         void on_timeline_item_gradient_depth_change ();
61         void on_all_dialogs_toggled ();
62         void on_transients_follow_front_toggled ();
63         void on_floating_monitor_section_toggled ();
64         void on_icon_set_changed ();
65         void on_color_theme_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                 }
75
76                 Gtk::TreeModelColumn<std::string>  name;
77                 Gtk::TreeModelColumn<Gdk::Color>   gdkcolor;
78         };
79
80         Gtk::ColorSelectionDialog color_dialog;
81         sigc::connection color_dialog_connection;
82
83         Gtk::HBox theme_selection_hbox;
84         Gtk::RadioButton dark_button;
85         Gtk::RadioButton light_button;
86         Gtk::Button reset_button;
87         Gtk::CheckButton flat_buttons;
88         Gtk::CheckButton blink_rec_button;
89         Gtk::CheckButton region_color_button;
90         Gtk::CheckButton show_clipping_button;
91         Gtk::HScale waveform_gradient_depth;
92         Gtk::Label waveform_gradient_depth_label;
93         Gtk::HScale timeline_item_gradient_depth;
94         Gtk::Label timeline_item_gradient_depth_label;
95         Gtk::CheckButton all_dialogs;
96         Gtk::CheckButton transients_follow_front;
97         Gtk::CheckButton floating_monitor_section;
98         Gtk::CheckButton gradient_waveforms;
99         Gtk::Label icon_set_label;
100         Gtk::ComboBoxText icon_set_dropdown;
101         Gtk::Label color_theme_label;
102         Gtk::ComboBoxText color_theme_dropdown;
103
104         /* handls response from color dialog when it is used to
105            edit a derived color.
106         */
107         void palette_color_response (int, std::string);
108
109         Gtk::ScrolledWindow palette_scroller;
110         ArdourCanvas::GtkCanvasViewport palette_viewport;
111         ArdourCanvas::Container* palette_group;
112
113         /* these methods create and manage a canvas for use in either the
114            palette tab or in a separate dialog. Different behaviour is
115            accomplished by changing the event handler passed into the
116            allocation handler. We do it there because we have to rebuild
117            the canvas on allocation events, and during the rebuild, connect
118            each rectangle to the event handler.
119
120            the alternative is one event handler for the canvas and a map
121            of where each color rectangle is. nothing wrong with this
122            but the per-rect event setup is simpler and avoids building
123            and looking up the map information.
124         */
125         ArdourCanvas::Container* initialize_palette_canvas (ArdourCanvas::Canvas& canvas);
126         void build_palette_canvas (ArdourCanvas::Canvas&, ArdourCanvas::Container&, sigc::slot<bool,GdkEvent*,std::string> event_handler);
127         void palette_canvas_allocated (Gtk::Allocation& alloc, ArdourCanvas::Container* group, ArdourCanvas::Canvas* canvas, sigc::slot<bool,GdkEvent*,std::string> event_handler);
128         void palette_size_request (Gtk::Requisition*);
129
130         /* handles events from a palette canvas inside the palette (derived
131            colors) tab
132         */
133         bool palette_event (GdkEvent*, std::string name);
134         /* allows user to edit a named color (e.g. "color 3") after clicking
135            on it inside the palette tab.
136         */
137         void edit_palette_color (std::string);
138
139         struct ColorAliasModelColumns : public Gtk::TreeModel::ColumnRecord {
140                 ColorAliasModelColumns() {
141                         add (name);
142                         add (alias);
143                         add (color);
144                         add (key);
145                 }
146
147                 Gtk::TreeModelColumn<std::string>  name;
148                 Gtk::TreeModelColumn<std::string>  alias;
149                 Gtk::TreeModelColumn<Gdk::Color>   color;
150                 Gtk::TreeModelColumn<std::string>  key;
151         };
152
153         ColorAliasModelColumns       alias_columns;
154         Gtk::TreeView                alias_display;
155         Glib::RefPtr<Gtk::TreeStore> alias_list;
156         Gtk::ScrolledWindow          alias_scroller;
157
158         bool alias_button_press_event (GdkEventButton*);
159
160         ArdourDialog* palette_window;
161         sigc::connection palette_response_connection;
162
163         void choose_color_from_palette (std::string const &target_name);
164
165         bool alias_palette_event (GdkEvent*, std::string, std::string);
166         void alias_palette_response (int, std::string, std::string);
167
168         void setup_aliases ();
169         void setup_palette ();
170
171         Gtk::ScrolledWindow modifier_scroller;
172         Gtk::VBox modifier_vbox;
173
174         void setup_modifiers ();
175         void modifier_edited (Gtk::Range*, std::string);
176
177         void colors_changed ();
178         void set_ui_to_state ();
179 };
180
181 #endif /* __ardour_gtk_color_manager_h__ */