diff options
| author | Mirco Müller <mirco.mueller@ubuntu.com> | 2010-08-26 16:16:48 +0200 |
|---|---|---|
| committer | Mirco Müller <mirco.mueller@ubuntu.com> | 2010-08-26 16:16:48 +0200 |
| commit | 8ad44d4411d42739ee9d69e84a88956c157c3e96 (patch) | |
| tree | 64a72e411d954108725aa692d139a5d7c1093efc /unity-private | |
| parent | 23d0a9508ead47da10c8774cf3b6a4f92e1e1b76 (diff) | |
put custom rendering of slider and trough into place, different states are not supported by Ctk.ScrollView yet, more pixel-tweaking could be done
(bzr r459.1.4)
Diffstat (limited to 'unity-private')
| -rw-r--r-- | unity-private/places/places-default-renderer.vala | 98 |
1 files changed, 62 insertions, 36 deletions
diff --git a/unity-private/places/places-default-renderer.vala b/unity-private/places/places-default-renderer.vala index 3613ed1d4..f55f0bf2c 100644 --- a/unity-private/places/places-default-renderer.vala +++ b/unity-private/places/places-default-renderer.vala @@ -39,17 +39,46 @@ namespace Unity.Places Object (); } + private static double + _align (double val) + { + double fract = val - (int) val; + + if (fract != 0.5f) + return (double) ((int) val + 0.5f); + else + return val; + } + private void trough_paint (Cairo.Context cr, int width, int height) { + double radius = (double) width / 2.0f; + cr.set_operator (Cairo.Operator.CLEAR); cr.paint (); + cr.set_line_width (1.0f); cr.set_operator (Cairo.Operator.OVER); - cr.set_source_rgba (1.0f, 0.0f, 0.0f, 1.0f); - cr.paint (); + cr.set_source_rgba (1.0f, 1.0f, 1.0f, 0.25f); + + cr.move_to (0.5f, radius - 0.5f); + cr.arc (radius, radius, + radius - 0.5f, + 180.0f * GLib.Math.PI / 180.0f, + 0.0f * GLib.Math.PI / 180.0f); + cr.line_to ((double) width - 0.5f, (double) height - radius - 0.5f); + cr.arc (radius, (double) height - radius - 0.5f, + radius - 0.5f, + 0.0f * GLib.Math.PI / 180.0f, + 180.0f * GLib.Math.PI / 180.0f); + cr.close_path (); + cr.set_source_rgba (1.0f, 1.0f, 1.0f, 0.1f); + cr.fill_preserve (); + cr.set_source_rgba (1.0f, 1.0f, 1.0f, 0.35f); + cr.stroke (); } private void @@ -57,43 +86,41 @@ 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; + cr.set_operator (Cairo.Operator.CLEAR); cr.paint (); + cr.set_line_width (1.0f); cr.set_operator (Cairo.Operator.OVER); - - if (this.scroll.get_state () == Ctk.ActorState.STATE_NORMAL) - cr.set_source_rgba (0.0f, 1.0f, 0.0f, 1.0f); - - if (this.scroll.get_state () == Ctk.ActorState.STATE_PRELIGHT) - cr.set_source_rgba (0.5f, 1.0f, 0.5f, 1.0f); - - if (this.scroll.get_state () == Ctk.ActorState.STATE_ACTIVE) - cr.set_source_rgba (0.75f, 1.0f, 0.75f, 1.0f); - - cr.paint (); - } + cr.set_source_rgba (1.0f, 1.0f, 1.0f, 0.75f); + + cr.move_to (0.5f, radius - 0.5f); + cr.arc (radius, radius, + radius - 0.5f, + 180.0f * GLib.Math.PI / 180.0f, + 0.0f * GLib.Math.PI / 180.0f); + cr.line_to ((double) width - 0.5f, (double) height - radius - 0.5f); + cr.arc (radius, (double) height - radius - 0.5f, + radius - 0.5f, + 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); + cr.fill_preserve (); + cr.set_source_rgba (1.0f, 1.0f, 1.0f, 0.5f); + cr.stroke (); - private void - on_scroll_state_changed () - { - switch (this.scroll.get_state ()) - { - case Ctk.ActorState.STATE_NORMAL: - print ("normal/off\n"); - scroll.do_queue_redraw (); - break; - - case Ctk.ActorState.STATE_PRELIGHT: - print ("prelight/over\n"); - scroll.do_queue_redraw (); - break; - - case Ctk.ActorState.STATE_ACTIVE: - print ("active/down\n"); - scroll.do_queue_redraw (); - break; - } + cr.set_source_rgba (1.0f, 1.0f, 1.0f, 0.75f); + cr.move_to (_align (1.0f), _align (half_height - 2.0f)); + cr.line_to (_align ((double) width - 2.0f), _align (half_height - 2.0f)); + cr.move_to (_align (1.0f), _align (half_height)); + cr.line_to (_align ((double) width - 2.0f), _align (half_height)); + cr.move_to (_align (1.0f), _align (half_height + 2.0f)); + cr.line_to (_align ((double) width - 2.0f), _align (half_height + 2.0f)); + cr.stroke (); } construct @@ -105,13 +132,12 @@ namespace Unity.Places scroll = new Ctk.ScrollView (); scroll.set_scroll_bar (trough, slider); + //slider.reactive = true; add_actor (scroll); scroll.show (); trough.show (); slider.show (); - notify["state"].connect (on_state_changed); - box = new Ctk.VBox (SPACING); box.padding = { 0.0f, PADDING, 0.0f, PADDING}; box.homogeneous = false; |
