Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions dw/fltkui.cc
Original file line number Diff line number Diff line change
Expand Up @@ -752,10 +752,10 @@ void FltkComplexButtonResource::widgetCallback (Fl_Widget *widget,
res->click_x = Fl::event_x() - widget->x();
res->click_y = Fl::event_y() - widget->y();
if (res->style) {
res->click_x -= res->style->boxOffsetX();
res->click_y -= res->style->boxOffsetY();
w -= res->style->boxDiffWidth();
h -= res->style->boxDiffHeight();
res->click_x -= res->getEmbed()->marginBoxOffsetX();
res->click_y -= res->getEmbed()->marginBoxOffsetY();
w -= res->getEmbed()->marginBoxDiffWidth();
h -= res->getEmbed()->marginBoxDiffHeight();
}
if (res->click_x >= 0 && res->click_y >= 0 &&
res->click_x < w && res->click_y < h) {
Expand All @@ -768,8 +768,8 @@ void FltkComplexButtonResource::widgetCallback (Fl_Widget *widget,
dw::core::EventButton event;

res->click_x = res->click_y = 0;
event.xCanvas = widget->x() + res->style->boxOffsetX();
event.yCanvas = widget->y() + res->style->boxOffsetY();
event.xCanvas = widget->x() + res->getEmbed()->marginBoxOffsetX();
event.yCanvas = widget->y() + res->getEmbed()->marginBoxOffsetY();
// ButtonState doesn't have mouse button values on a release.
event.state = (core::ButtonState) 0;
event.button = 1;
Expand Down
10 changes: 5 additions & 5 deletions dw/ooffloatsmgr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ int OOFFloatsMgr::calcFloatX (Float *vloat)
// Left floats are always aligned on the left side of the generator
// (content, not allocation) ...
x = generator->getGeneratorX (oofmIndex)
+ generator->getStyle()->boxOffsetX();
+ generator->marginBoxOffsetX();

// ... but when the float exceeds the line break width of the container,
// it is corrected (but not left of the container). This way, we save
Expand Down Expand Up @@ -479,7 +479,7 @@ int OOFFloatsMgr::calcFloatX (Float *vloat)
vloat->generator->getMaxGeneratorWidth ());

x = max (generator->getGeneratorX (oofmIndex) + effGeneratorWidth
- vloat->size.width - generator->getStyle()->boxRestWidth(),
- vloat->size.width - generator->marginBoxRestWidth(),
// Do not exceed container allocation:
0);
break;
Expand Down Expand Up @@ -1064,7 +1064,7 @@ void OOFFloatsMgr::getFloatsExtremes (Extremes *cbExtr, Side side,
// For the maximal width, borders must be considered.
*maxWidth = max (*maxWidth,
extr.maxWidth
+ vloat->generator->getStyle()->boxDiffWidth(),
+ vloat->generator->marginBoxDiffWidth(),
+ max (container->getGeneratorWidth ()
- vloat->generator->getGeneratorWidth (),
0));
Expand Down Expand Up @@ -1147,7 +1147,7 @@ int OOFFloatsMgr::getBorder (Side side, int y, int h, OOFAwareWidget *lastGB,
switch (side) {
case LEFT:
d = vloat->generator->getGeneratorX (oofmIndex)
+ vloat->generator->getStyle()->boxOffsetX ();
+ vloat->generator->marginBoxOffsetX ();
break;

case RIGHT:
Expand All @@ -1158,7 +1158,7 @@ int OOFFloatsMgr::getBorder (Side side, int y, int h, OOFAwareWidget *lastGB,
d = container->getMaxGeneratorWidth ()
- (vloat->generator->getGeneratorX (oofmIndex)
+ vloat->generator->getMaxGeneratorWidth ())
+ vloat->generator->getStyle()->boxRestWidth ();
+ vloat->generator->marginBoxRestWidth ();
break;

default:
Expand Down
4 changes: 2 additions & 2 deletions dw/oofposrelmgr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ int OOFPosRelMgr::getChildPosX (Child *child, int refWidth)
child->widget->getStyle()->right,
child->x,
refWidth
- child->widget->getStyle()->boxDiffWidth ());
- child->widget->marginBoxDiffWidth ());

DBG_OBJ_LEAVE_VAL ("%d + %d = %d", gx, dim, gx + dim);
return gx + dim;
Expand All @@ -194,7 +194,7 @@ int OOFPosRelMgr::getChildPosY (Child *child, int refHeight)
child->widget->getStyle()->bottom,
child->y,
refHeight
- child->widget->getStyle()->boxDiffHeight ());
- child->widget->marginBoxDiffHeight ());

DBG_OBJ_LEAVE_VAL ("%d + %d = %d", gy, dim, gy + dim);
return gy + dim;
Expand Down
13 changes: 7 additions & 6 deletions dw/style.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ void StyleAttrs::initValues ()
position = POSITION_STATIC;
top = bottom = left = right = LENGTH_AUTO;
textIndent = 0;
margin.setVal (0);
margin.setVal (createAbsLength(0));
borderWidth.setVal (0);
padding.setVal (0);
borderCollapse = BORDER_MODEL_SEPARATE;
Expand Down Expand Up @@ -123,7 +123,7 @@ void StyleAttrs::resetValues ()
height = LENGTH_AUTO;
minWidth = maxWidth = minHeight = maxHeight = LENGTH_AUTO;

margin.setVal (0);
margin.setVal (createAbsLength(0));
borderWidth.setVal (0);
padding.setVal (0);
setBorderColor (NULL);
Expand Down Expand Up @@ -1167,16 +1167,17 @@ static void drawBorderRight(View *view, Style *style,
*/
void drawBorder (View *view, Layout *layout, Rectangle *area,
int x, int y, int width, int height,
int marginLeft, int marginRight,
Style *style, bool inverse)
{
/** \todo a lot! */
int xb1, yb1, xb2, yb2;

// top left and bottom right point of outer border boundary
xb1 = x + style->margin.left;
yb1 = y + style->margin.top;
xb2 = x + (width > 0 ? width - 1 : 0) - style->margin.right;
yb2 = y + (height > 0 ? height - 1 : 0) - style->margin.bottom;
xb1 = x + marginLeft;
yb1 = y + style->marginTop();
xb2 = x + (width > 0 ? width - 1 : 0) - marginRight;
yb2 = y + (height > 0 ? height - 1 : 0) - style->marginBottom();

/*
// top left and bottom right point of inner border boundary
Expand Down
43 changes: 33 additions & 10 deletions dw/style.hh
Original file line number Diff line number Diff line change
Expand Up @@ -589,16 +589,38 @@ public:
borderStyle.top = borderStyle.right = borderStyle.bottom
= borderStyle.left = val; }

inline int boxOffsetX ()
{ return margin.left + borderWidth.left + padding.left; }
inline int boxRestWidth ()
{ return margin.right + borderWidth.right + padding.right; }
inline int boxDiffWidth () { return boxOffsetX () + boxRestWidth (); }
inline int boxOffsetY ()
{ return margin.top + borderWidth.top + padding.top; }
inline int boxRestHeight ()
{ return margin.bottom + borderWidth.bottom + padding.bottom; }
inline int boxDiffHeight () { return boxOffsetY () + boxRestHeight (); }
inline int marginLeft()
{
if (style::isAbsLength (margin.left)) {
return style::absLengthVal (margin.left);
} else {
return 0;
}
}
inline int marginRight()
{
if (style::isAbsLength (margin.right)) {
return style::absLengthVal (margin.right);
} else {
return 0;
}
}
inline int marginTop()
{
if (style::isAbsLength (margin.top)) {
return style::absLengthVal (margin.top);
} else {
return 0;
}
}
inline int marginBottom()
{
if (style::isAbsLength (margin.bottom)) {
return style::absLengthVal (margin.bottom);
} else {
return 0;
}
}

inline bool hasBackground ()
{ return backgroundColor != NULL || backgroundImage != NULL; }
Expand Down Expand Up @@ -901,6 +923,7 @@ public:

void drawBorder (View *view, Layout *layout, Rectangle *area,
int x, int y, int width, int height,
int marginLeft, int marginRight,
Style *style, bool inverse);
void drawBackground (View *view, Layout *layout, Rectangle *area,
int x, int y, int width, int height,
Expand Down
22 changes: 11 additions & 11 deletions dw/textblock.cc
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ void Textblock::sizeRequestImpl (core::Requisition *requisition, int numPos,
// margin of the first line box:
requisition->ascent = calcVerticalBorder (getStyle()->padding.top,
getStyle()->borderWidth.top,
getStyle()->margin.top
getStyle()->marginTop()
+ extraSpace.top,
firstLine->borderAscent,
firstLine->marginAscent);
Expand All @@ -373,7 +373,7 @@ void Textblock::sizeRequestImpl (core::Requisition *requisition, int numPos,
// for this case is not necessary.)
calcVerticalBorder (getStyle()->padding.bottom,
getStyle()->borderWidth.bottom,
getStyle()->margin.bottom + extraSpace.bottom,
getStyle()->marginBottom() + extraSpace.bottom,
lastLine->borderDescent, lastLine->marginDescent);
} else {
requisition->width = leftInnerPadding + boxDiffWidth ();
Expand Down Expand Up @@ -777,12 +777,12 @@ int Textblock::getAvailWidthOfChild (Widget *child, bool forceValue)
/* Clamp to min-width and max-width if given, taking into
* account leftInnerPadding. */
int maxWidth = child->calcWidth (child->getStyle()->maxWidth,
-1, this, -1, false);
-1, this, -1, false).total;
if (maxWidth != -1 && width > maxWidth - leftInnerPadding)
width = maxWidth - leftInnerPadding;

int minWidth = child->calcWidth (child->getStyle()->minWidth,
-1, this, -1, false);
-1, this, -1, false).total;
if (minWidth != -1 && width < minWidth - leftInnerPadding)
width = minWidth - leftInnerPadding;
}
Expand Down Expand Up @@ -1583,7 +1583,7 @@ int Textblock::findLineIndexWhenNotAllocated (int y)
return
findLineIndex (y, calcVerticalBorder (getStyle()->padding.top,
getStyle()->borderWidth.top,
getStyle()->margin.top
getStyle()->marginTop()
+ extraSpace.top,
lines->getRef(0)->borderAscent,
lines->getRef(0)->marginAscent));
Expand Down Expand Up @@ -2337,14 +2337,14 @@ bool Textblock::calcSizeOfWidgetInFlow (int wordIndex, Widget *widget,
int rightBorder = boxRestWidth ();

int lastMargin, yLine = yOffsetOfLineToBeCreated (&lastMargin);
int yRel = yLine - min (lastMargin, widget->getStyle()->margin.top);
int yRel = yLine - min (lastMargin, widget->getStyle()->marginTop());

DBG_OBJ_MSGF ("resize", 1,
"leftBorder = %d + %d + (%d == 0 ? %d : 0) = %d, "
"rightBorder = %d, yRel = %d - min (%d, %d) = %d",
boxOffsetX (), leftInnerPadding , lines->size (),
line1OffsetEff, leftBorder, rightBorder, yLine, lastMargin,
widget->getStyle()->margin.top, yRel);
widget->getStyle()->marginTop(), yRel);

core::SizeParams childParams;
DBG_OBJ_ASSOC_CHILD (&childParams);
Expand Down Expand Up @@ -3328,14 +3328,14 @@ int Textblock::yOffsetOfLineToBeCreated (int *lastMargin)
if (lines->size () == 0) {
result = calcVerticalBorder (getStyle()->padding.top,
getStyle()->borderWidth.top + extraSpace.top,
getStyle()->margin.top, 0, 0);
getStyle()->marginTop(), 0, 0);
if (lastMargin)
*lastMargin = getStyle()->margin.top;
*lastMargin = getStyle()->marginTop();
} else {
Line *firstLine = lines->getRef (0), *lastLine = lines->getLastRef ();
result = calcVerticalBorder (getStyle()->padding.top,
getStyle()->borderWidth.top,
getStyle()->margin.top + extraSpace.top,
getStyle()->marginTop() + extraSpace.top,
firstLine->borderAscent,
firstLine->marginAscent)
- firstLine->borderAscent + lastLine->top + lastLine->totalHeight (0);
Expand Down Expand Up @@ -3365,7 +3365,7 @@ int Textblock::yOffsetOfLineCreated (Line *line)
Line *firstLine = lines->getRef (0);
result = calcVerticalBorder (getStyle()->padding.top,
getStyle()->borderWidth.top,
getStyle()->margin.top + extraSpace.top,
getStyle()->marginTop() + extraSpace.top,
firstLine->borderAscent,
firstLine->marginAscent)
- firstLine->borderAscent + line->top;
Expand Down
2 changes: 1 addition & 1 deletion dw/textblock_iterator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ void Textblock::TextblockIterator::getAllocation (int start, int end,
Word *w = textblock->words->getRef (i);
int borderAscent =
w->content.type == core::Content::WIDGET_IN_FLOW ?
w->size.ascent - w->content.widget->getStyle()->margin.top :
w->size.ascent - w->content.widget->getStyle()->marginTop() :
w->size.ascent;
lineBorderAscent = misc::max (lineBorderAscent, borderAscent);
}
Expand Down
6 changes: 3 additions & 3 deletions dw/textblock_linebreaking.cc
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ Textblock::Line *Textblock::addLine (int firstWord, int lastWord,
// just before. The correction in sizeAllocateImpl() is irrelevant
// in this regard. Also, right floats are not regarded here, but in
// OutOfFlowMgr::getSize(),
lineWidth += (line->leftOffset - getStyle()->boxOffsetX ());
lineWidth += (line->leftOffset - marginBoxOffsetX ());

if (lines->size () == 1) {
// first line
Expand Down Expand Up @@ -1589,9 +1589,9 @@ void Textblock::accumulateWordForLine (int lineIndex, int wordIndex)
marginAscent = word->size.ascent;
marginDescent = word->size.descent;
borderAscent =
marginAscent - word->content.widget->getStyle()->margin.top;
marginAscent - word->content.widget->getStyle()->marginTop();
borderDescent =
marginDescent - word->content.widget->getStyle()->margin.bottom;
marginDescent - word->content.widget->getStyle()->marginBottom();

word->content.widget->parentRef = makeParentRefInFlow (lineIndex);
DBG_OBJ_SET_NUM_O (word->content.widget, "parentRef",
Expand Down
Loading