Do not try to restore Route solo state after clearing all solo state
[ardour.git] / gtk2_ardour / speaker_dialog.cc
index 3d0c348df42aa850cd81bffd3ea9236fdbed0633..3831094c5d8065897b08ffcc485745294b99b02f 100644 (file)
@@ -24,7 +24,7 @@
 #include "speaker_dialog.h"
 #include "gui_thread.h"
 
-#include "i18n.h"
+#include "pbd/i18n.h"
 
 using namespace ARDOUR;
 using namespace PBD;
@@ -33,8 +33,8 @@ using namespace Gtk;
 using namespace Gtkmm2ext;
 
 SpeakerDialog::SpeakerDialog ()
-        : ArdourDialog (_("Speaker Configuration"))
-        , aspect_frame ("", 0.5, 0.5, 1.0, false)
+        : ArdourWindow (_("Speaker Configuration"))
+        , aspect_frame ("", 0.5, 0.5, 1.5, false)
         , azimuth_adjustment (0, 0.0, 360.0, 10.0, 1.0)
         , azimuth_spinner (azimuth_adjustment)
         , add_speaker_button (_("Add Speaker"))
@@ -49,14 +49,14 @@ SpeakerDialog::SpeakerDialog ()
         side_vbox.set_spacing (6);
         side_vbox.pack_start (add_speaker_button, false, false);
 
-        aspect_frame.set_size_request (200, 200);
+        aspect_frame.set_size_request (300, 200);
         aspect_frame.set_shadow_type (SHADOW_NONE);
         aspect_frame.add (darea);
 
         hbox.set_spacing (6);
         hbox.set_border_width (6);
         hbox.pack_start (aspect_frame, true, true);
-        hbox.pack_start (side_vbox, true, true);
+        hbox.pack_start (side_vbox, false, false);
 
        HBox* current_speaker_hbox = manage (new HBox);
        current_speaker_hbox->set_spacing (4);
@@ -64,9 +64,11 @@ SpeakerDialog::SpeakerDialog ()
        current_speaker_hbox->pack_start (azimuth_spinner, true, true);
        current_speaker_hbox->pack_start (remove_speaker_button, true, true);
 
-        get_vbox()->pack_start (hbox);
-        get_vbox()->pack_start (*current_speaker_hbox, true, true);
-        get_vbox()->show_all ();
+       VBox* vbox = manage (new VBox);
+       vbox->pack_start (hbox);
+       vbox->pack_start (*current_speaker_hbox, true, true);
+       vbox->show_all ();
+       add (*vbox);
 
         darea.add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK|Gdk::POINTER_MOTION_MASK);
 
@@ -160,6 +162,12 @@ SpeakerDialog::darea_expose_event (GdkEventExpose* event)
 
                 cart_to_gtk (c);
 
+               /* We have already moved our plotting origin to x_origin, y_origin,
+                  so compensate for that.
+               */
+               c.x -= x_origin;
+               c.y -= y_origin;
+
                 x = (gint) floor (c.x);
                 y = (gint) floor (c.y);
 
@@ -177,7 +185,11 @@ SpeakerDialog::darea_expose_event (GdkEventExpose* event)
                 cairo_move_to (cr, x + 6, y + 6);
 
                 char buf[256];
-                snprintf (buf, sizeof (buf), "%d:%d", n+1, (int) lrint (s.angles().azi));
+               if (n == selected_index) {
+                       snprintf (buf, sizeof (buf), "%d:%d", n+1, (int) lrint (s.angles().azi));
+               } else {
+                       snprintf (buf, sizeof (buf), "%d", n + 1);
+               }
                 cairo_show_text (cr, buf);
                 ++n;
         }
@@ -205,8 +217,8 @@ SpeakerDialog::cart_to_gtk (CartesianVector& c) const
           0,height
        */
 
-       c.x = (width / 2) * (c.x + 1);
-       c.y = (height / 2) * (1 - c.y);
+       c.x = (width / 2) * (c.x + 1) + x_origin;
+       c.y = (height / 2) * (1 - c.y) + y_origin;
 
        /* XXX z-axis not handled - 2D for now */
 }
@@ -214,8 +226,8 @@ SpeakerDialog::cart_to_gtk (CartesianVector& c) const
 void
 SpeakerDialog::gtk_to_cart (CartesianVector& c) const
 {
-       c.x = (c.x / (width / 2.0)) - 1.0;
-       c.y = -((c.y / (height / 2.0)) - 1.0);
+       c.x = ((c.x - x_origin) / (width / 2.0)) - 1.0;
+       c.y = -(((c.y - y_origin) / (height / 2.0)) - 1.0);
 
        /* XXX z-axis not handled - 2D for now */
 }
@@ -237,12 +249,19 @@ SpeakerDialog::darea_size_allocate (Gtk::Allocation& alloc)
        width = alloc.get_width();
        height = alloc.get_height();
 
+       /* The allocation will (should) be rectangualar, but make the basic
+          drawing square; space to the right of the square is for over-hanging
+          text labels.
+       */
+       width = height;
+
        if (height > 100) {
                width -= 20;
                height -= 20;
        }
 
-       x_origin = (alloc.get_width() - width) / 2;
+       /* Put the x origin to the left of the rectangular allocation */
+       x_origin = (alloc.get_width() - width) / 3;
        y_origin = (alloc.get_height() - height) / 2;
 }