summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
authorGnome CVS User <gnomecvs@src.gnome.org>1997-11-26 02:36:43 +0000
committerGnome CVS User <gnomecvs@src.gnome.org>1997-11-26 02:36:43 +0000
commite522ad46baaef62bb639a3a120c59203cb0af847 (patch)
tree084aa2739a3195db960fc8d0d8772a176924f400 /gtk
parentaedb8717f13d126b7bf9c8a4db028579d564156a (diff)
downloadgtk+-e522ad46baaef62bb639a3a120c59203cb0af847.tar.gz
gtk/gtkaspectframe.c:
Some minor improvements to rounding in aspectframes. Make sure that child allocation is always >= 0 Always trigger size allocation with gtk_widget_queue_resize to prevent calling size_allocate before allocation done. gtk/gtkframe.c: Changed tests for drawability to GTK_WIDGET_DRAWABLE Always trigger size allocation with gtk_widget_queue_resize to prevent calling size_allocate before allocation done.
Diffstat (limited to 'gtk')
-rw-r--r--gtk/gtkaspectframe.c32
-rw-r--r--gtk/gtkframe.c13
2 files changed, 24 insertions, 21 deletions
diff --git a/gtk/gtkaspectframe.c b/gtk/gtkaspectframe.c
index 16feba5f02..870c0b2f59 100644
--- a/gtk/gtkaspectframe.c
+++ b/gtk/gtkaspectframe.c
@@ -124,22 +124,21 @@ gtk_aspect_frame_set (GtkAspectFrame *aspect_frame,
(aspect_frame->ratio != ratio) ||
(aspect_frame->obey_child != obey_child))
{
- GtkWidget * this = GTK_WIDGET(aspect_frame);
-
+ GtkWidget *widget = GTK_WIDGET(aspect_frame);
+
aspect_frame->xalign = xalign;
aspect_frame->yalign = yalign;
aspect_frame->ratio = ratio;
aspect_frame->obey_child = obey_child;
- if (GTK_WIDGET_MAPPED(this))
- gdk_window_clear_area (this->window,
- this->allocation.x,
- this->allocation.y,
- this->allocation.width,
- this->allocation.height);
+ if (GTK_WIDGET_DRAWABLE(widget))
+ gdk_window_clear_area (widget->window,
+ widget->allocation.x,
+ widget->allocation.y,
+ widget->allocation.width,
+ widget->allocation.height);
- gtk_widget_size_allocate (this, &this->allocation);
- gtk_widget_queue_draw (this);
+ gtk_widget_queue_resize (widget);
}
}
@@ -275,7 +274,7 @@ gtk_aspect_frame_size_allocate (GtkWidget *widget,
frame = GTK_FRAME (widget);
bin = GTK_BIN (widget);
- if (GTK_WIDGET_MAPPED (widget) &&
+ if (GTK_WIDGET_DRAWABLE (widget) &&
((widget->allocation.x != allocation->x) ||
(widget->allocation.y != allocation->y) ||
(widget->allocation.width != allocation->width) ||
@@ -319,14 +318,19 @@ gtk_aspect_frame_size_allocate (GtkWidget *widget,
GTK_CONTAINER (frame)->border_width -
GTK_WIDGET (frame)->style->klass->ythickness);
- if (height > width / ratio)
+ /* make sure we don't allocate a negative width or height,
+ * since that will be cast to a (very big) guint16 */
+ width = MAX (0, width);
+ height = MAX (0, height);
+
+ if (ratio * height > width)
{
child_allocation.width = width;
child_allocation.height = width/ratio + 0.5;
}
- else if (width > height * ratio)
+ else
{
- child_allocation.width = ratio * height + 0.5;
+ child_allocation.width = ratio*height + 0.5;
child_allocation.height = height;
}
diff --git a/gtk/gtkframe.c b/gtk/gtkframe.c
index fe78897432..a3160307eb 100644
--- a/gtk/gtkframe.c
+++ b/gtk/gtkframe.c
@@ -144,8 +144,9 @@ gtk_frame_set_label (GtkFrame *frame,
widget->allocation.width - GTK_CONTAINER (frame)->border_width,
widget->allocation.y + frame->label_height);
- gtk_widget_queue_resize (GTK_WIDGET (frame));
}
+
+ gtk_widget_queue_resize (GTK_WIDGET (frame));
}
void
@@ -164,7 +165,7 @@ gtk_frame_set_label_align (GtkFrame *frame,
frame->label_xalign = xalign;
frame->label_yalign = yalign;
- if (GTK_WIDGET_VISIBLE (frame))
+ if (GTK_WIDGET_DRAWABLE (frame))
{
GtkWidget *widget;
@@ -177,9 +178,8 @@ gtk_frame_set_label_align (GtkFrame *frame,
widget->allocation.width - GTK_CONTAINER (frame)->border_width,
widget->allocation.y + frame->label_height);
- gtk_widget_size_allocate (GTK_WIDGET (frame), &(GTK_WIDGET (frame)->allocation));
- gtk_widget_queue_draw (GTK_WIDGET (frame));
}
+ gtk_widget_queue_resize (GTK_WIDGET (frame));
}
}
@@ -194,16 +194,15 @@ gtk_frame_set_shadow_type (GtkFrame *frame,
{
frame->shadow_type = type;
- if (GTK_WIDGET_MAPPED (frame))
+ if (GTK_WIDGET_DRAWABLE (frame))
{
gdk_window_clear_area (GTK_WIDGET (frame)->window,
GTK_WIDGET (frame)->allocation.x,
GTK_WIDGET (frame)->allocation.y,
GTK_WIDGET (frame)->allocation.width,
GTK_WIDGET (frame)->allocation.height);
- gtk_widget_size_allocate (GTK_WIDGET (frame), &(GTK_WIDGET (frame)->allocation));
- gtk_widget_queue_draw (GTK_WIDGET (frame));
}
+ gtk_widget_queue_resize (GTK_WIDGET (frame));
}
}