several steps closer to more sane color system
[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/canvas.h"
33
34 #include "ardour_window.h"
35
36 #include "ui_config.h"
37
38 namespace ArdourCanvas {
39         class Container;
40         class ScrollGroup;
41 }
42
43 class ThemeManager : public ArdourWindow
44 {
45   public:
46         ThemeManager();
47         ~ThemeManager();
48
49         int save (std::string path);
50         void setup_theme ();
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_icon_set_changed ();
63
64   private:
65         Gtk::Notebook notebook;
66
67         struct ColorDisplayModelColumns : public Gtk::TreeModel::ColumnRecord {
68             ColorDisplayModelColumns() {
69                     add (name);
70                     add (gdkcolor);
71                     add (pVar);
72                     add (rgba);
73             }
74
75             Gtk::TreeModelColumn<std::string>  name;
76             Gtk::TreeModelColumn<Gdk::Color>   gdkcolor;
77             Gtk::TreeModelColumn<ColorVariable<uint32_t> *> pVar;
78             Gtk::TreeModelColumn<uint32_t>     rgba;
79         };
80
81         ColorDisplayModelColumns columns;
82         Gtk::TreeView color_display;
83         Glib::RefPtr<Gtk::TreeStore> color_list;
84         Gtk::ColorSelectionDialog color_dialog;
85         Gtk::ScrolledWindow scroller;
86         Gtk::HBox theme_selection_hbox;
87         Gtk::RadioButton dark_button;
88         Gtk::RadioButton light_button;
89         Gtk::Button reset_button;
90         Gtk::CheckButton flat_buttons;
91         Gtk::CheckButton blink_rec_button;
92         Gtk::CheckButton region_color_button;
93         Gtk::CheckButton show_clipping_button;
94         Gtk::HScale waveform_gradient_depth;
95         Gtk::Label waveform_gradient_depth_label;
96         Gtk::HScale timeline_item_gradient_depth;
97         Gtk::Label timeline_item_gradient_depth_label;
98         Gtk::CheckButton all_dialogs;
99         Gtk::CheckButton gradient_waveforms;
100         Gtk::Label icon_set_label;
101         Gtk::ComboBoxText icon_set_dropdown;
102
103         ColorDisplayModelColumns base_color_columns;
104         Gtk::ScrolledWindow base_color_scroller;
105         ArdourCanvas::GtkCanvasViewport base_color_viewport;
106         ArdourCanvas::Container* base_color_group;
107         std::string base_color_edit_name;
108
109         sigc::connection color_dialog_connection;
110         void foobar_response (int);
111         
112         ArdourCanvas::Container* initialize_canvas (ArdourCanvas::Canvas& canvas);
113         void build_base_color_canvas (ArdourCanvas::Container&, bool (ThemeManager::*event_handler)(GdkEvent*,std::string), double width, double height);
114         void base_color_viewport_allocated (Gtk::Allocation&);
115         void base_color_dialog_done (int);
116         bool base_color_event (GdkEvent*, std::string);
117         void edit_named_color (std::string);
118         
119         bool button_press_event (GdkEventButton*);
120
121
122         struct ColorAliasModelColumns : public Gtk::TreeModel::ColumnRecord {
123                 ColorAliasModelColumns() {
124                         add (name);
125                         add (alias);
126                         add (color);
127                 }
128                 
129                 Gtk::TreeModelColumn<std::string>  name;
130                 Gtk::TreeModelColumn<std::string>  alias;
131                 Gtk::TreeModelColumn<Gdk::Color>   color;
132         };
133
134         ColorAliasModelColumns       alias_columns;
135         Gtk::TreeView                alias_display;
136         Glib::RefPtr<Gtk::TreeStore> alias_list;
137         Gtk::ScrolledWindow          alias_scroller;
138
139         bool alias_button_press_event (GdkEventButton*);
140
141         Gtk::Window* palette_window;
142         std::string palette_edit_name;
143         
144         void choose_color_from_palette (std::string const &target_name);
145         bool palette_chosen (GdkEvent*, std::string);
146         void palette_canvas_allocated (Gtk::Allocation& alloc, ArdourCanvas::Container* group, bool (ThemeManager::*event_handler)(GdkEvent*,std::string));
147         bool palette_done (GdkEventAny*);
148
149         void setup_aliases ();
150 };
151
152 #endif /* __ardour_gtk_color_manager_h__ */
153