summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gtk2_ardour/theme_manager.cc61
-rw-r--r--gtk2_ardour/theme_manager.h4
2 files changed, 54 insertions, 11 deletions
diff --git a/gtk2_ardour/theme_manager.cc b/gtk2_ardour/theme_manager.cc
index b800554fb9..0d37d50abc 100644
--- a/gtk2_ardour/theme_manager.cc
+++ b/gtk2_ardour/theme_manager.cc
@@ -56,7 +56,7 @@ ThemeManager::ThemeManager()
{
set_title (_("Theme Manager"));
- color_list = ListStore::create (columns);
+ color_list = TreeStore::create (columns);
color_display.set_model (color_list);
color_display.append_column (_("Object"), columns.name);
color_display.append_column (_("Color"), columns.color);
@@ -132,6 +132,12 @@ ThemeManager::button_press_event (GdkEventButton* ev)
case 1: /* color */
if ((iter = color_list->get_iter (path))) {
+ UIConfigVariable<uint32_t>* var = (*iter)[columns.pVar];
+ if (!var) {
+ /* parent row, do nothing */
+ return false;
+ }
+
int r,g, b, a;
uint32_t rgba = (*iter)[columns.rgba];
Gdk::Color color;
@@ -156,8 +162,6 @@ ThemeManager::button_press_event (GdkEventButton* ev)
b = (int) floor (color.get_blue_p() * 255.0);
rgba = RGBA_TO_UINT(r,g,b,a>>8);
- //cerr << (*iter)[columns.name] << " == " << hex << rgba << endl;
- //cerr << "a = " << a << endl;
(*iter)[columns.rgba] = rgba;
(*iter)[columns.gdkcolor] = color;
@@ -165,8 +169,7 @@ ThemeManager::button_press_event (GdkEventButton* ev)
ccvar->set(rgba);
ARDOUR_UI::config()->set_dirty ();
- //ColorChanged (rgba);
- ColorsChanged();//EMIT SIGNAL
+ ColorsChanged(); //EMIT SIGNAL
break;
default:
@@ -251,25 +254,65 @@ void
ThemeManager::setup_theme ()
{
int r, g, b, a;
+
color_list->clear();
for (std::map<std::string,UIConfigVariable<uint32_t> *>::iterator i = ARDOUR_UI::config()->canvas_colors.begin(); i != ARDOUR_UI::config()->canvas_colors.end(); i++) {
- TreeModel::Row row = *(color_list->append());
- Gdk::Color col;
UIConfigVariable<uint32_t>* var = i->second;
+
+ TreeModel::Children rows = color_list->children();
+ TreeModel::Row row;
+ string::size_type colon;
+
+ if ((colon = var->name().find (':')) != string::npos) {
+
+ /* this is supposed to be a child node, so find the
+ * parent
+ */
+
+ string parent = var->name().substr (0, colon);
+ TreeModel::iterator ri;
+
+ for (ri = rows.begin(); ri != rows.end(); ++ri) {
+ string s = (*ri)[columns.name];
+ if (s == parent) {
+ break;
+ }
+ }
+
+ if (ri == rows.end()) {
+ /* not found, add the parent as new top level row */
+ row = *(color_list->append());
+ row[columns.name] = parent;
+ row[columns.pVar] = 0;
+
+ /* now add the child as a child of this one */
+
+ row = *(color_list->insert (row->children().end()));
+ row[columns.name] = var->name().substr (colon+1);
+ } else {
+ row = *(color_list->insert ((*ri)->children().end()));
+ row[columns.name] = var->name().substr (colon+1);
+ }
+
+ } else {
+ /* add as a child */
+ row = *(color_list->append());
+ row[columns.name] = var->name();
+ }
+
+ Gdk::Color col;
uint32_t rgba = var->get();
UINT_TO_RGBA (rgba, &r, &g, &b, &a);
//cerr << (*i)->name() << " == " << hex << rgba << ": " << hex << r << " " << hex << g << " " << hex << b << endl;
col.set_rgb_p (r / 255.0, g / 255.0, b / 255.0);
- row[columns.name] = var->name();
row[columns.color] = "";
row[columns.pVar] = var;
row[columns.rgba] = rgba;
row[columns.gdkcolor] = col;
-
}
ColorsChanged.emit();
diff --git a/gtk2_ardour/theme_manager.h b/gtk2_ardour/theme_manager.h
index 6e4adc57a0..37a451da07 100644
--- a/gtk2_ardour/theme_manager.h
+++ b/gtk2_ardour/theme_manager.h
@@ -21,7 +21,7 @@
#define __ardour_gtk_color_manager_h__
#include <gtkmm/treeview.h>
-#include <gtkmm/liststore.h>
+#include <gtkmm/treestore.h>
#include <gtkmm/scrolledwindow.h>
#include <gtkmm/colorselection.h>
#include <gtkmm/radiobutton.h>
@@ -62,7 +62,7 @@ class ThemeManager : public ArdourDialog
ColorDisplayModelColumns columns;
Gtk::TreeView color_display;
- Glib::RefPtr<Gtk::ListStore> color_list;
+ Glib::RefPtr<Gtk::TreeStore> color_list;
Gtk::ColorSelectionDialog color_dialog;
Gtk::ScrolledWindow scroller;
Gtk::HBox theme_selection_hbox;