[gtk+/wip/baedert/drawing] Fix a few allocation coordinates & sizes
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/baedert/drawing] Fix a few allocation coordinates & sizes
- Date: Wed, 28 Jun 2017 09:13:22 +0000 (UTC)
commit 9b518f87ea68f6468dff8e7dfbff12f9bffc2f4a
Author: Timm Bäder <mail baedert org>
Date: Wed Jun 28 08:19:35 2017 +0200
Fix a few allocation coordinates & sizes
gtk/gtkcolorswatch.c | 12 ++-----
gtk/gtkdrawingarea.c | 10 +++--
gtk/gtkentrycompletion.c | 3 +-
gtk/gtkiconview.c | 88 +++++++++++++++++++--------------------------
gtk/gtklistbox.c | 4 +-
gtk/gtkmenu.c | 9 +----
gtk/gtkrange.c | 13 +++----
gtk/gtkscale.c | 8 ++--
gtk/gtkscrolledwindow.c | 8 +----
gtk/gtkstack.c | 47 ++++++++++++------------
gtk/gtkstackswitcher.c | 14 +++-----
11 files changed, 90 insertions(+), 126 deletions(-)
---
diff --git a/gtk/gtkcolorswatch.c b/gtk/gtkcolorswatch.c
index dd5c493..507039c 100644
--- a/gtk/gtkcolorswatch.c
+++ b/gtk/gtkcolorswatch.c
@@ -98,22 +98,16 @@ swatch_snapshot (GtkWidget *widget,
{
cairo_pattern_t *pattern;
cairo_matrix_t matrix;
- GtkAllocation allocation, border_allocation;
+ GtkAllocation border_allocation;
GskRoundedRect content_box;
- gtk_widget_get_allocation (widget, &allocation);
- /* TODO: This should be the border allocation */
- gtk_widget_get_allocation (widget, &border_allocation);
-
- border_allocation.x -= allocation.x;
- border_allocation.y -= allocation.y;
+ gtk_widget_get_border_allocation (widget, &border_allocation);
gtk_rounded_boxes_init_for_style (NULL,
NULL,
&content_box,
gtk_style_context_lookup_style (context),
- border_allocation.x,
- border_allocation.y,
+ 0, 0,
border_allocation.width,
border_allocation.height);
gtk_snapshot_push_rounded_clip (snapshot,
diff --git a/gtk/gtkdrawingarea.c b/gtk/gtkdrawingarea.c
index 7478256..cc2c94a 100644
--- a/gtk/gtkdrawingarea.c
+++ b/gtk/gtkdrawingarea.c
@@ -28,6 +28,7 @@
#include "gtkprivate.h"
#include "gtksnapshot.h"
#include "gtkstylecontext.h"
+#include "gtkwidgetprivate.h"
typedef struct _GtkDrawingAreaPrivate GtkDrawingAreaPrivate;
@@ -235,21 +236,22 @@ gtk_drawing_area_snapshot (GtkWidget *widget,
GtkDrawingArea *self = GTK_DRAWING_AREA (widget);
GtkDrawingAreaPrivate *priv = gtk_drawing_area_get_instance_private (self);
cairo_t *cr;
+ int width, height;
if (!priv->draw_func)
return;
+ gtk_widget_get_content_size (widget, &width, &height);
+
cr = gtk_snapshot_append_cairo (snapshot,
&GRAPHENE_RECT_INIT (
0, 0,
- gtk_widget_get_allocated_width (widget),
- gtk_widget_get_allocated_height (widget)
+ width, height
),
"DrawingAreaContents");
priv->draw_func (self,
cr,
- gtk_widget_get_allocated_width (widget),
- gtk_widget_get_allocated_height (widget),
+ width, height,
priv->draw_func_target);
cairo_destroy (cr);
}
diff --git a/gtk/gtkentrycompletion.c b/gtk/gtkentrycompletion.c
index 856cf0e..6b45e67 100644
--- a/gtk/gtkentrycompletion.c
+++ b/gtk/gtkentrycompletion.c
@@ -86,6 +86,7 @@
#include "gtkprivate.h"
#include "gtkwindowprivate.h"
+#include "gtkwidgetprivate.h"
#include <string.h>
@@ -1515,7 +1516,7 @@ _gtk_entry_completion_resize_popup (GtkEntryCompletion *completion)
if (!completion->priv->filter_model)
return;
- gtk_widget_get_allocation (completion->priv->entry, &allocation);
+ gtk_widget_get_window_allocation (completion->priv->entry, &allocation);
gtk_widget_get_preferred_size (completion->priv->entry,
&entry_req, NULL);
diff --git a/gtk/gtkiconview.c b/gtk/gtkiconview.c
index 845f70a..cf06fb1 100644
--- a/gtk/gtkiconview.c
+++ b/gtk/gtkiconview.c
@@ -1660,16 +1660,17 @@ gtk_icon_view_snapshot (GtkWidget *widget,
GtkIconViewDropPosition dest_pos;
GtkIconViewItem *dest_item = NULL;
GtkStyleContext *context;
+ int width, height;
icon_view = GTK_ICON_VIEW (widget);
context = gtk_widget_get_style_context (widget);
+ gtk_widget_get_content_size (widget, &width, &height);
gtk_snapshot_push_clip (snapshot,
&GRAPHENE_RECT_INIT (
0, 0,
- gtk_widget_get_allocated_width (widget),
- gtk_widget_get_allocated_height (widget)
+ width, height
),
"IconView Clip");
@@ -1790,7 +1791,6 @@ static gboolean
gtk_icon_view_motion (GtkWidget *widget,
GdkEventMotion *event)
{
- GtkAllocation allocation;
GtkIconView *icon_view;
gint abs_y;
@@ -1802,6 +1802,7 @@ gtk_icon_view_motion (GtkWidget *widget,
if (icon_view->priv->doing_rubberband)
{
+ int width, height;
gtk_icon_view_update_rubberband (icon_view);
abs_y = event->y - icon_view->priv->height *
@@ -1809,14 +1810,14 @@ gtk_icon_view_motion (GtkWidget *widget,
(gtk_adjustment_get_upper (icon_view->priv->vadjustment) -
gtk_adjustment_get_lower (icon_view->priv->vadjustment)));
- gtk_widget_get_allocation (widget, &allocation);
+ gtk_widget_get_content_size (widget, &width, &height);
- if (abs_y < 0 || abs_y > allocation.height)
+ if (abs_y < 0 || abs_y > height)
{
if (abs_y < 0)
icon_view->priv->scroll_value_diff = abs_y;
else
- icon_view->priv->scroll_value_diff = abs_y - allocation.height;
+ icon_view->priv->scroll_value_diff = abs_y - height;
icon_view->priv->event_last_x = event->x;
icon_view->priv->event_last_y = event->y;
@@ -2582,7 +2583,7 @@ gtk_icon_view_real_toggle_cursor_item (GtkIconView *icon_view)
static void
gtk_icon_view_set_hadjustment_values (GtkIconView *icon_view)
{
- GtkAllocation allocation;
+ int width, height;
GtkAdjustment *adj = icon_view->priv->hadjustment;
gdouble old_page_size;
gdouble old_upper;
@@ -2590,12 +2591,12 @@ gtk_icon_view_set_hadjustment_values (GtkIconView *icon_view)
gdouble new_value;
gdouble new_upper;
- gtk_widget_get_allocation (GTK_WIDGET (icon_view), &allocation);
+ gtk_widget_get_content_size (GTK_WIDGET (icon_view), &width, &height);
old_value = gtk_adjustment_get_value (adj);
old_upper = gtk_adjustment_get_upper (adj);
old_page_size = gtk_adjustment_get_page_size (adj);
- new_upper = MAX (allocation.width, icon_view->priv->width);
+ new_upper = MAX (width, icon_view->priv->width);
if (gtk_widget_get_direction (GTK_WIDGET (icon_view)) == GTK_TEXT_DIR_RTL)
{
@@ -2609,37 +2610,37 @@ gtk_icon_view_set_hadjustment_values (GtkIconView *icon_view)
* rectangle fixed. This means right edge of thumb should remain fixed.
* In this case, upper - value - page_size should remain constant.
*/
- new_value = (new_upper - allocation.width) -
+ new_value = (new_upper - width) -
(old_upper - old_value - old_page_size);
- new_value = CLAMP (new_value, 0, new_upper - allocation.width);
+ new_value = CLAMP (new_value, 0, new_upper - width);
}
else
- new_value = CLAMP (old_value, 0, new_upper - allocation.width);
+ new_value = CLAMP (old_value, 0, new_upper - width);
gtk_adjustment_configure (adj,
new_value,
0.0,
new_upper,
- allocation.width * 0.1,
- allocation.width * 0.9,
- allocation.width);
+ width * 0.1,
+ width * 0.9,
+ width);
}
static void
gtk_icon_view_set_vadjustment_values (GtkIconView *icon_view)
{
- GtkAllocation allocation;
+ int width, height;
GtkAdjustment *adj = icon_view->priv->vadjustment;
- gtk_widget_get_allocation (GTK_WIDGET (icon_view), &allocation);
+ gtk_widget_get_content_size (GTK_WIDGET (icon_view), &width, &height);
gtk_adjustment_configure (adj,
gtk_adjustment_get_value (adj),
0.0,
- MAX (allocation.height, icon_view->priv->height),
- allocation.height * 0.1,
- allocation.height * 0.9,
- allocation.height);
+ MAX (height, icon_view->priv->height),
+ height * 0.1,
+ height * 0.9,
+ height);
}
static void
@@ -2735,6 +2736,7 @@ gtk_icon_view_layout (GtkIconView *icon_view)
gint col, row;
GtkRequestedSize *sizes;
gboolean rtl;
+ int width, height;
if (gtk_icon_view_is_empty (icon_view))
return;
@@ -2742,16 +2744,18 @@ gtk_icon_view_layout (GtkIconView *icon_view)
rtl = gtk_widget_get_direction (GTK_WIDGET (icon_view)) == GTK_TEXT_DIR_RTL;
n_items = gtk_icon_view_get_n_items (icon_view);
+ gtk_widget_get_content_size (widget, &width, &height);
+
gtk_icon_view_compute_n_items_for_size (icon_view,
GTK_ORIENTATION_HORIZONTAL,
- gtk_widget_get_allocated_width (widget),
+ width,
NULL, NULL,
&n_columns, &item_width);
n_rows = (n_items + n_columns - 1) / n_columns;
priv->width = n_columns * (item_width + 2 * priv->item_padding + priv->column_spacing) -
priv->column_spacing;
priv->width += 2 * priv->margin;
- priv->width = MAX (priv->width, gtk_widget_get_allocated_width (widget));
+ priv->width = MAX (priv->width, width);
/* Clear the per row contexts */
g_ptr_array_set_size (icon_view->priv->row_contexts, 0);
@@ -2801,9 +2805,9 @@ gtk_icon_view_layout (GtkIconView *icon_view)
priv->height -= priv->row_spacing;
priv->height += priv->margin;
- priv->height = MIN (priv->height, gtk_widget_get_allocated_height (widget));
+ priv->height = MIN (priv->height, height);
- gtk_distribute_natural_allocation (gtk_widget_get_allocated_height (widget) - priv->height,
+ gtk_distribute_natural_allocation (height - priv->height,
n_rows,
sizes);
@@ -2842,7 +2846,7 @@ gtk_icon_view_layout (GtkIconView *icon_view)
priv->height -= priv->row_spacing;
priv->height += priv->margin;
- priv->height = MAX (priv->height, gtk_widget_get_allocated_height (widget));
+ priv->height = MAX (priv->height, height);
}
static void
@@ -2989,23 +2993,7 @@ static void
gtk_icon_view_queue_draw_item (GtkIconView *icon_view,
GtkIconViewItem *item)
{
- GdkRectangle rect;
- GdkRectangle *item_area = &item->cell_area;
- GtkAllocation allocation;
-
- rect.x = item_area->x - icon_view->priv->item_padding;
- rect.y = item_area->y - icon_view->priv->item_padding;
- rect.width = item_area->width + icon_view->priv->item_padding * 2;
- rect.height = item_area->height + icon_view->priv->item_padding * 2;
-
- gtk_widget_get_allocation (GTK_WIDGET (icon_view), &allocation);
-
- rect.x += allocation.x -
- gtk_adjustment_get_value (icon_view->priv->hadjustment);
- rect.y += allocation.y -
- gtk_adjustment_get_value (icon_view->priv->vadjustment);
-
- gtk_widget_queue_draw_area (GTK_WIDGET (icon_view), rect.x, rect.y, rect.width, rect.height);
+ gtk_widget_queue_draw (GTK_WIDGET (icon_view));
}
void
@@ -3988,7 +3976,7 @@ gtk_icon_view_scroll_to_path (GtkIconView *icon_view,
if (use_align)
{
- GtkAllocation allocation;
+ int width, height;
gint x, y;
gfloat offset;
GdkRectangle item_area =
@@ -4002,14 +3990,14 @@ gtk_icon_view_scroll_to_path (GtkIconView *icon_view,
x =0;
y =0;
- gtk_widget_get_allocation (widget, &allocation);
+ gtk_widget_get_content_size (widget, &width, &height);
- offset = y + item_area.y - row_align * (allocation.height - item_area.height);
+ offset = y + item_area.y - row_align * (height - item_area.height);
gtk_adjustment_set_value (icon_view->priv->vadjustment,
gtk_adjustment_get_value (icon_view->priv->vadjustment) + offset);
- offset = x + item_area.x - col_align * (allocation.width - item_area.width);
+ offset = x + item_area.x - col_align * (width - item_area.width);
gtk_adjustment_set_value (icon_view->priv->hadjustment,
gtk_adjustment_get_value (icon_view->priv->hadjustment) + offset);
@@ -5931,15 +5919,13 @@ remove_scroll_timeout (GtkIconView *icon_view)
static void
gtk_icon_view_autoscroll (GtkIconView *icon_view)
{
- GtkAllocation allocation;
gint px, py, width, height;
gint hoffset, voffset;
- gtk_widget_get_allocation (GTK_WIDGET (icon_view), &allocation);
px = icon_view->priv->event_last_x;
py = icon_view->priv->event_last_y;
- width = allocation.width;
- height = allocation.height;
+
+ gtk_widget_get_content_size (GTK_WIDGET (icon_view), &width, &height);
/* see if we are near the edge. */
voffset = py - 2 * SCROLL_EDGE_SIZE;
diff --git a/gtk/gtklistbox.c b/gtk/gtklistbox.c
index ee5de48..12d76fe 100644
--- a/gtk/gtklistbox.c
+++ b/gtk/gtklistbox.c
@@ -1440,7 +1440,7 @@ ensure_row_visible (GtkListBox *box,
if (!priv->adjustment)
return;
- gtk_widget_get_allocation (GTK_WIDGET (row), &allocation);
+ gtk_widget_get_outer_allocation (GTK_WIDGET (row), &allocation);
y = allocation.y;
height = allocation.height;
@@ -1448,7 +1448,7 @@ ensure_row_visible (GtkListBox *box,
header = ROW_PRIV (row)->header;
if (GTK_IS_WIDGET (header) && gtk_widget_is_drawable (header))
{
- gtk_widget_get_allocation (header, &allocation);
+ gtk_widget_get_outer_allocation (header, &allocation);
y = allocation.y;
height += allocation.height;
}
diff --git a/gtk/gtkmenu.c b/gtk/gtkmenu.c
index 368fad7..5a66f30 100644
--- a/gtk/gtkmenu.c
+++ b/gtk/gtkmenu.c
@@ -2559,15 +2559,8 @@ gtk_menu_reorder_child (GtkMenu *menu,
static void
gtk_menu_realize (GtkWidget *widget)
{
- GtkMenu *menu = GTK_MENU (widget);
- GtkAllocation allocation;
- GtkBorder arrow_border;
-
GTK_WIDGET_CLASS (gtk_menu_parent_class)->realize (widget);
- gtk_widget_get_allocation (widget, &allocation);
- get_arrows_border (menu, &arrow_border);
-
if (GTK_MENU_SHELL (widget)->priv->active_menu_item)
gtk_menu_scroll_item_visible (GTK_MENU_SHELL (widget),
GTK_MENU_SHELL (widget)->priv->active_menu_item);
@@ -3160,7 +3153,7 @@ definitely_within_item (GtkWidget *widget,
GtkAllocation allocation;
int w, h;
- gtk_widget_get_allocation (widget, &allocation);
+ gtk_widget_get_outer_allocation (widget, &allocation);
w = allocation.width;
h = allocation.height;
diff --git a/gtk/gtkrange.c b/gtk/gtkrange.c
index 9e6320d..f74f1b2 100644
--- a/gtk/gtkrange.c
+++ b/gtk/gtkrange.c
@@ -1412,15 +1412,12 @@ gtk_range_allocate_trough (GtkGizmo *gizmo,
GtkWidget *widget = gtk_widget_get_parent (GTK_WIDGET (gizmo));
GtkRange *range = GTK_RANGE (widget);
GtkRangePrivate *priv = range->priv;
- GtkAllocation slider_alloc, widget_alloc;
- GtkAllocation trough_alloc;
+ GtkAllocation slider_alloc;
double value;
/* Slider */
gtk_range_calc_marks (range);
- gtk_widget_get_allocation (widget, &widget_alloc);
- gtk_widget_get_allocation (GTK_WIDGET (gizmo), &trough_alloc);
gtk_range_compute_slider_position (range,
gtk_adjustment_get_value (priv->adjustment),
&slider_alloc);
@@ -2358,19 +2355,19 @@ update_autoscroll_mode (GtkRange *range)
if (range->priv->zoom)
{
- GtkAllocation allocation;
+ int width, height;
gint size, pos;
- gtk_widget_get_allocation (GTK_WIDGET (range), &allocation);
+ gtk_widget_get_content_size (GTK_WIDGET (range), &width, &height);
if (range->priv->orientation == GTK_ORIENTATION_VERTICAL)
{
- size = allocation.height;
+ size = height;
pos = range->priv->mouse_y;
}
else
{
- size = allocation.width;
+ size = width;
pos = range->priv->mouse_x;
}
diff --git a/gtk/gtkscale.c b/gtk/gtkscale.c
index 8b5442b..75fd355 100644
--- a/gtk/gtkscale.c
+++ b/gtk/gtkscale.c
@@ -485,9 +485,9 @@ find_next_pos (GtkWidget *widget,
gint *marks,
GtkPositionType pos)
{
- GtkAllocation allocation;
GSList *m;
gint i;
+ int width, height;
for (m = list->next, i = 1; m; m = m->next, i++)
{
@@ -497,11 +497,11 @@ find_next_pos (GtkWidget *widget,
return marks[i];
}
- gtk_widget_get_allocation (widget, &allocation);
+ gtk_widget_get_content_size (widget, &width, &height);
if (gtk_orientable_get_orientation (GTK_ORIENTABLE (widget)) == GTK_ORIENTATION_HORIZONTAL)
- return allocation.width;
+ return width;
else
- return allocation.height;
+ return height;
}
static void
diff --git a/gtk/gtkscrolledwindow.c b/gtk/gtkscrolledwindow.c
index a9c1303..14efd37 100644
--- a/gtk/gtkscrolledwindow.c
+++ b/gtk/gtkscrolledwindow.c
@@ -1083,7 +1083,7 @@ event_close_to_indicator (GtkScrolledWindow *sw,
priv = sw->priv;
- gtk_widget_get_allocation (indicator->scrollbar, &indicator_alloc);
+ gtk_widget_get_outer_allocation (indicator->scrollbar, &indicator_alloc);
gdk_event_get_coords (event, &x, &y);
if (indicator->over)
@@ -1354,14 +1354,11 @@ gtk_scrolled_window_size_allocate (GtkWidget *widget,
GtkScrolledWindowPrivate *priv = scrolled_window->priv;
GtkBin *bin;
GtkAllocation child_allocation;
- GtkAllocation sw_allocation;
GtkWidget *child;
gint sb_width;
gint sb_height;
bin = GTK_BIN (scrolled_window);
- gtk_widget_get_allocation (GTK_WIDGET (scrolled_window), &sw_allocation);
-
/* Get possible scrollbar dimensions */
gtk_widget_measure (priv->vscrollbar, GTK_ORIENTATION_HORIZONTAL, -1,
@@ -3985,9 +3982,6 @@ gtk_scrolled_window_realize (GtkWidget *widget)
{
GtkScrolledWindow *scrolled_window = GTK_SCROLLED_WINDOW (widget);
GtkScrolledWindowPrivate *priv = scrolled_window->priv;
- GtkAllocation allocation;
-
- gtk_widget_get_allocation (widget, &allocation);
priv->hindicator.scrollbar = priv->hscrollbar;
priv->vindicator.scrollbar = priv->vscrollbar;
diff --git a/gtk/gtkstack.c b/gtk/gtkstack.c
index 6855e67..baa56d4 100644
--- a/gtk/gtkstack.c
+++ b/gtk/gtkstack.c
@@ -1834,35 +1834,34 @@ gtk_stack_snapshot_under (GtkWidget *widget,
{
GtkStack *stack = GTK_STACK (widget);
GtkStackPrivate *priv = gtk_stack_get_instance_private (stack);
- GtkAllocation allocation;
+ int widget_width, widget_height;
gint x, y, width, height, pos_x, pos_y;
- gtk_widget_get_allocation (widget, &allocation);
+
+ gtk_widget_get_content_size (widget, &widget_width, &widget_height);
x = y = 0;
- width = allocation.width;
- height = allocation.height;
pos_x = pos_y = 0;
switch (priv->active_transition_type)
{
case GTK_STACK_TRANSITION_TYPE_UNDER_DOWN:
y = 0;
- height = allocation.height * (gtk_progress_tracker_get_ease_out_cubic (&priv->tracker, FALSE));
+ height = widget_height * (gtk_progress_tracker_get_ease_out_cubic (&priv->tracker, FALSE));
pos_y = height;
break;
case GTK_STACK_TRANSITION_TYPE_UNDER_UP:
- y = allocation.height * (1 - gtk_progress_tracker_get_ease_out_cubic (&priv->tracker, FALSE));
- height = allocation.height - y;
- pos_y = y - allocation.height;
+ y = widget_height * (1 - gtk_progress_tracker_get_ease_out_cubic (&priv->tracker, FALSE));
+ height = widget_height - y;
+ pos_y = y - widget_height;
break;
case GTK_STACK_TRANSITION_TYPE_UNDER_LEFT:
- x = allocation.width * (1 - gtk_progress_tracker_get_ease_out_cubic (&priv->tracker, FALSE));
- width = allocation.width - x;
- pos_x = x - allocation.width;
+ x = widget_width * (1 - gtk_progress_tracker_get_ease_out_cubic (&priv->tracker, FALSE));
+ width = widget_width - x;
+ pos_x = x - widget_width;
break;
case GTK_STACK_TRANSITION_TYPE_UNDER_RIGHT:
x = 0;
- width = allocation.width * (gtk_progress_tracker_get_ease_out_cubic (&priv->tracker, FALSE));
+ width = widget_width * (gtk_progress_tracker_get_ease_out_cubic (&priv->tracker, FALSE));
pos_x = width;
break;
default:
@@ -1900,11 +1899,11 @@ gtk_stack_snapshot_slide (GtkWidget *widget,
if (priv->last_visible_node)
{
- GtkAllocation allocation;
graphene_matrix_t matrix;
int x, y;
+ int width, height;
- gtk_widget_get_allocation (widget, &allocation);
+ gtk_widget_get_content_size (widget, &width, &height);
x = get_bin_window_x (stack);
y = get_bin_window_y (stack);
@@ -1912,16 +1911,16 @@ gtk_stack_snapshot_slide (GtkWidget *widget,
switch (priv->active_transition_type)
{
case GTK_STACK_TRANSITION_TYPE_SLIDE_LEFT:
- x -= allocation.width;
+ x -= width;
break;
case GTK_STACK_TRANSITION_TYPE_SLIDE_RIGHT:
- x += allocation.width;
+ x += width;
break;
case GTK_STACK_TRANSITION_TYPE_SLIDE_UP:
- y -= allocation.height;
+ y -= height;
break;
case GTK_STACK_TRANSITION_TYPE_SLIDE_DOWN:
- y += allocation.height;
+ y += height;
break;
case GTK_STACK_TRANSITION_TYPE_OVER_UP:
case GTK_STACK_TRANSITION_TYPE_OVER_DOWN:
@@ -1937,10 +1936,10 @@ gtk_stack_snapshot_slide (GtkWidget *widget,
}
if (gtk_widget_get_valign (priv->last_visible_child->widget) == GTK_ALIGN_END &&
- priv->last_visible_widget_height > allocation.height)
- y -= priv->last_visible_widget_height - allocation.height;
+ priv->last_visible_widget_height > height)
+ y -= priv->last_visible_widget_height - height;
else if (gtk_widget_get_valign (priv->last_visible_child->widget) == GTK_ALIGN_CENTER)
- y -= (priv->last_visible_widget_height - allocation.height) / 2;
+ y -= (priv->last_visible_widget_height - height) / 2;
graphene_matrix_init_translate (&matrix, &GRAPHENE_POINT3D_INIT (x, y, 0));
gtk_snapshot_push_transform (snapshot, &matrix, "StackSlide");
@@ -1964,6 +1963,8 @@ gtk_stack_snapshot (GtkWidget *widget,
{
if (gtk_progress_tracker_get_state (&priv->tracker) != GTK_PROGRESS_STATE_AFTER)
{
+ int width, height;
+
if (priv->last_visible_node == NULL &&
priv->last_visible_child != NULL)
{
@@ -1980,11 +1981,11 @@ gtk_stack_snapshot (GtkWidget *widget,
priv->last_visible_node = gtk_snapshot_finish (&last_visible_snapshot);
}
+ gtk_widget_get_content_size (widget, &width, &height);
gtk_snapshot_push_clip (snapshot,
&GRAPHENE_RECT_INIT(
0, 0,
- gtk_widget_get_allocated_width (widget),
- gtk_widget_get_allocated_height (widget)
+ width, height
),
"StackAnimationClip");
diff --git a/gtk/gtkstackswitcher.c b/gtk/gtkstackswitcher.c
index 37678fd..19c887f 100644
--- a/gtk/gtkstackswitcher.c
+++ b/gtk/gtkstackswitcher.c
@@ -26,6 +26,7 @@
#include "gtkorientable.h"
#include "gtkprivate.h"
#include "gtkintl.h"
+#include "gtkwidgetprivate.h"
/**
* SECTION:gtkstackswitcher
@@ -294,26 +295,21 @@ gtk_stack_switcher_drag_motion (GtkWidget *widget,
{
GtkStackSwitcher *self = GTK_STACK_SWITCHER (widget);
GtkStackSwitcherPrivate *priv;
- GtkAllocation allocation;
GtkWidget *button;
GHashTableIter iter;
gpointer value;
gboolean retval = FALSE;
- gtk_widget_get_allocation (widget, &allocation);
-
priv = gtk_stack_switcher_get_instance_private (self);
- x += allocation.x;
- y += allocation.y;
-
button = NULL;
g_hash_table_iter_init (&iter, priv->buttons);
while (g_hash_table_iter_next (&iter, NULL, &value))
{
- gtk_widget_get_allocation (GTK_WIDGET (value), &allocation);
- if (x >= allocation.x && x <= allocation.x + allocation.width &&
- y >= allocation.y && y <= allocation.y + allocation.height)
+ GdkRectangle allocation;
+
+ gtk_widget_get_outer_allocation (GTK_WIDGET (value), &allocation);
+ if (gdk_rectangle_contains_point (&allocation, (int)x, (int)y))
{
button = GTK_WIDGET (value);
retval = TRUE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]