summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dw/image.cc21
-rw-r--r--dw/widget.cc30
2 files changed, 42 insertions, 9 deletions
diff --git a/dw/image.cc b/dw/image.cc
index ba3348de..79331afb 100644
--- a/dw/image.cc
+++ b/dw/image.cc
@@ -181,6 +181,9 @@ void Image::sizeRequestSimpl (core::Requisition *requisition)
DEBUG_MSG(1, "-- Image::sizeRequestSimpl() begins\n");
+ DEBUG_MSG(1, "Image::sizeRequestImpl border: w=%d h=%d\n",
+ boxDiffWidth(), boxDiffHeight());
+
/* First set a naive size based on the image properties if given */
if (buffer) {
@@ -207,7 +210,7 @@ void Image::sizeRequestSimpl (core::Requisition *requisition)
requisition->ascent += boxOffsetY ();
requisition->descent += boxRestHeight ();
- DEBUG_MSG(1, "initial requisition: w=%d, h=%d\n",
+ DEBUG_MSG(1, "Image: initial requisition (with border): w=%d, h=%d\n",
requisition->width, requisition->ascent + requisition->descent);
/* Then correct the size if needed, so it fits within the available space in
@@ -217,7 +220,7 @@ void Image::sizeRequestSimpl (core::Requisition *requisition)
correctRequisition (requisition, core::splitHeightPreserveDescent, true,
true);
- DEBUG_MSG(1, "corrected requisition: w=%d, h=%d\n",
+ DEBUG_MSG(1, "Image: corrected requisition: w=%d, h=%d\n",
requisition->width, requisition->ascent + requisition->descent);
DBG_OBJ_MSGF ("resize", 1, "=> %d * (%d + %d)",
@@ -264,6 +267,13 @@ void Image::sizeAllocateImpl (core::Allocation *allocation)
allocation->x, allocation->y, allocation->width,
allocation->ascent, allocation->descent);
+ DEBUG_MSG(1, "Image::sizeAllocateImpl x=%d y=%d w=%d h=(%d + %d)\n",
+ allocation->x, allocation->y, allocation->width,
+ allocation->ascent, allocation->descent);
+
+ DEBUG_MSG(1, "Image::sizeAllocateImpl border: w=%d h=%d\n",
+ boxDiffWidth(), boxDiffHeight());
+
int newBufWidth = allocation->width - boxDiffWidth ();
int newBufHeight =
@@ -274,6 +284,9 @@ void Image::sizeAllocateImpl (core::Allocation *allocation)
(newBufWidth != bufWidth || newBufHeight != bufHeight)) {
DBG_OBJ_MSG ("resize", 1, "replacing buffer");
+ DEBUG_MSG(1, "Image::sizeAllocateImpl new buffer size: w=%d h=%d\n",
+ newBufWidth, newBufHeight);
+
core::Imgbuf *oldBuffer = buffer;
buffer = oldBuffer->getScaledBuf (newBufWidth, newBufHeight);
oldBuffer->unref ();
@@ -286,6 +299,10 @@ void Image::sizeAllocateImpl (core::Allocation *allocation)
DBG_OBJ_SET_NUM ("bufHeight", bufHeight);
}
+ DEBUG_MSG(1, "Image::sizeAllocateImpl x=%d y=%d w=%d h=(%d + %d)\n",
+ allocation->x, allocation->y, allocation->width,
+ allocation->ascent, allocation->descent);
+
DBG_OBJ_LEAVE ();
}
diff --git a/dw/widget.cc b/dw/widget.cc
index eaa9e985..354b644d 100644
--- a/dw/widget.cc
+++ b/dw/widget.cc
@@ -1972,12 +1972,17 @@ bool Widget::correctReqAspectRatio (int pass, Widget *child, Requisition *requis
DEBUG_MSG(1, "Widget::correctReqAspectRatio() -- wReq=%d, hReq=%d, pass=%d\n",
wReq, hReq, pass);
+
+ DEBUG_MSG(1, "Widget::correctReqAspectRatio() -- border: w=%d, h=%d\n",
+ child->boxDiffWidth(), child->boxDiffHeight());
+
+ wReq -= child->boxDiffWidth();
+ hReq -= child->boxDiffHeight();
+ DEBUG_MSG(1, "Widget::correctReqAspectRatio() -- with border: wReq=%d, hReq=%d\n",
+ wReq, hReq);
DEBUG_MSG(1, "child=%s, preferred ratio=%f\n", child->getClassName(), ratio);
if (pass != PASS_KEEP && ratio > 0.0 && sizeSet) {
- /* TODO: Ensure we are dealing with the content box rather than the
- * margin box (as in the CSS box model). */
-
/* Compute the current ratio from the content box. */
float curRatio = (float) wReq / (float) hReq;
DEBUG_MSG(1, "curRatio=%f, preferred ratio=%f\n", curRatio, ratio);
@@ -1987,9 +1992,11 @@ bool Widget::correctReqAspectRatio (int pass, Widget *child, Requisition *requis
if (pass == PASS_INCREASE) {
/* Increase w */
int w = (float) hReq * ratio;
+ DEBUG_MSG(1, "increase w: %d -> %d\n", wReq, w);
+ w += child->boxDiffWidth();
+ DEBUG_MSG(1, "increase w (with border): %d -> %d\n", wReq, w);
requisition->width = w;
changed = true;
- DEBUG_MSG(1, "increase w: %d -> %d\n", wReq, w);
} else if (pass == PASS_DECREASE) {
/* Decrease h */
if (allowDecreaseHeight) {
@@ -1998,9 +2005,11 @@ bool Widget::correctReqAspectRatio (int pass, Widget *child, Requisition *requis
* reduce the corrected hight above the original height, without
* making the requisition height smaller. */
int h = (float) wReq / ratio;
+ DEBUG_MSG(1, "decrease h: %d -> %d\n", hReq, h);
+ h += child->boxDiffHeight();
+ DEBUG_MSG(1, "decrease h (with border): %d -> %d\n", hReq, h);
splitHeightFun (h, &requisition->ascent, &requisition->descent);
changed = true;
- DEBUG_MSG(1, "decrease h: %d -> %d\n", hReq, h);
}
}
} else if (curRatio > ratio) {
@@ -2008,9 +2017,11 @@ bool Widget::correctReqAspectRatio (int pass, Widget *child, Requisition *requis
if (pass == PASS_INCREASE) {
/* Increase h */
int h = (float) wReq / ratio;
+ DEBUG_MSG(1, "increase h: %d -> %d\n", hReq, h);
+ h += child->boxDiffHeight();
+ DEBUG_MSG(1, "increase h (width border): %d -> %d\n", hReq, h);
splitHeightFun (h, &requisition->ascent, &requisition->descent);
changed = true;
- DEBUG_MSG(1, "increase h: %d -> %d\n", hReq, h);
} else if (pass == PASS_DECREASE) {
/* Decrease w */
if (allowDecreaseWidth) {
@@ -2019,9 +2030,11 @@ bool Widget::correctReqAspectRatio (int pass, Widget *child, Requisition *requis
* reduce the corrected width above the original width, without
* making the requisition width smaller. */
int w = (float) hReq * ratio;
+ DEBUG_MSG(1, "decrease w: %d -> %d\n", wReq, w);
+ w += child->boxDiffWidth();
+ DEBUG_MSG(1, "decrease w (width border): %d -> %d\n", wReq, w);
requisition->width = w;
changed = true;
- DEBUG_MSG(1, "decrease w: %d -> %d\n", wReq, w);
}
}
} else {
@@ -2029,6 +2042,9 @@ bool Widget::correctReqAspectRatio (int pass, Widget *child, Requisition *requis
}
}
+ DEBUG_MSG(1, "Widget::correctReqAspectRatio() -- output: wReq=%d, hReq=%d, changed=%d\n",
+ requisition->width, requisition->ascent + requisition->descent, changed);
+
return changed;
}