[gtk+] GtkScrolledWindow: Take border into account
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] GtkScrolledWindow: Take border into account
- Date: Wed, 10 Dec 2014 15:03:36 +0000 (UTC)
commit a083809b937e6714ff9259e53ff28d659fb427e2
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Nov 28 17:20:23 2014 -0500
GtkScrolledWindow: Take border into account
Use the new scrollable API for getting non-scrollable borders
and draw over/undershoot at the right place. In practice, this
means that they now appear below treeview headers.
gtk/gtkscrolledwindow.c | 25 +++++++++++++++++++++++--
1 files changed, 23 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkscrolledwindow.c b/gtk/gtkscrolledwindow.c
index c2b3ecb..1365eb6 100644
--- a/gtk/gtkscrolledwindow.c
+++ b/gtk/gtkscrolledwindow.c
@@ -1766,6 +1766,26 @@ gtk_scrolled_window_draw_scrollbars_junction (GtkScrolledWindow *scrolled_window
}
static void
+gtk_scrolled_window_inner_allocation (GtkWidget *widget,
+ GtkAllocation *rect)
+{
+ GtkWidget *child;
+ GtkBorder border = { 0 };
+
+ gtk_scrolled_window_relative_allocation (widget, rect);
+
+ child = gtk_bin_get_child (GTK_BIN (widget));
+ if (GTK_IS_SCROLLABLE (child) &&
+ gtk_scrollable_get_border (GTK_SCROLLABLE (child), &border))
+ {
+ rect->x += border.left;
+ rect->y += border.top;
+ rect->width -= border.left + border.right;
+ rect->height -= border.top + border.bottom;
+ }
+}
+
+static void
gtk_scrolled_window_draw_overshoot (GtkScrolledWindow *scrolled_window,
cairo_t *cr)
{
@@ -1778,7 +1798,8 @@ gtk_scrolled_window_draw_overshoot (GtkScrolledWindow *scrolled_window,
return;
context = gtk_widget_get_style_context (widget);
- gtk_scrolled_window_relative_allocation (widget, &rect);
+ gtk_scrolled_window_inner_allocation (widget, &rect);
+
overshoot_x = CLAMP (overshoot_x, - MAX_OVERSHOOT_DISTANCE, MAX_OVERSHOOT_DISTANCE);
overshoot_y = CLAMP (overshoot_y, - MAX_OVERSHOOT_DISTANCE, MAX_OVERSHOOT_DISTANCE);
@@ -1836,7 +1857,7 @@ gtk_scrolled_window_draw_undershoot (GtkScrolledWindow *scrolled_window,
GtkAdjustment *adj;
context = gtk_widget_get_style_context (widget);
- gtk_scrolled_window_relative_allocation (widget, &rect);
+ gtk_scrolled_window_inner_allocation (widget, &rect);
gtk_style_context_save (context);
gtk_style_context_remove_class (context, GTK_STYLE_CLASS_FRAME);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]