forked from AuroraMiddleware/gtk
frame: Let GtkContainer handle border-width
https://bugzilla.gnome.org/show_bug.cgi?id=760482
This commit is contained in:
parent
abd781a2c9
commit
3431451463
@ -265,6 +265,8 @@ gtk_frame_class_init (GtkFrameClass *class)
|
|||||||
container_class->remove = gtk_frame_remove;
|
container_class->remove = gtk_frame_remove;
|
||||||
container_class->forall = gtk_frame_forall;
|
container_class->forall = gtk_frame_forall;
|
||||||
|
|
||||||
|
gtk_container_class_handle_border_width (container_class);
|
||||||
|
|
||||||
class->compute_child_allocation = gtk_frame_real_compute_child_allocation;
|
class->compute_child_allocation = gtk_frame_real_compute_child_allocation;
|
||||||
|
|
||||||
gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_FRAME_ACCESSIBLE);
|
gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_FRAME_ACCESSIBLE);
|
||||||
@ -889,26 +891,25 @@ gtk_frame_real_compute_child_allocation (GtkFrame *frame,
|
|||||||
{
|
{
|
||||||
GtkFramePrivate *priv = frame->priv;
|
GtkFramePrivate *priv = frame->priv;
|
||||||
GtkAllocation allocation;
|
GtkAllocation allocation;
|
||||||
gint border_width, height;
|
gint height;
|
||||||
|
|
||||||
gtk_css_gadget_get_content_allocation (priv->gadget, &allocation, NULL);
|
gtk_css_gadget_get_content_allocation (priv->gadget, &allocation, NULL);
|
||||||
border_width = gtk_container_get_border_width (GTK_CONTAINER (frame));
|
|
||||||
|
|
||||||
if (priv->label_widget)
|
if (priv->label_widget)
|
||||||
{
|
{
|
||||||
gint nat_width, width;
|
gint nat_width, width;
|
||||||
|
|
||||||
gtk_widget_get_preferred_width (priv->label_widget, NULL, &nat_width);
|
gtk_widget_get_preferred_width (priv->label_widget, NULL, &nat_width);
|
||||||
width = MIN (allocation.width - 2 * border_width, nat_width);
|
width = MIN (allocation.width, nat_width);
|
||||||
gtk_widget_get_preferred_height_for_width (priv->label_widget, width, &height, NULL);
|
gtk_widget_get_preferred_height_for_width (priv->label_widget, width, &height, NULL);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
height = 0;
|
height = 0;
|
||||||
|
|
||||||
child_allocation->x = allocation.x + border_width;
|
child_allocation->x = allocation.x;
|
||||||
child_allocation->y = allocation.y + border_width + height;
|
child_allocation->y = allocation.y + height;
|
||||||
child_allocation->width = MAX (1, allocation.width - 2 * border_width);
|
child_allocation->width = MAX (1, allocation.width);
|
||||||
child_allocation->height = MAX (1, allocation.height - 2 * border_width - height);
|
child_allocation->height = MAX (1, allocation.height - height);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -926,14 +927,11 @@ gtk_frame_measure (GtkCssGadget *gadget,
|
|||||||
GtkFramePrivate *priv;
|
GtkFramePrivate *priv;
|
||||||
GtkWidget *child;
|
GtkWidget *child;
|
||||||
gint child_min, child_nat;
|
gint child_min, child_nat;
|
||||||
guint border_width;
|
|
||||||
|
|
||||||
widget = gtk_css_gadget_get_owner (gadget);
|
widget = gtk_css_gadget_get_owner (gadget);
|
||||||
frame = GTK_FRAME (widget);
|
frame = GTK_FRAME (widget);
|
||||||
priv = frame->priv;
|
priv = frame->priv;
|
||||||
|
|
||||||
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
|
|
||||||
|
|
||||||
if (priv->label_widget && gtk_widget_get_visible (priv->label_widget))
|
if (priv->label_widget && gtk_widget_get_visible (priv->label_widget))
|
||||||
{
|
{
|
||||||
if (orientation == GTK_ORIENTATION_HORIZONTAL)
|
if (orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||||
@ -946,7 +944,7 @@ gtk_frame_measure (GtkCssGadget *gadget,
|
|||||||
{
|
{
|
||||||
if (for_size > 0)
|
if (for_size > 0)
|
||||||
gtk_widget_get_preferred_height_for_width (priv->label_widget,
|
gtk_widget_get_preferred_height_for_width (priv->label_widget,
|
||||||
for_size - 2 * border_width, &child_min, &child_nat);
|
for_size, &child_min, &child_nat);
|
||||||
else
|
else
|
||||||
gtk_widget_get_preferred_height (priv->label_widget, &child_min, &child_nat);
|
gtk_widget_get_preferred_height (priv->label_widget, &child_min, &child_nat);
|
||||||
|
|
||||||
@ -972,7 +970,7 @@ gtk_frame_measure (GtkCssGadget *gadget,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (for_size > 0)
|
if (for_size > 0)
|
||||||
gtk_widget_get_preferred_height_for_width (child, for_size - 2 * border_width, &child_min, &child_nat);
|
gtk_widget_get_preferred_height_for_width (child, for_size, &child_min, &child_nat);
|
||||||
else
|
else
|
||||||
gtk_widget_get_preferred_height (child, &child_min, &child_nat);
|
gtk_widget_get_preferred_height (child, &child_min, &child_nat);
|
||||||
|
|
||||||
@ -981,8 +979,6 @@ gtk_frame_measure (GtkCssGadget *gadget,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*minimum += 2 * border_width;
|
|
||||||
*natural += 2 * border_width;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
Reference in New Issue
Block a user