entry, searchentry: Fix measuring baseline
If the entry has icons, we may end up increasing our minimum and natural height compared to the values the text child returned. In that case, we should also adjust the baseline values to account for the text being shifted down. Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
This commit is contained in:
committed by
Matthias Clasen
parent
317b64e599
commit
6ffbaa6bb0
@@ -1646,14 +1646,18 @@ gtk_entry_measure (GtkWidget *widget,
|
||||
{
|
||||
GtkEntry *entry = GTK_ENTRY (widget);
|
||||
GtkEntryPrivate *priv = gtk_entry_get_instance_private (entry);
|
||||
int text_min, text_nat;
|
||||
int i;
|
||||
|
||||
gtk_widget_measure (priv->text,
|
||||
orientation,
|
||||
for_size,
|
||||
minimum, natural,
|
||||
&text_min, &text_nat,
|
||||
minimum_baseline, natural_baseline);
|
||||
|
||||
*minimum = text_min;
|
||||
*natural = text_nat;
|
||||
|
||||
for (i = 0; i < MAX_ICONS; i++)
|
||||
{
|
||||
EntryIconInfo *icon_info = priv->icons[i];
|
||||
@@ -1691,6 +1695,14 @@ gtk_entry_measure (GtkWidget *widget,
|
||||
*minimum = MAX (*minimum, prog_min);
|
||||
*natural = MAX (*natural, prog_nat);
|
||||
}
|
||||
|
||||
if (orientation == GTK_ORIENTATION_VERTICAL)
|
||||
{
|
||||
if (G_LIKELY (*minimum_baseline >= 0))
|
||||
*minimum_baseline += (*minimum - text_min) / 2;
|
||||
if (G_LIKELY (*natural_baseline >= 0))
|
||||
*natural_baseline += (*natural - text_nat) / 2;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -301,6 +301,7 @@ gtk_search_entry_measure (GtkWidget *widget,
|
||||
int *natural_baseline)
|
||||
{
|
||||
GtkSearchEntry *entry = GTK_SEARCH_ENTRY (widget);
|
||||
int text_min, text_nat;
|
||||
int icon_min, icon_nat;
|
||||
int spacing;
|
||||
|
||||
@@ -309,9 +310,12 @@ gtk_search_entry_measure (GtkWidget *widget,
|
||||
gtk_widget_measure (entry->entry,
|
||||
orientation,
|
||||
for_size,
|
||||
minimum, natural,
|
||||
&text_min, &text_nat,
|
||||
minimum_baseline, natural_baseline);
|
||||
|
||||
*minimum = text_min;
|
||||
*natural = text_nat;
|
||||
|
||||
gtk_widget_measure (entry->search_icon,
|
||||
GTK_ORIENTATION_HORIZONTAL,
|
||||
-1,
|
||||
@@ -344,6 +348,11 @@ gtk_search_entry_measure (GtkWidget *widget,
|
||||
{
|
||||
*minimum = MAX (*minimum, icon_min);
|
||||
*natural = MAX (*natural, icon_nat);
|
||||
|
||||
if (G_LIKELY (*minimum_baseline >= 0))
|
||||
*minimum_baseline += (*minimum - text_min) / 2;
|
||||
if (G_LIKELY (*natural_baseline >= 0))
|
||||
*natural_baseline += (*natural - text_nat) / 2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user