Commit Graph

139 Commits

Author SHA1 Message Date
Timm Bäder
1aa811ce12 Remove all gtk_widget_get_content_size usages
And remove the function itself. Make everything use gtk_widget_get_width
and gtk_widget_get_height instead.
2017-12-06 07:56:12 +01:00
Matthias Clasen
ffd6baec42 gtk: Intern css names
This avoids a bunch of strdups at startup.
2017-11-17 22:49:57 -05: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
Daniel Boles
37b23927c4 Stack: Fix copy-paste error
This fixes Coverity CID 1452217.
2017-08-01 19:18:39 +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
c8ca43ad51 stack: Fix under transitions
make sure we initialize both width and height with proper values.
2017-07-19 21:27:15 -04:00
Timm Bäder
3dc6d240b3 Fix a few allocation coordinates & sizes 2017-07-19 21:27:15 -04:00
Timm Bäder
27202ff6cb stack: Compute clip directly 2017-07-19 21:27:14 -04:00
Timm Bäder
c2abb698be Replace a few get_content_allocation calls with get_content_size
The position of the content allocation is almost never relevant since
it's 0/0 for measure, size_allocate and snapshot.
2017-07-19 21:27:14 -04:00
Timm Bäder
9e50447253 stack: Remove bin_window 2017-07-19 21:27:13 -04:00
Timm Bäder
dc4bdc2021 stack: Remove gadget 2017-07-19 21:27:12 -04:00
Timm Bäder
ede6f2ab59 Slightly rework clip handling
always initialize clips to the (content) allocation, don't walk up the
widget hierarchy in gtk_widget_set_clip, implement
gtk_widget_size_allocate in GtkSeparator. This way we don't end up using
uninitialized clip values.

The entire clip handling is up for major rework since we can't and don't
want to force every single widget to call _set_clip in size-allocate
implementations.
2017-07-19 21:27:12 -04:00
Timm Bäder
5504dc6684 stack: Remove css box drawing 2017-07-19 21:27:11 -04:00
Carlos Garnacho
ea4ee876ec gtkstack: Remove view window
This widget already sets a clip area, so the view window can be safely
removed.
2017-05-25 16:25:59 +02:00
Carlos Garnacho
a72404dd5a gtk: Mass delete all GtkWidget event mask API
We now rely on toplevels receiving and forwarding all the events
the windowing should be able to handle. Event masks are no longer a
way to determine whether an event is deliverable ot a widget.

Events will always be delivered in the three captured/target/bubbled
phases, widgets can now just attach GtkEventControllers and let those
handle the events.
2017-05-25 16:25:58 +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
2f6d60d6af stack: Fix node position during crossfade 2017-01-30 18:11:15 +01:00
Benjamin Otte
b58de2d16c snapshot: Redo pop() API
gtk_snapshot_pop() => removed
gtk_snapshot_pop_and_append() => gtk_snapshot_pop()

So now there is no way to get a rendernode out of the snapshotting API
until you gtk_snapshot_finish().
2017-01-13 03:38:36 +01:00
Benjamin Otte
4668e6dc63 stack: Build stored render node with custom Snapshot object
This is in preparation for API changes in GtkSnapshot.
2017-01-13 03:38:36 +01:00
Benjamin Otte
d9b0685b49 Add gtk_snapshot_push_cross_fade()
... and use it.

The function is a bit awkward because it requires 2 calls to
gtk_snapshot_pop(), but once you accept that, it's very convenient to
use, as can be seen by the 2 implementations.
2017-01-13 03:38:36 +01:00
Alexander Larsson
7bee22bcb6 Avoid some more type checks for internal calls 2017-01-11 15:27:51 +01:00
Alexander Larsson
65ad2541d7 Snapshot: Only record names if inspector is recording
Otherwise we do a lot of allocations and vprintf calls which are
not used.
2017-01-11 10:22:40 +01: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
Benjamin Otte
0dbdf0c428 gadget: Remove gtk_css_gadget_draw()
And with it, remove the draw func from custom gadgets, that has been
NULL everywhere.

All gadgets are snapshot now.
2016-12-20 18:01:12 +01:00
Benjamin Otte
30438c6e8b gsk: Add cross-fade node
And implement stack crossfades with it.
2016-12-20 18:01:11 +01:00
Benjamin Otte
b0175421f2 stack: Implement snapshot()
This uses the new push()/pop() mechanism to its fullest extent when
implementing transitions. It's fun to inspect the results in the
inspector.

Crossfades don't work yet, they continue using a Cairo fallback.

A side effect of the stack conversion is that widget-factory now uses
snapshots for a lot more things.
2016-12-20 18:01:10 +01:00
Benjamin Otte
68a54ae81f stack: Don't draw an extra background
The gadget draws a background for us, we don't need another one.
2016-12-20 18:01:10 +01:00
Debarshi Ray
faf2295440 GtkStack: Remove redundant code
Commit 7ce96cb6ac avoids notifications
during destruction by using gtk_widget_in_destruction. Therefore this
code is no longer needed.

This reverts commit 39e7afecb1

https://bugzilla.gnome.org/show_bug.cgi?id=749012
2016-12-20 00:32:15 +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
da207c9fdd snapshot: Add a snapshot function to GtkCssCustomGadget 2016-11-15 17:48:45 +01:00
Olivier Fourdan
03b8a8a880 gtkstack: reorder size_allocate and move_window
Unlike other container widgets, GtkStack would allocate its children
prior to moving its windows, which might prevent further valid size
allocation signals to be emitted.

Re-order the size allocation of child widgets to be performed after
moving the GtkStack windows.

Thanks to Owen for spotting the real issue here.

https://bugzilla.gnome.org/show_bug.cgi?id=767713
2016-11-14 12:24:18 +01:00
Timm Bäder
0d88fe65ba stack: Use gtk_widget_measure 2016-11-12 20:37:22 +01:00
Benjamin Otte
32a5729d18 gtk: Chain up in realize()
... instead of copy/paste from gtk_widget_real_realize.
2016-11-02 07:16:08 +01:00
Timm Bäder
ee4ba18d5e stack: Don't underallocate child in interpolate-size case
In that case, we can't just rely on the stack allocation being big
enough. Especially, the child can actually be bigger than the current
stack allocation, so take that into account when positioning it.
2016-10-31 19:29:36 +01:00
Timm Bäder
8dce94c47a stack: Redraw last_visible_surface if child allocation changes
So the widget is properly aligned.
2016-10-31 19:29:36 +01:00
Timm Bäder
acbdd5c8f2 Fix clip position of windowed widgets 2016-10-28 17:56:51 +02:00
Timm Bäder
82d38e35f8 stack: Use measure() to measure child widget
Simpler code this way \o/
2016-10-28 16:33:02 +02:00
Timm Bäder
9992a616ef widget: Use ::measure vfunc to measure size
Add a new ::measure vfunc similar to GtkCssGadget's that widget
implementations have to override instead of the old get_preferred_width,
get_preferred_height, get_preferred_width_for_height,
get_preferred_height_for_width and
get_preferred_height_and_baseline_for_width.
2016-10-22 19:05:47 +02:00
Benjamin Otte
edc9a08b7c stack: Use gdk_window_new_child() 2016-10-18 00:22:35 +02:00
Benjamin Otte
4df6ddad54 API: container: Remove gtk_container_set_border_width() 2016-10-16 18:18:58 +02:00
Benjamin Otte
662001b60a API: Remove ability to set visuals on windows
And with it, gtk_widget_get_visual() and gtk_widget_set_visual() are
gone.

We now always use the RGBA visual (if available) and otherwise fall back
to the system visual.
2016-10-16 18:17:21 +02:00
Timm Bäder
0b0d4765a0 Add GtkStackAccessible
Show only the currently visible child to a11y.
2016-05-30 19:12:52 +02:00
Florian Müllner
57efcabfd6 stack: Only map children when necessary
gtk_widget_set_parent() will map the widget if the parent is mapped
and the widget is both visible and child-visible. As we currently
only set the child visibility after adding the child, we immediately
map all children that are added to a mapped stack, even when they
are not actually shown. Avoid this by setting the child visibility
before adding the child, so widgets are only mapped when shown.

https://bugzilla.gnome.org/show_bug.cgi?id=766737
2016-05-21 00:56:34 +02:00
Matt Watson
175cf7e32d stack: always update window position at transition start
Sometimes on wayland we're seeing a frame draw before the first tick
callback, where the window position has not yet been updated.

With this change, the window is properly positioned as soon as
gtk_stack_start_transition returns.

https://bugzilla.gnome.org/show_bug.cgi?id=766405
2016-05-16 13:53:26 -07:00
Timm Bäder
0d8993fb24 stack: Don't underallocate the last_child 2016-05-12 20:40:06 +02:00
Timm Bäder
292e0c2663 stack: Remove some code duplication 2016-05-12 20:40:00 +02:00
Matthias Clasen
df72478375 stack: Use getter for gtk-enable-animations 2016-05-01 00:39:55 -04:00
Matt Watson
62b224a8df stack: skip first frame for animations
Not the ideal solution for this problem, but in practice leads to
much better performance on lower end hardware.

Stack does a double draw on the first frame of its animation, of
both the old contents (into a cairo surface) and the new contents.
Homogeneous stacks only need to reallocate contents on the first
frame.

On lower powered hardware where our frames will be a good deal
slower than the refresh rate anyway, we can assure a smother
experience by waiting a frame to start tweening where frame duration
will be more consistent.
2016-04-08 16:09:30 -07:00
Matt Watson
3909f818c4 stack: port to progress tracker 2016-04-08 16:09:30 -07:00
Christian Hergert
ca63330b19 stack: query preferred size for last_visible_child
When animating, we might be changing the size allocation of the previous
stack child. However, we were not querying the size in the process
meaning you would often see warnings about allocating the size without
knowing what it should be.

This simply adds an innocuous size request, since responding to last_child
sizing requests is not all that critical in the transition.

https://bugzilla.gnome.org/show_bug.cgi?id=763900
2016-03-21 11:50:27 -04:00