Merge lp:~cimi/overlay-scrollbar/new-visuals into lp:overlay-scrollbar

Proposed by Andrea Cimitan
Status: Merged
Merged at revision: 326
Proposed branch: lp:~cimi/overlay-scrollbar/new-visuals
Merge into: lp:overlay-scrollbar
Diff against target: 343 lines (+113/-69)
3 files modified
os/os-private.h (+1/-1)
os/os-scrollbar.c (+1/-1)
os/os-thumb.c (+111/-67)
To merge this branch: bzr merge lp:~cimi/overlay-scrollbar/new-visuals
Reviewer Review Type Date Requested Status
Alberto Ruiz (community) Approve
Ayatana Scrollbar Team Pending
Review via email: mp+86260@code.launchpad.net

Description of the change

Some changes to visuals, bigger thumbs too

To post a comment you must log in.
Revision history for this message
Alberto Ruiz (alberto.ruiz) wrote :

Changes look good to me, mostly changes in rendering besides the new action enumeration/variable. I don't see anything risky or wrong here. Approved.

review: Approve
329. By Andrea Cimitan

More tweaks

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'os/os-private.h'
--- os/os-private.h 2011-10-20 20:05:45 +0000
+++ os/os-private.h 2011-12-20 14:36:31 +0000
@@ -35,7 +35,7 @@
3535
36/* Size of the thumb in pixels. */36/* Size of the thumb in pixels. */
37#define MIN_THUMB_HEIGHT 3537#define MIN_THUMB_HEIGHT 35
38#define THUMB_WIDTH 1738#define THUMB_WIDTH 21
39#define THUMB_HEIGHT 6839#define THUMB_HEIGHT 68
4040
41/* Number of tolerance pixels on pageup/down, while intercepting a motion-notify-event. */41/* Number of tolerance pixels on pageup/down, while intercepting a motion-notify-event. */
4242
=== modified file 'os/os-scrollbar.c'
--- os/os-scrollbar.c 2011-12-05 16:45:35 +0000
+++ os/os-scrollbar.c 2011-12-20 14:36:31 +0000
@@ -38,7 +38,7 @@
38#define BAR_SIZE 338#define BAR_SIZE 3
3939
40/* Size of the proximity effect in pixels. */40/* Size of the proximity effect in pixels. */
41#define PROXIMITY_SIZE 3041#define PROXIMITY_SIZE 34
4242
43/* Max duration of the scrolling. */43/* Max duration of the scrolling. */
44#define MAX_DURATION_SCROLLING 100044#define MAX_DURATION_SCROLLING 1000
4545
=== modified file 'os/os-thumb.c'
--- os/os-thumb.c 2011-10-20 20:05:45 +0000
+++ os/os-thumb.c 2011-12-20 14:36:31 +0000
@@ -369,8 +369,6 @@
369/* Draw a grip using cairo. */369/* Draw a grip using cairo. */
370static void370static void
371draw_grip (cairo_t *cr,371draw_grip (cairo_t *cr,
372 const GdkRGBA *color1,
373 const GdkRGBA *color2,
374 gdouble x,372 gdouble x,
375 gdouble y,373 gdouble y,
376 gint nx,374 gint nx,
@@ -385,13 +383,7 @@
385 gint sx = lx * 3;383 gint sx = lx * 3;
386 gint sy = ly * 3;384 gint sy = ly * 3;
387385
388 cairo_set_source_rgba (cr, color2->red, color2->green, color2->blue, color2->alpha);
389 cairo_rectangle (cr, x + sx, y + sy, 2, 2);
390 cairo_fill (cr);
391
392 cairo_set_source_rgba (cr, color1->red, color1->green, color1->blue, color1->alpha);
393 cairo_rectangle (cr, x + sx, y + sy, 1, 1);386 cairo_rectangle (cr, x + sx, y + sy, 1, 1);
394 cairo_fill (cr);
395 }387 }
396 }388 }
397}389}
@@ -636,6 +628,13 @@
636}628}
637#endif629#endif
638630
631enum {
632 ACTION_NORMAL,
633 ACTION_DRAG,
634 ACTION_PAGE_UP,
635 ACTION_PAGE_DOWN
636};
637
639static gboolean638static gboolean
640#ifdef USE_GTK3639#ifdef USE_GTK3
641os_thumb_draw (GtkWidget *widget,640os_thumb_draw (GtkWidget *widget,
@@ -659,6 +658,7 @@
659 cairo_pattern_t *pat;658 cairo_pattern_t *pat;
660 gint width, height;659 gint width, height;
661 gint radius;660 gint radius;
661 gint action;
662662
663 thumb = OS_THUMB (widget);663 thumb = OS_THUMB (widget);
664 priv = thumb->priv;664 priv = thumb->priv;
@@ -704,6 +704,19 @@
704 cairo_set_line_width (cr, 1.0);704 cairo_set_line_width (cr, 1.0);
705 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);705 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
706706
707 /* Type of action. */
708 action = ACTION_NORMAL;
709 if (priv->event & OS_EVENT_BUTTON_PRESS)
710 {
711 if (priv->event & OS_EVENT_MOTION_NOTIFY)
712 action = ACTION_DRAG;
713 else if ((priv->orientation == GTK_ORIENTATION_VERTICAL && (priv->pointer.y < height / 2)) ||
714 (priv->orientation == GTK_ORIENTATION_HORIZONTAL && (priv->pointer.x < width / 2)))
715 action = ACTION_PAGE_UP;
716 else
717 action = ACTION_PAGE_DOWN;
718 }
719
707 /* Background. */720 /* Background. */
708 draw_round_rect (cr, 0, 0, width, height, radius);721 draw_round_rect (cr, 0, 0, width, height, radius);
709722
@@ -711,52 +724,52 @@
711 cairo_fill_preserve (cr);724 cairo_fill_preserve (cr);
712725
713 /* Background pattern from top to bottom. */726 /* Background pattern from top to bottom. */
714 shade_gdk_rgba (&bg, 1.3, &bg_arrow_up);727 shade_gdk_rgba (&bg, 0.86, &bg_arrow_up);
715 shade_gdk_rgba (&bg, 0.7, &bg_arrow_down);728 shade_gdk_rgba (&bg, 1.1, &bg_arrow_down);
716729
717 if (priv->orientation == GTK_ORIENTATION_VERTICAL)730 if (priv->orientation == GTK_ORIENTATION_VERTICAL)
718 pat = cairo_pattern_create_linear (0, 0, 0, height);731 pat = cairo_pattern_create_linear (0, 0, 0, height);
719 else732 else
720 pat = cairo_pattern_create_linear (0, 0, width, 0);733 pat = cairo_pattern_create_linear (0, 0, width, 0);
721734
722 if ((priv->event & OS_EVENT_BUTTON_PRESS) &&735 pattern_add_gdk_rgba_stop (pat, 0.0, &bg_arrow_up, 0.8);
723 !(priv->event & OS_EVENT_MOTION_NOTIFY))736 pattern_add_gdk_rgba_stop (pat, 1.0, &bg_arrow_down, 0.8);
724 {737
725 if ((priv->orientation == GTK_ORIENTATION_VERTICAL && (priv->pointer.y < height / 2)) ||
726 (priv->orientation == GTK_ORIENTATION_HORIZONTAL && (priv->pointer.x < width / 2)))
727 {
728 pattern_add_gdk_rgba_stop (pat, 0.0, &bg_arrow_down, 0.6);
729 pattern_add_gdk_rgba_stop (pat, 0.49, &bg_arrow_down, 0.1);
730 pattern_add_gdk_rgba_stop (pat, 0.49, &bg_arrow_down, 0.1);
731 pattern_add_gdk_rgba_stop (pat, 1.0, &bg_arrow_down, 0.8);
732 }
733 else
734 {
735 pattern_add_gdk_rgba_stop (pat, 0.0, &bg_arrow_up, 0.8);
736 pattern_add_gdk_rgba_stop (pat, 0.49, &bg_arrow_up, 0.1);
737 pattern_add_gdk_rgba_stop (pat, 0.49, &bg_arrow_down, 0.2);
738 pattern_add_gdk_rgba_stop (pat, 1.0, &bg_arrow_down, 1.0);
739 }
740 }
741 else
742 {
743 pattern_add_gdk_rgba_stop (pat, 0.0, &bg_arrow_up, 0.8);
744 pattern_add_gdk_rgba_stop (pat, 0.49, &bg_arrow_up, 0.1);
745 pattern_add_gdk_rgba_stop (pat, 0.49, &bg_arrow_down, 0.1);
746 pattern_add_gdk_rgba_stop (pat, 1.0, &bg_arrow_down, 0.8);
747 }
748 cairo_set_source (cr, pat);738 cairo_set_source (cr, pat);
749 cairo_pattern_destroy (pat);739 cairo_pattern_destroy (pat);
750740
751 if (priv->event & OS_EVENT_MOTION_NOTIFY)741 if (action == ACTION_DRAG)
752 {742 {
753 cairo_fill_preserve (cr);743 cairo_fill_preserve (cr);
754 set_source_gdk_rgba (cr, &bg_arrow_down, 0.3);744 set_source_gdk_rgba (cr, &bg, 0.8);
755 cairo_fill (cr);745 cairo_fill (cr);
756 }746 }
757 else747 else
758 cairo_fill (cr);748 cairo_fill (cr);
759749
750 /* Page up or down pressed buttons. */
751 if (action == ACTION_PAGE_UP ||
752 action == ACTION_PAGE_DOWN)
753 {
754 if (priv->orientation == GTK_ORIENTATION_VERTICAL)
755 {
756 if (action == ACTION_PAGE_UP)
757 cairo_rectangle (cr, 0, 0, width, height / 2);
758 else
759 cairo_rectangle (cr, 0, height / 2, width, height / 2);
760 }
761 else
762 {
763 if (action == ACTION_PAGE_UP)
764 cairo_rectangle (cr, 0, 0, width / 2, height);
765 else
766 cairo_rectangle (cr, width / 2, 0, width / 2, height);
767 }
768
769 set_source_gdk_rgba (cr, &bg, 0.8);
770 cairo_fill (cr);
771 }
772
760 /* 2px fat border around the thumb. */773 /* 2px fat border around the thumb. */
761 cairo_save (cr);774 cairo_save (cr);
762775
@@ -773,75 +786,106 @@
773 /* 1px subtle shadow around the background. */786 /* 1px subtle shadow around the background. */
774 shade_gdk_rgba (&bg, 0.2, &bg_shadow);787 shade_gdk_rgba (&bg, 0.2, &bg_shadow);
775788
789 if (priv->orientation == GTK_ORIENTATION_VERTICAL)
790 pat = cairo_pattern_create_linear (0, 0, 0, height);
791 else
792 pat = cairo_pattern_create_linear (0, 0, width, 0);
793
794 pattern_add_gdk_rgba_stop (pat, 0.5, &bg_shadow, 0.06);
795 switch (action)
796 {
797 default:
798 case ACTION_NORMAL:
799 pattern_add_gdk_rgba_stop (pat, 0.0, &bg_shadow, 0.22);
800 pattern_add_gdk_rgba_stop (pat, 1.0, &bg_shadow, 0.22);
801 break;
802 case ACTION_DRAG:
803 pattern_add_gdk_rgba_stop (pat, 0.0, &bg_shadow, 0.2);
804 pattern_add_gdk_rgba_stop (pat, 1.0, &bg_shadow, 0.2);
805 break;
806 case ACTION_PAGE_UP:
807 pattern_add_gdk_rgba_stop (pat, 0.0, &bg_shadow, 0.1);
808 pattern_add_gdk_rgba_stop (pat, 1.0, &bg_shadow, 0.22);
809 break;
810 case ACTION_PAGE_DOWN:
811 pattern_add_gdk_rgba_stop (pat, 0.0, &bg_shadow, 0.22);
812 pattern_add_gdk_rgba_stop (pat, 1.0, &bg_shadow, 0.1);
813 break;
814 }
815
816 cairo_set_source (cr, pat);
817 cairo_pattern_destroy (pat);
818
776 draw_round_rect (cr, 1, 1, width - 2, height - 2, radius);819 draw_round_rect (cr, 1, 1, width - 2, height - 2, radius);
777 set_source_gdk_rgba (cr, &bg_shadow, 0.26);
778 cairo_stroke (cr);820 cairo_stroke (cr);
779821
780 /* 1px frame around the background. */822 /* 1px frame around the background. */
781 shade_gdk_rgba (&bg, 0.6, &bg_dark_line);823 shade_gdk_rgba (&bg, 0.6, &bg_dark_line);
824 shade_gdk_rgba (&bg, 1.2, &bg_bright_line);
782825
783 draw_round_rect (cr, 2, 2, width - 4, height - 4, radius - 1);826 draw_round_rect (cr, 2, 2, width - 4, height - 4, radius - 1);
784 set_source_gdk_rgba (cr, &bg_dark_line, 0.26);827 set_source_gdk_rgba (cr, &bg_bright_line, 0.6);
785 cairo_stroke (cr);828 cairo_stroke (cr);
786829
787 shade_gdk_rgba (&bg, 1.2, &bg_bright_line);
788
789 /* Only draw the grip when the thumb is at full height. */830 /* Only draw the grip when the thumb is at full height. */
790 if ((priv->orientation == GTK_ORIENTATION_VERTICAL && height == THUMB_HEIGHT - 1) ||831 if ((priv->orientation == GTK_ORIENTATION_VERTICAL && height == THUMB_HEIGHT - 1) ||
791 (priv->orientation == GTK_ORIENTATION_HORIZONTAL && width == THUMB_HEIGHT - 1) )832 (priv->orientation == GTK_ORIENTATION_HORIZONTAL && width == THUMB_HEIGHT - 1) )
792 {833 {
793 GdkRGBA grip_dot_up, grip_dot_down, grip_inset_up, grip_inset_down;834 if (priv->orientation == GTK_ORIENTATION_VERTICAL)
835 pat = cairo_pattern_create_linear (0, 0, 0, height);
836 else
837 pat = cairo_pattern_create_linear (0, 0, width, 0);
794838
795 grip_dot_up = bg_dark_line;839 pattern_add_gdk_rgba_stop (pat, 0.0, &bg_dark_line, 0.0);
796 grip_dot_up.alpha = 0.74;840 pattern_add_gdk_rgba_stop (pat, 0.49, &bg_dark_line, 0.36);
797 grip_dot_down = bg_dark_line;841 pattern_add_gdk_rgba_stop (pat, 0.49, &bg_dark_line, 0.36);
798 grip_dot_down.alpha = 0.86;842 pattern_add_gdk_rgba_stop (pat, 1.0, &bg_dark_line, 0.0);
799 grip_inset_up = bg_bright_line;843 cairo_set_source (cr, pat);
800 grip_inset_up.alpha = priv->event & OS_EVENT_BUTTON_PRESS ? 0.62 : 1.0;844 cairo_pattern_destroy (pat);
801 grip_inset_down = bg_bright_line;
802 grip_inset_down.alpha = 0.36;
803845
804 /* Grip. */846 /* Grip. */
805 if (priv->orientation == GTK_ORIENTATION_VERTICAL)847 if (priv->orientation == GTK_ORIENTATION_VERTICAL)
806 {848 {
807 /* Page UP. */849 /* Page UP. */
808 draw_grip (cr, &grip_dot_up, &grip_inset_up, 4.5, 15.5, 3, 5);850 draw_grip (cr, width / 2 - 6.5, 13.5, 5, 6);
809851
810 /* Page DOWN. */852 /* Page DOWN. */
811 draw_grip (cr, &grip_dot_down, &grip_inset_down, 4.5, height / 2 + 4.5, 3, 5);853 draw_grip (cr, width / 2 - 6.5, height / 2 + 3.5, 5, 6);
812 }854 }
813 else855 else
814 {856 {
815 /* Page UP. */857 /* Page UP. */
816 draw_grip (cr, &grip_dot_up, &grip_inset_up, 15.5, 4.5, 5, 3);858 draw_grip (cr, 16.5, height / 2 - 6.5, 5, 6);
817859
818 /* Page DOWN. */860 /* Page DOWN. */
819 draw_grip (cr, &grip_dot_down, &grip_inset_down, width / 2 + 4.5, 4.5, 5, 3);861 draw_grip (cr, width / 2 + 3.5, height / 2 - 6.5, 5, 6);
820 }862 }
863
864 cairo_fill (cr);
821 }865 }
822866
823 /* Separators between the two steppers. */867 /* Separators between the two steppers. */
824 if (priv->orientation == GTK_ORIENTATION_VERTICAL)868 if (priv->orientation == GTK_ORIENTATION_VERTICAL)
825 {869 {
826 cairo_move_to (cr, 2.5, height / 2);870 cairo_move_to (cr, 1.5, height / 2);
827 cairo_line_to (cr, width - 2.5, height / 2);871 cairo_line_to (cr, width - 1.5, height / 2);
828 set_source_gdk_rgba (cr, &bg_dark_line, 0.36);872 set_source_gdk_rgba (cr, &bg_dark_line, 0.36);
829 cairo_stroke (cr);873 cairo_stroke (cr);
830874
831 cairo_move_to (cr, 2.5, 1 + height / 2);875 cairo_move_to (cr, 1.5, 1 + height / 2);
832 cairo_line_to (cr, width - 2.5, 1 + height / 2);876 cairo_line_to (cr, width - 1.5, 1 + height / 2);
833 set_source_gdk_rgba (cr, &bg_bright_line, 0.5);877 set_source_gdk_rgba (cr, &bg_bright_line, 0.5);
834 cairo_stroke (cr);878 cairo_stroke (cr);
835 }879 }
836 else880 else
837 {881 {
838 cairo_move_to (cr, width / 2, 2.5);882 cairo_move_to (cr, width / 2, 1.5);
839 cairo_line_to (cr, width / 2, height - 2.5);883 cairo_line_to (cr, width / 2, height - 1.5);
840 set_source_gdk_rgba (cr, &bg_dark_line, 0.36);884 set_source_gdk_rgba (cr, &bg_dark_line, 0.36);
841 cairo_stroke (cr);885 cairo_stroke (cr);
842886
843 cairo_move_to (cr, 1 + width / 2, 2.5);887 cairo_move_to (cr, 1 + width / 2, 1.5);
844 cairo_line_to (cr, 1 + width / 2, height - 2.5);888 cairo_line_to (cr, 1 + width / 2, height - 1.5);
845 set_source_gdk_rgba (cr, &bg_bright_line, 0.5);889 set_source_gdk_rgba (cr, &bg_bright_line, 0.5);
846 cairo_stroke (cr);890 cairo_stroke (cr);
847 }891 }
@@ -851,14 +895,14 @@
851 {895 {
852 /* Direction UP. */896 /* Direction UP. */
853 cairo_save (cr);897 cairo_save (cr);
854 cairo_translate (cr, 8.5, 8.5);898 cairo_translate (cr, width / 2 + 0.5, 8.5);
855 cairo_rotate (cr, G_PI); 899 cairo_rotate (cr, G_PI);
856 draw_arrow (cr, &arrow_color, 0.5, 0, 5, 3);900 draw_arrow (cr, &arrow_color, 0.5, 0, 5, 3);
857 cairo_restore (cr);901 cairo_restore (cr);
858902
859 /* Direction DOWN. */903 /* Direction DOWN. */
860 cairo_save (cr);904 cairo_save (cr);
861 cairo_translate (cr, 8.5, height - 8.5);905 cairo_translate (cr, width / 2 + 0.5, height - 8.5);
862 cairo_rotate (cr, 0);906 cairo_rotate (cr, 0);
863 draw_arrow (cr, &arrow_color, -0.5, 0, 5, 3);907 draw_arrow (cr, &arrow_color, -0.5, 0, 5, 3);
864 cairo_restore (cr);908 cairo_restore (cr);
@@ -867,14 +911,14 @@
867 {911 {
868 /* Direction LEFT. */912 /* Direction LEFT. */
869 cairo_save (cr);913 cairo_save (cr);
870 cairo_translate (cr, 8.5, 8.5);914 cairo_translate (cr, 8.5, height / 2 + 0.5);
871 cairo_rotate (cr, G_PI * 0.5); 915 cairo_rotate (cr, G_PI * 0.5);
872 draw_arrow (cr, &arrow_color, -0.5, 0, 5, 3);916 draw_arrow (cr, &arrow_color, -0.5, 0, 5, 3);
873 cairo_restore (cr);917 cairo_restore (cr);
874918
875 /* Direction RIGHT. */919 /* Direction RIGHT. */
876 cairo_save (cr);920 cairo_save (cr);
877 cairo_translate (cr, width - 8.5, 8.5);921 cairo_translate (cr, width - 8.5, height / 2 + 0.5);
878 cairo_rotate (cr, G_PI * 1.5);922 cairo_rotate (cr, G_PI * 1.5);
879 draw_arrow (cr, &arrow_color, 0.5, 0, 5, 3);923 draw_arrow (cr, &arrow_color, 0.5, 0, 5, 3);
880 cairo_restore (cr);924 cairo_restore (cr);

Subscribers

People subscribed via source and target branches