add API to query Gtk::ComboBoxText entries
[ardour.git] / libs / gtkmm2ext / gtkmm2ext / motionfeedback.h
index cb256bed22641886f97c3a2a746968ec08400c3b..9e051b04b8738fc5bfc76f0f39458323e7b69556 100644 (file)
 #ifndef __gtkmm2ext_motion_feedback_h__
 #define __gtkmm2ext_motion_feedback_h__
 
+#include "pbd/signals.h"
+
 #include <gdkmm/pixbuf.h>
 #include <gtkmm/box.h>
+#include <gtkmm/label.h>
 #include <gtkmm/eventbox.h>
 
+#include "gtkmm2ext/visibility.h"
 #include "gtkmm2ext/binding_proxy.h"
+#include "gtkmm2ext/prolooks-helpers.h"
 
 namespace Gtk {
        class Adjustment;
@@ -33,7 +38,7 @@ namespace Gtk {
 
 namespace Gtkmm2ext {
 
-class MotionFeedback : public Gtk::VBox
+class LIBGTKMM2EXT_API MotionFeedback : public Gtk::VBox
 {
  public:
        enum Type {
@@ -44,29 +49,37 @@ class MotionFeedback : public Gtk::VBox
 
        MotionFeedback (Glib::RefPtr<Gdk::Pixbuf>, 
                        Type type,
+                       boost::shared_ptr<PBD::Controllable>,
+                       double default_value,
+                       double step_increment,
+                       double page_increment,
                        const char *widget_name = NULL,
-                       Gtk::Adjustment *adj = NULL, 
                        bool with_numeric_display = true,
                         int sub_image_width = 40,
                         int sub_image_height = 40);
        virtual ~MotionFeedback ();
 
-       void set_adjustment (Gtk::Adjustment *adj);
-       Gtk::Adjustment *get_adjustment () { return adjustment; }
+       Gtk::Widget& eventwin () { return pixwin; }
 
-       Gtk::Widget&     eventwin () { return pixwin; }
-        Gtk::SpinButton& spinner() const { return *value; }
+        boost::shared_ptr<PBD::Controllable> controllable() const;
+       virtual void set_controllable (boost::shared_ptr<PBD::Controllable> c);
 
-       gfloat lower () { return _lower; }
-       gfloat upper () { return _upper; }
-       gfloat range () { return _range; }
+        static void set_lamp_color (const std::string&);
+        
+        static Glib::RefPtr<Gdk::Pixbuf> render_pixbuf (int size);
 
-       void set_controllable (boost::shared_ptr<PBD::Controllable> c) { binding_proxy.set_controllable (c); }
+       void set_print_func(void (*pf)(char buf[32], const boost::shared_ptr<PBD::Controllable>&, void *),
+                           void *arg) {
+               print_func = pf;
+               print_arg = arg;
+       };
 
  protected:
-       gfloat _range;
-       gfloat _lower;
-       gfloat _upper;
+       boost::shared_ptr<PBD::Controllable> _controllable;
+       Gtk::Label* value;
+        double default_value;
+       double step_inc;
+       double page_inc;
 
        void pixwin_size_request (GtkRequisition *);
 
@@ -81,25 +94,39 @@ class MotionFeedback : public Gtk::VBox
        bool pixwin_expose_event (GdkEventExpose*);
        bool pixwin_scroll_event (GdkEventScroll*);
 
+       /* map a display value (0.0 .. 1.0) to a control
+          value (controllable->lower() .. controllable()->upper)
+       */
+       virtual double to_control_value (double) = 0;
+
+       /* map a control value (controllable->lower() .. controllable()->upper)
+          to a display value (0.0 .. 1.0)
+       */
+       virtual double to_display_value (double) = 0;
+       
+       virtual double adjust (double nominal_delta) = 0;
+
   private:
        Type type;
        Gtk::EventBox      pixwin;
-        Gtk::HBox*         value_packer;
-       Gtk::SpinButton*   value;
-       Gtk::Adjustment*   adjustment;
+        Gtk::EventBox*     value_packer;
        Glib::RefPtr<Gdk::Pixbuf> pixbuf;
         BindingProxy       binding_proxy;
+       static Gdk::Color* base_color;
+
+       void (*print_func) (char buf[32], const boost::shared_ptr<PBD::Controllable>&, void *);
+       void *print_arg;
+       static void default_printer (char buf[32], const boost::shared_ptr<PBD::Controllable>&, void *);
 
-        double default_value;
-       double  step_inc;
-       double page_inc;
        bool   grab_is_fine;
        double grabbed_y;
        double grabbed_x;
-       bool i_own_my_adjustment;
         int subwidth;
         int subheight;
-       void adjustment_changed ();
+       void controllable_value_changed ();
+       PBD::ScopedConnection controller_connection;
+
+        static void core_draw (cairo_t*, int, double, double, double, double, const GdkColor* bright, const GdkColor* dark);
 };
 
 } /* namespace */