Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shading #88

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 60 additions & 5 deletions mx/mx-scroll-view.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ struct _MxScrollViewPrivate
guint scrollbar_width;
guint scrollbar_height;

gboolean top_shading;
gboolean bottom_shading;
gboolean left_shading;
gboolean right_shading;

MxScrollPolicy scroll_policy;
MxScrollPolicy scroll_visibility;
};
Expand Down Expand Up @@ -242,7 +247,8 @@ mx_scroll_view_paint (ClutterActor *actor)
if (vadjustment)
{
gdouble len;
if ((len = mx_adjustment_get_value (vadjustment)) > 0)
if ((len = mx_adjustment_get_value (vadjustment)) > 0 &&
priv->top_shading)
{
CoglTextureVertex top[4] = { { 0,}, };

Expand All @@ -263,7 +269,8 @@ mx_scroll_view_paint (ClutterActor *actor)

if ((len = (mx_adjustment_get_upper (vadjustment)
- mx_adjustment_get_page_size (vadjustment))
- mx_adjustment_get_value (vadjustment)) > 0)
- mx_adjustment_get_value (vadjustment)) > 0 &&
priv->bottom_shading)
{
CoglTextureVertex bottom[4] = { {0, }, };

Expand All @@ -290,7 +297,8 @@ mx_scroll_view_paint (ClutterActor *actor)
{
gdouble len;

if ((len = mx_adjustment_get_value (hadjustment)) > 0)
if ((len = mx_adjustment_get_value (hadjustment)) > 0 &&
priv->left_shading)
{

CoglTextureVertex left[4] = { { 0, }, };
Expand All @@ -313,7 +321,8 @@ mx_scroll_view_paint (ClutterActor *actor)

if ((len = (mx_adjustment_get_upper (hadjustment)
- mx_adjustment_get_page_size (hadjustment))
- mx_adjustment_get_value (hadjustment)) > 0)
- mx_adjustment_get_value (hadjustment)) > 0 &&
priv->right_shading)
{
CoglTextureVertex right[4] = { { 0, }, };

Expand Down Expand Up @@ -543,17 +552,31 @@ mx_scroll_view_style_changed (MxWidget *widget, MxStyleChangedFlags flags)
{
MxScrollViewPrivate *priv = MX_SCROLL_VIEW (widget)->priv;
gint scrollbar_width, scrollbar_height;
gboolean top_shading, bottom_shading, left_shading, right_shading;

mx_stylable_get (MX_STYLABLE (widget),
"x-mx-scrollbar-width", &scrollbar_width,
"x-mx-scrollbar-height", &scrollbar_height,
"x-mx-top-shading", &top_shading,
"x-mx-bottom-shading", &bottom_shading,
"x-mx-left-shading", &left_shading,
"x-mx-right-shading", &right_shading,
NULL);


if (scrollbar_width != priv->scrollbar_width ||
scrollbar_height != priv->scrollbar_height)
scrollbar_height != priv->scrollbar_height ||
top_shading != priv->top_shading ||
bottom_shading != priv->bottom_shading ||
left_shading != priv->left_shading ||
right_shading != priv->right_shading)
{
priv->scrollbar_width = scrollbar_width;
priv->scrollbar_height = scrollbar_height;
priv->top_shading = top_shading;
priv->bottom_shading = bottom_shading;
priv->left_shading = left_shading;
priv->right_shading = right_shading;
clutter_actor_queue_relayout (CLUTTER_ACTOR (widget));
}
}
Expand Down Expand Up @@ -781,6 +804,38 @@ mx_stylable_iface_init (MxStylableIface *iface)
0, G_MAXUINT, 24,
G_PARAM_READWRITE);
mx_stylable_iface_install_property (iface, MX_TYPE_SCROLL_VIEW, pspec);

pspec = g_param_spec_boolean ("x-mx-top-shading",
"Display top shading",
"If we should display a shading on top "
"of the view",
TRUE,
G_PARAM_READWRITE);
mx_stylable_iface_install_property (iface, MX_TYPE_SCROLL_VIEW, pspec);

pspec = g_param_spec_boolean ("x-mx-bottom-shading",
"Display bottom shading",
"If we should display a shading on bottom "
"of the view",
TRUE,
G_PARAM_READWRITE);
mx_stylable_iface_install_property (iface, MX_TYPE_SCROLL_VIEW, pspec);

pspec = g_param_spec_boolean ("x-mx-left-shading",
"Display left shading",
"If we should display a shading on left "
"of the view",
TRUE,
G_PARAM_READWRITE);
mx_stylable_iface_install_property (iface, MX_TYPE_SCROLL_VIEW, pspec);

pspec = g_param_spec_boolean ("x-mx-right-shading",
"Display right shading",
"If we should display a shading on right "
"of the view",
TRUE,
G_PARAM_READWRITE);
mx_stylable_iface_install_property (iface, MX_TYPE_SCROLL_VIEW, pspec);
}
}

Expand Down
20 changes: 20 additions & 0 deletions mx/mx-style.c
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,26 @@ mx_style_transform_css_value (MxStyleSheetValue *css_value,

g_type_class_unref (class);
}
else if (g_type_is_a (pspec->value_type, G_TYPE_BOOLEAN))
{
g_value_init (value, pspec->value_type);

if (css_value->string)
{
gboolean b = TRUE;

if (g_ascii_strcasecmp (css_value->string, "false") == 0 ||
strcmp (css_value->string, "0") == 0)
b = FALSE;

g_value_set_boolean (value, b);
}
else
{
g_value_set_boolean (value,
((GParamSpecUInt *) pspec)->default_value);
}
}
else
{
GValue strval = { 0, };
Expand Down