[gtk+/extended-layout-jhs: 61/64] Consider width-for-height information. Move GtkChildSizeRequest to
- From: Johannes Schmid <jhs src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gtk+/extended-layout-jhs: 61/64] Consider width-for-height information. Move GtkChildSizeRequest to
- Date: Wed, 25 Nov 2009 11:24:02 +0000 (UTC)
commit 78cdc825bf5131ba0a256c705e566d58c8ae6444
Author: Mathias Hasselmann <mathias hasselmann gmx de>
Date: Tue Aug 28 16:06:16 2007 +0000
Consider width-for-height information. Move GtkChildSizeRequest to
2007-08-28 Mathias Hasselmann <mathias hasselmann gmx de>
* gtk/gtkhbox.c: Consider width-for-height information.
* gtk/gtkvbox.c, gtk/gtkprivate.h: Move GtkChildSizeRequest
to gtkprivate.h.
svn path=/branches/extended-layout/; revision=18694
ChangeLog.gtk-extended-layout | 6 +++
gtk/gtkhbox.c | 75 +++++++++++++++++++++++++++++------------
gtk/gtkprivate.h | 4 ++
gtk/gtkvbox.c | 11 ++----
4 files changed, 66 insertions(+), 30 deletions(-)
---
diff --git a/ChangeLog.gtk-extended-layout b/ChangeLog.gtk-extended-layout
index fef9120..ad4f559 100644
--- a/ChangeLog.gtk-extended-layout
+++ b/ChangeLog.gtk-extended-layout
@@ -1,3 +1,9 @@
+2007-08-28 Mathias Hasselmann <mathias hasselmann gmx de>
+
+ * gtk/gtkhbox.c: Consider width-for-height information.
+ * gtk/gtkvbox.c, gtk/gtkprivate.h: Move GtkChildSizeRequest
+ to gtkprivate.h.
+
2007-08-20 Mathias Hasselmann <mathias hasselmann gmx de>
* gtk/gtkvbox.c: Properly calculate minimum_height in size-allocate.
diff --git a/gtk/gtkhbox.c b/gtk/gtkhbox.c
index 3fc8d85..e0a905a 100644
--- a/gtk/gtkhbox.c
+++ b/gtk/gtkhbox.c
@@ -29,6 +29,7 @@
#include "gtkextendedlayout.h"
#include "gtkintl.h"
#include "gtkalias.h"
+#include "gtkprivate.h"
enum {
@@ -148,9 +149,31 @@ gtk_hbox_get_property (GObject *object,
}
static void
+gtk_hbox_natural_size_request (GtkWidget *child,
+ GtkRequisition *requisition,
+ GtkWidget *widget)
+{
+ GtkExtendedLayoutFeatures features = 0;
+
+ if (GTK_IS_EXTENDED_LAYOUT (child))
+ features = gtk_extended_layout_get_features ((GtkExtendedLayout*) child);
+
+ if (features & GTK_EXTENDED_LAYOUT_WIDTH_FOR_HEIGHT)
+ {
+ requisition->width = gtk_extended_layout_get_width_for_height (
+ (GtkExtendedLayout*) child, widget->allocation.height);
+ requisition->height = widget->allocation.height;
+ }
+ else if (features & GTK_EXTENDED_LAYOUT_NATURAL_SIZE)
+ gtk_extended_layout_get_natural_size ((GtkExtendedLayout*) child, requisition);
+ else
+ gtk_widget_size_request (child, requisition);
+}
+
+static void
gtk_hbox_real_size_request (GtkWidget *widget,
GtkRequisition *requisition,
- gboolean consider_natural_size)
+ GtkChildSizeRequest size_request_func)
{
GtkBox *box = GTK_BOX (widget);
@@ -218,17 +241,11 @@ gtk_hbox_real_size_request (GtkWidget *widget,
if (GTK_WIDGET_VISIBLE (child->widget))
{
GtkRequisition child_requisition;
- gint width;
-
- if (consider_natural_size && GTK_EXTENDED_LAYOUT_HAS_NATURAL_SIZE (child->widget))
- gtk_extended_layout_get_natural_size (GTK_EXTENDED_LAYOUT (child->widget),
- &child_requisition);
- else
- gtk_widget_size_request (child->widget, &child_requisition);
+ size_request_func (child->widget, &child_requisition, widget);
if (box->homogeneous)
{
- width = child_requisition.width + child->padding * 2;
+ gint width = child_requisition.width + child->padding * 2;
requisition->width = MAX (requisition->width, width);
}
else
@@ -262,7 +279,7 @@ static void
gtk_hbox_size_request (GtkWidget *widget,
GtkRequisition *requisition)
{
- gtk_hbox_real_size_request (widget, requisition, FALSE);
+ gtk_hbox_real_size_request (widget, requisition, (GtkChildSizeRequest)gtk_widget_size_request);
}
static void
@@ -309,13 +326,15 @@ gtk_hbox_size_allocate (GtkWidget *widget,
gint *minimum_requisitions;
gint available, natural, extra;
- gint natural_width;
+ gint minimum_width, natural_width;
gint i;
direction = gtk_widget_get_direction (widget);
border_width = GTK_CONTAINER (box)->border_width;
+ minimum_width = widget->requisition.width;
natural_width = 0;
+
natural_requisitions = g_newa (gint, nvis_children);
minimum_requisitions = g_newa (gint, nvis_children);
@@ -333,18 +352,30 @@ gtk_hbox_size_allocate (GtkWidget *widget,
gtk_widget_size_request (child->widget, &child_requisition);
minimum_requisitions[i] = child_requisition.width;
+ natural_requisitions[i] = 0;
+
+ if (GTK_IS_EXTENDED_LAYOUT (child->widget))
+ {
+ GtkExtendedLayout *layout = (GtkExtendedLayout*)child->widget;
+ GtkExtendedLayoutFeatures features = gtk_extended_layout_get_features (layout);
+
+ if (features & GTK_EXTENDED_LAYOUT_WIDTH_FOR_HEIGHT)
+ {
+ gint width = gtk_extended_layout_get_width_for_height (layout, allocation->height);
+ gint dx = minimum_requisitions[i] - width;
- if (GTK_EXTENDED_LAYOUT_HAS_NATURAL_SIZE (child->widget))
+ if (dx > 0)
{
- gtk_extended_layout_get_natural_size (
- GTK_EXTENDED_LAYOUT (child->widget),
- &child_requisition);
- natural_requisitions[i] =
- child_requisition.width -
- minimum_requisitions[i];
+ minimum_requisitions[i] = width;
+ minimum_width -= dx;
+ }
+ }
+ else if (features & GTK_EXTENDED_LAYOUT_NATURAL_SIZE)
+ {
+ gtk_extended_layout_get_natural_size (layout, &child_requisition);
+ natural_requisitions[i] = child_requisition.width - minimum_requisitions[i];
+ }
}
- else
- natural_requisitions[i] = 0;
natural_width += natural_requisitions[i++];
}
@@ -361,7 +392,7 @@ gtk_hbox_size_allocate (GtkWidget *widget,
{
if (nexpand_children > 0 || natural_width > 0)
{
- available = (gint)allocation->width - widget->requisition.width;
+ available = (gint)allocation->width - minimum_width;
natural = MAX (0, MIN (available, natural_width));
available -= natural;
}
@@ -542,7 +573,7 @@ static void
gtk_hbox_extended_layout_get_natural_size (GtkExtendedLayout *layout,
GtkRequisition *requisition)
{
- gtk_hbox_real_size_request (GTK_WIDGET (layout), requisition, TRUE);
+ gtk_hbox_real_size_request (GTK_WIDGET (layout), requisition, gtk_hbox_natural_size_request);
}
static gint
diff --git a/gtk/gtkprivate.h b/gtk/gtkprivate.h
index 690cc8a..5399ee5 100644
--- a/gtk/gtkprivate.h
+++ b/gtk/gtkprivate.h
@@ -104,6 +104,10 @@ gboolean _gtk_fnmatch (const char *pattern,
#define GTK_PARAM_WRITABLE G_PARAM_WRITABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB
#define GTK_PARAM_READWRITE G_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB
+typedef void (*GtkChildSizeRequest) (GtkWidget *child,
+ GtkRequisition *requisition,
+ GtkWidget *widget);
+
G_END_DECLS
#endif /* __GTK_PRIVATE_H__ */
diff --git a/gtk/gtkvbox.c b/gtk/gtkvbox.c
index bf9c917..2966586 100644
--- a/gtk/gtkvbox.c
+++ b/gtk/gtkvbox.c
@@ -29,6 +29,7 @@
#include "gtkextendedlayout.h"
#include "gtkintl.h"
#include "gtkalias.h"
+#include "gtkprivate.h"
static void gtk_vbox_size_request (GtkWidget *widget,
@@ -72,10 +73,6 @@ gtk_vbox_new (gboolean homogeneous,
return GTK_WIDGET (vbox);
}
-typedef void (*GtkChildSizeRequest) (GtkWidget *child,
- GtkRequisition *requisition,
- GtkWidget *widget);
-
static void
gtk_vbox_natural_size_request (GtkWidget *child,
GtkRequisition *requisition,
@@ -105,10 +102,8 @@ gtk_vbox_real_size_request (GtkWidget *widget,
{
GtkBox *box;
GtkBoxChild *child;
- GtkRequisition child_requisition;
GList *children;
gint nvis_children;
- gint height;
box = GTK_BOX (widget);
requisition->width = 0;
@@ -123,11 +118,12 @@ gtk_vbox_real_size_request (GtkWidget *widget,
if (GTK_WIDGET_VISIBLE (child->widget))
{
+ GtkRequisition child_requisition;
size_request_func (child->widget, &child_requisition, widget);
if (box->homogeneous)
{
- height = child_requisition.height + child->padding * 2;
+ gint height = child_requisition.height + child->padding * 2;
requisition->height = MAX (requisition->height, height);
}
else
@@ -248,7 +244,6 @@ gtk_vbox_size_allocate (GtkWidget *widget,
gtk_extended_layout_get_natural_size (layout, &child_requisition);
natural_requisitions[i] = child_requisition.height - minimum_requisitions[i];
}
-
}
natural_height += natural_requisitions[i++];
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]