X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fcolor_theme_manager.cc;h=c9ee7ac308b83ec6931479338b85816db5c98d2a;hb=e5a181c323243a03338f5a9934a5df254986370d;hp=10eb9402e27bdf7834e14b697aa5fc39c9d99c2f;hpb=74f567b7891d80d59558aab5d92e765af7e0ffc2;p=ardour.git diff --git a/gtk2_ardour/color_theme_manager.cc b/gtk2_ardour/color_theme_manager.cc index 10eb9402e2..c9ee7ac308 100644 --- a/gtk2_ardour/color_theme_manager.cc +++ b/gtk2_ardour/color_theme_manager.cc @@ -20,13 +20,12 @@ #include #include +#include + #include "fix_carbon.h" #include "pbd/gstdio_compat.h" -#include "gtkmm2ext/cell_renderer_color_selector.h" -#include "gtkmm2ext/utils.h" - #include "pbd/compose.h" #include "pbd/file_utils.h" #include "pbd/replace_all.h" @@ -34,24 +33,28 @@ #include "ardour/filesystem_paths.h" #include "ardour/profile.h" +#include "gtkmm2ext/cell_renderer_color_selector.h" +#include "gtkmm2ext/utils.h" + #include "canvas/container.h" #include "canvas/rectangle.h" #include "canvas/scroll_group.h" -#include "canvas/wave_view.h" -#include "ardour_button.h" +#include "waveview/wave_view.h" + #include "ardour_dialog.h" #include "color_theme_manager.h" #include "rgb_macros.h" #include "ui_config.h" #include "utils.h" -#include "i18n.h" +#include "pbd/i18n.h" using namespace std; using namespace Gtk; using namespace PBD; using namespace ARDOUR; +using namespace Gtkmm2ext; using namespace ARDOUR_UI_UTILS; ColorThemeManager::ColorThemeManager () @@ -61,17 +64,15 @@ ColorThemeManager::ColorThemeManager () , palette_window (0) , color_theme_label (_("Color Theme")) { - set_spacing (12); - std::map color_themes; get_color_themes (color_themes); + int n = 0; if (color_themes.size() > 1) { theme_list = TreeStore::create (color_theme_columns); TreeModel::iterator selected_iter = theme_list->children().end(); - const bool running_from_source = running_from_source_tree(); for (std::map::iterator c = color_themes.begin(); c != color_themes.end(); ++c) { TreeModel::Row row; @@ -81,13 +82,6 @@ ColorThemeManager::ColorThemeManager () string color_file_name = c->second; - if (running_from_source) { - /* color themes from within the source tree are - suffixed by "-PROGRAM-NAME" (lowercased) - */ - replace_all (color_file_name, string_compose ("-%1", downcase (PROGRAM_NAME)), ""); - } - row[color_theme_columns.path] = color_file_name; /* match second (path; really basename) since that is @@ -113,8 +107,9 @@ ColorThemeManager::ColorThemeManager () hbox->set_spacing (6); hbox->pack_start (color_theme_label, false, false); hbox->pack_start (*align, true, true); - pack_start (*hbox, PACK_SHRINK); hbox->show_all (); + table.attach (*hbox, 0, 3, n, n + 1); + ++n; } reset_button.signal_clicked().connect (sigc::mem_fun (*this, &ColorThemeManager::reset_canvas_colors)); @@ -154,8 +149,9 @@ ColorThemeManager::ColorThemeManager () notebook.set_size_request (400, 400); - pack_start (notebook, true, true); - pack_start (reset_button, false, false); + table.attach (notebook, 0, 3, n, n + 1); + ++n; + table.attach (reset_button, 0, 3, n, n + 1); color_dialog.get_colorsel()->set_has_opacity_control (true); color_dialog.get_colorsel()->set_has_palette (true); @@ -169,10 +165,18 @@ ColorThemeManager::ColorThemeManager () setup_modifiers (); UIConfiguration::instance().ColorsChanged.connect (sigc::mem_fun (*this, &ColorThemeManager::colors_changed)); +} + - show_all (); +ColorThemeManager::~ColorThemeManager () +{ + if (palette_group) { + palette_group->clear (true); + delete palette_group; + } } + void ColorThemeManager::setup_modifiers () { @@ -231,7 +235,9 @@ ColorThemeManager::reset_canvas_colors() string cfile; string basename; - basename = UIConfiguration::instance().color_file_name (false, running_from_source_tree(), false); + /* look for a versioned user-owned color file, and try to rename it */ + + basename = UIConfiguration::instance().color_file_name (true, true); if (find_file (ardour_config_search_path(), basename, cfile)) { string backup = cfile + string (X_(".old")); @@ -269,8 +275,8 @@ ColorThemeManager::palette_canvas_allocated (Gtk::Allocation& alloc, ArdourCanva struct NamedColor { string name; - ArdourCanvas::HSV color; - NamedColor (string s, ArdourCanvas::HSV c) : name (s), color (c) {} + Gtkmm2ext::HSV color; + NamedColor (string s, Gtkmm2ext::HSV c) : name (s), color (c) {} }; struct SortByHue { @@ -317,7 +323,6 @@ ColorThemeManager::build_palette_canvas (ArdourCanvas::Canvas& canvas, ArdourCan for (uint32_t y = 0; y < height - box_size && color_num < color_limit; y += box_size) { for (uint32_t x = 0; x < width - box_size && color_num < color_limit; x += box_size) { ArdourCanvas::Rectangle* r = new ArdourCanvas::Rectangle (&group, ArdourCanvas::Rect (x, y, x + box_size, y + box_size)); - string name = nc[color_num++].name; UIConfiguration::Colors::iterator c = colors.find (name); @@ -375,7 +380,7 @@ ColorThemeManager::edit_palette_color (std::string name) using namespace ArdourCanvas; double r,g, b, a; UIConfiguration* uic (&UIConfiguration::instance()); - ArdourCanvas::Color c = uic->color (name); + Gtkmm2ext::Color c = uic->color (name); Gdk::Color gdkcolor; color_to_rgba (c, r, g, b, a); @@ -601,9 +606,16 @@ ColorThemeManager::set_state_from_config () } void -ColorThemeManager::add_to_page (OptionEditorPage* page) +ColorThemeManager::add_to_page (OptionEditorPage* p) { - add_widget_to_page (page, this); + int const n = p->table.property_n_rows(); + int m = n + 1; + if (!_note.empty ()) { + ++m; + } + p->table.resize (m, 3); + p->table.attach (box, 1, 3, n, n + 1, FILL | EXPAND, SHRINK, 0, 0); + maybe_add_note (p, n + 1); } Gtk::Widget&