new GUIs for stereo panners
authorPaul Davis <paul@linuxaudiosystems.com>
Wed, 20 Dec 2006 21:03:11 +0000 (21:03 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Wed, 20 Dec 2006 21:03:11 +0000 (21:03 +0000)
git-svn-id: svn://localhost/ardour2/trunk@1236 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/SConscript
gtk2_ardour/ardour2_ui.rc
gtk2_ardour/panner.cc [new file with mode: 0644]
gtk2_ardour/panner.h [new file with mode: 0644]
gtk2_ardour/panner_ui.cc
gtk2_ardour/panner_ui.h
libs/gtkmm2ext/barcontroller.cc
libs/gtkmm2ext/gtkmm2ext/barcontroller.h

index fe98307c2db724d9ad237007337dec06c555fb20..466713272a279042ff67ca791db14fe6ed870023 100644 (file)
@@ -167,6 +167,7 @@ new_session_dialog.cc
 option_editor.cc
 opts.cc
 pan_automation_time_axis.cc
+panner.cc
 panner2d.cc
 panner_ui.cc
 playlist_selector.cc
index 35349795e89abdad158524862c79e53169f98b36..c5da7dd2bc6878a76108fcd8d88fa4bd4abe8458 100644 (file)
@@ -968,6 +968,15 @@ style "pan_slider"
        text[INSENSITIVE] = { 0.70, 0.70, 0.70 }
        text[SELECTED] = { 0.70, 0.70, 0.70 }
        text[PRELIGHT] = { 0.70, 0.70, 0.70 }
+
+       # used to draw the triangular indicators 
+
+       base[NORMAL] = { 0.93, 0.94, 0.71 }
+       base[ACTIVE] =  {0.93, 0.94, 0.71 }
+       base[INSENSITIVE] = {0.32, 0.39, 0.45 } # matches default_base
+       base[SELECTED] = { 0.93, 0.94, 0.71 }
+       base[PRELIGHT] = { 0.93, 0.94, 0.71 }
+
 }
 
 style "region_list_whole_file"
diff --git a/gtk2_ardour/panner.cc b/gtk2_ardour/panner.cc
new file mode 100644 (file)
index 0000000..938e804
--- /dev/null
@@ -0,0 +1,113 @@
+#include <iostream>
+
+#include "panner.h"
+
+using namespace std;
+
+static const int triangle_size = 9;
+
+static void
+null_label_callback (char* buf, unsigned int bufsize)
+{
+       /* no label */
+
+       buf[0] = '\0';
+}
+
+
+PannerBar::PannerBar (Gtk::Adjustment& adj, PBD::Controllable& c)
+       : BarController (adj, c, sigc::ptr_fun (null_label_callback))
+{
+       
+}
+
+PannerBar::~PannerBar ()
+{
+}
+
+bool
+PannerBar::expose (GdkEventExpose* ev)
+{
+       Glib::RefPtr<Gdk::Window> win (darea.get_window());
+       Glib::RefPtr<Gdk::GC> gc (get_style()->get_base_gc (get_state()));
+
+       BarController::expose (ev);
+
+       /* now draw triangles for left, right and center */
+
+       GdkPoint points[3];
+
+       
+
+       points[0].x = 0;
+       points[0].y = 0;
+
+       points[1].x = triangle_size;
+       points[1].y = 0;
+       
+       points[2].x = 0;
+       points[2].y = triangle_size;
+
+       gdk_draw_polygon (win->gobj(), gc->gobj(), true, points, 3);
+
+       points[0].x = darea.get_width()/2 - (triangle_size - 2);
+       points[0].y = 0;
+
+       points[1].x = darea.get_width()/2 + (triangle_size - 2);
+       points[1].y = 0;
+       
+       points[2].x = darea.get_width()/2;
+       points[2].y = triangle_size - 2;
+
+       gdk_draw_polygon (win->gobj(), gc->gobj(), true, points, 3);
+
+       points[0].x = darea.get_width() - triangle_size;
+       points[0].y = 0;
+
+       points[1].x = darea.get_width();
+       points[1].y = 0;
+       
+       points[2].x = darea.get_width();
+       points[2].y = triangle_size;
+
+       gdk_draw_polygon (win->gobj(), gc->gobj(), true, points, 3);
+
+       return true;
+}
+
+bool
+PannerBar::button_press (GdkEventButton* ev)
+{
+       if (ev->button == 1 && ev->type == GDK_BUTTON_PRESS && ev->y < 10) {
+               if (ev->x < triangle_size) {
+                       return true;
+               } else if (ev->x > (darea.get_width() - triangle_size)) {
+                       return true;
+               } else if (ev->x > (darea.get_width()/2 - triangle_size) &&
+                          ev->x < (darea.get_width()/2 + triangle_size)) {
+                       return true;
+               }
+       }
+
+       return BarController::button_press (ev);
+}
+
+bool
+PannerBar::button_release (GdkEventButton* ev)
+{
+       if (ev->button == 1 && ev->type == GDK_BUTTON_RELEASE && ev->y < 10) {
+               if (ev->x < triangle_size) {
+                       adjustment.set_value (adjustment.get_lower());
+                       return true;
+               } else if (ev->x > (darea.get_width() - triangle_size)) {
+                       adjustment.set_value (adjustment.get_upper());
+                       return true;
+               } else if (ev->x > (darea.get_width()/2 - triangle_size) &&
+                          ev->x < (darea.get_width()/2 + triangle_size)) {
+                       adjustment.set_value (adjustment.get_lower() + ((adjustment.get_upper() - adjustment.get_lower()) / 2.0));
+                       return true;
+               }
+       }
+
+       return BarController::button_release (ev);
+}
diff --git a/gtk2_ardour/panner.h b/gtk2_ardour/panner.h
new file mode 100644 (file)
index 0000000..d06a4c2
--- /dev/null
@@ -0,0 +1,18 @@
+#ifndef __gtk_ardour_panner_h__
+#define __gtk_ardour_panner_h__
+
+#include <gtkmm2ext/barcontroller.h>
+
+class PannerBar : public Gtkmm2ext::BarController
+{
+  public:
+       PannerBar (Gtk::Adjustment& adj, PBD::Controllable&);
+       ~PannerBar ();
+
+  protected:
+       bool expose (GdkEventExpose*);
+       bool button_press (GdkEventButton*);
+       bool button_release (GdkEventButton*);
+};
+
+#endif /* __gtk_ardour_panner_h__ */
index ccce2ec9f16ff1092ba66b4569ebb430abbbe280..b12013e9eec2f7905fcfd573c84afbc32b12811f 100644 (file)
@@ -30,6 +30,7 @@
 #include "panner_ui.h"
 #include "panner2d.h"
 #include "utils.h"
+#include "panner.h"
 #include "gui_thread.h"
 
 #include <ardour/session.h>
@@ -217,7 +218,7 @@ PannerUI::set_width (Width w)
                if (panner) {
                        panner->set_size_request (61, 61);
                }
-               for (vector<BarController*>::iterator i = pan_bars.begin(); i != pan_bars.end(); ++i) {
+               for (vector<PannerBar*>::iterator i = pan_bars.begin(); i != pan_bars.end(); ++i) {
                                (*i)->set_size_request (61, 15);
                }
                panning_link_button.set_label (_("link"));
@@ -227,7 +228,7 @@ PannerUI::set_width (Width w)
                if (panner) {
                        panner->set_size_request (31, 61);
                }
-               for (vector<BarController*>::iterator i = pan_bars.begin(); i != pan_bars.end(); ++i) {
+               for (vector<PannerBar*>::iterator i = pan_bars.begin(); i != pan_bars.end(); ++i) {
                                (*i)->set_size_request (31, 15);
                }
                panning_link_button.set_label (_("L"));
@@ -244,7 +245,7 @@ PannerUI::~PannerUI ()
                delete (*i);
        }
        
-       for (vector<BarController*>::iterator i = pan_bars.begin(); i != pan_bars.end(); ++i) {
+       for (vector<PannerBar*>::iterator i = pan_bars.begin(); i != pan_bars.end(); ++i) {
                delete (*i);
        }
 
@@ -302,7 +303,7 @@ PannerUI::setup_pan ()
                while ((asz = pan_adjustments.size()) < npans) {
 
                        float x;
-                       BarController* bc;
+                       PannerBar* bc;
 
                        /* initialize adjustment with current value of panner */
 
@@ -313,9 +314,7 @@ PannerUI::setup_pan ()
 
                        _io->panner()[asz]->Changed.connect (bind (mem_fun(*this, &PannerUI::pan_value_changed), (uint32_t) asz));
 
-                       bc = new BarController (*pan_adjustments[asz], 
-                                               _io->panner()[asz]->control(),
-                                               bind (mem_fun(*this, &PannerUI::pan_printer), pan_adjustments[asz]));
+                       bc = new PannerBar (*pan_adjustments[asz], _io->panner()[asz]->control());
                        
                        bc->set_name ("PanSlider");
                        bc->set_shadow_type (Gtk::SHADOW_NONE);
@@ -341,7 +340,7 @@ PannerUI::setup_pan ()
                                break;
                        }
 
-                       pan_bar_packer.pack_start (*pan_bars.back(), false, false);
+                       pan_bar_packer.pack_start (*pan_bars.back(), true, true);
                }
 
                /* now that we actually have the pan bars,
@@ -631,7 +630,7 @@ PannerUI::update_pan_sensitive ()
        case 1:
                break;
        case 2:
-               for (vector<BarController*>::iterator i = pan_bars.begin(); i != pan_bars.end(); ++i) {
+               for (vector<PannerBar*>::iterator i = pan_bars.begin(); i != pan_bars.end(); ++i) {
                        (*i)->set_sensitive (sensitive);
                }
                break;
index 76589782331ea7e4f53ff063291ae765e2117f93..b4547a4a0e5fff764161ebfbd06d430bc871eb37 100644 (file)
@@ -37,6 +37,7 @@
 #include "enums.h"
 
 class Panner2d;
+class PannerBar;
 
 namespace ARDOUR {
        class IO;
@@ -44,7 +45,6 @@ namespace ARDOUR {
 }
 namespace Gtkmm2ext {
        class FastMeter;
-       class BarController;
 }
 
 namespace Gtk {
@@ -107,7 +107,7 @@ class PannerUI : public Gtk::HBox
        void panning_link_direction_clicked ();
 
        vector<Gtk::Adjustment*> pan_adjustments;
-       vector<Gtkmm2ext::BarController*> pan_bars;
+       vector<PannerBar*> pan_bars;
 
        void pan_adjustment_changed (uint32_t which);
        void pan_value_changed (uint32_t which);
index 734c4b77e283874204884d5b6f6fda2a35acd482..fcd6476772c23654ece25503f40d0947b1b1e58f 100644 (file)
@@ -456,3 +456,10 @@ BarController::set_use_parent (bool yn)
        use_parent = yn;
        queue_draw ();
 }
+
+void
+BarController::set_sensitive (bool yn)
+{
+       Frame::set_sensitive (yn);
+       darea.set_sensitive (yn);
+}
index ebce4e2de925e79192a0f6eac8d4149dfb14afa4..a6883238ea6fadc7715518cdf2ebd93699b2504e 100644 (file)
@@ -35,10 +35,6 @@ class BarController : public Gtk::Frame
        BarController (Gtk::Adjustment& adj, PBD::Controllable&, sigc::slot<void,char*,unsigned int>);
        virtual ~BarController () {}
        
-       void set_sensitive (bool yn) {
-               darea.set_sensitive (yn);
-       }
-       
        enum Style {
                LeftToRight,
                RightToLeft,
@@ -53,6 +49,8 @@ class BarController : public Gtk::Frame
        void set_with_text (bool yn);
        void set_use_parent (bool yn);
 
+       void set_sensitive (bool yn);
+
        Gtk::SpinButton& get_spin_button() { return spinner; }
 
        sigc::signal<void> StartGesture;
@@ -79,12 +77,12 @@ class BarController : public Gtk::Frame
        Gtk::SpinButton     spinner;
        bool                use_parent;
 
-       bool button_press (GdkEventButton *);
-       bool button_release (GdkEventButton *);
-       bool motion (GdkEventMotion *);
-       bool expose (GdkEventExpose *);
-       bool scroll (GdkEventScroll *);
-       bool entry_focus_out (GdkEventFocus*);
+       virtual bool button_press (GdkEventButton *);
+       virtual bool button_release (GdkEventButton *);
+       virtual bool motion (GdkEventMotion *);
+       virtual bool expose (GdkEventExpose *);
+       virtual bool scroll (GdkEventScroll *);
+       virtual bool entry_focus_out (GdkEventFocus*);
 
        gint mouse_control (double x, GdkWindow* w, double scaling);