#include "gtktypebuiltins.h"
#include "gtkwidgetprivate.h"
+/* Allow shadows to overdraw without immediately culling the widget at the viewport
+ * boundary.
+ * Choose this so that roughly 1 extra widget gets drawn on each side of the viewport,
+ * but not more. Icons are 16px, text height is somewhere there, too.
+ */
+#define GTK_LIST_BASE_CHILD_MAX_OVERDRAW 10
+
typedef struct _RubberbandData RubberbandData;
struct _RubberbandData
int height)
{
GtkAllocation child_allocation;
+ int self_width, self_height;
+
+ self_width = gtk_widget_get_width (GTK_WIDGET (self));
+ self_height = gtk_widget_get_height (GTK_WIDGET (self));
+
+ if (y + height + GTK_LIST_BASE_CHILD_MAX_OVERDRAW <= 0 ||
+ y - GTK_LIST_BASE_CHILD_MAX_OVERDRAW >= self_height ||
+ x + width + GTK_LIST_BASE_CHILD_MAX_OVERDRAW <= 0 ||
+ x - GTK_LIST_BASE_CHILD_MAX_OVERDRAW >= self_width)
+ {
+ /* child is fully outside the viewport, hide it and don't allocate it */
+ gtk_widget_set_child_visible (child, FALSE);
+ return;
+ }
+
+ gtk_widget_set_child_visible (child, TRUE);
if (gtk_list_base_get_orientation (GTK_LIST_BASE (self)) == GTK_ORIENTATION_VERTICAL)
{
}
else
{
- int mirror_point = gtk_widget_get_width (GTK_WIDGET (self));
-
- child_allocation.x = mirror_point - x - width;
+ child_allocation.x = self_width - x - width;
child_allocation.y = y;
child_allocation.width = width;
child_allocation.height = height;
}
else
{
- int mirror_point = gtk_widget_get_width (GTK_WIDGET (self));
-
- child_allocation.x = mirror_point - y - height;
+ child_allocation.x = self_width - y - height;
child_allocation.y = x;
child_allocation.width = height;
child_allocation.height = width;