st: Add StScrollViewFade:fade-edges
Add a new property which controls whether edge areas are excluded from the effect (the default and current behavior), or not. https://bugzilla.gnome.org/show_bug.cgi?id=707409
This commit is contained in:
parent
6fb044f351
commit
4f5d3e00db
@ -49,6 +49,8 @@ struct _StScrollViewFade
|
|||||||
StAdjustment *vadjustment;
|
StAdjustment *vadjustment;
|
||||||
StAdjustment *hadjustment;
|
StAdjustment *hadjustment;
|
||||||
|
|
||||||
|
guint fade_edges : 1;
|
||||||
|
|
||||||
float vfade_offset;
|
float vfade_offset;
|
||||||
float hfade_offset;
|
float hfade_offset;
|
||||||
};
|
};
|
||||||
@ -66,7 +68,8 @@ enum {
|
|||||||
PROP_0,
|
PROP_0,
|
||||||
|
|
||||||
PROP_VFADE_OFFSET,
|
PROP_VFADE_OFFSET,
|
||||||
PROP_HFADE_OFFSET
|
PROP_HFADE_OFFSET,
|
||||||
|
PROP_FADE_EDGES
|
||||||
};
|
};
|
||||||
|
|
||||||
static CoglHandle
|
static CoglHandle
|
||||||
@ -151,6 +154,7 @@ st_scroll_view_fade_paint_target (ClutterOffscreenEffect *effect)
|
|||||||
clutter_shader_effect_set_uniform (shader, "tex", G_TYPE_INT, 1, 0);
|
clutter_shader_effect_set_uniform (shader, "tex", G_TYPE_INT, 1, 0);
|
||||||
clutter_shader_effect_set_uniform (shader, "height", G_TYPE_FLOAT, 1, clutter_actor_get_height (self->actor));
|
clutter_shader_effect_set_uniform (shader, "height", G_TYPE_FLOAT, 1, clutter_actor_get_height (self->actor));
|
||||||
clutter_shader_effect_set_uniform (shader, "width", G_TYPE_FLOAT, 1, clutter_actor_get_width (self->actor));
|
clutter_shader_effect_set_uniform (shader, "width", G_TYPE_FLOAT, 1, clutter_actor_get_width (self->actor));
|
||||||
|
clutter_shader_effect_set_uniform (shader, "fade_edges", G_TYPE_INT, 1, self->fade_edges);
|
||||||
clutter_shader_effect_set_uniform (shader, "fade_area_topleft", CLUTTER_TYPE_SHADER_FLOAT, 2, fade_area_topleft);
|
clutter_shader_effect_set_uniform (shader, "fade_area_topleft", CLUTTER_TYPE_SHADER_FLOAT, 2, fade_area_topleft);
|
||||||
clutter_shader_effect_set_uniform (shader, "fade_area_bottomright", CLUTTER_TYPE_SHADER_FLOAT, 2, fade_area_bottomright);
|
clutter_shader_effect_set_uniform (shader, "fade_area_bottomright", CLUTTER_TYPE_SHADER_FLOAT, 2, fade_area_bottomright);
|
||||||
|
|
||||||
@ -292,6 +296,24 @@ st_scroll_view_hfade_set_offset (StScrollViewFade *self,
|
|||||||
g_object_thaw_notify (G_OBJECT (self));
|
g_object_thaw_notify (G_OBJECT (self));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
st_scroll_view_fade_set_fade_edges (StScrollViewFade *self,
|
||||||
|
gboolean fade_edges)
|
||||||
|
{
|
||||||
|
if (self->fade_edges == fade_edges)
|
||||||
|
return;
|
||||||
|
|
||||||
|
g_object_freeze_notify (G_OBJECT (self));
|
||||||
|
|
||||||
|
self->fade_edges = fade_edges;
|
||||||
|
|
||||||
|
if (self->actor != NULL)
|
||||||
|
clutter_actor_queue_redraw (self->actor);
|
||||||
|
|
||||||
|
g_object_notify (G_OBJECT (self), "fade-edges");
|
||||||
|
g_object_thaw_notify (G_OBJECT (self));
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
st_scroll_view_fade_set_property (GObject *object,
|
st_scroll_view_fade_set_property (GObject *object,
|
||||||
guint prop_id,
|
guint prop_id,
|
||||||
@ -308,6 +330,9 @@ st_scroll_view_fade_set_property (GObject *object,
|
|||||||
case PROP_HFADE_OFFSET:
|
case PROP_HFADE_OFFSET:
|
||||||
st_scroll_view_hfade_set_offset (self, g_value_get_float (value));
|
st_scroll_view_hfade_set_offset (self, g_value_get_float (value));
|
||||||
break;
|
break;
|
||||||
|
case PROP_FADE_EDGES:
|
||||||
|
st_scroll_view_fade_set_fade_edges (self, g_value_get_boolean (value));
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
@ -330,6 +355,9 @@ st_scroll_view_fade_get_property (GObject *object,
|
|||||||
case PROP_VFADE_OFFSET:
|
case PROP_VFADE_OFFSET:
|
||||||
g_value_set_float (value, self->vfade_offset);
|
g_value_set_float (value, self->vfade_offset);
|
||||||
break;
|
break;
|
||||||
|
case PROP_FADE_EDGES:
|
||||||
|
g_value_set_boolean (value, self->fade_edges);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
@ -371,6 +399,14 @@ st_scroll_view_fade_class_init (StScrollViewFadeClass *klass)
|
|||||||
"The width of the area which is faded at the edge",
|
"The width of the area which is faded at the edge",
|
||||||
0.f, G_MAXFLOAT, DEFAULT_FADE_OFFSET,
|
0.f, G_MAXFLOAT, DEFAULT_FADE_OFFSET,
|
||||||
G_PARAM_READWRITE));
|
G_PARAM_READWRITE));
|
||||||
|
g_object_class_install_property (gobject_class,
|
||||||
|
PROP_FADE_EDGES,
|
||||||
|
g_param_spec_boolean ("fade-edges",
|
||||||
|
"Fade Edges",
|
||||||
|
"Whether the faded area should extend to the edges",
|
||||||
|
FALSE,
|
||||||
|
G_PARAM_READWRITE));
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@ uniform float vfade_offset;
|
|||||||
uniform float hfade_offset;
|
uniform float hfade_offset;
|
||||||
uniform float vvalue;
|
uniform float vvalue;
|
||||||
uniform float hvalue;
|
uniform float hvalue;
|
||||||
|
uniform bool fade_edges;
|
||||||
|
|
||||||
uniform vec2 fade_area_topleft;
|
uniform vec2 fade_area_topleft;
|
||||||
uniform vec2 fade_area_bottomright;
|
uniform vec2 fade_area_bottomright;
|
||||||
@ -44,10 +45,14 @@ void main ()
|
|||||||
float ratio = 1.0;
|
float ratio = 1.0;
|
||||||
float fade_bottom_start = fade_area_bottomright[1] - vfade_offset;
|
float fade_bottom_start = fade_area_bottomright[1] - vfade_offset;
|
||||||
float fade_right_start = fade_area_bottomright[0] - hfade_offset;
|
float fade_right_start = fade_area_bottomright[0] - hfade_offset;
|
||||||
bool fade_top = y < vfade_offset && vvalue > 0.0;
|
bool fade_top = y < vfade_offset && (fade_edges ? vvalue >= 0.0
|
||||||
bool fade_bottom = y > fade_bottom_start && vvalue < 1.0;
|
: vvalue > 0.0);
|
||||||
bool fade_left = x < hfade_offset && hvalue > 0.0;
|
bool fade_bottom = y > fade_bottom_start && (fade_edges ? vvalue <= 1.0
|
||||||
bool fade_right = x > fade_right_start && hvalue < 1.0;
|
: vvalue < 1.0);
|
||||||
|
bool fade_left = x < hfade_offset && (fade_edges ? hvalue >= 0.0
|
||||||
|
: hvalue > 0.0);
|
||||||
|
bool fade_right = x > fade_right_start && (fade_edges ? hvalue <= 1.0
|
||||||
|
: hvalue < 1.0);
|
||||||
|
|
||||||
float vfade_scale = height / vfade_offset;
|
float vfade_scale = height / vfade_offset;
|
||||||
if (fade_top) {
|
if (fade_top) {
|
||||||
|
Loading…
Reference in New Issue
Block a user