diff options
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/gtkboxlayout.c | 3 | ||||
-rw-r--r-- | gtk/gtkenums.h | 6 | ||||
-rw-r--r-- | gtk/gtkflowbox.c | 3 | ||||
-rw-r--r-- | gtk/gtkgridlayout.c | 4 | ||||
-rw-r--r-- | gtk/gtkoverlay.c | 9 | ||||
-rw-r--r-- | gtk/gtkoverlaylayout.c | 3 | ||||
-rw-r--r-- | gtk/gtkpopover.c | 12 | ||||
-rw-r--r-- | gtk/gtkwidget.c | 29 |
8 files changed, 46 insertions, 23 deletions
diff --git a/gtk/gtkboxlayout.c b/gtk/gtkboxlayout.c index 0b5c22a22a..a95a4ee3cb 100644 --- a/gtk/gtkboxlayout.c +++ b/gtk/gtkboxlayout.c @@ -885,7 +885,8 @@ gtk_box_layout_allocate (GtkLayoutManager *layout_manager, sizes[i].natural_size = child_size; if (self->orientation == GTK_ORIENTATION_HORIZONTAL && - gtk_widget_get_valign (child) == GTK_ALIGN_BASELINE) + (gtk_widget_get_valign (child) == GTK_ALIGN_BASELINE_FILL || + gtk_widget_get_valign (child) == GTK_ALIGN_BASELINE_CENTER)) { int child_allocation_width; int child_minimum_height, child_natural_height; diff --git a/gtk/gtkenums.h b/gtk/gtkenums.h index 815e25de55..c683e9d01e 100644 --- a/gtk/gtkenums.h +++ b/gtk/gtkenums.h @@ -42,6 +42,8 @@ G_BEGIN_DECLS * @GTK_ALIGN_CENTER: center natural width of widget inside the allocation * @GTK_ALIGN_BASELINE: align the widget according to the baseline. * See [class@Gtk.Widget]. + * @GTK_ALIGN_BASELINE_FILL: a different name for @GTK_ALIGN_BASELINE. Since 4.12 + * @GTK_ALIGN_BASELINE_CENTER: stretch to fill all space, but align the baseline. Since 4.12 * * Controls how a widget deals with extra space in a single dimension. * @@ -67,7 +69,9 @@ typedef enum GTK_ALIGN_START, GTK_ALIGN_END, GTK_ALIGN_CENTER, - GTK_ALIGN_BASELINE + GTK_ALIGN_BASELINE, + GTK_ALIGN_BASELINE_FILL = GTK_ALIGN_BASELINE, + GTK_ALIGN_BASELINE_CENTER, } GtkAlign; /** diff --git a/gtk/gtkflowbox.c b/gtk/gtkflowbox.c index a0ecc3d056..93c3f8ec46 100644 --- a/gtk/gtkflowbox.c +++ b/gtk/gtkflowbox.c @@ -1530,7 +1530,8 @@ get_offset_pixels (GtkAlign align, case GTK_ALIGN_END: offset = pixels; break; - case GTK_ALIGN_BASELINE: + case GTK_ALIGN_BASELINE_FILL: + case GTK_ALIGN_BASELINE_CENTER: default: g_assert_not_reached (); break; diff --git a/gtk/gtkgridlayout.c b/gtk/gtkgridlayout.c index 1e2a8b7bcc..fca1d2f215 100644 --- a/gtk/gtkgridlayout.c +++ b/gtk/gtkgridlayout.c @@ -1463,7 +1463,9 @@ allocate_child (GridRequest *request, attach = &grid_child->attach[orientation]; *position = lines->lines[attach->pos - lines->min].position; - if (attach->span == 1 && gtk_widget_get_valign (child) == GTK_ALIGN_BASELINE) + if (attach->span == 1 && + (gtk_widget_get_valign (child) == GTK_ALIGN_BASELINE_CENTER || + gtk_widget_get_valign (child) == GTK_ALIGN_BASELINE_FILL)) *baseline = lines->lines[attach->pos - lines->min].allocated_baseline; else *baseline = -1; diff --git a/gtk/gtkoverlay.c b/gtk/gtkoverlay.c index 43286c0624..6aed2e59f4 100644 --- a/gtk/gtkoverlay.c +++ b/gtk/gtkoverlay.c @@ -114,7 +114,8 @@ effective_align (GtkAlign align, return direction == GTK_TEXT_DIR_RTL ? GTK_ALIGN_START : GTK_ALIGN_END; case GTK_ALIGN_FILL: case GTK_ALIGN_CENTER: - case GTK_ALIGN_BASELINE: + case GTK_ALIGN_BASELINE_FILL: + case GTK_ALIGN_BASELINE_CENTER: default: return align; } @@ -154,7 +155,8 @@ gtk_overlay_get_child_position (GtkOverlay *overlay, case GTK_ALIGN_END: alloc->x += width - alloc->width; break; - case GTK_ALIGN_BASELINE: + case GTK_ALIGN_BASELINE_FILL: + case GTK_ALIGN_BASELINE_CENTER: default: g_assert_not_reached (); break; @@ -177,7 +179,8 @@ gtk_overlay_get_child_position (GtkOverlay *overlay, case GTK_ALIGN_END: alloc->y += height - alloc->height; break; - case GTK_ALIGN_BASELINE: + case GTK_ALIGN_BASELINE_FILL: + case GTK_ALIGN_BASELINE_CENTER: default: g_assert_not_reached (); break; diff --git a/gtk/gtkoverlaylayout.c b/gtk/gtkoverlaylayout.c index 204babbf30..33f8de7a20 100644 --- a/gtk/gtkoverlaylayout.c +++ b/gtk/gtkoverlaylayout.c @@ -324,7 +324,8 @@ effective_align (GtkAlign align, return direction == GTK_TEXT_DIR_RTL ? GTK_ALIGN_START : GTK_ALIGN_END; case GTK_ALIGN_FILL: case GTK_ALIGN_CENTER: - case GTK_ALIGN_BASELINE: + case GTK_ALIGN_BASELINE_FILL: + case GTK_ALIGN_BASELINE_CENTER: default: return align; } diff --git a/gtk/gtkpopover.c b/gtk/gtkpopover.c index f1025fc333..42e2b06384 100644 --- a/gtk/gtkpopover.c +++ b/gtk/gtkpopover.c @@ -505,7 +505,8 @@ create_popup_layout (GtkPopover *popover) case GTK_ALIGN_FILL: case GTK_ALIGN_CENTER: - case GTK_ALIGN_BASELINE: + case GTK_ALIGN_BASELINE_FILL: + case GTK_ALIGN_BASELINE_CENTER: default: parent_anchor = GDK_GRAVITY_WEST; surface_anchor = GDK_GRAVITY_EAST; @@ -529,7 +530,8 @@ create_popup_layout (GtkPopover *popover) case GTK_ALIGN_FILL: case GTK_ALIGN_CENTER: - case GTK_ALIGN_BASELINE: + case GTK_ALIGN_BASELINE_FILL: + case GTK_ALIGN_BASELINE_CENTER: default: parent_anchor = GDK_GRAVITY_EAST; surface_anchor = GDK_GRAVITY_WEST; @@ -553,7 +555,8 @@ create_popup_layout (GtkPopover *popover) case GTK_ALIGN_FILL: case GTK_ALIGN_CENTER: - case GTK_ALIGN_BASELINE: + case GTK_ALIGN_BASELINE_FILL: + case GTK_ALIGN_BASELINE_CENTER: default: parent_anchor = GDK_GRAVITY_NORTH; surface_anchor = GDK_GRAVITY_SOUTH; @@ -577,7 +580,8 @@ create_popup_layout (GtkPopover *popover) case GTK_ALIGN_FILL: case GTK_ALIGN_CENTER: - case GTK_ALIGN_BASELINE: + case GTK_ALIGN_BASELINE_FILL: + case GTK_ALIGN_BASELINE_CENTER: default: parent_anchor = GDK_GRAVITY_SOUTH; surface_anchor = GDK_GRAVITY_NORTH; diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index d5542a3b3b..a13ce9711b 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -3749,7 +3749,8 @@ effective_align (GtkAlign align, return direction == GTK_TEXT_DIR_RTL ? GTK_ALIGN_START : GTK_ALIGN_END; case GTK_ALIGN_FILL: case GTK_ALIGN_CENTER: - case GTK_ALIGN_BASELINE: + case GTK_ALIGN_BASELINE_FILL: + case GTK_ALIGN_BASELINE_CENTER: default: return align; } @@ -3765,7 +3766,7 @@ adjust_for_align (GtkAlign align, { switch (align) { - case GTK_ALIGN_BASELINE: + case GTK_ALIGN_BASELINE_CENTER: if (*allocated_size > natural_size && nat_baseline > -1 && *allocated_baseline > -1) @@ -3773,8 +3774,18 @@ adjust_for_align (GtkAlign align, *allocated_pos = *allocated_baseline - nat_baseline; *allocated_size = MIN (*allocated_size, natural_size); *allocated_baseline = nat_baseline; + break; + } + G_GNUC_FALLTHROUGH; + + case GTK_ALIGN_CENTER: + if (*allocated_size > natural_size) + { + *allocated_pos += (*allocated_size - natural_size) / 2; + *allocated_size = MIN (*allocated_size, natural_size); } break; + case GTK_ALIGN_BASELINE_FILL: case GTK_ALIGN_FILL: default: /* change nothing */ @@ -3790,13 +3801,6 @@ adjust_for_align (GtkAlign align, *allocated_size = natural_size; } break; - case GTK_ALIGN_CENTER: - if (*allocated_size > natural_size) - { - *allocated_pos += (*allocated_size - natural_size) / 2; - *allocated_size = MIN (*allocated_size, natural_size); - } - break; } } @@ -3868,7 +3872,8 @@ gtk_widget_adjust_size_allocation (GtkWidget *widget, } out: - if (priv->valign != GTK_ALIGN_BASELINE) + if (priv->valign != GTK_ALIGN_BASELINE_FILL && + priv->valign != GTK_ALIGN_BASELINE_CENTER) *baseline = -1; } @@ -9444,8 +9449,10 @@ gtk_widget_get_halign (GtkWidget *widget) g_return_val_if_fail (GTK_IS_WIDGET (widget), GTK_ALIGN_FILL); - if (priv->halign == GTK_ALIGN_BASELINE) + if (priv->halign == GTK_ALIGN_BASELINE_FILL) return GTK_ALIGN_FILL; + else if (priv->halign == GTK_ALIGN_BASELINE_CENTER) + return GTK_ALIGN_CENTER; return priv->halign; } |