[gtk+/wip/baedert/drawing] Fix baselines wrt css min sizes
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/baedert/drawing] Fix baselines wrt css min sizes
- Date: Tue, 27 Jun 2017 11:25:52 +0000 (UTC)
commit 4253a9b61c1e002fb518da5072d8cb50796a5b4b
Author: Timm Bäder <mail baedert org>
Date: Tue Jun 27 13:27:58 2017 +0200
Fix baselines wrt css min sizes
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.
gtk/gtksizerequest.c | 24 ++++++++++++++++--------
gtk/gtkwidget.c | 1 -
2 files changed, 16 insertions(+), 9 deletions(-)
---
diff --git a/gtk/gtksizerequest.c b/gtk/gtksizerequest.c
index ea1b7c0..d337075 100644
--- a/gtk/gtksizerequest.c
+++ b/gtk/gtksizerequest.c
@@ -155,6 +155,8 @@ gtk_widget_query_size_for_orientation (GtkWidget *widget,
{
int adjusted_min, adjusted_natural;
int adjusted_for_size = for_size;
+ int reported_min_size = 0;
+ int reported_nat_size = 0;
style = gtk_css_node_get_style (gtk_widget_get_css_node (widget));
get_box_margin (style, &margin);
@@ -180,7 +182,7 @@ gtk_widget_query_size_for_orientation (GtkWidget *widget,
{
push_recursion_check (widget, orientation);
widget_class->measure (widget, orientation, -1,
- &min_size, &nat_size,
+ &reported_min_size, &reported_nat_size,
&min_baseline, &nat_baseline);
pop_recursion_check (widget, orientation);
}
@@ -214,16 +216,14 @@ gtk_widget_query_size_for_orientation (GtkWidget *widget,
widget_class->measure (widget,
orientation,
adjusted_for_size,
- &min_size, &nat_size,
+ &reported_min_size, &reported_nat_size,
&min_baseline, &nat_baseline);
pop_recursion_check (widget, orientation);
}
- /* TODO: Baselines */
-
- min_size = MAX (0, MAX (min_size, css_min_size)) + css_extra_size;
- nat_size = MAX (0, MAX (nat_size, css_min_size)) + css_extra_size;
+ min_size = MAX (0, MAX (reported_min_size, css_min_size)) + css_extra_size;
+ nat_size = MAX (0, MAX (reported_nat_size, css_min_size)) + css_extra_size;
if (G_UNLIKELY (min_size > nat_size))
{
@@ -306,8 +306,16 @@ gtk_widget_query_size_for_orientation (GtkWidget *widget,
nat_baseline = -1;
}
else
- gtk_widget_adjust_baseline_request (widget, &min_baseline, &nat_baseline);
- }
+ {
+ if (css_min_size > reported_min_size)
+ {
+ min_baseline += (css_min_size - reported_min_size) / 2;
+ nat_baseline += (css_min_size - reported_min_size) / 2;
+ }
+
+ gtk_widget_adjust_baseline_request (widget, &min_baseline, &nat_baseline);
+ }
+ }
_gtk_size_request_cache_commit (cache,
orientation,
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index a986dbc..b914e3a 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -5557,7 +5557,6 @@ gtk_widget_size_allocate_with_baseline (GtkWidget *widget,
margin.right + border.right + padding.right;
real_allocation.height -= margin.top + border.top + padding.top +
margin.bottom + border.bottom + padding.bottom;
- /* TODO: Baseline! */
priv->allocated_baseline = baseline;
if (g_signal_has_handler_pending (widget, widget_signals[SIZE_ALLOCATE], 0, FALSE))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]