diff options
| author | Mirco Müller <mirco.mueller@ubuntu.com> | 2010-08-27 20:13:55 +0200 |
|---|---|---|
| committer | Mirco Müller <mirco.mueller@ubuntu.com> | 2010-08-27 20:13:55 +0200 |
| commit | d20acc89056d1a7ceac826f5c55042f2ec61a150 (patch) | |
| tree | 4cb2ea9ad60249e428c2804548f3d70b80c50632 /unity-private | |
| parent | f4031d0ac3f0f2c12fd8780eba9e9ac2f57cadf9 (diff) | |
added missing background-pattern to trough, added striped pattern to prelight slider, work-around state-handling for slider still not working
(bzr r473.1.1)
Diffstat (limited to 'unity-private')
| -rw-r--r-- | unity-private/places/places-default-renderer.vala | 131 |
1 files changed, 124 insertions, 7 deletions
diff --git a/unity-private/places/places-default-renderer.vala b/unity-private/places/places-default-renderer.vala index ab65b71b3..a896b68e9 100644 --- a/unity-private/places/places-default-renderer.vala +++ b/unity-private/places/places-default-renderer.vala @@ -24,13 +24,17 @@ namespace Unity.Places static const float TOP_PADDING = 22.0f; static const float PADDING = 12.0f; static const int SPACING = 0; - + static const int SLIDER_STATE_NORMAL = 0; + static const int SLIDER_STATE_PRELIGHT = 1; + static const int SLIDER_STATE_ACTIVE = 2; + private EmptySearchGroup search_empty; private EmptySectionGroup section_empty; private Ctk.ScrollView scroll; private Unity.CairoCanvas trough; private Unity.CairoCanvas slider; + private int slider_state; private Ctk.VBox box; private Dee.Model groups_model; private Dee.Model results_model; @@ -58,7 +62,12 @@ namespace Unity.Places int width, int height) { - double radius = (double) width / 2.0f; + Cairo.Surface dots = new Cairo.ImageSurface (Cairo.Format.ARGB32, + 4, + 4); + Cairo.Context cr_dots = new Cairo.Context (dots); + Cairo.Pattern dot_pattern; + double radius = (double) width / 2.0f; cr.set_operator (Cairo.Operator.CLEAR); cr.paint (); @@ -79,6 +88,30 @@ namespace Unity.Places 180.0f * GLib.Math.PI / 180.0f); cr.close_path (); cr.set_source_rgba (1.0f, 1.0f, 1.0f, 0.1f); + + // draw dotted pattern + cr_dots.set_operator (Cairo.Operator.CLEAR); + cr_dots.paint (); + cr_dots.scale (1.0f, 1.0f); + cr_dots.set_operator (Cairo.Operator.OVER); + cr_dots.set_source_rgba (1.0f, 1.0f, 1.0f, 0.025f); + cr_dots.rectangle (0.0f, 0.0f, 1.0f, 1.0f); + cr_dots.fill (); + cr_dots.rectangle (1.0f, 1.0f, 1.0f, 1.0f); + cr_dots.fill (); + cr_dots.rectangle (2.0f, 0.0f, 1.0f, 1.0f); + cr_dots.fill (); + cr_dots.rectangle (0.0f, 2.0f, 1.0f, 1.0f); + cr_dots.fill (); + cr_dots.rectangle (2.0f, 2.0f, 1.0f, 1.0f); + cr_dots.fill (); + cr_dots.rectangle (3.0f, 3.0f, 1.0f, 1.0f); + cr_dots.fill (); + + dot_pattern = new Cairo.Pattern.for_surface (dots); + cr.set_operator (Cairo.Operator.OVER); + cr.set_source (dot_pattern); + dot_pattern.set_extend (Cairo.Extend.REPEAT); cr.fill_preserve (); cr.set_source_rgba (1.0f, 1.0f, 1.0f, 0.35f); cr.stroke (); @@ -89,9 +122,14 @@ namespace Unity.Places int width, int height) { - double radius = (double) width / 2.0f; - double half = (double) width / 2.0f; - double half_height = (double) height / 2.0f; + Cairo.Surface stripes = new Cairo.ImageSurface (Cairo.Format.ARGB32, + 4, + 4); + Cairo.Context cr_stripes = new Cairo.Context (stripes); + Cairo.Pattern stripe_pattern; + double radius = (double) width / 2.0f; + double half = (double) width / 2.0f; + double half_height = (double) height / 2.0f; cr.set_operator (Cairo.Operator.CLEAR); cr.paint (); @@ -111,8 +149,47 @@ namespace Unity.Places 0.0f * GLib.Math.PI / 180.0f, 180.0f * GLib.Math.PI / 180.0f); cr.close_path (); - cr.set_source_rgba (0.0f, 0.0f, 0.0f, 0.15f); + + /*if (slider_state == SLIDER_STATE_NORMAL) + { + print ("normal state\n"); + cr.set_source_rgba (1.0f, 0.0f, 0.0f, 0.15f); + } + if (slider_state == SLIDER_STATE_PRELIGHT) + { + print ("prelight state\n"); + cr.set_source_rgba (0.0f, 1.0f, 0.0f, 0.15f); + } + if (slider_state == SLIDER_STATE_ACTIVE) + { + print ("active state\n"); + cr.set_source_rgba (0.0f, 0.0f, 1.0f, 0.15f); + }*/ + + cr.set_source_rgba (1.0f, 1.0f, 1.0f, 0.125f); + cr.fill_preserve (); + + // draw striped pattern + cr_stripes.set_operator (Cairo.Operator.CLEAR); + cr_stripes.paint (); + cr_stripes.scale (1.0f, 1.0f); + cr_stripes.set_operator (Cairo.Operator.OVER); + cr_stripes.set_source_rgba (1.0f, 1.0f, 1.0f, 0.25f); + cr_stripes.rectangle (0.0f, 0.0f, 1.0f, 1.0f); + cr_stripes.fill (); + cr_stripes.rectangle (1.0f, 1.0f, 1.0f, 1.0f); + cr_stripes.fill (); + cr_stripes.rectangle (2.0f, 2.0f, 1.0f, 1.0f); + cr_stripes.fill (); + cr_stripes.rectangle (3.0f, 3.0f, 1.0f, 1.0f); + cr_stripes.fill (); + + stripe_pattern = new Cairo.Pattern.for_surface (stripes); + cr.set_operator (Cairo.Operator.OVER); + cr.set_source (stripe_pattern); + stripe_pattern.set_extend (Cairo.Extend.REPEAT); cr.fill_preserve (); + cr.set_source_rgba (1.0f, 1.0f, 1.0f, 0.5f); cr.stroke (); @@ -126,16 +203,56 @@ namespace Unity.Places cr.stroke (); } + private bool + on_slider_enter (Clutter.Event event) + { + slider_state = SLIDER_STATE_PRELIGHT; + slider.do_queue_redraw (); + scroll.do_queue_redraw (); + return false; + } + + private bool + on_slider_leave (Clutter.Event event) + { + slider_state = SLIDER_STATE_NORMAL; + slider.do_queue_redraw (); + scroll.do_queue_redraw (); + return false; + } + + private bool + on_slider_button_press (Clutter.Event event) + { + slider_state = SLIDER_STATE_ACTIVE; + slider.do_queue_redraw (); + scroll.do_queue_redraw (); + return false; + } + + private bool + on_slider_button_release (Clutter.Event event) + { + slider_state = SLIDER_STATE_PRELIGHT; + slider.do_queue_redraw (); + scroll.do_queue_redraw (); + return false; + } + construct { padding = { PADDING, 0.0f, 0.0f, 0.0f }; trough = new Unity.CairoCanvas (trough_paint); slider = new Unity.CairoCanvas (slider_paint); + slider.enter_event.connect (on_slider_enter); + slider.leave_event.connect (on_slider_leave); + slider.button_press_event.connect (on_slider_button_press); + slider.button_release_event.connect (on_slider_button_release); + slider_state = SLIDER_STATE_NORMAL; scroll = new Ctk.ScrollView (); scroll.set_scroll_bar (trough, slider); - //slider.reactive = true; add_actor (scroll); scroll.show (); trough.show (); |
