summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Geerken <devnull@localhost>2015-01-02 22:25:57 +0100
committerSebastian Geerken <devnull@localhost>2015-01-02 22:25:57 +0100
commit74b99eda62247a675cc2f1c7a4b74be2fe6f03a2 (patch)
tree84da08e8f7a8a4479384317284c94f5cdc7c4d9f
parentd607e263e4481f38f0c1f089b0bae9522b1bb71a (diff)
Some more work on 'adjust_min_width' correction.
-rw-r--r--dw/image.hh4
-rw-r--r--dw/widget.cc24
-rw-r--r--dw/widget.hh2
3 files changed, 21 insertions, 9 deletions
diff --git a/dw/image.hh b/dw/image.hh
index 9adf7806..b94f647d 100644
--- a/dw/image.hh
+++ b/dw/image.hh
@@ -153,6 +153,10 @@ public:
Image(const char *altText);
~Image();
+ // For images, the minimal width is not well defined, and
+ // correction of the size makes not much sense.
+ virtual bool getAdjustMinWidth () { return false; }
+
core::Iterator *iterator (core::Content::Type mask, bool atEnd);
inline core::Imgbuf *getBuffer () { return buffer; }
diff --git a/dw/widget.cc b/dw/widget.cc
index 916dfd21..5f599e4a 100644
--- a/dw/widget.cc
+++ b/dw/widget.cc
@@ -511,9 +511,11 @@ void Widget::sizeRequest (Requisition *requisition)
*
* If extremes == NULL, getExtremes is called. ForceValue is the same
* value passed to getAvailWidth etc.; if false, getExtremes is not
- * called.
+ * called. A value of "false" is passed for "useCorrected" in the
+ * context of correctExtemes etc., to avoid cyclic dependencies.
+ *
*/
-int Widget::getMinWidth (Extremes *extremes, bool forceValue)
+int Widget::getMinWidth (Extremes *extremes, bool useCorrected, bool forceValue)
{
if (extremes)
DBG_OBJ_ENTER ("resize", 0, "getMinWidth", "[%d (%d) / %d (%d), %s",
@@ -538,8 +540,14 @@ int Widget::getMinWidth (Extremes *extremes, bool forceValue)
// TODO Not completely clear whether this is feasable: Within
// the context of getAvailWidth(false) etc., getExtremes may not
// be called. We ignore the minimal width then.
- minWidth = extremes ?
- misc::max (extremes->minWidth, extremes->minWidthIntrinsic) : 0;
+ if (extremes) {
+ if (useCorrected)
+ minWidth =
+ misc::max (extremes->minWidth, extremes->minWidthIntrinsic);
+ else
+ minWidth = extremes->minWidthIntrinsic;
+ } else
+ minWidth = 0;
} else
minWidth = 0;
@@ -665,7 +673,7 @@ void Widget::correctRequisition (Requisition *requisition,
DBG_OBJ_MSG ("resize", 1, "no parent, regarding viewport");
DBG_OBJ_MSG_START ();
- int limitMinWidth = getMinWidth (NULL, true);
+ int limitMinWidth = getMinWidth (NULL, true, true);
int viewportWidth =
layout->viewportWidth - (layout->canvasHeightGreater ?
layout->vScrollbarThickness : 0);
@@ -722,7 +730,7 @@ void Widget::correctExtremes (Extremes *extremes)
DBG_OBJ_MSG ("resize", 1, "no parent, regarding viewport");
DBG_OBJ_MSG_START ();
- int limitMinWidth = getMinWidth (extremes, false);
+ int limitMinWidth = getMinWidth (extremes, false, false);
int viewportWidth =
layout->viewportWidth - (layout->canvasHeightGreater ?
layout->vScrollbarThickness : 0);
@@ -1590,7 +1598,7 @@ void Widget::correctReqWidthOfChild (Widget *child, Requisition *requisition)
assert (this == child->quasiParent || this == child->container);
- int limitMinWidth = child->getMinWidth (NULL, true);
+ int limitMinWidth = child->getMinWidth (NULL, true, true);
child->calcFinalWidth (child->getStyle(), -1, this, limitMinWidth, false,
&requisition->width);
@@ -1650,7 +1658,7 @@ void Widget::correctExtremesOfChild (Widget *child, Extremes *extremes)
(child->container ? child->container : child->parent);
if (effContainer == this) {
- int limitMinWidth = child->getMinWidth (extremes, false);
+ int limitMinWidth = child->getMinWidth (extremes, false, false);
int width = child->calcWidth (child->getStyle()->width, -1, this,
limitMinWidth, false);
int minWidth = child->calcWidth (child->getStyle()->minWidth, -1, this,
diff --git a/dw/widget.hh b/dw/widget.hh
index 0f3e2d37..bef35715 100644
--- a/dw/widget.hh
+++ b/dw/widget.hh
@@ -292,7 +292,7 @@ protected:
*/
virtual void markExtremesChange (int ref);
- int getMinWidth (Extremes *extremes, bool forceValue);
+ int getMinWidth (Extremes *extremes, bool useCorrected, bool forceValue);
virtual int getAvailWidthOfChild (Widget *child, bool forceValue);
virtual int getAvailHeightOfChild (Widget *child, bool forceValue);