Commit Graph

116 Commits

Author SHA1 Message Date
Timm Bäder
f699fff6e0 sizerequest: Pull locals into closest scope 2018-07-17 17:33:47 +02:00
Timm Bäder
4bc145549d Correctly mark an enum value in a doc comment 2018-07-17 17:33:47 +02:00
Timm Bäder
cf7fa931d3 sizerequest: Only check reported baselines if requested
If the passed-in store locations for the baselines are NULL anyway, we
don't need to check the reported baselines for correctness.
2018-07-17 17:33:47 +02:00
Daniel Boles
3396c5e983 SizeRequest: Round px values up for min CSS sizes
Otherwise, requesting a min size in em where the equivalent in px had a
fractional part would lead to the widget getting allocated 1 too few px.
You could see this in the CSS property vs. allocation in the Inspector.

Note that margin/border/padding are left alone: the rationale is that we
do as browsers do, and Benjamin said we already do that for those,
whereas his tests on min-(width|height) showed otherwise. My subsequent
analysis indicated it to be far less clear-cut than that, but he remains
unconvinced that we should ceil() all the things! So just do these ones.

https://gitlab.gnome.org/GNOME/gtk/issues/1088
2018-06-05 18:49:52 +01:00
Timm Bäder
1313234ae0 Use inlined gtk_widget_get_display version in a few places
We can safely do this whenever we already made sure that the given
pointer is a valid GtkWidget.
2018-04-21 19:06:21 +02:00
Timm Bäder
bb412cdda1 sizerequest: Pull locals in closest scope 2018-04-21 10:06:57 +02: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
e7b3909fd1 sizerequest: Fix for_size adjustment
We need to pull the proper size from the size request cache and adjust
it accordingly.
2018-01-17 21:57:20 +01:00
Matthias Clasen
af7f695068 Make geometry logging per-display
Use the new macro to do this.
2018-01-14 17:05:04 -05:00
Matthias Clasen
0fe6d76ab6 Make size request warnings more useful
Print the css name of the widget in question, so we have
a chance of knowing that this is caused by the marks, not
by the slider.
2018-01-09 17:48:51 -05: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
Timm Bäder
4dee08dd52 sizerequest: Don't pass uninitialized values to measure
The GtkWidgetClass::measure vfunc is not required to assign a value to
any of the (out) parameters, so we need to initialize the locals we pass
to it, otherwise we can end up with a garbage size request.
2017-10-28 11:42:08 +02:00
Timm Bäder
e19e3b72a3 widget: Always pass on baselines 2017-07-19 21:27:15 -04:00
Timm Bäder
6a7d903612 sizerequest: Add more assertions for baselines
min baselines must be <= natural baselines and both must lie inside the
content size of the widget.
2017-07-19 21:27:15 -04:00
Timm Bäder
42aa7453ab Fix baselines wrt css values
The reported minimum baseline is for the reported min height, but if the
css min-height is greater than that, we need to account for that fact
when saving the baseline.

Since the reported baseline is relative to the widget's origin, we also
need to add the top values for margin, border and padding to the
reported baseline.
2017-07-19 21:27:14 -04:00
Timm Bäder
99b00b4d9c sizerequest: Assert that min_size >= 0
This should generally be true, so remove the checks from gtkbox.c and
move it into gtksizerequest.c
2017-07-19 21:27:13 -04:00
Timm Bäder
3a64ef42df sizerequest: Fix min size with widget margins 2017-07-19 21:27:11 -04:00
Timm Bäder
ba58c796b0 sizerequest: Stop checking orientation in query_size_for_orientation
Since we have ->measure now, we can implement this code more elegantly.
2017-07-19 21:27:11 -04:00
Timm Bäder
4d7768d5e8 sizerequest: Remove for_size parameter from push_recursion_check
It's not needed anymore after also fixing the warning message to not
mention the old get_preferred* functions.
2017-07-19 21:27:11 -04:00
Timm Bäder
b0c7a876a9 sizerequest: Make sure widget sizes stay positive
They can otherwise become negative, e.g. when large negative css
margins are applied.
2017-07-19 21:27:11 -04:00
Timm Bäder
6d34a19cdd sizerequest: Make size groups "work"
We have to query the css margin/border/padding values for all widgets
in the size group.
2017-07-19 21:27:11 -04:00
Timm Bäder
78bb0ed2cb sizerequest: Move css handling to gtk_widget_measure
We need to adjust the passed for_size to fit into the content allocation
of the widget.
That also means that we can't call gtk_widget_measure(widget) inside
gtk_widget_measure(widget) since now the for_size will be adjusted
twice.
2017-07-19 21:27:11 -04:00
Timm Bäder
5066308e86 sizerequest: Honor css min size 2017-07-19 21:27:11 -04:00
Timm Bäder
05a83b74b0 sizerequest: Fix indentation 2017-07-19 21:27:11 -04:00
Timm Bäder
3d21128dbb Remove gtk_widget_get_preferred_*
They are unnecessary now that we have gtk_widget_measure.
2017-05-05 11:18:25 +02:00
Timm Bäder
f860ff8647 widget: Remove get_valign_with_baseline
This only existed for backwards compat reasons which aren't interesting
for gtk4.
2017-03-05 15:18:32 +01:00
Timm Bäder
f1f39e8924 sizerequest: Fix min_size > nat_size error message
Instead of mentioning the old _get_preferred_xxx functions, mention
measure() and print the for_size value as well. The orientation is given
by printing either "width" for GTK_ORIENTATION_HORIZONTAL or "height"
for GTK_ORIENTATION_VERTICAL.
2017-03-05 15:01:57 +01:00
Timm Bäder
d862c5c6df sizerequest: Use gtk_widget_measure to measure widget sizes 2017-01-20 21:33:38 +01:00
Timm Bäder
489aee5d00 widget: Remove unused adjust_* vfuncs
Expose them privately to gtksizerequest.c using normal functions
instead.
2016-12-07 18:12:54 +01:00
Timm Bäder
36377e9964 Remove gtk_widget_get_preferred_height_and_baseline_for_width
It's just a wrapper around gtk_widget_measure nowadays.
2016-12-03 13:19:25 +01:00
Timm Bäder
f4929360aa sizerequest: rename _compute_size_for_orientation to _measure
They have the exact same parameters and gtk_widget_measure did
unnecessary work before. Also better stack traces!
2016-11-17 15:42:25 +01:00
Timm Bäder
ab467317a1 widget: Add docs for ::measure 2016-10-22 21:40:04 +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
0df388051d API: Remove GtkStyle
All the remaining gtkrc.c stuff like GtkRcStyle goes with it.
2016-10-16 18:17:21 +02:00
Benjamin Otte
35c96c2c1f Add braces to appease gcc
-ftrack-macro-expansion=0 doesn't like if statements without braces when
evaluating indentation levels.
2016-08-25 23:02:27 +02:00
Matthias Clasen
2ee7fb1818 Don't use g_print for debug output
The g_print documentation explicitly says not to do this, since
g_print is meant to be redirected by applications. Instead use
g_message for logging that can be triggered via GTK_DEBUG.
2016-02-28 21:40:23 -05:00
Matthias Clasen
339023dee5 Fix indentation
gcc 6 complains about this.
2016-02-05 11:42:28 +01:00
Benjamin Otte
6cc2615b63 widget: Add a resize_needed flag
... and API to set and unset it.

It is set when gtk_widget_queue_resize() is called.
It is unset when gtk_widget_get_preferred_width/height() is called.

So far it is not used.
2015-10-28 19:44:28 +01:00
Matthias Clasen
cd35a14bbb size request: Avoid unnecessary reffing
There is no particular reason why we should have to ref the
widgets if they are in a size group - we are not reffing them
in the simple case either.
2015-09-23 07:01:16 -04:00
Matthias Clasen
caa0ee3d25 Remove type check from gtk_widget_get_request_mode 2015-09-12 12:50:38 -04:00
Matthias Clasen
bf9a72976f size request: Redo the recursion checks
Use G_ENABLE_CONSISTENCY checks for the recursion checks
in gtksizerequest.c
2015-09-09 06:32:46 -04:00
Matthias Clasen
0f92a43e10 Move GtkWidgetPrivate to gtkwidgetprivate.h
This lets us use inlined getters for members in there,
avoiding the type checks in the public getters.
2015-09-07 02:40:22 -04:00
Matthias Clasen
7f6a964c47 Docs: Remove all entities and turn off sgml mode
With all element markup gone, it is time to turn off
sgml mode, and get rid of entities as well.
2014-02-09 17:58:07 -05:00
William Jon McCann
7a208fbbf3 docs: use proper apostrophe
https://wiki.gnome.org/Design/OS/Typography
2014-02-07 13:06:10 -05:00
Matthias Clasen
245c385ae7 Docs: Don't use note elements
In most cases, the text itself makes the message clear enough.
2014-02-02 01:22:14 -05:00
William Jon McCann
13ace3ef33 docs: fix name of function to use for baseline alignment 2014-01-21 18:57:38 -05:00
Benjamin Otte
689905c1b4 widget: make gtk_widget_compute_size_for_orientation() static
It's not used anywhere outside of gtksizerequest.c anymore.
2013-05-11 15:11:53 +02:00
Benjamin Otte
bd4d00918e API: Don't export gtk_widget_preferred_size_and_baseline()
gtk_widget_preferred_size() is only useful if you want to quickly port a
widget from GTK2 sizing code to GTK3 but does not properly work with
height-for-width as used in GTK. So we don't want to encourage people to
use it. In particular we want people to convert to height-for-width
before adding baseline support to their widgets.
2013-05-11 14:48:01 +02:00
Benjamin Otte
1349292e47 widget: Adapt _gtk_widget_get_preferred_size_for_size()
... for baseline support byu taking two extra (possible NULL) arguments.
2013-05-01 16:41:11 +02:00
Alexander Larsson
316d450421 Handle non-baseline supporting subclasses overriding baseline supporting classes
If a subclass (say a child of GtkButton) overrides the non-baseline
size request methods we need to call these, rather than the new
get_height_and_baseline_for_width method.

In order to handle this we make the default for this method to be
NULL, and instead check at runtime which method to call. If any
non-baseline vfunc has changed in a class but the baseline one
hasn't, then we can't use the baseline one.
2013-04-23 05:58:48 +02:00