mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-09 10:20:07 +00:00
listview: Measure children only, not self
The previous code would include CSS padding/margin/border in the
measurement and that is wrong.
Until commit a96c75ff02
this was not actually visible, but afterwards
listitems were allocated 16px too wide.
Test included
This commit is contained in:
parent
1f4adb60bb
commit
be6a4722c0
@ -606,9 +606,9 @@ gtk_list_view_size_allocate (GtkWidget *widget,
|
||||
}
|
||||
|
||||
/* step 1: determine width of the list */
|
||||
gtk_widget_measure (widget, opposite_orientation,
|
||||
-1,
|
||||
&min, &nat, NULL, NULL);
|
||||
gtk_list_view_measure_across (widget, opposite_orientation,
|
||||
-1,
|
||||
&min, &nat);
|
||||
self->list_width = orientation == GTK_ORIENTATION_VERTICAL ? width : height;
|
||||
if (opposite_scroll_policy == GTK_SCROLL_MINIMUM)
|
||||
self->list_width = MAX (min, self->list_width);
|
||||
|
8
testsuite/reftests/listview-margin.css
Normal file
8
testsuite/reftests/listview-margin.css
Normal file
@ -0,0 +1,8 @@
|
||||
listview, box {
|
||||
margin: 50px;
|
||||
padding: 50px;
|
||||
}
|
||||
|
||||
row {
|
||||
all: unset;
|
||||
}
|
32
testsuite/reftests/listview-margin.ref.ui
Normal file
32
testsuite/reftests/listview-margin.ref.ui
Normal file
@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<object class="GtkWindow">
|
||||
<property name="decorated">0</property>
|
||||
<property name="child">
|
||||
<object class="GtkBox">
|
||||
<style>
|
||||
<class name="view"/>
|
||||
</style>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="xalign">1</property>
|
||||
<property name="label">One</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="xalign">1</property>
|
||||
<property name="label">Two</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="xalign">1</property>
|
||||
<property name="label">Three</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</interface>
|
44
testsuite/reftests/listview-margin.ui
Normal file
44
testsuite/reftests/listview-margin.ui
Normal file
@ -0,0 +1,44 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<object class="GtkWindow">
|
||||
<property name="decorated">0</property>
|
||||
<property name="child">
|
||||
<object class="GtkListView">
|
||||
<property name="model">
|
||||
<object class="GtkNoSelection">
|
||||
<property name="model">
|
||||
<object class="GtkStringList">
|
||||
<items>
|
||||
<item translatable="yes">One</item>
|
||||
<item translatable="yes">Two</item>
|
||||
<item translatable="yes">Three</item>
|
||||
</items>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</property>
|
||||
<property name="factory">
|
||||
<object class="GtkBuilderListItemFactory">
|
||||
<property name="bytes"><![CDATA[
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<template class="GtkListItem">
|
||||
<property name="child">
|
||||
<object class="GtkLabel">
|
||||
<property name="xalign">1</property>
|
||||
<binding name="label">
|
||||
<lookup name="string" type="GtkStringObject">
|
||||
<lookup name="item">GtkListItem</lookup>
|
||||
</lookup>
|
||||
</binding>
|
||||
</object>
|
||||
</property>
|
||||
</template>
|
||||
</interface>
|
||||
]]></property>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</interface>
|
@ -446,6 +446,9 @@ testdata = [
|
||||
'link-coloring.css',
|
||||
'link-coloring.ref.ui',
|
||||
'link-coloring.ui',
|
||||
'listview-margin.css',
|
||||
'listview-margin.ref.ui',
|
||||
'listview-margin.ui',
|
||||
'listview-with-wrapped-labels.ref.ui',
|
||||
'listview-with-wrapped-labels.ui',
|
||||
'marble.xpm',
|
||||
|
Loading…
Reference in New Issue
Block a user