Commit Graph

147 Commits

Author SHA1 Message Date
Matthias Clasen
e499a09759 Drop gtkintl.h
Include gtkprivate.h for I_() and glib-i18n.h for
gettext macros.
2022-09-24 10:03:37 -04:00
Matthias Clasen
f33f55bcbb gtk: Use the new debug macros 2022-09-23 18:12:39 -04:00
Timm Bäder
2b062d60f2 baseline = -1 means no baseline
Fixes #4385
2021-12-31 13:08:01 +01:00
Matthias Clasen
de42b5bfae sizerequest: Remove critical warning for now
At last as long as widgets like GtkFlowBox and
GtkGrid still trigger this, it is not a great
idea to have this warning in a stable release.
So remove it for 4.6
2021-12-23 16:59:26 -05:00
Benjamin Otte
eefb6a0dd4 sizerequest: Change critical message
Printing the affected widget leads people to assume that it is to blame
for the error. However, the widget is the object the function is being
called on, not the caller. And the caller is doing it wrong.

Usually the caller is the parent widget, so we could print that one, but
it's only usually, it can be an issue propagating from a grandparent and
it doesn't tell you from where the function is called (allocation or
measuring), so you need a debugger anyway.

So don't put anything there instead.
2021-11-20 17:05:36 +01:00
Benjamin Otte
de3c50a237 sizerequest: Use g_printerr() for debug messages
glib doesn't print debug messages by default anymore.
2021-11-20 06:04:10 +01:00
Benjamin Otte
163616cc0a sizerequest: Add a critical when for_size is too small
It's not expensive to check it because we'll cache the dfault size
request anyway, and people do it wrong a lot.
As a bonus, don't do any return_if_fail(), just use the min size
instead.
2021-11-19 23:46:59 +01:00
Benjamin Otte
b004706009 Revert "sizerequest: Only check reported baselines if requested"
This reverts commit cf7fa931d3.

We store the baseline in the cache and we do not know if baselines might
be queried in the future. So always store them.

No reftest because I don't know how to write one.

premature optimization == √😈
2021-11-09 03:41:43 +01:00
Matthias Clasen
d76460343a sizerequest: Simplify some code
Avoid some repeated MAX().
2021-07-24 18:49:41 -04:00
Matthias Clasen
0d8dd0c664 sizerequest: Keep branches in sync
There are some unintentional differences between
the path that uses a layout manager, and the path
that uses widget vfuncs. Sync them up.
2021-07-24 18:49:41 -04:00
Matthias Clasen
91f7b9663f gtk: Clean up docs syntax
Replace leftover gtk-doc syntax (#Type) with backquotes.
2021-05-22 17:25:26 -04:00
Matthias Clasen
4a0d3d7acc docs: Reduce redundancy
Remove a boatload of "or %NULL" from nullable parameters
and return values. gi-docgen generates suitable text from
the annotation that we don't need to duplicate.

This adds a few missing nullable annotations too.
2021-05-20 20:45:06 -04:00
Matthias Clasen
7fe0610b68 introspection: Stop using allow-none
allow-none has been deprecated for a long time
already. Instead use optional and nullable everywhere.
2021-05-20 19:17:49 -04:00
Matthias Clasen
8ba16eb4f1 Documentation fixes
Mostly fixing up indentation of continuation lines,
and other small cleanups.
2021-05-20 19:17:49 -04:00
Matthias Clasen
b5558f3e97 layout: Be quiet about trivialities
Commit 8b82993dde added a noisy warning
to gtk_distribute_natural_allocation to quiet a
compiler warning. It turn out that the file chooser
managed to trigger this warning, so make it a quiet
return.
2021-03-27 08:59:21 -04:00
Matthias Clasen
8b82993dde sizerequest: Avoid a corner case
gcc 11 warns that the code isn't safe when
n_requested_sizes is 0. Add a precondition check
to make it clear that that never happens.
2021-03-17 07:50:24 -04:00
Matthias Clasen
8d7103116a widget: Fix up some links
Fix up some links to vfuncs and to sections, as well as class methods.
2021-03-11 16:37:38 +00:00
Bilal Elmoussaoui
4980f620f9 g-i: update distribute_natural_allocation annotation 2021-03-07 20:59:01 +01:00
Benjamin Otte
d7266b25ba Replace "gint" with "int" 2020-07-25 00:47:36 +02:00
Emmanuele Bassi
7e03288724 Fix typo in a comment 2020-06-18 17:20:56 +01:00
Benjamin Otte
418bdc87ef sizerequest: Stop clamping for_size to natural size
Widgets should be given the actual size they will be allocated, so they
can do something with it.

If they want to clamp themselves to their natural size, nothing's
stopping them, they know their natural size after all.
2020-02-22 07:33:23 +01:00
Matthias Clasen
10e4c04e61 Use style values directly
Replace uses of gtk_css_style_get_value with direct access,
throughout the tree. We don't replace all uses, just those
where we are dealing with a fixed property. Be careful to
handle the currentColor special case for color properties.
2020-01-29 11:07:32 +01:00
Benjamin Otte
146b921246 cssnode: Convert name + id from interned string to GQuark
The reason for this is simply that I want to get hash functions that
have their values close together, so they can fit in a smaller range
(the goal here is 12 bits). By using GQuark, we get consecutive numbers
starting with 1 (and applications have <1000 quarks usually), whereas
interned strings can be all over the place.

As a side effect we also save 64 bytes per declaration.
2020-01-28 02:17:03 +01:00
Timm Bäder
8e4f0b9484 sizerequest: Remove _gtk_widget_get_preferred_size_and_baseline
Private and unused function.
2020-01-07 17:27:19 +01:00
Matthias Clasen
948347afa9 Stop using gtk_widget_is_toplevel 2019-05-28 20:25:16 +00:00
Timm Bäder
e22073dc97 sizerequest: Fix request mode for layout managers
We can't just call GtkWidgetClass::get_request_mode() anymore. If the
widget has a layout manager, we need to ask that one.
2019-05-27 18:12:26 +02:00
Emmanuele Bassi
65965bed16 Changes after review
- Rename GtkLegacyLayout to GtkCustomLayout
 - Use for() to iterate over children in GtkBinLayout
 - Whitespace fixes for code imported from GtkBox
 - Store the GtkLayoutChild instances inside LayoutManager
 - Simplify the GtkLayoutManager API by dropping unnecessary arguments
 - Fix the ownership model of GtkLayoutManager
2019-03-26 00:11:27 +00:00
Emmanuele Bassi
1b8595b5f2 Hook GtkLayoutManager into GtkWidget
We delegate the size request mode, the measuring, and the allocation of
a widget through a GtkLayoutManager instance, if one has been attached
to the widget; otherwise, we fall back to the widget's own implementation.
2019-03-26 00:11:27 +00:00
Benjamin Otte
d247e5707d widget: Fix gtk_widget_size_allocate()
Compute the matrix for adjusted sizes etc properly.
2019-02-19 05:52:11 +01:00
Timm Bäder
10e5856583 widget: Save transform as matrix
The transform matrix is a translation matrix from the parent's origin to
the widget origin. We will later allow more transformations than just
translations.
2019-02-16 15:44:37 +01:00
Timm Bäder
f8df527c68 sizerequest: Directly query new request_mode
We are already inside the function that populates the size request
cache, so do it here instead of implicitly in get_request_mode.
2018-12-02 13:25:43 +01:00
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