Missing file.
[ardour.git] / libs / gtkmm2ext / barcontroller.cc
index 75e5d4e7d679ff9c7b8ace9443b3b2bd613d1555..59c313621ea66b24df847b2585d81d731e79cfd8 100644 (file)
@@ -79,7 +79,7 @@ BarController::BarController (Gtk::Adjustment& adj,
        spinner.signal_focus_out_event().connect (mem_fun (*this, &BarController::entry_focus_out));
        spinner.signal_input().connect (mem_fun (*this, &BarController::entry_input));
        spinner.signal_output().connect (mem_fun (*this, &BarController::entry_output));
-       spinner.set_digits (3);
+       spinner.set_digits (9);
        spinner.set_numeric (true);
 
        add (darea);
@@ -244,16 +244,17 @@ BarController::mouse_control (double x, GdkWindow* window, double scaling)
 
        delta = x - grab_x;
        grab_x = x;
-
+        
        switch (_style) {
        case Line:
+       case Blob:
        case LeftToRight:
+        case CenterOut:
                fract = scaling * (delta / (darea.get_width() - 2));
                fract = min (1.0, fract);
                fract = max (-1.0, fract);
                adjustment.set_value (adjustment.get_value() + fract * (adjustment.get_upper() - adjustment.get_lower()));
                break;
-
        default:
                fract = 0.0;
        }
@@ -266,10 +267,13 @@ bool
 BarController::expose (GdkEventExpose* /*event*/)
 {
        Glib::RefPtr<Gdk::Window> win (darea.get_window());
+        Cairo::RefPtr<Cairo::Context> context = win->create_cairo_context();
+        Gdk::Color c;
        Widget* parent;
        gint x1=0, x2=0, y1=0, y2=0;
        gint w, h;
        double fract;
+        float r, g, b;
 
        fract = ((adjustment.get_value() - adjustment.get_lower()) /
                 (adjustment.get_upper() - adjustment.get_lower()));
@@ -283,26 +287,108 @@ BarController::expose (GdkEventExpose* /*event*/)
                y1 = 0;
                y2 = h - 1;
 
+               if (use_parent) {
+                       parent = get_parent();
+                        
+                       if (parent) {
+                                c = parent->get_style()->get_fg (parent->get_state());
+                                r = c.get_red_p ();
+                                g = c.get_green_p ();
+                                b = c.get_blue_p ();
+                                context->set_source_rgb (r, g, b);
+                                context->rectangle (0, 0, darea.get_width(), darea.get_height());
+                                context->fill ();
+                       }
+
+               } else {
+
+                        c = get_style()->get_bg (get_state());
+                        r = c.get_red_p ();
+                        g = c.get_green_p ();
+                        b = c.get_blue_p ();
+                        context->set_source_rgb (r, g, b);
+                        context->rectangle (0, 0, darea.get_width() - ((darea.get_width()+1) % 2), darea.get_height());
+                        context->fill ();
+               }
+                
+                c = get_style()->get_fg (get_state());
+                r = c.get_red_p ();
+                g = c.get_green_p ();
+                b = c.get_blue_p ();
+                context->set_source_rgb (r, g, b);
+                context->move_to (x1, 0);
+                context->line_to (x1, h);
+                context->stroke ();
+               break;
+
+        case Blob:
+               w = darea.get_width() - 1;
+               h = darea.get_height();
+               x1 = (gint) floor (w * fract);
+               x2 = min (w-2,h-2);
+
                if (use_parent) {
                        parent = get_parent();
                        
                        if (parent) {
-                               win->draw_rectangle (parent->get_style()->get_fg_gc (parent->get_state()),
-                                                    true,
-                                                    0, 0, darea.get_width(), darea.get_height());
+                                c = parent->get_style()->get_fg (parent->get_state());
+                                r = c.get_red_p ();
+                                g = c.get_green_p ();
+                                b = c.get_blue_p ();
+                                context->set_source_rgb (r, g, b);
+                                context->rectangle (0, 0, darea.get_width(), darea.get_height());
+                                context->fill ();
                        }
 
                } else {
 
-                       win->draw_rectangle (get_style()->get_bg_gc (get_state()),
-                                            true,
-                                            0, 0, darea.get_width() - ((darea.get_width()+1) % 2), darea.get_height());
+                        c = get_style()->get_bg (get_state());
+                        r = c.get_red_p ();
+                        g = c.get_green_p ();
+                        b = c.get_blue_p ();
+                        context->set_source_rgb (r, g, b);
+                        context->rectangle (0, 0, darea.get_width() - ((darea.get_width()+1) % 2), darea.get_height());
+                        context->fill ();
                }
                
-               win->draw_line (get_style()->get_fg_gc (get_state()), x1, 0, x1, h);
+                c = get_style()->get_fg (get_state());
+                r = c.get_red_p ();
+                g = c.get_green_p ();
+                b = c.get_blue_p ();
+                context->arc (x1, ((h-2)/2)-1, x2, 0, 2*M_PI);
                break;
 
        case CenterOut:
+               w = darea.get_width();
+               h = darea.get_height()-2;
+                if (use_parent) {
+                        parent = get_parent();
+                        if (parent) {
+                                c = parent->get_style()->get_fg (parent->get_state());
+                                r = c.get_red_p ();
+                                g = c.get_green_p ();
+                                b = c.get_blue_p ();
+                                context->set_source_rgb (r, g, b);
+                                context->rectangle (0, 0, darea.get_width(), darea.get_height());
+                                context->fill ();
+                        }
+                } else {
+                        c = get_style()->get_bg (get_state());
+                        r = c.get_red_p ();
+                        g = c.get_green_p ();
+                        b = c.get_blue_p ();
+                        context->set_source_rgb (r, g, b);
+                        context->rectangle (0, 0, darea.get_width(), darea.get_height());
+                        context->fill ();
+                }
+                c = get_style()->get_fg (get_state());
+                r = c.get_red_p ();
+                g = c.get_green_p ();
+                b = c.get_blue_p ();
+                x1 = (w/2) - ((w*fract)/2); // center, back up half the bar width
+                context->set_source_rgb (r, g, b);
+                context->rectangle (x1, 1, w*fract, h);
+                context->fill ();
                break;
 
        case LeftToRight:
@@ -313,29 +399,37 @@ BarController::expose (GdkEventExpose* /*event*/)
                x1 = 0;
                x2 = (gint) floor (w * fract);
                y1 = 0;
-               y2 = h - 1;
+               y2 = h;
+
+                /* bounding box */
 
-               win->draw_rectangle (get_style()->get_bg_gc (get_state()),
-                                   false,
-                                   0, 0, darea.get_width() - 1, darea.get_height() - 1);
+                c = get_style()->get_bg (get_state());
+                r = c.get_red_p ();
+                g = c.get_green_p ();
+                b = c.get_blue_p ();
+                context->set_source_rgb (r, g, b);
+                rounded_rectangle (context, 0, 0, darea.get_width(), darea.get_height());
+                context->stroke ();
 
                /* draw active box */
 
-               win->draw_rectangle (get_style()->get_fg_gc (get_state()),
-                                   true,
-                                   1 + x1,
-                                   1 + y1,
-                                   x2,
-                                   1 + y2);
-               
+                c = get_style()->get_fg (get_state());
+                r = c.get_red_p ();
+                g = c.get_green_p ();
+                b = c.get_blue_p ();
+                context->set_source_rgb (r, g, b);
+                rounded_rectangle (context, 1 + x1, 1 + y1, x2, y2);
+                context->fill ();
+
                /* draw inactive box */
 
-               win->draw_rectangle (get_style()->get_fg_gc (STATE_INSENSITIVE),
-                                   true,
-                                   1 + x2,
-                                   1 + y1,
-                                   w - x2,
-                                   1 + y2);
+                c = get_style()->get_fg (STATE_INSENSITIVE);
+                r = c.get_red_p ();
+                g = c.get_green_p ();
+                b = c.get_blue_p ();
+                context->set_source_rgb (r, g, b);
+                rounded_rectangle (context, 1 + x2, 1 + y1, w - x2, y2);
+                context->fill ();
 
                break;
 
@@ -349,25 +443,30 @@ BarController::expose (GdkEventExpose* /*event*/)
 
        /* draw label */
 
-       int xpos = -1;
+       double xpos = -1;
        std::string const label = get_label (xpos);
 
        if (!label.empty()) {
                
                layout->set_text (label);
                
-               int width, height;
+               int width, height, x;
                layout->get_pixel_size (width, height);
 
                if (xpos == -1) {
-                       xpos = max (3, 1 + (x2 - (width/2)));
-                       xpos = min (darea.get_width() - width - 3, xpos);
-               }
-               
-               win->draw_layout (get_style()->get_text_gc (get_state()),
-                                 xpos,
-                                 (darea.get_height()/2) - (height/2),
-                                 layout);
+                       x = max (3, 1 + (x2 - (width/2)));
+                       x = min (darea.get_width() - width - 3, (int) lrint (xpos));
+               } else {
+                        x = lrint (darea.get_width() * xpos);
+                }
+
+                c = get_style()->get_text (get_state());
+                r = c.get_red_p ();
+                g = c.get_green_p ();
+                b = c.get_blue_p ();
+                context->set_source_rgb (r, g, b);
+                context->move_to (x, (darea.get_height()/2) - (height/2));
+                layout->show_in_cairo_context (context);
        }
        
        return true;
@@ -398,6 +497,9 @@ BarController::switch_to_bar ()
        darea.show ();
 
        switching = false;
+
+       SpinnerActive (false); /* EMIT SIGNAL */
+       
        return FALSE;
 }
 
@@ -421,6 +523,9 @@ BarController::switch_to_spinner ()
        spinner.grab_focus ();
 
        switching = false;
+
+       SpinnerActive (true); /* EMIT SIGNAL */
+
        return FALSE;
 }