Remove internal edit mode and add "content" tool.
[ardour.git] / gtk2_ardour / mono_panner.cc
index 0fd883983a3fef98387b9604c4803f554d45335c..0d9981dcf89a123d3ad14c775dc16ad549b0a362 100644 (file)
@@ -50,6 +50,7 @@
 using namespace std;
 using namespace Gtk;
 using namespace Gtkmm2ext;
+using namespace ARDOUR_UI_UTILS;
 
 static const int pos_box_size = 9;
 static const int lr_box_size = 15;
@@ -80,18 +81,17 @@ MonoPanner::MonoPanner (boost::shared_ptr<ARDOUR::PannerShell> p)
        if (!have_font) {
                Pango::FontDescription font;
                Pango::AttrFontDesc* font_attr;
-               font = Pango::FontDescription ("ArdourMono");
-               font.set_weight (Pango::WEIGHT_BOLD);
-               font.set_size(9 * PANGO_SCALE);
+               font = Pango::FontDescription (ARDOUR_UI::config()->get_SmallBoldMonospaceFont());
                font_attr = new Pango::AttrFontDesc (Pango::Attribute::create_attr_font_desc (font));
                panner_font_attributes.change(*font_attr);
                delete font_attr;
                have_font = true;
        }
 
-       position_control->Changed.connect (connections, invalidator(*this), boost::bind (&MonoPanner::value_change, this), gui_context());
+       position_control->Changed.connect (panvalue_connections, invalidator(*this), boost::bind (&MonoPanner::value_change, this), gui_context());
 
-       _panner_shell->Changed.connect (connections, invalidator (*this), boost::bind (&MonoPanner::bypass_handler, this), gui_context());
+       _panner_shell->Changed.connect (panshell_connections, invalidator (*this), boost::bind (&MonoPanner::bypass_handler, this), gui_context());
+       _panner_shell->PannableChanged.connect (panshell_connections, invalidator (*this), boost::bind (&MonoPanner::pannable_handler, this), gui_context());
        ColorsChanged.connect (sigc::mem_fun (*this, &MonoPanner::color_handler));
 
        set_tooltip ();
@@ -157,30 +157,24 @@ MonoPanner::on_expose_event (GdkEventExpose*)
                t  = 0x606060ff;
        }
 
+       if (_send_mode) {
+               b = ARDOUR_UI::config()->color ("send bg");
+       }
        /* background */
-
        context->set_source_rgba (UINT_RGBA_R_FLT(b), UINT_RGBA_G_FLT(b), UINT_RGBA_B_FLT(b), UINT_RGBA_A_FLT(b));
        context->rectangle (0, 0, width, height);
        context->fill ();
 
+
        double usable_width = width - pos_box_size;
 
        /* compute the centers of the L/R boxes based on the current stereo width */
-
        if (fmod (usable_width,2.0) == 0) {
-               /* even width, but we need odd, so that there is an exact center.
-                        So, offset cairo by 1, and reduce effective width by 1
-                        */
                usable_width -= 1.0;
-               context->translate (1.0, 0.0);
        }
-
        const double half_lr_box = lr_box_size/2.0;
-       double left;
-       double right;
-
-       left = 4 + half_lr_box; // center of left box
-       right = width  - 4 - half_lr_box; // center of right box
+       const double left = 4 + half_lr_box; // center of left box
+       const double right = width - 4 - half_lr_box; // center of right box
 
        /* center line */
        context->set_source_rgba (UINT_RGBA_R_FLT(o), UINT_RGBA_G_FLT(o), UINT_RGBA_B_FLT(o), UINT_RGBA_A_FLT(o));
@@ -189,16 +183,17 @@ MonoPanner::on_expose_event (GdkEventExpose*)
        context->line_to ((pos_box_size/2.0) + (usable_width/2.0), height);
        context->stroke ();
 
+       context->set_line_width (1.0);
        /* left box */
 
-       rounded_rectangle (context,
-                       left - half_lr_box,
-                       half_lr_box+step_down,
+       rounded_left_half_rectangle (context,
+                       left - half_lr_box + .5,
+                       half_lr_box + step_down,
                        lr_box_size, lr_box_size, corner_radius);
-       context->set_source_rgba (UINT_RGBA_R_FLT(o), UINT_RGBA_G_FLT(o), UINT_RGBA_B_FLT(o), UINT_RGBA_A_FLT(o));
-       context->stroke_preserve ();
        context->set_source_rgba (UINT_RGBA_R_FLT(f), UINT_RGBA_G_FLT(f), UINT_RGBA_B_FLT(f), UINT_RGBA_A_FLT(f));
-       context->fill ();
+       context->fill_preserve ();
+       context->set_source_rgba (UINT_RGBA_R_FLT(o), UINT_RGBA_G_FLT(o), UINT_RGBA_B_FLT(o), UINT_RGBA_A_FLT(o));
+       context->stroke();
 
        /* add text */
        int tw, th;
@@ -212,15 +207,14 @@ MonoPanner::on_expose_event (GdkEventExpose*)
        pango_cairo_show_layout (context->cobj(), layout->gobj());
 
        /* right box */
-
-       rounded_rectangle (context,
-                       right - half_lr_box,
-                       half_lr_box+step_down,
+       rounded_right_half_rectangle (context,
+                       right - half_lr_box - .5,
+                       half_lr_box + step_down,
                        lr_box_size, lr_box_size, corner_radius);
-       context->set_source_rgba (UINT_RGBA_R_FLT(o), UINT_RGBA_G_FLT(o), UINT_RGBA_B_FLT(o), UINT_RGBA_A_FLT(o));
-       context->stroke_preserve ();
        context->set_source_rgba (UINT_RGBA_R_FLT(f), UINT_RGBA_G_FLT(f), UINT_RGBA_B_FLT(f), UINT_RGBA_A_FLT(f));
-       context->fill ();
+       context->fill_preserve ();
+       context->set_source_rgba (UINT_RGBA_R_FLT(o), UINT_RGBA_G_FLT(o), UINT_RGBA_B_FLT(o), UINT_RGBA_A_FLT(o));
+       context->stroke();
 
        /* add text */
        layout->set_text (_("R"));
@@ -230,23 +224,32 @@ MonoPanner::on_expose_event (GdkEventExpose*)
        pango_cairo_show_layout (context->cobj(), layout->gobj());
 
        /* 2 lines that connect them both */
-       context->set_source_rgba (UINT_RGBA_R_FLT(o), UINT_RGBA_G_FLT(o), UINT_RGBA_B_FLT(o), UINT_RGBA_A_FLT(o));
        context->set_line_width (1.0);
 
-       /* make the lines a little longer than they need to be, because the corners of
-                the boxes are rounded and we don't want a gap
-                */
-       context->move_to (left + half_lr_box - corner_radius, half_lr_box+step_down);
-       context->line_to (right - half_lr_box + corner_radius, half_lr_box+step_down);
-       context->stroke ();
-
+       if (_panner_shell->panner_gui_uri() != "http://ardour.org/plugin/panner_balance#ui") {
+               context->set_source_rgba (UINT_RGBA_R_FLT(o), UINT_RGBA_G_FLT(o), UINT_RGBA_B_FLT(o), UINT_RGBA_A_FLT(o));
+               context->move_to (left  + half_lr_box, half_lr_box + step_down);
+               context->line_to (right - half_lr_box, half_lr_box + step_down);
+               context->stroke ();
 
-       context->move_to (left + half_lr_box - corner_radius, half_lr_box+step_down+lr_box_size);
-       context->line_to (right - half_lr_box + corner_radius, half_lr_box+step_down+lr_box_size);
-       context->stroke ();
+               context->move_to (left  + half_lr_box, half_lr_box+step_down+lr_box_size);
+               context->line_to (right - half_lr_box, half_lr_box+step_down+lr_box_size);
+               context->stroke ();
+       } else {
+               context->move_to (left  + half_lr_box, half_lr_box+step_down+lr_box_size);
+               context->line_to (left  + half_lr_box, half_lr_box + step_down);
+               context->line_to ((pos_box_size/2.0) + (usable_width/2.0), half_lr_box+step_down+lr_box_size);
+               context->line_to (right - half_lr_box, half_lr_box + step_down);
+               context->line_to (right - half_lr_box, half_lr_box+step_down+lr_box_size);
+               context->close_path();
+
+               context->set_source_rgba (UINT_RGBA_R_FLT(f), UINT_RGBA_G_FLT(f), UINT_RGBA_B_FLT(f), UINT_RGBA_A_FLT(f));
+               context->fill_preserve ();
+               context->set_source_rgba (UINT_RGBA_R_FLT(o), UINT_RGBA_G_FLT(o), UINT_RGBA_B_FLT(o), UINT_RGBA_A_FLT(o));
+               context->stroke ();
+       }
 
        /* draw the position indicator */
-
        double spos = (pos_box_size/2.0) + (usable_width * pos);
 
        context->set_line_width (2.0);
@@ -264,9 +267,8 @@ MonoPanner::on_expose_event (GdkEventExpose*)
        context->fill ();
 
        /* marker line */
-
        context->set_line_width (1.0);
-       context->move_to (spos, pos_box_size+4);
+       context->move_to (spos, pos_box_size + 5);
        context->rel_line_to (0, half_lr_box+step_down);
        context->set_source_rgba (UINT_RGBA_R_FLT(po), UINT_RGBA_G_FLT(po), UINT_RGBA_B_FLT(po), UINT_RGBA_A_FLT(po));
        context->stroke ();
@@ -405,7 +407,7 @@ MonoPanner::on_scroll_event (GdkEventScroll* ev)
        return true;
 }
 
-       bool
+bool
 MonoPanner::on_motion_notify_event (GdkEventMotion* ev)
 {
        if (_panner_shell->bypassed()) {
@@ -445,7 +447,7 @@ MonoPanner::on_motion_notify_event (GdkEventMotion* ev)
        return true;
 }
 
-       bool
+bool
 MonoPanner::on_key_press_event (GdkEventKey* ev)
 {
        double one_degree = 1.0/180.0;
@@ -482,31 +484,41 @@ MonoPanner::on_key_press_event (GdkEventKey* ev)
        return true;
 }
 
-       void
+void
 MonoPanner::set_colors ()
 {
-       colors.fill = ARDOUR_UI::config()->canvasvar_MonoPannerFill.get();
-       colors.outline = ARDOUR_UI::config()->canvasvar_MonoPannerOutline.get();
-       colors.text = ARDOUR_UI::config()->canvasvar_MonoPannerText.get();
-       colors.background = ARDOUR_UI::config()->canvasvar_MonoPannerBackground.get();
-       colors.pos_outline = ARDOUR_UI::config()->canvasvar_MonoPannerPositionOutline.get();
-       colors.pos_fill = ARDOUR_UI::config()->canvasvar_MonoPannerPositionFill.get();
+        colors.fill = ARDOUR_UI::config()->color_mod ("mono panner fill", "panner fill");
+        colors.outline = ARDOUR_UI::config()->color ("mono panner outline");
+        colors.text = ARDOUR_UI::config()->color ("mono panner text");
+        colors.background = ARDOUR_UI::config()->color ("mono panner bg");
+        colors.pos_outline = ARDOUR_UI::config()->color ("mono panner position outline");
+        colors.pos_fill = ARDOUR_UI::config()->color_mod ("mono panner position fill", "mono panner position fill");
 }
 
-       void
+void
 MonoPanner::color_handler ()
 {
        set_colors ();
        queue_draw ();
 }
 
-       void
+void
 MonoPanner::bypass_handler ()
 {
        queue_draw ();
 }
 
-       PannerEditor*
+void
+MonoPanner::pannable_handler ()
+{
+       panvalue_connections.drop_connections();
+       position_control = _panner->pannable()->pan_azimuth_control;
+       position_binder.set_controllable(position_control);
+       position_control->Changed.connect (panvalue_connections, invalidator(*this), boost::bind (&MonoPanner::value_change, this), gui_context());
+       queue_draw ();
+}
+
+PannerEditor*
 MonoPanner::editor ()
 {
        return new MonoPannerEditor (this);