Commit Graph

172 Commits

Author SHA1 Message Date
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
f637006b3e popover: Add a contents node
Remove the special case in gtkwidget.c where we didn't draw any css
background/border for popovers. Instead, rely on themes to not style the
popover node and add a contents gizmo that gets the actual css styling.
We then requeste enough space for the popover to draw both the contents
and the arrow on the side.
2017-07-19 21:27:15 -04:00
Timm Bäder
4b0da8682d popover: set the shape on the correct window
the parent window is now the toplevel's window.
2017-07-19 21:27:15 -04:00
Timm Bäder
bda2f4f582 popover: Create subsurface on wayland 2017-07-19 21:27:14 -04:00
Timm Bäder
bc807789ba popover: "Fix" child allocation
This is still wrong but will be fixed in the future.
2017-07-19 21:27:14 -04:00
Timm Bäder
9350a0f85b popover: Remove useless if case
rect is not nullable, so stop checking if it is NULL and instead add a
g_return_val_if_fail guard.
2017-07-19 21:27:13 -04:00
Timm Bäder
1d4d5b2eb9 popover: Stop looking at padidng and border in measure
GtkWidget does it for us now
2017-07-19 21:27:12 -04:00
Timm Bäder
60e053f52a Remove calls to gtk_widget_set_allocation
gtk_widget_size_allocate_with_baselines does it automatically now.
2017-07-19 21:27:12 -04:00
Carlos Garnacho
ee894903c7 gtkpopover: Use event coordinates right away to detect clicks outside.
There's no need anymore to translate coordinates, the event already contains
popover-relative ones.
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
Olof-Joachim Frahm
1681d4ad77 Move style change for popover creation.
Creating with `gtk_popover_new_from_model` should be exactly the same as
if via `gtk_popover_new` plus `gtk_popover_bind_model`.

Also remove the style if the model is unbound at any point.
2017-05-05 11:37:20 +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
78a36cf4bb popover: Simplify gtk_popover_measure 2017-02-05 15:03:35 +01:00
Timm Bäder
56a58655fe Remove unnecessary gtk_widget_show calls 2017-01-22 14:38:21 +01:00
Timm Bäder
ab051fd53f Don't hide windows and popovers in init()
Instead, don't make them visible in gtk_widget_init in the first place.
2017-01-20 21:51:05 +01:00
Timm Bäder
33d41fccdd Hide popovers and toplevels by default 2017-01-20 21:33:37 +01:00
Benjamin Otte
6055028c96 snapshot: Rename append APIs
Instead of having gtk_snapshot_append_foo_node(), just have
gtk_snapshot_append_foo(). Nobody needs to know that this internally
uses nodes.
2017-01-13 04:46:09 +01:00
Alexander Larsson
7bee22bcb6 Avoid some more type checks for internal calls 2017-01-11 15:27:51 +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
4d9eedafcd roundedbox: Add gtk_rounded_boxes_init_for_style()
Instead of making people intiialize a rectangle and then applying border
radius manually, provide a constructor that does it for them.
While doing that, also allow people to instead request the padding box
or the content box.

Refactor all relevant code to use this new constructor.
2016-12-20 18:01:12 +01:00
Benjamin Otte
95a2a5c54c gtk: Remove GtkJunctionSides 2016-12-20 18:01:12 +01:00
Benjamin Otte
f96f16899d roundedbox: Remove _gtk_rounded_box_path()
Use gsk_rounded_rect_path() instead.

That's a private GSK function, be we can just include its header.
2016-12-20 18:01:10 +01:00
Benjamin Otte
e26f84fca0 gtk: Remove GtkRoundedBox struct
Use GskRoundedRect instead.
2016-12-20 18:01:10 +01:00
Benjamin Otte
d1b80a6baa gtk: Don't push cairo nodes
We want to split nodes into containers and nodes that do actual drawing.
So pushing nodes that do drawing is exactly the wrong thing.

Also fix up GtkPopover. There's no need for it to push anything.
2016-12-20 18:01:09 +01:00
Benjamin Otte
e8381f84d6 snapshot: Convert GtkPopover 2016-11-15 17:49:19 +01:00
Ernestas Kulik
3885e85f77 popover: pop down when pressing escape
Simply hiding the popover may introduce inconsistencies in application
behavior, since popping up/down is the usual use case.

https://bugzilla.gnome.org/show_bug.cgi?id=773885
2016-11-03 15:46:04 +02:00
Benjamin Otte
a0e63b8a07 rendernode: Require passing a renderer to get_draw_context()
This is in preparation of making render nodes independent of the
renderer, so that they can be rendered multiple times with different
renderers.
2016-11-01 16:32:26 +01:00
Timm Bäder
679b515170 popover: convert to indirect rendering 2016-10-31 19:29:35 +01: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
Timm Bäder
3573cdc0cd popover: Remove deprecated API 2016-10-18 00:29:19 +02:00
Benjamin Otte
6a399ebd15 popover: 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
1518fe0a8f API: stylecontext: Remove state argument from getters
The argument must always be the current state.
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
Carlos Garnacho
769ee1156d popover: Update scrollable on relative-to hierarchy changes
The relative-to widget may be reparented itself into/out of a
scrollable. In this cases make the hierachy-changed handler to
unset the parent scrollable when unparented, and look up again
the parent scrollable after it's reparented.

https://bugzilla.gnome.org/show_bug.cgi?id=771812
2016-09-29 12:46:34 +02:00
Carlos Garnacho
588a1dce2b popover: Add helper functions around setting up an scrollable
gtk_popover_set_scrollable_full() takes care of the signal connected
on the scrollable itself, in addition to the adjustment signals the
popover listens to.

gtk_popover_update_scrollable() looks up the current relative-to
widget hierarchy and updates the current scrollable.

The places where the scrollable is being maintained have been updated
to use these functions.

https://bugzilla.gnome.org/show_bug.cgi?id=771812
2016-09-29 12:46:34 +02:00
Timm Bäder
857997be8c popover: Skip first frame when transitioning
Similar to what we do in GtkStack.
2016-09-03 12:24:58 +02:00
Timm Bäder
ce1ae60da2 popover: Propagate drawing 2016-09-01 15:20:12 +02:00
Timm Bäder
2c04941c5c popover: Fix hfw/wfh size request
Since we're using _get_rect_coords in size-allocate when allocating the
size of the child widget, use the newly introduced _get_rect_for_size to
calculate the difference between the passed size_for and the one we're
supposed to pass on to the child widget.
2016-09-01 15:16:58 +02:00
Timm Bäder
7f1ab32e60 popover: Introduce _get_rect helper for a size
When calculating the requested size of a popover, we need to do the
exact same same thing _get_rect_coords did, but not for the
current popopver allocation. Add _get_rect_for_size that can be used for
this purpose
2016-09-01 15:15:18 +02:00
Timm Bäder
5c696a7ee3 popover: Clarify transitions-enabled deprecation
https://bugzilla.gnome.org/show_bug.cgi?id=769706
2016-08-20 20:54:20 +02:00
Timm Bäder
a6b9b3648d GtkPopover: Deprecate transitions-enabled
The effect of transitions-enabled=true can now be
achieved using gtk_popover_popup/popdown and the effect
of transitions-enabled=false can be achieved using
gtk_widget_show/hide.

https://bugzilla.gnome.org/show_bug.cgi?id=769706
2016-08-16 11:49:26 -04:00
Timm Bäder
1f7b6c1d6f GtkPopover: Add gtk_popover_popdown/popup
Since not chaining up in gtk_widget_show/gtk_widget_hide is not allowed,
we can't just implicitly delay the hiding in GtkPopover's hide
implementation. Fix this by introducing gtk_popover_popup() and
gtk_popover_popdown() to show or hide a popover with transition and
revert GtkPopover's show/hide implementation to apply their effect
without the transition.

https://bugzilla.gnome.org/show_bug.cgi?id=769706
2016-08-16 11:49:26 -04:00
Timm Bäder
0d17421ffd popover: Make some public API NULL-safe
Instad of potentially dereferencing a NULL-pointer, use the NULL-safe
gtk_popover_get_instance_private before the g_return_if_fail
precondition check.
2016-08-10 16:37:17 +02:00
Carlos Garnacho
ed227f9e7b GtkPopover: Honor widget margins when calculating tail position
If there are widget margins set, the whole popover will be displaced.
However the calculation of the tail position doesn't have this into
account, ending up with the tail being detached from the popover if
the margin grew too big.

We should not render the arrows invariably next to the GdkWindow edge,
but optionally displaced inside it depending on the widget margins.
Fixes the gtk3-demo "Popovers" demo case, whose GtkEntry popovers set
widget margins for some reason.

https://bugzilla.gnome.org/show_bug.cgi?id=767851
2016-06-21 17:54:42 +02:00
Phillip Wood
72ea348ad6 Fix hiding popover when focus moves outside
Commit a01fe14 changed the behaviour of popovers when the focus leaves
them to stop child popovers being hidden when the focus leaves their
parent. However they are now a bit too reluctant to hide - if the
focus passes to an unrelated popover the first popover is not
hidden. Also if the focus passes to another widget that does not
perform a gtk grab then the popover isn't hidden until the user
presses a non-movement key or clicks outside the popover.

The solution is to go back to checking if the focused widget is a
descendant of the popover, but to include popovers and their related
widgets in the ancestry chain.

https://bugzilla.gnome.org/show_bug.cgi?id=765595
2016-06-05 22:54:00 -04:00
Carlos Garnacho
76a5e3fc3c popover: set priv->window before setting doing add_popover() on it
If the popover's relative-to widget is unparented/reparented, we end
up unparenting/reparenting the popover as well. In that case, at the
moment of reparenting, the widget might have been visible (and is
thus mapped again), but priv->window hasn't been set yet.

We must first set priv->window, and then call gtk_window_add_popover(),
that way gtk_popover_map() has its prerequisites straight.

https://bugzilla.gnome.org/show_bug.cgi?id=766323
2016-05-21 20:40:43 +02:00
Matthias Clasen
9d038df7de popover: Use getter for gtk-enable-animations 2016-05-01 00:39:03 -04:00
Matt Watson
dc8b80cd32 popover: port to progress tracker 2016-04-08 16:09:30 -07:00
Michael Catanzaro
ea423318f1 Fix a typo 2016-02-13 22:15:07 -06:00