scroll-view-fade: Adjust the effect to work in RTL locales
The vertical scrollbar is located on the left in RTL locales, so pass an additional parameter to the shader which indicates the locale's text direction. https://bugzilla.gnome.org/show_bug.cgi?id=643156
This commit is contained in:
parent
d15122c4b2
commit
63be52e191
@ -42,6 +42,7 @@ static const gchar *fade_glsl_shader =
|
|||||||
"uniform float scrollbar_width;\n"
|
"uniform float scrollbar_width;\n"
|
||||||
"uniform float offset_bottom;\n"
|
"uniform float offset_bottom;\n"
|
||||||
"uniform float offset_top;\n"
|
"uniform float offset_top;\n"
|
||||||
|
"uniform bool rtl;\n"
|
||||||
"\n"
|
"\n"
|
||||||
"void main ()\n"
|
"void main ()\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
@ -51,11 +52,11 @@ static const gchar *fade_glsl_shader =
|
|||||||
" float ratio = 0.0;\n"
|
" float ratio = 0.0;\n"
|
||||||
" float fade_bottom_start = height - offset_bottom;\n"
|
" float fade_bottom_start = height - offset_bottom;\n"
|
||||||
" \n"
|
" \n"
|
||||||
" if (offset_top != 0.0 && y < offset_top && x < (width - scrollbar_width)) {\n"
|
" if (offset_top != 0.0 && y < offset_top && ((rtl && x > scrollbar_width) || (!rtl && x < (width - scrollbar_width)))) {\n"
|
||||||
" ratio = y / offset_top;\n"
|
" ratio = y / offset_top;\n"
|
||||||
" cogl_color_out = color * ratio;\n"
|
" cogl_color_out = color * ratio;\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
" else if (offset_bottom != 0.0 && y > fade_bottom_start && x < (width - scrollbar_width)) {\n"
|
" else if (offset_bottom != 0.0 && y > fade_bottom_start && ((rtl && x > scrollbar_width) || (!rtl && x < (width - scrollbar_width)))) {\n"
|
||||||
" ratio = (height - y)/(height - fade_bottom_start);\n"
|
" ratio = (height - y)/(height - fade_bottom_start);\n"
|
||||||
" cogl_color_out = color * ratio;\n"
|
" cogl_color_out = color * ratio;\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
@ -80,6 +81,7 @@ struct _StScrollViewFade
|
|||||||
gint scrollbar_width_uniform;
|
gint scrollbar_width_uniform;
|
||||||
gint offset_top_uniform;
|
gint offset_top_uniform;
|
||||||
gint offset_bottom_uniform;
|
gint offset_bottom_uniform;
|
||||||
|
gint rtl_uniform;
|
||||||
|
|
||||||
StAdjustment *vadjustment;
|
StAdjustment *vadjustment;
|
||||||
|
|
||||||
@ -141,6 +143,8 @@ st_scroll_view_fade_pre_paint (ClutterEffect *effect)
|
|||||||
cogl_program_get_uniform_location (self->program, "width");
|
cogl_program_get_uniform_location (self->program, "width");
|
||||||
self->scrollbar_width_uniform =
|
self->scrollbar_width_uniform =
|
||||||
cogl_program_get_uniform_location (self->program, "scrollbar_width");
|
cogl_program_get_uniform_location (self->program, "scrollbar_width");
|
||||||
|
self->rtl_uniform =
|
||||||
|
cogl_program_get_uniform_location (self->program, "rtl");
|
||||||
self->offset_top_uniform =
|
self->offset_top_uniform =
|
||||||
cogl_program_get_uniform_location (self->program, "offset_top");
|
cogl_program_get_uniform_location (self->program, "offset_top");
|
||||||
self->offset_bottom_uniform =
|
self->offset_bottom_uniform =
|
||||||
@ -199,6 +203,8 @@ st_scroll_view_fade_paint_target (ClutterOffscreenEffect *effect)
|
|||||||
cogl_program_set_uniform_1f (self->program, self->width_uniform, clutter_actor_get_width (self->actor));
|
cogl_program_set_uniform_1f (self->program, self->width_uniform, clutter_actor_get_width (self->actor));
|
||||||
if (self->scrollbar_width_uniform > -1)
|
if (self->scrollbar_width_uniform > -1)
|
||||||
cogl_program_set_uniform_1f (self->program, self->scrollbar_width_uniform, clutter_actor_get_width (vscroll));
|
cogl_program_set_uniform_1f (self->program, self->scrollbar_width_uniform, clutter_actor_get_width (vscroll));
|
||||||
|
if (self->rtl_uniform > -1)
|
||||||
|
cogl_program_set_uniform_1i (self->program, self->rtl_uniform, (st_widget_get_direction (ST_WIDGET (self->actor)) == ST_TEXT_DIRECTION_RTL));
|
||||||
|
|
||||||
material = clutter_offscreen_effect_get_target (effect);
|
material = clutter_offscreen_effect_get_target (effect);
|
||||||
cogl_material_set_user_program (material, self->program);
|
cogl_material_set_user_program (material, self->program);
|
||||||
@ -408,6 +414,7 @@ st_scroll_view_fade_init (StScrollViewFade *self)
|
|||||||
self->height_uniform = -1;
|
self->height_uniform = -1;
|
||||||
self->width_uniform = -1;
|
self->width_uniform = -1;
|
||||||
self->scrollbar_width_uniform = -1;
|
self->scrollbar_width_uniform = -1;
|
||||||
|
self->rtl_uniform = -1;
|
||||||
self->offset_top_uniform = -1;
|
self->offset_top_uniform = -1;
|
||||||
self->offset_bottom_uniform = -1;
|
self->offset_bottom_uniform = -1;
|
||||||
self->fade_offset = DEFAULT_FADE_OFFSET;
|
self->fade_offset = DEFAULT_FADE_OFFSET;
|
||||||
|
Loading…
Reference in New Issue
Block a user