Author: rpmcruz
Date: Thu Oct 11 20:14:20 2007
New Revision: 41395
URL: http://svn.opensuse.org/viewcvs/yast?rev=41395&view=rev
Log:
* src/ygtkratiobox.c: seems like we aren't being completely faithful to
yast-core. Made widget base-size with the boss algo from yast-core.
Modified:
trunk/gtk/ChangeLog
trunk/gtk/src/ygtkratiobox.c
trunk/gtk/src/ygtkratiobox.h
Modified: trunk/gtk/ChangeLog
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/ChangeLog?rev=41395&r1=41394&r2=41395&view=diff
==============================================================================
--- trunk/gtk/ChangeLog (original)
+++ trunk/gtk/ChangeLog Thu Oct 11 20:14:20 2007
@@ -27,6 +27,9 @@
* src/YGTable.cc: forgot to block new hook: select_delayed_cb when
changing selection.
+ * src/ygtkratiobox.c: seems like we aren't being completely faithful to
+ yast-core. Made widget base-size with the boss algo from yast-core.
+
2007-10-10 Ricardo Cruz
* src/YGPackageSelector.cc: fixed bug #330467. Do a full match to
Modified: trunk/gtk/src/ygtkratiobox.c
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/ygtkratiobox.c?rev=41395&r1=41394&r2=41395&view=diff
==============================================================================
--- trunk/gtk/src/ygtkratiobox.c (original)
+++ trunk/gtk/src/ygtkratiobox.c Thu Oct 11 20:14:20 2007
@@ -104,8 +104,7 @@
GtkOrientation orientation)
{
YGtkRatioBox* box = YGTK_RATIO_BOX (widget);
- guint ratios_num = 0;
- gfloat max_ratio = 0;
+ gfloat ratios_sum = 0;
box->has_must_expand = FALSE;
GList* child;
for (child = box->children; child; child = child->next) {
@@ -113,10 +112,7 @@
if (!GTK_WIDGET_VISIBLE (box_child->widget))
continue;
if (box_child->ratio)
- {
- max_ratio = MAX (max_ratio, box_child->ratio);
- ratios_num++;
- }
+ ratios_sum += box_child->ratio;
if (box_child->must_expand)
box->has_must_expand = TRUE;
}
@@ -124,7 +120,7 @@
// If we want to calculate horizontal size, primary_req would be horizontal
// length, while secondary the height. Idem for the inverse.
guint primary_req = 0, secondary_req = 0;
- box->ratio_width = 0;
+ box->weight_length = 0; // biggest ratio of widget-size / widget-ratio
for (child = box->children; child; child = child->next) {
YGtkRatioBoxChild* box_child = (YGtkRatioBoxChild*) child->data;
@@ -145,14 +141,17 @@
}
if (box_child->ratio)
- box->ratio_width = MAX (box->ratio_width, (prim_length * max_ratio) / box_child->ratio);
+ {
+ int length = (prim_length * ratios_sum) / box_child->ratio;
+ box->weight_length = MAX (box->weight_length, length);
+ }
else
primary_req += prim_length;
primary_req += box_child->padding + box->spacing;
secondary_req = MAX (secondary_req, sec_length);
}
- primary_req += box->ratio_width * ratios_num;
+ primary_req += box->weight_length;
guint border = GTK_CONTAINER (widget)->border_width * 2;
primary_req += border*2; secondary_req += border*2;
@@ -171,6 +170,7 @@
GtkAllocation *allocation,
GtkOrientation orientation)
{
+ YGtkRatioBox* box = YGTK_RATIO_BOX (widget);
guint border = GTK_CONTAINER (widget)->border_width;
// a first loop to get some data for expansibles (ie. childs with weight)
@@ -183,7 +183,6 @@
expansable_length = allocation->height - border*2;
GList* child;
- YGtkRatioBox* box = YGTK_RATIO_BOX (widget);
for (child = box->children; child; child = child->next) {
YGtkRatioBoxChild* box_child = (YGtkRatioBoxChild*) child->data;
if (!GTK_WIDGET_VISIBLE (box_child->widget))
@@ -197,12 +196,7 @@
max_ratio = MAX (max_ratio, box_child->ratio);
}
- if (box_child->ratio)
- {
- if (box->has_must_expand)
- expansable_length -= (box->ratio_width * box_child->ratio) / max_ratio;
- }
- else
+ if (!box_child->ratio)
{
GtkRequisition child_req;
gtk_widget_get_child_requisition (box_child->widget, &child_req);
@@ -213,6 +207,8 @@
}
expansable_length -= box->spacing - box_child->padding;
}
+ expansable_length -= box->weight_length;
+
gint child_pos = 0;
if (orientation == GTK_ORIENTATION_HORIZONTAL)
@@ -232,9 +228,7 @@
GtkRequisition child_req;
gtk_widget_get_child_requisition (box_child->widget, &child_req);
- if (box_child->ratio)
- length = box->ratio_width;
- else
+ if (!box_child->ratio)
{
if (orientation == GTK_ORIENTATION_HORIZONTAL)
length = child_req.width;
@@ -245,10 +239,10 @@
// give extra size (honor stretch order)
if (box_child->ratio)
{
- if (box->has_must_expand)
- length = (box->ratio_width * box_child->ratio) / max_ratio;
- else
- length = (box_child->ratio * expansable_length) / ratios_sum;
+ int available_length = box->weight_length;
+ if (!box->has_must_expand)
+ available_length += expansable_length;
+ length = (box_child->ratio * available_length) / ratios_sum;
}
else if (box_child->expand && (ratios_sum == 0 || box_child->must_expand))
length += expansable_length / expand_num;
Modified: trunk/gtk/src/ygtkratiobox.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/ygtkratiobox.h?rev=41395&r1=41394&r2=41395&view=diff
==============================================================================
--- trunk/gtk/src/ygtkratiobox.h (original)
+++ trunk/gtk/src/ygtkratiobox.h Thu Oct 11 20:14:20 2007
@@ -51,7 +51,7 @@
// private (read-only):
GList *children;
gint16 spacing;
- guint ratio_width; // the width of ratio widgets
+ guint weight_length; // min-length for weight widgets
gboolean has_must_expand; // cache
} YGtkRatioBox;
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org