[gnome-shell] [StScrollbar] Allocate steppers according to size requests
- From: Florian Müllner <fmuellner src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-shell] [StScrollbar] Allocate steppers according to size requests
- Date: Wed, 10 Feb 2010 09:17:00 +0000 (UTC)
commit 32e2ff75735f6a29fee521e9fcfbb080ec38135c
Author: Florian Müllner <fmuellner src gnome org>
Date: Tue Feb 9 07:26:25 2010 +0100
[StScrollbar] Allocate steppers according to size requests
The forward/backward steppers are always allocated a square region at the
scroll bar's ends. Change the allocation to be based on the steppers' size
requests instead.
https://bugzilla.gnome.org/show_bug.cgi?id=609401
src/st/st-scroll-bar.c | 48 ++++++++++++++++++++++++++++++++++--------------
1 files changed, 34 insertions(+), 14 deletions(-)
---
diff --git a/src/st/st-scroll-bar.c b/src/st/st-scroll-bar.c
index d99e2db..836681c 100644
--- a/src/st/st-scroll-bar.c
+++ b/src/st/st-scroll-bar.c
@@ -271,7 +271,7 @@ st_scroll_bar_allocate (ClutterActor *actor,
StScrollBarPrivate *priv = ST_SCROLL_BAR (actor)->priv;
StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (actor));
ClutterActorBox content_box, bw_box, fw_box, trough_box;
- gfloat stepper_size;
+ gfloat bw_stepper_size, fw_stepper_size, min_size, natural_size;
/* Chain up */
CLUTTER_ACTOR_CLASS (st_scroll_bar_parent_class)->
@@ -281,52 +281,70 @@ st_scroll_bar_allocate (ClutterActor *actor,
if (priv->vertical)
{
- stepper_size = content_box.x2 - content_box.x1;
+ gfloat width = content_box.x2 - content_box.x1;
+
+ clutter_actor_get_preferred_height (priv->bw_stepper, width,
+ &min_size, &natural_size);
+ bw_stepper_size = MAX (min_size, natural_size);
/* Backward stepper */
bw_box.x1 = content_box.x1;
bw_box.y1 = content_box.y1;
bw_box.x2 = content_box.x2;
- bw_box.y2 = bw_box.y1 + stepper_size;
+ bw_box.y2 = bw_box.y1 + bw_stepper_size;
clutter_actor_allocate (priv->bw_stepper, &bw_box, flags);
+
+ clutter_actor_get_preferred_height (priv->fw_stepper, width,
+ &min_size, &natural_size);
+ fw_stepper_size = MAX (min_size, natural_size);
+
/* Forward stepper */
fw_box.x1 = content_box.x1;
- fw_box.y1 = content_box.y2 - stepper_size;
+ fw_box.y1 = content_box.y2 - fw_stepper_size;
fw_box.x2 = content_box.x2;
fw_box.y2 = content_box.y2;
clutter_actor_allocate (priv->fw_stepper, &fw_box, flags);
/* Trough */
trough_box.x1 = content_box.x1;
- trough_box.y1 = content_box.y1 + stepper_size;
+ trough_box.y1 = content_box.y1 + bw_stepper_size;
trough_box.x2 = content_box.x2;
- trough_box.y2 = content_box.y2 - stepper_size;
+ trough_box.y2 = content_box.y2 - fw_stepper_size;
clutter_actor_allocate (priv->trough, &trough_box, flags);
}
else
{
- stepper_size = content_box.y2 - content_box.y1;
+ gfloat height = content_box.y2 - content_box.y1;
+
+ clutter_actor_get_preferred_width (priv->bw_stepper, height,
+ &min_size, &natural_size);
+ bw_stepper_size = MAX (min_size, natural_size);
/* Backward stepper */
bw_box.x1 = content_box.x1;
bw_box.y1 = content_box.y1;
- bw_box.x2 = bw_box.x1 + stepper_size;
+ bw_box.x2 = bw_box.x1 + bw_stepper_size;
bw_box.y2 = content_box.y2;
clutter_actor_allocate (priv->bw_stepper, &bw_box, flags);
+
+ clutter_actor_get_preferred_width (priv->fw_stepper, height,
+ &min_size, &natural_size);
+ fw_stepper_size = MAX (min_size, natural_size);
+
/* Forward stepper */
- fw_box.x1 = content_box.x2 - stepper_size;
+ fw_box.x1 = content_box.x2 - fw_stepper_size;
fw_box.y1 = content_box.y1;
fw_box.x2 = content_box.x2;
fw_box.y2 = content_box.y2;
clutter_actor_allocate (priv->fw_stepper, &fw_box, flags);
/* Trough */
- trough_box.x1 = content_box.x1 + stepper_size;
+ trough_box.x1 = content_box.x1 + bw_stepper_size;
trough_box.y1 = content_box.y1;
- trough_box.x2 = content_box.x2 - stepper_size;
+ trough_box.x2 = content_box.x2 - fw_stepper_size;
trough_box.y2 = content_box.y2;
clutter_actor_allocate (priv->trough, &trough_box, flags);
}
@@ -335,10 +353,12 @@ st_scroll_bar_allocate (ClutterActor *actor,
if (priv->adjustment)
{
StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (actor));
- float handle_size, position, avail_size;
+ float handle_size, position, avail_size, stepper_size;
gdouble value, lower, upper, page_size, increment, min_size, max_size;
ClutterActorBox handle_box = { 0, };
+ stepper_size = bw_stepper_size + fw_stepper_size;
+
st_adjustment_get_values (priv->adjustment,
&value,
&lower,
@@ -365,7 +385,7 @@ st_scroll_bar_allocate (ClutterActor *actor,
if (priv->vertical)
{
- avail_size = content_box.y2 - content_box.y1 - stepper_size * 2;
+ avail_size = content_box.y2 - content_box.y1 - stepper_size;
handle_size = increment * avail_size;
handle_size = CLAMP (handle_size, min_size, max_size);
@@ -377,7 +397,7 @@ st_scroll_bar_allocate (ClutterActor *actor,
}
else
{
- avail_size = content_box.x2 - content_box.x1 - stepper_size * 2;
+ avail_size = content_box.x2 - content_box.x1 - stepper_size;
handle_size = increment * avail_size;
handle_size = CLAMP (handle_size, min_size, max_size);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]