RouteUI is no longer an AxisView so use ARDOUR_UI::instance()->gui_object_state(...
[ardour.git] / gtk2_ardour / route_ui.cc
index 074f35a08d4a14ab88201e11992660c448b86d37..067adc25f817caba7a1a4d34335c7c46b2864fc1 100644 (file)
@@ -83,8 +83,7 @@ boost::weak_ptr<Route> RouteUI::_showing_sends_to;
 std::string RouteUI::program_port_prefix;
 
 RouteUI::RouteUI (ARDOUR::Session* sess)
-       : AxisView(sess)
-       , mute_menu(0)
+       : mute_menu(0)
        , solo_menu(0)
        , sends_menu(0)
        , record_menu(0)
@@ -100,13 +99,16 @@ RouteUI::RouteUI (ARDOUR::Session* sess)
                boost::to_lower (lpn);
                program_port_prefix = lpn + ":"; // e.g. "ardour:"
        }
-       if (sess) init ();
+
+       if (sess) {
+               init ();
+       }
 }
 
 RouteUI::~RouteUI()
 {
        if (_route) {
-               gui_object_state().remove_node (route_state_id());
+               ARDOUR_UI::instance()->gui_object_state->remove_node (route_state_id());
        }
 
        _route.reset (); /* drop reference to route, so that it can be cleaned up */
@@ -249,7 +251,7 @@ RouteUI::set_route (boost::shared_ptr<Route> rp)
        _route = rp;
 
        if (set_color_from_route()) {
-               set_color (unique_random_color());
+               set_color (gdk_color_to_rgba (AxisView::unique_random_color ()));
        }
 
        if (self_destruct) {
@@ -1596,10 +1598,11 @@ void
 RouteUI::choose_color ()
 {
        bool picked;
-       Gdk::Color const color = Gtkmm2ext::UI::instance()->get_color (_("Color Selection"), picked, &_color);
+       Gdk::Color c (gdk_color_from_rgb (_route->presentation_info().color()));
+       Gdk::Color const color = Gtkmm2ext::UI::instance()->get_color (_("Color Selection"), picked, &c);
 
        if (picked) {
-               set_color(color);
+               set_color (gdk_color_to_rgba (color));
        }
 }
 
@@ -1607,21 +1610,9 @@ RouteUI::choose_color ()
  *  the route is in a group which shares its color with its routes.
  */
 void
-RouteUI::set_color (const Gdk::Color & c)
+RouteUI::set_color (uint32_t c)
 {
-       /* leave _color alone in the group case so that tracks can retain their
-        * own pre-group colors.
-        */
-
-       char buf[64];
-       _color = c;
-       snprintf (buf, sizeof (buf), "%d:%d:%d", c.get_red(), c.get_green(), c.get_blue());
-
-       /* note: we use the route state ID here so that color is the same for both
-          the time axis view and the mixer strip
-       */
-
-       gui_object_state().set_property<string> (route_state_id(), X_("color"), buf);
+       _route->presentation_info().set_color (c);
        _route->gui_changed ("color", (void *) 0); /* EMIT_SIGNAL */
 }
 
@@ -1635,20 +1626,6 @@ RouteUI::route_state_id () const
 int
 RouteUI::set_color_from_route ()
 {
-       const string str = gui_object_state().get_string (route_state_id(), X_("color"));
-
-       if (str.empty()) {
-               return 1;
-       }
-
-       int r, g, b;
-
-       sscanf (str.c_str(), "%d:%d:%d", &r, &g, &b);
-
-       _color.set_red (r);
-       _color.set_green (g);
-       _color.set_blue (b);
-
        return 0;
 }
 
@@ -2230,18 +2207,20 @@ RouteUI::track_mode_changed (void)
 /** @return the color that this route should use; it maybe its own,
     or it maybe that of its route group.
 */
+
 Gdk::Color
-RouteUI::color () const
+RouteUI::route_color () const
 {
+       Gdk::Color c;
        RouteGroup* g = _route->route_group ();
 
        if (g && g->is_color()) {
-               Gdk::Color c;
                set_color_from_rgba (c, GroupTabs::group_color (g));
-               return c;
+       } else {
+               set_color_from_rgba (c, _route->presentation_info().color());
        }
 
-       return _color;
+       return c;
 }
 
 void
@@ -2356,3 +2335,13 @@ RouteUI::manage_pins ()
                proxy->present();
        }
 }
+
+bool
+RouteUI::mark_hidden (bool yn)
+{
+       if (yn != _route->presentation_info().hidden()) {
+               _route->presentation_info().set_hidden (yn);
+               return true; // things changed
+       }
+       return false;
+}