- {
- case GTK_POS_LEFT:
- gdk_window_get_position (GTK_RANGE (scale)->trough, &x, &y);
- gdk_window_get_size (GTK_RANGE (scale)->trough, &width, &height);
-
- x -= SCALE_CLASS (scale)->value_spacing + text_width;
- y += ((height -
- (GTK_WIDGET (scale)->style->font->ascent +
- GTK_WIDGET (scale)->style->font->descent)) / 2 +
- GTK_WIDGET (scale)->style->font->ascent);
- break;
- case GTK_POS_RIGHT:
- gdk_window_get_position (GTK_RANGE (scale)->trough, &x, &y);
- gdk_window_get_size (GTK_RANGE (scale)->trough, &width, &height);
-
- x += width + SCALE_CLASS (scale)->value_spacing;
- y += ((height -
- (GTK_WIDGET (scale)->style->font->ascent +
- GTK_WIDGET (scale)->style->font->descent)) / 2 +
- GTK_WIDGET (scale)->style->font->ascent);
- break;
- case GTK_POS_TOP:
- gdk_window_get_position (GTK_RANGE (scale)->slider, &x, NULL);
- gdk_window_get_position (GTK_RANGE (scale)->trough, NULL, &y);
- gdk_window_get_size (GTK_RANGE (scale)->slider, &width, NULL);
- gdk_window_get_size (GTK_RANGE (scale)->trough, NULL, &height);
-
- x += (width - text_width) / 2;
- y -= GTK_WIDGET (scale)->style->font->descent;
- break;
- case GTK_POS_BOTTOM:
- gdk_window_get_position (GTK_RANGE (scale)->slider, &x, NULL);
- gdk_window_get_position (GTK_RANGE (scale)->trough, NULL, &y);
- gdk_window_get_size (GTK_RANGE (scale)->slider, &width, NULL);
- gdk_window_get_size (GTK_RANGE (scale)->trough, NULL, &height);
-
- x += (width - text_width) / 2;
- y += height + GTK_WIDGET (scale)->style->font->ascent;
- break;
- }
-
+ {
+ case GTK_POS_LEFT:
+ gdk_window_get_position (GTK_RANGE (scale)->trough, &x, &y);
+ gdk_window_get_size (GTK_RANGE (scale)->trough, &width, &height);
+
+ x -= SCALE_CLASS (scale)->value_spacing + logical_rect.width;
+ y += (height - logical_rect.height) / 2;
+ break;
+ case GTK_POS_RIGHT:
+ gdk_window_get_position (GTK_RANGE (scale)->trough, &x, &y);
+ gdk_window_get_size (GTK_RANGE (scale)->trough, &width, &height);
+
+ x += width + SCALE_CLASS (scale)->value_spacing;
+ y += (height - logical_rect.height) / 2;
+ break;
+ case GTK_POS_TOP:
+ gdk_window_get_position (GTK_RANGE (scale)->slider, &x, NULL);
+ gdk_window_get_position (GTK_RANGE (scale)->trough, NULL, &y);
+ gdk_window_get_size (GTK_RANGE (scale)->slider, &width, NULL);
+ gdk_window_get_size (GTK_RANGE (scale)->trough, NULL, &height);
+
+ x += widget->allocation.x + (width - logical_rect.width) / 2;
+ x = CLAMP (x, widget->allocation.x,
+ widget->allocation.x + widget->allocation.width - logical_rect.width);
+ y -= logical_rect.height;
+ break;
+ case GTK_POS_BOTTOM:
+ gdk_window_get_position (GTK_RANGE (scale)->slider, &x, NULL);
+ gdk_window_get_position (GTK_RANGE (scale)->trough, NULL, &y);
+ gdk_window_get_size (GTK_RANGE (scale)->slider, &width, NULL);
+ gdk_window_get_size (GTK_RANGE (scale)->trough, NULL, &height);
+
+ x += widget->allocation.x + (width - logical_rect.width) / 2;
+ x = CLAMP (x, widget->allocation.x,
+ widget->allocation.x + widget->allocation.width - logical_rect.width);
+ y += height;
+ break;
+ }
+