overlay: Handle overlays when no main widget exists

Just pretend that the main widget is an empty widget the size of the
overlay.
Makes it possible to write testcases where no size requests are run on
overlay widgets before size_allocate() is called.

Testcase included.
This commit is contained in:
Benjamin Otte 2014-09-07 01:52:45 +02:00
parent c849b8edd6
commit 95959ef470
4 changed files with 65 additions and 6 deletions

View File

@ -214,8 +214,8 @@ gtk_overlay_get_main_widget_allocation (GtkOverlay *overlay,
{
main_alloc.x = 0;
main_alloc.y = 0;
main_alloc.width = 1;
main_alloc.height = 1;
main_alloc.width = gtk_widget_get_allocated_width (GTK_WIDGET (overlay));
main_alloc.height = gtk_widget_get_allocated_height (GTK_WIDGET (overlay));
}
if (main_alloc_out)
@ -325,10 +325,8 @@ gtk_overlay_size_allocate (GtkWidget *widget,
GTK_WIDGET_CLASS (gtk_overlay_parent_class)->size_allocate (widget, allocation);
main_widget = gtk_bin_get_child (GTK_BIN (overlay));
if (!main_widget || !gtk_widget_get_visible (main_widget))
return;
gtk_widget_size_allocate (main_widget, allocation);
if (main_widget && gtk_widget_get_visible (main_widget))
gtk_widget_size_allocate (main_widget, allocation);
for (children = priv->children; children; children = children->next)
gtk_overlay_child_allocate (overlay, children->data);

View File

@ -314,6 +314,8 @@ testdata = \
opacity.css \
opacity.ui \
opacity.ref.ui \
overlay-no-main-widget.ref.ui \
overlay-no-main-widget.ui \
paned-undersized.css \
paned-undersized.ref.ui \
paned-undersized.ui \

View File

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.1 -->
<interface>
<requires lib="gtk+" version="3.12"/>
<object class="GtkWindow" id="window1">
<property name="can_focus">False</property>
<child>
<object class="GtkOverlay" id="overlay1">
<property name="width_request">100</property>
<property name="height_request">100</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkBox" id="box1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<placeholder/>
</child>
</object>
</child>
<child type="overlay">
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">VISIBLE</property>
</object>
</child>
</object>
</child>
</object>
</interface>

View File

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.1 -->
<interface>
<requires lib="gtk+" version="3.12"/>
<object class="GtkWindow" id="window1">
<property name="can_focus">False</property>
<child>
<object class="GtkOverlay" id="overlay1">
<property name="width_request">100</property>
<property name="height_request">100</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<placeholder/>
</child>
<child type="overlay">
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">VISIBLE</property>
</object>
</child>
</object>
</child>
</object>
</interface>