Small refactoring and cleanup:
* Add constants for the length of the resize area on a window border and for the size of the resize knob on document windows. * Clarify some comments. * Change instances of thumb to knob in reference to the resize knob. It was called knob in some places and thumb in others. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35706 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -6,6 +6,7 @@
|
|||||||
* DarkWyrm <[email protected]>
|
* DarkWyrm <[email protected]>
|
||||||
* Stephan Aßmus <[email protected]>
|
* Stephan Aßmus <[email protected]>
|
||||||
* Philippe Saint-Pierre, [email protected]
|
* Philippe Saint-Pierre, [email protected]
|
||||||
|
* Ryan Leavengood <[email protected]>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@@ -41,6 +42,9 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
static const float kBorderResizeLength = 22.0;
|
||||||
|
static const float kResizeKnobSize = 18.0;
|
||||||
|
|
||||||
static inline uint8
|
static inline uint8
|
||||||
blend_color_value(uint8 a, uint8 b, float position)
|
blend_color_value(uint8 a, uint8 b, float position)
|
||||||
{
|
{
|
||||||
@@ -238,36 +242,38 @@ DefaultDecorator::ResizeBy(BPoint offset, BRegion* dirty)
|
|||||||
fFrame.right += offset.x;
|
fFrame.right += offset.x;
|
||||||
fFrame.bottom += offset.y;
|
fFrame.bottom += offset.y;
|
||||||
|
|
||||||
// handle invalidation of resize rect
|
// Handle invalidation of resize rect
|
||||||
if (dirty && !(fFlags & B_NOT_RESIZABLE)) {
|
if (dirty && !(fFlags & B_NOT_RESIZABLE)) {
|
||||||
BRect realResizeRect;
|
BRect realResizeRect;
|
||||||
switch (fLook) {
|
switch (fLook) {
|
||||||
case B_DOCUMENT_WINDOW_LOOK:
|
case B_DOCUMENT_WINDOW_LOOK:
|
||||||
realResizeRect = fResizeRect;
|
realResizeRect = fResizeRect;
|
||||||
// resize rect at old location
|
// Resize rect at old location
|
||||||
dirty->Include(realResizeRect);
|
dirty->Include(realResizeRect);
|
||||||
realResizeRect.OffsetBy(offset);
|
realResizeRect.OffsetBy(offset);
|
||||||
// resize rect at new location
|
// Resize rect at new location
|
||||||
dirty->Include(realResizeRect);
|
dirty->Include(realResizeRect);
|
||||||
break;
|
break;
|
||||||
case B_TITLED_WINDOW_LOOK:
|
case B_TITLED_WINDOW_LOOK:
|
||||||
case B_FLOATING_WINDOW_LOOK:
|
case B_FLOATING_WINDOW_LOOK:
|
||||||
case B_MODAL_WINDOW_LOOK:
|
case B_MODAL_WINDOW_LOOK:
|
||||||
case kLeftTitledWindowLook:
|
case kLeftTitledWindowLook:
|
||||||
realResizeRect.Set(fRightBorder.right - 22, fBottomBorder.top,
|
// The bottom border resize line
|
||||||
fRightBorder.right - 22, fBottomBorder.bottom - 1);
|
realResizeRect.Set(fRightBorder.right - kBorderResizeLength, fBottomBorder.top,
|
||||||
// resize rect at old location
|
fRightBorder.right - kBorderResizeLength, fBottomBorder.bottom - 1);
|
||||||
|
// Old location
|
||||||
dirty->Include(realResizeRect);
|
dirty->Include(realResizeRect);
|
||||||
realResizeRect.OffsetBy(offset);
|
realResizeRect.OffsetBy(offset);
|
||||||
// resize rect at new location
|
// New location
|
||||||
dirty->Include(realResizeRect);
|
dirty->Include(realResizeRect);
|
||||||
|
|
||||||
realResizeRect.Set(fRightBorder.left, fBottomBorder.bottom - 22,
|
// The right border resize line
|
||||||
fRightBorder.right - 1, fBottomBorder.bottom - 22);
|
realResizeRect.Set(fRightBorder.left, fBottomBorder.bottom - kBorderResizeLength,
|
||||||
// resize rect at old location
|
fRightBorder.right - 1, fBottomBorder.bottom - kBorderResizeLength);
|
||||||
|
// Old location
|
||||||
dirty->Include(realResizeRect);
|
dirty->Include(realResizeRect);
|
||||||
realResizeRect.OffsetBy(offset);
|
realResizeRect.OffsetBy(offset);
|
||||||
// resize rect at new location
|
// New location
|
||||||
dirty->Include(realResizeRect);
|
dirty->Include(realResizeRect);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -447,7 +453,7 @@ DefaultDecorator::Draw(BRect update)
|
|||||||
STRACE(("DefaultDecorator: Draw(%.1f,%.1f,%.1f,%.1f)\n",
|
STRACE(("DefaultDecorator: Draw(%.1f,%.1f,%.1f,%.1f)\n",
|
||||||
update.left, update.top, update.right, update.bottom));
|
update.left, update.top, update.right, update.bottom));
|
||||||
|
|
||||||
// We need to draw a few things: the tab, the resize thumb, the borders,
|
// We need to draw a few things: the tab, the resize knob, the borders,
|
||||||
// and the buttons
|
// and the buttons
|
||||||
fDrawingEngine->SetDrawState(&fDrawState);
|
fDrawingEngine->SetDrawState(&fDrawState);
|
||||||
|
|
||||||
@@ -510,7 +516,8 @@ DefaultDecorator::GetFootprint(BRegion* region)
|
|||||||
|
|
||||||
if (fLook == B_DOCUMENT_WINDOW_LOOK) {
|
if (fLook == B_DOCUMENT_WINDOW_LOOK) {
|
||||||
// include the rectangular resize knob on the bottom right
|
// include the rectangular resize knob on the bottom right
|
||||||
region->Include(BRect(fFrame.right - 13.0f, fFrame.bottom - 13.0f,
|
float knobSize = kResizeKnobSize - fBorderWidth - 1.0;
|
||||||
|
region->Include(BRect(fFrame.right - knobSize, fFrame.bottom - knobSize,
|
||||||
fFrame.right, fFrame.bottom));
|
fFrame.right, fFrame.bottom));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -565,8 +572,8 @@ DefaultDecorator::Clicked(BPoint point, int32 buttons, int32 modifiers)
|
|||||||
|| fLook == B_FLOATING_WINDOW_LOOK
|
|| fLook == B_FLOATING_WINDOW_LOOK
|
||||||
|| fLook == B_MODAL_WINDOW_LOOK
|
|| fLook == B_MODAL_WINDOW_LOOK
|
||||||
|| fLook == kLeftTitledWindowLook)) {
|
|| fLook == kLeftTitledWindowLook)) {
|
||||||
BRect temp(BPoint(fBottomBorder.right - 22,
|
BRect temp(BPoint(fBottomBorder.right - kBorderResizeLength,
|
||||||
fBottomBorder.bottom - 22), fBottomBorder.RightBottom());
|
fBottomBorder.bottom - kBorderResizeLength), fBottomBorder.RightBottom());
|
||||||
if (temp.Contains(point))
|
if (temp.Contains(point))
|
||||||
return CLICK_RESIZE;
|
return CLICK_RESIZE;
|
||||||
}
|
}
|
||||||
@@ -711,8 +718,8 @@ DefaultDecorator::_DoLayout()
|
|||||||
|
|
||||||
// calculate resize rect
|
// calculate resize rect
|
||||||
if (fBorderWidth > 1) {
|
if (fBorderWidth > 1) {
|
||||||
fResizeRect.Set(fBottomBorder.right - 18.0,
|
fResizeRect.Set(fBottomBorder.right - kResizeKnobSize,
|
||||||
fBottomBorder.bottom - 18.0, fBottomBorder.right,
|
fBottomBorder.bottom - kResizeKnobSize, fBottomBorder.right,
|
||||||
fBottomBorder.bottom);
|
fBottomBorder.bottom);
|
||||||
} else {
|
} else {
|
||||||
// no border or one pixel border (menus and such)
|
// no border or one pixel border (menus and such)
|
||||||
@@ -861,7 +868,7 @@ DefaultDecorator::_DrawFrame(BRect invalid)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw the resize thumb if we're supposed to
|
// Draw the resize knob if we're supposed to
|
||||||
if (!(fFlags & B_NOT_RESIZABLE)) {
|
if (!(fFlags & B_NOT_RESIZABLE)) {
|
||||||
r = fResizeRect;
|
r = fResizeRect;
|
||||||
|
|
||||||
@@ -914,18 +921,18 @@ DefaultDecorator::_DrawFrame(BRect invalid)
|
|||||||
case B_MODAL_WINDOW_LOOK:
|
case B_MODAL_WINDOW_LOOK:
|
||||||
case kLeftTitledWindowLook:
|
case kLeftTitledWindowLook:
|
||||||
{
|
{
|
||||||
if (!invalid.Intersects(BRect(fRightBorder.right - 22,
|
if (!invalid.Intersects(BRect(fRightBorder.right - kBorderResizeLength,
|
||||||
fBottomBorder.bottom - 22, fRightBorder.right - 1,
|
fBottomBorder.bottom - kBorderResizeLength, fRightBorder.right - 1,
|
||||||
fBottomBorder.bottom - 1)))
|
fBottomBorder.bottom - 1)))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
fDrawingEngine->StrokeLine(
|
fDrawingEngine->StrokeLine(
|
||||||
BPoint(fRightBorder.left, fBottomBorder.bottom - 22),
|
BPoint(fRightBorder.left, fBottomBorder.bottom - kBorderResizeLength),
|
||||||
BPoint(fRightBorder.right - 1, fBottomBorder.bottom - 22),
|
BPoint(fRightBorder.right - 1, fBottomBorder.bottom - kBorderResizeLength),
|
||||||
fFrameColors[0]);
|
fFrameColors[0]);
|
||||||
fDrawingEngine->StrokeLine(
|
fDrawingEngine->StrokeLine(
|
||||||
BPoint(fRightBorder.right - 22, fBottomBorder.top),
|
BPoint(fRightBorder.right - kBorderResizeLength, fBottomBorder.top),
|
||||||
BPoint(fRightBorder.right - 22, fBottomBorder.bottom - 1),
|
BPoint(fRightBorder.right - kBorderResizeLength, fBottomBorder.bottom - 1),
|
||||||
fFrameColors[0]);
|
fFrameColors[0]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user