audio clocks: use defined cursor color
authorPaul Davis <paul@linuxaudiosystems.com>
Sun, 20 Nov 2011 15:26:43 +0000 (15:26 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Sun, 20 Nov 2011 15:26:43 +0000 (15:26 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@10707 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/audio_clock.cc
gtk2_ardour/audio_clock.h

index e4228819610da89246bdcc9edbd674ff0de3c990..284885ad442efa83bf1a10b33483dba11a539371 100644 (file)
@@ -187,18 +187,21 @@ AudioClock::set_colors ()
        uint32_t bg_color;
        uint32_t text_color;
        uint32_t editing_color;
+       uint32_t cursor_color;
 
        if (active_state()) {
                bg_color = ARDOUR_UI::config()->color_by_name (string_compose ("%1 active: background", get_name()));
                text_color = ARDOUR_UI::config()->color_by_name (string_compose ("%1 active: text", get_name()));
                editing_color = ARDOUR_UI::config()->color_by_name (string_compose ("%1 active: edited text", get_name()));
+               cursor_color = ARDOUR_UI::config()->color_by_name (string_compose ("%1 active: cursor", get_name()));
        } else {
                bg_color = ARDOUR_UI::config()->color_by_name (string_compose ("%1: background", get_name()));
                text_color = ARDOUR_UI::config()->color_by_name (string_compose ("%1: text", get_name()));
                editing_color = ARDOUR_UI::config()->color_by_name (string_compose ("%1: edited text", get_name()));
+               cursor_color = ARDOUR_UI::config()->color_by_name (string_compose ("%1: cursor", get_name()));
        }
 
-       /* store for bg in render() */
+       /* store for bg and cursor in render() */
 
        UINT_TO_RGBA (bg_color, &r, &g, &b, &a);
 
@@ -207,6 +210,13 @@ AudioClock::set_colors ()
        bg_b = b/255.0;
        bg_a = a/255.0;
 
+       UINT_TO_RGBA (cursor_color, &r, &g, &b, &a);
+
+       cursor_r = r/255.0;
+       cursor_g = g/255.0;
+       cursor_b = b/255.0;
+       cursor_a = a/255.0;
+
        /* rescale for Pango colors ... sigh */
 
        r = lrint (r * 65535.0);
@@ -330,19 +340,33 @@ AudioClock::render (cairo_t* cr)
                if (!insert_map.empty()) {
                        Pango::Rectangle cursor = _layout->get_cursor_strong_pos (insert_map[input_string.length()]);
                        
-                       cairo_set_source_rgba (cr, 0.9, 0.1, 0.1, 0.8);
-                       cairo_rectangle (cr, 
-                                        layout_x_offset + cursor.get_x()/PANGO_SCALE + cursor_width,
-                                        (upper_height - layout_height)/2.0, 
-                                        2.0, cursor.get_height()/PANGO_SCALE);
+                       cairo_set_source_rgba (cr, cursor_r, cursor_g, cursor_b, cursor_a);
+                       if (!_fixed_width) {
+                               cairo_rectangle (cr, 
+                                                layout_x_offset + cursor.get_x()/PANGO_SCALE + cursor_width,
+                                                0,
+                                                2.0, cursor.get_height()/PANGO_SCALE);
+                       } else {
+                               cairo_rectangle (cr, 
+                                                layout_x_offset + cursor.get_x()/PANGO_SCALE + cursor_width,
+                                                (upper_height - layout_height)/2.0, 
+                                                2.0, cursor.get_height()/PANGO_SCALE);
+                       }
                        cairo_fill (cr);        
                } else {
                        if (input_string.empty()) {
-                               cairo_set_source_rgba (cr, 0.9, 0.1, 0.1, 0.8);
-                               cairo_rectangle (cr, 
-                                                (get_width()/2.0),
-                                                (upper_height - layout_height)/2.0, 
-                                                2.0, upper_height);
+                               cairo_set_source_rgba (cr, cursor_r, cursor_g, cursor_b, cursor_a);
+                               if (!_fixed_width) {
+                                       cairo_rectangle (cr, 
+                                                        (get_width()/2.0),
+                                                        0,
+                                                        2.0, upper_height);
+                               } else {
+                                       cairo_rectangle (cr, 
+                                                        (get_width()/2.0),
+                                                        (upper_height - layout_height)/2.0, 
+                                                        2.0, upper_height);
+                               }
                                cairo_fill (cr);
                        }
                }
index 651072733624b29b2aed3e6c7050098e2173880d..42f2bf88bef5a027575251a8deb0b3da2ce74173 100644 (file)
@@ -218,6 +218,7 @@ class AudioClock : public CairoWidget, public ARDOUR::SessionHandlePtr
        void dpi_reset ();
 
        double bg_r, bg_g, bg_b, bg_a;
+       double cursor_r, cursor_g, cursor_b, cursor_a;
 };
 
 #endif /* __audio_clock_h__ */