Commit Graph

431 Commits

Author SHA1 Message Date
Timm Bäder
93aa5ce167 container: Don't use forall() in compute_expand
Use the widget list instead, which saves some code.
2018-03-20 09:37:58 +01:00
Timm Bäder
781400f6d3 container: Don't use forall() in get_request_mode
We can just use the widget child list, which save some code.
2018-03-20 09:37:58 +01:00
Timm Bäder
7351848c75 container: Fix scroll adjustment coordinates 2018-03-17 14:05:55 +01:00
Timm Bäder
3ca298ec94 container: Remove focus widget sorting code
The more general version of this code lives in gtkwidgetfocus.s now.
2018-03-17 12:09:30 +01:00
Timm Bäder
fd28bddde1 container: Only do custom focus management if a focus chain is set
Otherwise, the process should be the same one we use in GtkWidget.
2018-03-17 12:09:30 +01:00
Timm Bäder
ca4f08136a container: Rename parent_class to gtk_container_parent_class
To match the name we have everywhere else.
2018-03-17 12:09:30 +01:00
Timm Bäder
71ae2fae2e container: Remove unused struct member 2018-03-04 19:12:04 +01:00
Benjamin Otte
3bb95a09bb a11y: Remove gtk.h include from container accessible 2018-02-09 00:42:38 +01:00
Matthias Clasen
4c150d8eb5 The big versioning cleanup
Remove all the old 2.x and 3.x version annotations.
GTK+ 4 is a new start, and from the perspective of a
GTK+ 4 developer all these APIs have been around since
the beginning.
2018-02-06 01:16:32 -05:00
Timm Bäder
d3329bb36b container: Remove some unused includes 2018-01-17 21:57:19 +01:00
Timm Bäder
cba24360b1 Move geometry management docs do GtkWidget
Both GtkWidget and GtkContainer had similar docs regarding hfw/wfh
geometry management. Move these just to GtkWidget. Also make sure the
examples compile, port everything from gtk_preferred_* to measure and
replace some occurrences of "container" with "widget" where container
was just used to refer to a widget with child widgets.
2018-01-03 17:11:32 +01:00
Benjamin Otte
43c212ac28 build: Enable -Wswitch-enum and -Wswitch-default
This patch makes that work using 1 of 2 options:

1. Add all missing enums to the switch statement
  or
2. Cast the switch argument to a uint to avoid having to do that (mostly
   for GdkEventType).

I even found a bug while doing that: clearing a GtkImage with a surface
did not notify thae surface property.

The reason for enabling this flag even though it is tedious at times is
that it is very useful when adding values to an enum, because it makes
GTK immediately warn about all the switch statements where this enum is
relevant.
And I expect changes to enums to be frequent during the GTK4 development
cycle.
2017-10-06 21:23:39 +02:00
Timm Bäder
7481affb82 container: Drop priv pointer 2017-09-03 09:17:35 +02:00
Timm Bäder
f879750759 container: Fix scrolling adjustment coordinates 2017-08-21 12:30:47 +02:00
Timm Bäder
b24535ea75 container: Remove gtk_container_propagate_draw
It's superseded by gtk_widget_snapshot_child now.
2017-08-21 12:30:42 +02:00
Daniel Boles
23b6699ec3 Container: Don’t scroll to unset focus child coord
In gtk_container_real_set_focus_child(), we try to scroll to the
position of the new :focus-child if we have h or v adjustments.

gtk_widget_translate_coordinates() returns FALSE if neither widget is
realized or in other situations that cause output parameters x and y not
to be set. Thus, if the caller did not initialise x/y and uses them even
if the function returned FALSE, they are using uninitialised variables.

In gtk_container_real_set_focus_child(), we did not check the return
value but merrily went ahead and used x and y regardless. This is UB, as
revealed by Valgrind, as well as being pointless.

The trivial fix is to exit early if (!gtk_widget_translate_coordinates).

https://bugzilla.gnome.org/show_bug.cgi?id=776909
2017-08-07 19:21:09 +01:00
Daniel Boles
c4865bed43 Container: Fix scrolled coord in set_focus_child()
Commit 885bcd9fe4 trampled the bit here
that is meant to translate between the nominated focus child and the
actual innermost one that is used for updating the h/v adjustments.

So, we need to save the passed focus child before diving into its
children, then translate and get allocations between them both. This
makes GTK+ 4 behave like GTK+ 3 again: instead of priv->focus_child and
focus_child, we now have focus_child and child, serving the roles of the
nominated focus child and its innermost focus child respectively.

This also ditches the unnecessary call to Widget:get_focus_child(), as
Container::set_focus_child() gets that same new child as an argument.
2017-08-07 18:42:15 +01:00
Timm Bäder
36ab70ddf5 widget: Add baseline and out_clip parameters to size-allocate
Since setting a clip is mandatory for almost all widgets, we can as well
change the size-allocate signature to include a out_clip parameter, just
like GtkCssGadget did. And since we now always propagate baselines, we
might as well pass that one on to size-allocate.

This way we can also make sure to transform the clip returned from
size-allocate to parent-coordinates, i.e. the same coordinate space
priv->allocation is in.
2017-07-19 21:27:16 -04:00
Timm Bäder
f9f6f3027d container: Remove get_children_clip
Unused.
2017-07-19 21:27:14 -04:00
Timm Bäder
bccaeb0e2d widget: Make allocations parent-content-allocation relative 2017-07-19 21:27:13 -04:00
Timm Bäder
f1c1e52eea container: GtkActionBar is not a special container anymore 2017-07-19 21:27:13 -04:00
Timm Bäder
07cbbc6fa9 container: Propagate child properties if parent != container
This can happen when e.g. GtkNotebook adds the child page widgets not
directly inside the notebook, but inside the inner GtkStack.
2017-07-19 21:27:12 -04:00
Timm Bäder
ef0ab1fb00 container: Remove snapshot and draw implementations 2017-07-19 21:27:11 -04:00
Timm Bäder
0938183ae6 container: Use gtk_container_forall less
Just iterate over the child widgets directly and produce a much nicer
stack trace when debugging.
2017-04-25 20:30:37 +02:00
Timm Bäder
f053a63d74 container: Remove include_internals parameter from forall
with include_internals=TRUE, this is the same as the (still private)
gtk_widget_forall, or just using the children/sibling accessors in a
loop.
2017-04-25 20:30:37 +02:00
Timm Bäder
885bcd9fe4 container: Remove focus_child pointer
Use GtkWidget's instead.
2017-03-31 09:50:39 +02:00
Timm Bäder
0d480a3eb0 Remove gtk_container_get_focus_child 2017-03-31 09:50:39 +02:00
Timm Bäder
43cdeee3c4 widget: Save pointer to focus child
Do the same thing GtkContainer does.
2017-03-31 09:50:39 +02:00
Timm Bäder
47d4ad71fb Remove gtk_container_snapshot_child
Replace it with the already existing gtk_widget_snapshot_child.
2017-01-07 17:19:30 +01:00
Timm Bäder
8ef73660e4 widget: Implement map/unmap with child widgets
Once again, do what GtkContainer did before.
2017-01-07 16:44:01 +01:00
Timm Bäder
b15b9e028f widget: Implement show_all
Do what gtk_container_forall did: show_all all children, then the widget
itself.
2017-01-07 16:44:01 +01:00
Benjamin Otte
c4065b9ee0 API: Export gtk_container_snapshot_child()
It's equivalent to gtk_container_propagate_draw() and then one is
public, too.
2016-12-20 19:26:40 +01:00
Benjamin Otte
cb8483b0a6 gtk: Remove unneeded gtk_snapshot_push()/pop() calls 2016-12-09 21:39:43 +01:00
Benjamin Otte
4850271ae8 API: Remove gtk_cairo_should_draw_window()
The answer is: Yes.
2016-11-23 18:48:38 +01:00
Benjamin Otte
f728f33382 container: ensure we only append a single node
The snapshot vfuncs must only append at most a single node,
otherwise things are going to break if the widget is the root node.

Unfortunately there is no code that can check this in a generic fashion,
so we'll have to debug this on a case-by-case basis.
2016-11-15 22:39:26 +01:00
Benjamin Otte
e2fb970889 container: Remove get_render_node() support API
It's unused now.
2016-11-15 17:49:19 +01:00
Benjamin Otte
ae2477b1bc container: Add snapshot() implementation
Note that this implementation does not respect GDK windows at all. If
your widget requires respecting them, you should write your own
snapshot implementation and not chain up.
2016-11-15 17:48:45 +01:00
Benjamin Otte
d1fec79c00 snapshot: Completely reengineer API
We now try to emulate cairo_t:

We keep a stack of nodes via push/pop and a transform matrix.

So whenever a new node is added to the snapshot, we transform it
by the current transform matrix and append it to the current node.
2016-11-15 17:48:45 +01:00
Benjamin Otte
bb9626dc29 window: Implement snapshot() 2016-11-15 17:48:45 +01:00
Timm Bäder
846cf681e8 Remove gtk_widget_set_mapped
Let all the remaining callers chain up.
2016-11-05 11:56:36 +01:00
Matthias Clasen
68cc1412e5 container: Add a private api for render node propagation
Add a function that propagates a render node for a single
child. This will be used in the box gadget to handle widgets.
2016-11-01 14:29:25 -04:00
Timm Bäder
0f6235752e container: Remove composite_name 2016-10-20 20:12:05 +02:00
Timm Bäder
de65f87816 container: Remove reallocate_redraws 2016-10-20 20:12:05 +02:00
Timm Bäder
e772c2b622 container: Don't queue resize on non-toplevel widgets 2016-10-20 17:09:06 +02:00
Matthias Clasen
58b38d59c5 container: Prepare to prune render nodes
Add a should_propagate function for render nodes. Eventually,
this is meant to avoid creating render nodes for child widgets
that are outside the parents clip area. Since we don't have
that information available right now, just filter out nondrawable
children for now.
2016-10-18 11:49:15 +01:00
Matthias Clasen
f74dd416d6 Make outer shadows work again
Change get_render_node to return nodes that are sized to the clip
area and expect to be placed at the clip position; change
gtk_container_propagate_render_node to place child render nodes
accordingly, and change gtk_css_gadget_get_render_node to return
nodes that are sized accordingly as well.
2016-10-18 11:49:14 +01:00
Emmanuele Bassi
23a009a408 gtk: Sort children by window depth when rendering
This makes popovers pop over instead of under.
2016-10-18 11:49:14 +01:00
Emmanuele Bassi
bfad9fe4ee gtk: Update the coordinates when propagating render nodes
Just like gtk_container_propagate_draw() does for the immediate mode
rendering.
2016-10-18 11:49:10 +01:00
Emmanuele Bassi
cd0de3f87c gtk: Add GtkContainer API to gather render nodes
We cannot implement GtkWidgetClass.get_render_node() in GtkContainer
without breaking the fallback path that renders a widget to a single
render node rasterization. For GtkContainer subclasses we should provide
a simple API, similar to gtk_container_propagate_draw(), that gathers
all the render nodes for each child.
2016-10-18 11:49:09 +01:00
Emmanuele Bassi
9557364216 gtk: Mark internal functions as static
These functions are only used within their compilation unit.
2016-10-17 11:44:10 +01:00