Commit Graph

28 Commits

Author SHA1 Message Date
Timm Bäder
52aed5d607 Add 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
404cdd5d02 boxgadget: Implement CSS border-spacing 2016-12-10 04:32:55 +01:00
Benjamin Otte
475cffd7f8 gadget: Remove gtk_css_gadget_get_render_node()
It's unused now that we can snapshot.
2016-11-15 17:49:19 +01:00
Benjamin Otte
0cf9f70ccd snapshot: Convert box gadget
Makes spinbuttons have text again!
2016-11-15 17:49:19 +01:00
Matthias Clasen
953c7ba6be box gadget: Implement get_render_node vfunc
This implements get_render_node in the obvious way.
2016-11-01 14:29:25 -04: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
Matthias Clasen
f68eaae581 Prevent box gadget content from being drawn twice
Now that we split out box gadget children into separate
render nodes, we must not draw them onto the box gadgets
node anymore.
2016-10-18 11:49:12 +01:00
Matthias Clasen
2148708917 box gadget: Redo expand flag handling
We only keep one align flag per child, so it seems odd to
keep separate h/v expand flags. Just keep one expand flag
and interpret it according to orientation. Allow setting
the expand flag for child widgets too, though, so we can
make widget expand without interfering with the recursive
widget expand flag.

Update all callers.

Use the new possibility of expanding child widgets to make
the label of check and radio buttons expand. This fixes
unexpected behavior of these widgets in RTL in some places.

https://bugzilla.gnome.org/show_bug.cgi?id=765742
2016-04-28 21:59:34 -04:00
Matthias Clasen
2919e344ca box gadget: allow reversing alignments
In RTL, we want to interpret GTK_ALIGN_START and _END
in the opposite way. Since we don't give gadgets a text
direction, just allow setting an align_reverse flag
to the box gadget.
2016-04-28 21:59:34 -04:00
Matthias Clasen
c581259e06 box gadget: Add a way to allocate in reverse
This is needed to preserve expected allocation behavior
in rtl mode.
2016-03-03 21:28:51 -05:00
Cosimo Cecchi
6370d6cb27 boxgadget: add APIs to insert gadgets next to siblings 2016-02-29 10:45:13 -08:00
Cosimo Cecchi
06776d3d2f boxgadget: add API to set expand/align flags for gadget child 2016-02-29 10:45:13 -08:00
Benjamin Otte
245d217e06 boxgadget: Add ability to draw children in reverse
This is necessary for GtkNotebook so that the stack is always drawn
before the header.
And that is necessary so that the active tab can use negative
margins to overdraw the border of the stack to create a gap and
simulate old GTK2-style visuals for notebooks.
2016-02-27 03:59:20 +01:00
Matthias Clasen
ebff86d6f6 box gadget: Make it possible to draw focus
There are widgets which use a box gadget and take focus,
like GtkCheckButton.
2016-02-20 10:54:48 -05:00
Matthias Clasen
af64a60466 box gadget: Fix allocation without baseline
When we don't get a baseline passed in, we want to basically
center the children inside the allocation. There was an attempt
in the code to do 'internal baseline alignment', but it had the
side effect of moving the contents to the top when we don't get
a baseline passed in. Remove it for now, this needs some more
infrastructure to do properly.

https://bugzilla.gnome.org/show_bug.cgi?id=761363
2016-02-07 15:08:56 +01:00
Matthias Clasen
8991f17d49 box gadget: Improve assertion message
Include the owner of the gadget in the assertion message,
to improve the chances of tracking down whats actually
going wrong here.
2016-01-26 22:11:54 -05:00
Matthias Clasen
73307f78dc box gadget: Don't allow shifting too far
We don't want to let baseline adjustment shift the child
out of the original allocation. This is purely a sanity
measure - in practice, the baseline should always be bigger
than the child_baseline.
2016-01-22 22:49:01 -05:00
Matthias Clasen
50e923349e box gadget: Fix baseline calculation
Careful comparison with GtkBox revealed that the box gadget
code was confusing up and down, and thus shifted baselines
vertically.
2016-01-22 22:47:47 -05:00
Matthias Clasen
e26300625f box gadget: Fix baseline allocation for widgets
We were adjusting the allocation to line up baselines before
calling gtk_widget_size_allocate_with_baseline, but that function
is doing this alignment internally anyway and expects to be given
a 'fill' allocation.

Move the allocation adjustment code down into
gtk_box_gadget_allocate_child where it only affects child gadgets,
not child widgets.
2016-01-22 22:08:38 -05:00
Matthias Clasen
3d52fd3992 box gadget: Fix height-for-width handling
When measuring children while distributing a given height,
we must measure them for the given width that goes with
the height. Otherwise, things will go wrong if some of the
children do actual width-for-height. This was showing up
as misaligned images in anaconda.

https://bugzilla.gnome.org/show_bug.cgi?id=760967
2016-01-22 17:15:33 -05:00
Matthias Clasen
5265db5dd6 box gadget: Add a function to reverse children
This can be used to handle text direction changes.
2016-01-18 00:03:39 -05:00
Matthias Clasen
9c3907dab0 box gadget: Deal with optional arguments
The baseline arguments to the preferred size callback can
be NULL. Don't crash if they are.
2016-01-17 19:48:40 -05:00
Matthias Clasen
87171469b7 box gadget: Implement cross-axis alignment
So far, the box gadget is always allocating all children the
full size in the cross axis. This behavior corresponds to the
align-items: stretch behavior in
https://www.w3.org/TR/css-flexbox-1/#align-items-property
This commit implements the other modes described there.

While widgets have halign/valign properties that we can use for
this, the API for inserting gadgets has to change to take an
extra align parameter. All callers have been updated to pass
GTK_ALIGN_FILL, since that corresponds to the previous behavior.

https://bugzilla.gnome.org/show_bug.cgi?id=760668
2016-01-15 09:43:12 -05:00
Timm Bäder
4703d2bbf0 boxgadget: Don't use g_assert
Use g_return_if_fail instead so nothing abort()s.
2016-01-14 16:02:36 +01:00
Matthias Clasen
c71089a038 box gadget: Add some documentation 2016-01-12 23:57:35 -05:00
Benjamin Otte
3cda7e9503 boxgadget: Handle css nodes
Automatically insert the cssnode into the box gadget's node's children at
the right place and remove it again when done.
2016-01-11 17:05:23 +01:00
Benjamin Otte
acc534ebfa boxgadget: Add
Adds a GtkBoxGadget that is a Gadget that behaves like a GtkBox.

Use this gadget to implement the notebook base gadget.
2016-01-11 17:05:23 +01:00