Widget, drawing and event coordinates

The goal here is to unify the coordinate systems we use for events,
drawing and size allocation.

Widget coordinates definitely should be relative to the parent
allocation in some sense, so we can move subtrees around without
re-allocating every single widget in it.

In master, all event coordinates are relative to the widget allocation,
which excludes widget margins, but includes css margin/border/padding.

In wip/baedert/drawing[1], currently widget allocations are relative to
the parent content allocation, which means the size_allocate
implementations get an allocation of
{0, 0, content_allocation_width, content_allocation_height} passed.
When drawing a widget, we first offset to the widget's content
allocation and then call its snapshot implementation. As for input, the
events get routed to a widget if the (toplevel relative) coordinates
are inside the widget's margin allocation (widget allocation excluding
the css margins as well). The coordinates the gestures (or 
gdk_event_get_coords) report however, are relative to that widget's
content allocation, i.e. the values will be negative inside the widget's
padding and border[1].

So using the content allocation in size_allocate and snapshot
implementations makes IMO perfect sense. One problem now is that
gtk_widget_get_allocation (and the still private get_margin_allocation,
get_content_allocation and get_border_allocation) are not relative to
the widget's content allocation but to the parent's (since that's the
coordinate space passed to gtk_widget_size_allocate_with_baseline).
Changing this would however mean that gtk_widget_get_allocation can
also return negative x/y coordinates.

The question is now: does this all make sense or should we go another
way? One thing I would find useful (I haven't tried it though...) is to
also exclude css margins from the widget allocation, just like we do
with widget margins currently.

[1] See also https://mail.gnome.org/archives/gtk-devel-list/2017-May/msg00034.html
[2] I modified tests/testwidgetfocus to showcase this

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]