scroll-view: Support GTK_POLICY_EXTERNAL
GTK+ added a new PolicyType which currently triggers compiler warnings about unhandled values in switch statements. We also have a use case for it already, so add support for the new policy type. https://bugzilla.gnome.org/show_bug.cgi?id=739379
This commit is contained in:
parent
fb5b368ca7
commit
5fca85cd28
@ -373,6 +373,7 @@ st_scroll_view_get_preferred_width (ClutterActor *actor,
|
|||||||
break;
|
break;
|
||||||
case GTK_POLICY_ALWAYS:
|
case GTK_POLICY_ALWAYS:
|
||||||
case GTK_POLICY_AUTOMATIC:
|
case GTK_POLICY_AUTOMATIC:
|
||||||
|
case GTK_POLICY_EXTERNAL:
|
||||||
/* Should theoretically use the min width of the hscrollbar,
|
/* Should theoretically use the min width of the hscrollbar,
|
||||||
* but that's not cleanly defined at the moment */
|
* but that's not cleanly defined at the moment */
|
||||||
min_width = 0;
|
min_width = 0;
|
||||||
@ -382,6 +383,7 @@ st_scroll_view_get_preferred_width (ClutterActor *actor,
|
|||||||
switch (priv->vscrollbar_policy)
|
switch (priv->vscrollbar_policy)
|
||||||
{
|
{
|
||||||
case GTK_POLICY_NEVER:
|
case GTK_POLICY_NEVER:
|
||||||
|
case GTK_POLICY_EXTERNAL:
|
||||||
account_for_vscrollbar = FALSE;
|
account_for_vscrollbar = FALSE;
|
||||||
break;
|
break;
|
||||||
case GTK_POLICY_ALWAYS:
|
case GTK_POLICY_ALWAYS:
|
||||||
@ -443,6 +445,7 @@ st_scroll_view_get_preferred_height (ClutterActor *actor,
|
|||||||
switch (priv->vscrollbar_policy)
|
switch (priv->vscrollbar_policy)
|
||||||
{
|
{
|
||||||
case GTK_POLICY_NEVER:
|
case GTK_POLICY_NEVER:
|
||||||
|
case GTK_POLICY_EXTERNAL:
|
||||||
break;
|
break;
|
||||||
case GTK_POLICY_ALWAYS:
|
case GTK_POLICY_ALWAYS:
|
||||||
case GTK_POLICY_AUTOMATIC:
|
case GTK_POLICY_AUTOMATIC:
|
||||||
@ -454,6 +457,7 @@ st_scroll_view_get_preferred_height (ClutterActor *actor,
|
|||||||
switch (priv->hscrollbar_policy)
|
switch (priv->hscrollbar_policy)
|
||||||
{
|
{
|
||||||
case GTK_POLICY_NEVER:
|
case GTK_POLICY_NEVER:
|
||||||
|
case GTK_POLICY_EXTERNAL:
|
||||||
account_for_hscrollbar = FALSE;
|
account_for_hscrollbar = FALSE;
|
||||||
break;
|
break;
|
||||||
case GTK_POLICY_ALWAYS:
|
case GTK_POLICY_ALWAYS:
|
||||||
@ -480,6 +484,7 @@ st_scroll_view_get_preferred_height (ClutterActor *actor,
|
|||||||
break;
|
break;
|
||||||
case GTK_POLICY_ALWAYS:
|
case GTK_POLICY_ALWAYS:
|
||||||
case GTK_POLICY_AUTOMATIC:
|
case GTK_POLICY_AUTOMATIC:
|
||||||
|
case GTK_POLICY_EXTERNAL:
|
||||||
/* Should theoretically use the min height of the vscrollbar,
|
/* Should theoretically use the min height of the vscrollbar,
|
||||||
* but that's not cleanly defined at the moment */
|
* but that's not cleanly defined at the moment */
|
||||||
min_height = 0;
|
min_height = 0;
|
||||||
@ -567,7 +572,7 @@ st_scroll_view_allocate (ClutterActor *actor,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
hscrollbar_visible = priv->hscrollbar_policy != GTK_POLICY_NEVER;
|
hscrollbar_visible = priv->hscrollbar_policy == GTK_POLICY_ALWAYS;
|
||||||
|
|
||||||
/* try without a vertical scrollbar */
|
/* try without a vertical scrollbar */
|
||||||
clutter_actor_get_preferred_height (priv->child, avail_width, &child_min_height, NULL);
|
clutter_actor_get_preferred_height (priv->child, avail_width, &child_min_height, NULL);
|
||||||
@ -576,18 +581,20 @@ st_scroll_view_allocate (ClutterActor *actor,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
vscrollbar_visible = priv->vscrollbar_policy != GTK_POLICY_NEVER;
|
vscrollbar_visible = priv->vscrollbar_policy == GTK_POLICY_ALWAYS;
|
||||||
|
|
||||||
if (priv->hscrollbar_policy == GTK_POLICY_AUTOMATIC)
|
if (priv->hscrollbar_policy == GTK_POLICY_AUTOMATIC)
|
||||||
hscrollbar_visible = child_min_width > avail_height - (vscrollbar_visible ? 0 : sb_width);
|
hscrollbar_visible = child_min_width > avail_height - (vscrollbar_visible ? 0 : sb_width);
|
||||||
else
|
else
|
||||||
hscrollbar_visible = priv->hscrollbar_policy != GTK_POLICY_NEVER;
|
hscrollbar_visible = priv->hscrollbar_policy == GTK_POLICY_ALWAYS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
hscrollbar_visible = priv->hscrollbar_policy != GTK_POLICY_NEVER;
|
hscrollbar_visible = priv->hscrollbar_policy != GTK_POLICY_NEVER &&
|
||||||
vscrollbar_visible = priv->vscrollbar_policy != GTK_POLICY_NEVER;
|
priv->hscrollbar_policy != GTK_POLICY_EXTERNAL;
|
||||||
|
vscrollbar_visible = priv->vscrollbar_policy != GTK_POLICY_NEVER &&
|
||||||
|
priv->vscrollbar_policy != GTK_POLICY_EXTERNAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Whether or not we show the scrollbars, if the scrollbars are visible
|
/* Whether or not we show the scrollbars, if the scrollbars are visible
|
||||||
@ -629,15 +636,19 @@ st_scroll_view_allocate (ClutterActor *actor,
|
|||||||
|
|
||||||
clutter_actor_allocate (priv->hscroll, &child_box, flags);
|
clutter_actor_allocate (priv->hscroll, &child_box, flags);
|
||||||
|
|
||||||
/* In case the scrollbar policy is NEVER or scrollbars should be
|
/* In case the scrollbar policy is NEVER or EXTERNAL or scrollbars
|
||||||
* overlayed, we don't trim the content box allocation by the
|
* should be overlayed, we don't trim the content box allocation by
|
||||||
* scrollbar size.
|
* the scrollbar size.
|
||||||
* Fold this into the scrollbar sizes to simplify the rest of the
|
* Fold this into the scrollbar sizes to simplify the rest of the
|
||||||
* computations.
|
* computations.
|
||||||
*/
|
*/
|
||||||
if (priv->hscrollbar_policy == GTK_POLICY_NEVER || priv->overlay_scrollbars)
|
if (priv->hscrollbar_policy == GTK_POLICY_NEVER ||
|
||||||
|
priv->hscrollbar_policy == GTK_POLICY_EXTERNAL ||
|
||||||
|
priv->overlay_scrollbars)
|
||||||
sb_height = 0;
|
sb_height = 0;
|
||||||
if (priv->vscrollbar_policy == GTK_POLICY_NEVER || priv->overlay_scrollbars)
|
if (priv->vscrollbar_policy == GTK_POLICY_NEVER ||
|
||||||
|
priv->vscrollbar_policy == GTK_POLICY_EXTERNAL ||
|
||||||
|
priv->overlay_scrollbars)
|
||||||
sb_width = 0;
|
sb_width = 0;
|
||||||
|
|
||||||
/* Child */
|
/* Child */
|
||||||
|
@ -312,6 +312,9 @@ function test() {
|
|||||||
button.label = 'NEVER';
|
button.label = 'NEVER';
|
||||||
break;
|
break;
|
||||||
case 'NEVER':
|
case 'NEVER':
|
||||||
|
button.label = 'EXTERNAL';
|
||||||
|
break;
|
||||||
|
case 'EXTERNAL':
|
||||||
button.label = 'AUTOMATIC';
|
button.label = 'AUTOMATIC';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user