Minor cleanup.
[ardour.git] / gtk2_ardour / panner2d.h
index 5825faf80a3ed9ca0c2f68b787fe1b7732b4cd77..4a324e4c8a2c9da0b157a32497842266a89f2982 100644 (file)
@@ -32,6 +32,8 @@
 #include <gtkmm/spinbutton.h>
 #include <gtkmm/adjustment.h>
 
+#include "pbd/cartesian.h"
+
 namespace ARDOUR {
        class Panner;
 }
@@ -53,22 +55,21 @@ class Panner2d : public Gtk::DrawingArea
        Panner2d (boost::shared_ptr<ARDOUR::Panner>, int32_t height);
        ~Panner2d ();
 
-       void allow_x_motion(bool);
-       void allow_y_motion(bool);
        void allow_target_motion (bool);
 
-       int  add_target (float x, float y);
-       int  add_puck (const char* text, float x, float y);
-       void move_puck (int, float x, float y);
+       int  add_target (const PBD::AngularVector&);
+       int  add_puck (const char* text, const PBD::AngularVector&);
+       void move_puck (int which, const PBD::AngularVector&);
        void reset (uint32_t n_inputs);
 
-       Gtk::Adjustment& azimuth (uint32_t which);
-
        boost::shared_ptr<ARDOUR::Panner> get_panner() const { return panner; }
 
        sigc::signal<void,int> PuckMoved;
        sigc::signal<void,int> TargetMoved;
 
+       void cart_to_gtk (PBD::CartesianVector&) const;
+       void gtk_to_cart (PBD::CartesianVector&) const;
+
   protected:
        bool on_expose_event (GdkEventExpose *);
        bool on_button_press_event (GdkEventButton *);
@@ -77,17 +78,25 @@ class Panner2d : public Gtk::DrawingArea
        void on_size_allocate (Gtk::Allocation& alloc);
 
   private:
-       struct Target {
-           Gtk::Adjustment x;
-           Gtk::Adjustment y;
-           Gtk::Adjustment azimuth;
-           bool visible;
-           char* text;
-
-           Target (float xa, float ya, const char* txt = 0);
-           ~Target ();
-
-           void set_text (const char*);
+       class Target {
+       public:
+               PBD::AngularVector position;
+               bool visible;
+               std::string text;
+                
+               Target (const PBD::AngularVector&, const char* txt = 0);
+               ~Target ();
+                
+               void set_text (const char*);
+               void set_selected (bool yn) {
+                       _selected = yn;
+               }
+               bool selected() const { 
+                       return _selected;
+               }
+                
+       private:
+               bool _selected;
        };
 
        boost::shared_ptr<ARDOUR::Panner> panner;
@@ -98,22 +107,19 @@ class Panner2d : public Gtk::DrawingArea
        Targets pucks;
 
        Target *drag_target;
-       int drag_x;
-       int drag_y;
+       int     drag_x;
+       int     drag_y;
        int     drag_index;
-       bool    drag_is_puck;
-       bool  allow_x;
-       bool  allow_y;
-       bool  allow_target;
-       int width;
-       int height;
+       bool    allow_target;
+       int     width;
+       int     height;
 
        bool bypassflag;
 
        gint compute_x (float);
        gint compute_y (float);
 
-       Target *find_closest_object (gdouble x, gdouble y, int& which, bool& is_puck) const;
+       Target *find_closest_object (gdouble x, gdouble y, int& which) const;
 
        gint handle_motion (gint, gint, GdkModifierType);
 
@@ -123,6 +129,11 @@ class Panner2d : public Gtk::DrawingArea
 
        PBD::ScopedConnection state_connection;
        PBD::ScopedConnection change_connection;
+
+       /* cartesian coordinates in GTK units ; adjust to same but on a circle of radius 1.0
+          and centered in the middle of our area
+       */
+       void clamp_to_circle (double& x, double& y);
 };
 
 class Panner2dWindow : public Gtk::Window
@@ -135,13 +146,13 @@ class Panner2dWindow : public Gtk::Window
   private:
        Panner2d widget;
 
-       Gtk::HBox   hpacker;
-       Gtk::VBox   button_box;
-       Gtk::Button reset_button;
+       Gtk::HBox         hpacker;
+       Gtk::VBox         button_box;
+       Gtk::Button       reset_button;
        Gtk::ToggleButton bypass_button;
        Gtk::ToggleButton mute_button;
-       Gtk::VBox   spinner_box;
-       Gtk::VBox   left_side;
+       Gtk::VBox         spinner_box;
+       Gtk::VBox         left_side;
 
        std::vector<Gtk::SpinButton*> spinners;
 };