Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master Closes #3081 See merge request GNOME/gtk!2472
This commit is contained in:
@@ -122,9 +122,15 @@ gtk_center_layout_distribute (GtkCenterLayout *self,
|
||||
gboolean end_expand = FALSE;
|
||||
int avail;
|
||||
int i;
|
||||
int needed_spacing = 0;
|
||||
|
||||
/* Usable space is really less... */
|
||||
size -= spacing * 2;
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
if (self->children[i])
|
||||
needed_spacing += spacing;
|
||||
}
|
||||
needed_spacing -= spacing;
|
||||
|
||||
sizes[0].minimum_size = sizes[0].natural_size = 0;
|
||||
sizes[1].minimum_size = sizes[1].natural_size = 0;
|
||||
@@ -140,20 +146,20 @@ gtk_center_layout_distribute (GtkCenterLayout *self,
|
||||
|
||||
if (self->center_widget)
|
||||
{
|
||||
center_size = CLAMP (size - (sizes[0].minimum_size + sizes[2].minimum_size), sizes[1].minimum_size, sizes[1].natural_size);
|
||||
center_size = CLAMP (size - needed_spacing - (sizes[0].minimum_size + sizes[2].minimum_size), sizes[1].minimum_size, sizes[1].natural_size);
|
||||
center_expand = get_expand (self->center_widget, self->orientation);
|
||||
}
|
||||
|
||||
if (self->start_widget)
|
||||
{
|
||||
avail = MIN ((size - center_size) / 2, size - (center_size + sizes[2].minimum_size));
|
||||
avail = MIN ((size - needed_spacing - center_size) / 2, size - needed_spacing - (center_size + sizes[2].minimum_size));
|
||||
start_size = CLAMP (avail, sizes[0].minimum_size, sizes[0].natural_size);
|
||||
start_expand = get_expand (self->start_widget, self->orientation);
|
||||
}
|
||||
|
||||
if (self->end_widget)
|
||||
{
|
||||
avail = MIN ((size - center_size) / 2, size - (center_size + sizes[0].minimum_size));
|
||||
avail = MIN ((size - needed_spacing - center_size) / 2, size - needed_spacing - (center_size + sizes[0].minimum_size));
|
||||
end_size = CLAMP (avail, sizes[2].minimum_size, sizes[2].natural_size);
|
||||
end_expand = get_expand (self->end_widget, self->orientation);
|
||||
}
|
||||
@@ -165,25 +171,25 @@ gtk_center_layout_distribute (GtkCenterLayout *self,
|
||||
center_pos = (size / 2) - (center_size / 2);
|
||||
|
||||
/* Push in from start/end */
|
||||
if (start_size > center_pos)
|
||||
center_pos = start_size;
|
||||
else if (size - end_size < center_pos + center_size)
|
||||
center_pos = size - center_size - end_size;
|
||||
if (start_size > 0 && start_size + spacing > center_pos)
|
||||
center_pos = start_size + spacing;
|
||||
else if (end_size > 0 && size - end_size - spacing < center_pos + center_size)
|
||||
center_pos = size - center_size - end_size - spacing;
|
||||
else if (center_expand)
|
||||
{
|
||||
center_size = size - 2 * MAX (start_size, end_size);
|
||||
center_pos = (size / 2) - (center_size / 2);
|
||||
center_pos = (size / 2) - (center_size / 2) + spacing;
|
||||
}
|
||||
|
||||
if (start_expand)
|
||||
start_size = center_pos;
|
||||
start_size = center_pos - spacing;
|
||||
|
||||
if (end_expand)
|
||||
end_size = size - (center_pos + center_size);
|
||||
end_size = size - (center_pos + center_size) - spacing;
|
||||
}
|
||||
else
|
||||
{
|
||||
avail = size - (start_size + end_size);
|
||||
avail = size - needed_spacing - (start_size + end_size);
|
||||
if (start_expand && end_expand)
|
||||
{
|
||||
start_size += avail / 2;
|
||||
@@ -484,10 +490,10 @@ gtk_center_layout_allocate (GtkLayoutManager *layout_manager,
|
||||
if (child[1])
|
||||
{
|
||||
/* Push in from start/end */
|
||||
if (child_size[0] > child_pos[1])
|
||||
child_pos[1] = child_size[0];
|
||||
else if (size - child_size[2] < child_pos[1] + child_size[1])
|
||||
child_pos[1] = size - child_size[1] - child_size[2];
|
||||
if (child_size[0] > 0 && child_size[0] + spacing > child_pos[1])
|
||||
child_pos[1] = child_size[0] + spacing;
|
||||
else if (child_size[2] > 0 && size - child_size[2] - spacing < child_pos[1] + child_size[1])
|
||||
child_pos[1] = size - child_size[1] - child_size[2] - spacing;
|
||||
}
|
||||
|
||||
for (i = 0; i < 3; i++)
|
||||
|
||||
20
testsuite/reftests/boxlayout-invisible-child.ref.ui
Normal file
20
testsuite/reftests/boxlayout-invisible-child.ref.ui
Normal file
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<object class="GtkWindow" id="window_information_collection">
|
||||
<property name="decorated">0</property>
|
||||
<child>
|
||||
<object class="GtkBox" id="box1">
|
||||
<child>
|
||||
<object class="GtkLabel" id="label1">
|
||||
<property name="label" translatable="yes">Hello</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label3">
|
||||
<property name="label" translatable="yes">World</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
||||
27
testsuite/reftests/boxlayout-invisible-child.ui
Normal file
27
testsuite/reftests/boxlayout-invisible-child.ui
Normal file
@@ -0,0 +1,27 @@
|
||||
<!-- check that an invisible child does not influence the layout -->
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<object class="GtkWindow" id="window_information_collection">
|
||||
<property name="decorated">0</property>
|
||||
<child>
|
||||
<object class="GtkBox" id="box1">
|
||||
<child>
|
||||
<object class="GtkLabel" id="label1">
|
||||
<property name="label" translatable="yes">Hello</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label2">
|
||||
<property name="visible">0</property>
|
||||
<property name="label" translatable="yes">cruel</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label3">
|
||||
<property name="label" translatable="yes">World</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
||||
3
testsuite/reftests/centerlayout-invisible-child.css
Normal file
3
testsuite/reftests/centerlayout-invisible-child.css
Normal file
@@ -0,0 +1,3 @@
|
||||
box {
|
||||
border-spacing: 10px;
|
||||
}
|
||||
21
testsuite/reftests/centerlayout-invisible-child.ref.ui
Normal file
21
testsuite/reftests/centerlayout-invisible-child.ref.ui
Normal file
@@ -0,0 +1,21 @@
|
||||
<!-- check that an invisible child does not influence the layout -->
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<object class="GtkWindow" id="window_information_collection">
|
||||
<property name="decorated">0</property>
|
||||
<child>
|
||||
<object class="GtkCenterBox" id="box1">
|
||||
<child type="start">
|
||||
<object class="GtkLabel" id="label1">
|
||||
<property name="label" translatable="yes">Hello, Hello</property>
|
||||
</object>
|
||||
</child>
|
||||
<child type="end">
|
||||
<object class="GtkLabel" id="label3">
|
||||
<property name="label" translatable="yes">World</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
||||
27
testsuite/reftests/centerlayout-invisible-child.ui
Normal file
27
testsuite/reftests/centerlayout-invisible-child.ui
Normal file
@@ -0,0 +1,27 @@
|
||||
<!-- check that an invisible child does not influence the layout -->
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<object class="GtkWindow" id="window_information_collection">
|
||||
<property name="decorated">0</property>
|
||||
<child>
|
||||
<object class="GtkCenterBox" id="box1">
|
||||
<child type="start">
|
||||
<object class="GtkLabel" id="label1">
|
||||
<property name="label" translatable="yes">Hello, Hello</property>
|
||||
</object>
|
||||
</child>
|
||||
<child type="center">
|
||||
<object class="GtkLabel" id="label2">
|
||||
<property name="visible">0</property>
|
||||
<property name="label" translatable="yes">cruel</property>
|
||||
</object>
|
||||
</child>
|
||||
<child type="end">
|
||||
<object class="GtkLabel" id="label3">
|
||||
<property name="label" translatable="yes">World</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
||||
3
testsuite/reftests/centerlayout-minsize.css
Normal file
3
testsuite/reftests/centerlayout-minsize.css
Normal file
@@ -0,0 +1,3 @@
|
||||
box {
|
||||
border-spacing: 10px;
|
||||
}
|
||||
26
testsuite/reftests/centerlayout-minsize.ref.ui
Normal file
26
testsuite/reftests/centerlayout-minsize.ref.ui
Normal file
@@ -0,0 +1,26 @@
|
||||
<!-- check that an invisible child does not influence the layout -->
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<object class="GtkWindow" id="window_information_collection">
|
||||
<property name="decorated">0</property>
|
||||
<child>
|
||||
<object class="GtkBox" id="box1">
|
||||
<child>
|
||||
<object class="GtkLabel" id="label1">
|
||||
<property name="label" translatable="yes">Hello, Hello</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label2">
|
||||
<property name="label" translatable="yes">cruel</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label3">
|
||||
<property name="label" translatable="yes">World</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
||||
27
testsuite/reftests/centerlayout-minsize.ui
Normal file
27
testsuite/reftests/centerlayout-minsize.ui
Normal file
@@ -0,0 +1,27 @@
|
||||
<!-- check that an invisible child does not influence the layout -->
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<object class="GtkWindow" id="window_information_collection">
|
||||
<property name="decorated">0</property>
|
||||
<property name="default-width">20</property>
|
||||
<child>
|
||||
<object class="GtkCenterBox" id="box1">
|
||||
<child type="start">
|
||||
<object class="GtkLabel" id="label1">
|
||||
<property name="label" translatable="yes">Hello, Hello</property>
|
||||
</object>
|
||||
</child>
|
||||
<child type="center">
|
||||
<object class="GtkLabel" id="label2">
|
||||
<property name="label" translatable="yes">cruel</property>
|
||||
</object>
|
||||
</child>
|
||||
<child type="end">
|
||||
<object class="GtkLabel" id="label3">
|
||||
<property name="label" translatable="yes">World</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
||||
28
testsuite/reftests/gridlayout-invisible-child.ref.ui
Normal file
28
testsuite/reftests/gridlayout-invisible-child.ref.ui
Normal file
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<object class="GtkWindow" id="window_information_collection">
|
||||
<property name="decorated">0</property>
|
||||
<child>
|
||||
<object class="GtkGrid" id="grid1">
|
||||
<child>
|
||||
<object class="GtkLabel" id="label1">
|
||||
<property name="label" translatable="yes">Hello</property>
|
||||
<layout>
|
||||
<property name="row">0</property>
|
||||
<property name="column">0</property>
|
||||
</layout>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label3">
|
||||
<property name="label" translatable="yes">World</property>
|
||||
<layout>
|
||||
<property name="row">0</property>
|
||||
<property name="column">2</property>
|
||||
</layout>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
||||
39
testsuite/reftests/gridlayout-invisible-child.ui
Normal file
39
testsuite/reftests/gridlayout-invisible-child.ui
Normal file
@@ -0,0 +1,39 @@
|
||||
<!-- check that an invisible child does not influence the layout -->
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<object class="GtkWindow" id="window_information_collection">
|
||||
<property name="decorated">0</property>
|
||||
<child>
|
||||
<object class="GtkGrid" id="grid1">
|
||||
<child>
|
||||
<object class="GtkLabel" id="label1">
|
||||
<property name="label" translatable="yes">Hello</property>
|
||||
<layout>
|
||||
<property name="row">0</property>
|
||||
<property name="column">0</property>
|
||||
</layout>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label2">
|
||||
<property name="visible">0</property>
|
||||
<property name="label" translatable="yes">cruel</property>
|
||||
<layout>
|
||||
<property name="row">0</property>
|
||||
<property name="column">1</property>
|
||||
</layout>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label3">
|
||||
<property name="label" translatable="yes">World</property>
|
||||
<layout>
|
||||
<property name="row">0</property>
|
||||
<property name="column">2</property>
|
||||
</layout>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
||||
@@ -141,6 +141,8 @@ testdata = [
|
||||
'border-style.css',
|
||||
'border-style.ref.ui',
|
||||
'border-style.ui',
|
||||
'boxlayout-invisible-child.ref.ui',
|
||||
'boxlayout-invisible-child.ui',
|
||||
'box-order.css',
|
||||
'box-order.ref.ui',
|
||||
'box-order.ui',
|
||||
@@ -161,6 +163,12 @@ testdata = [
|
||||
'box-shadow-with-blend-mode.ui',
|
||||
'button-wrapping.ui',
|
||||
'button-wrapping.ref.ui',
|
||||
'centerlayout-invisible-child.css',
|
||||
'centerlayout-invisible-child.ref.ui',
|
||||
'centerlayout-invisible-child.ui',
|
||||
'centerlayout-minsize.css',
|
||||
'centerlayout-minsize.ref.ui',
|
||||
'centerlayout-minsize.ui',
|
||||
'color-transition.css',
|
||||
'color-transition.ref.ui',
|
||||
'color-transition.ui',
|
||||
@@ -227,6 +235,8 @@ testdata = [
|
||||
'gradient-hard-stop.ref.ui',
|
||||
'gradient-hard-stop.ui',
|
||||
'green-20x20.png',
|
||||
'gridlayout-invisible-child.ref.ui',
|
||||
'gridlayout-invisible-child.ui',
|
||||
'grid-empty-with-spacing.ref.ui',
|
||||
'grid-empty-with-spacing.ui',
|
||||
'grid-expand.css',
|
||||
|
||||
Reference in New Issue
Block a user