- BeDecorator synced to DefaultDecorator code (mostly style changes) and fixed for correct font rendering.

- Mac Decorator still not working.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34754 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Adrien Destugues
2009-12-23 11:07:17 +00:00
parent facf61e75c
commit b83b202d4d
2 changed files with 161 additions and 121 deletions
+161 -119
View File
@@ -24,7 +24,6 @@
#include <Rect.h> #include <Rect.h>
#include <View.h> #include <View.h>
#include <stdio.h>
//#define DEBUG_DECORATOR //#define DEBUG_DECORATOR
#ifdef DEBUG_DECORATOR #ifdef DEBUG_DECORATOR
@@ -98,14 +97,15 @@ BeDecorator::BeDecorator(DesktopSettings& settings, BRect rect,
fFrameColors[4].SetColor(152, 152, 152); fFrameColors[4].SetColor(152, 152, 152);
fFrameColors[5].SetColor(96, 96, 96); fFrameColors[5].SetColor(96, 96, 96);
// Set appropriate colors based on the current focus value. In this case, each decorator // Set appropriate colors based on the current focus value. In this case,
// defaults to not having the focus. // each decorator defaults to not having the focus.
_SetFocus(); _SetFocus();
// Do initial decorator setup // Do initial decorator setup
_DoLayout(); _DoLayout();
// ToDo: if the decorator was created with a frame too small, it should resize itself! // TODO: If the decorator was created with a frame too small, it should
// resize itself!
STRACE(("BeDecorator:\n")); STRACE(("BeDecorator:\n"));
STRACE(("\tFrame (%.1f,%.1f,%.1f,%.1f)\n", STRACE(("\tFrame (%.1f,%.1f,%.1f,%.1f)\n",
@@ -144,8 +144,8 @@ BeDecorator::SetTitle(const char* string, BRegion* updateRegion)
void void
BeDecorator::SetLook(DesktopSettings& settings, BeDecorator::SetLook(DesktopSettings& settings, window_look look,
window_look look, BRegion* updateRegion) BRegion* updateRegion)
{ {
// TODO: we could be much smarter about the update region // TODO: we could be much smarter about the update region
@@ -155,6 +155,8 @@ BeDecorator::SetLook(DesktopSettings& settings,
GetFootprint(&extent); GetFootprint(&extent);
updateRegion->Include(&extent); updateRegion->Include(&extent);
} }
Decorator::SetLook(settings, look, updateRegion);
ServerFont font; ServerFont font;
if (look == B_FLOATING_WINDOW_LOOK || look == kLeftTitledWindowLook) { if (look == B_FLOATING_WINDOW_LOOK || look == kLeftTitledWindowLook) {
@@ -166,10 +168,8 @@ BeDecorator::SetLook(DesktopSettings& settings,
font.SetFlags(B_FORCE_ANTIALIASING); font.SetFlags(B_FORCE_ANTIALIASING);
font.SetSpacing(B_STRING_SPACING); font.SetSpacing(B_STRING_SPACING);
// TODO Make this work... fDrawState.SetFont(font);
// SetFont(&font);
Decorator::SetLook(settings, look, updateRegion);
_DoLayout(); _DoLayout();
if (updateRegion != NULL) { if (updateRegion != NULL) {
@@ -247,7 +247,7 @@ BeDecorator::ResizeBy(BPoint pt, BRegion* dirty)
case B_MODAL_WINDOW_LOOK: case B_MODAL_WINDOW_LOOK:
case kLeftTitledWindowLook: case kLeftTitledWindowLook:
realResizeRect.Set(fRightBorder.right - 22, fBottomBorder.top, realResizeRect.Set(fRightBorder.right - 22, fBottomBorder.top,
fRightBorder.right - 22, fBottomBorder.bottom - 1); fRightBorder.right - 22, fBottomBorder.bottom - 1);
// resize rect at old location // resize rect at old location
dirty->Include(realResizeRect); dirty->Include(realResizeRect);
realResizeRect.OffsetBy(pt); realResizeRect.OffsetBy(pt);
@@ -255,7 +255,7 @@ BeDecorator::ResizeBy(BPoint pt, BRegion* dirty)
dirty->Include(realResizeRect); dirty->Include(realResizeRect);
realResizeRect.Set(fRightBorder.left, fBottomBorder.bottom - 22, realResizeRect.Set(fRightBorder.left, fBottomBorder.bottom - 22,
fRightBorder.right - 1, fBottomBorder.bottom - 22); fRightBorder.right - 1, fBottomBorder.bottom - 22);
// resize rect at old location // resize rect at old location
dirty->Include(realResizeRect); dirty->Include(realResizeRect);
realResizeRect.OffsetBy(pt); realResizeRect.OffsetBy(pt);
@@ -269,11 +269,11 @@ BeDecorator::ResizeBy(BPoint pt, BRegion* dirty)
fResizeRect.OffsetBy(pt); fResizeRect.OffsetBy(pt);
fBorderRect.right += pt.x; fBorderRect.right += pt.x;
fBorderRect.bottom += pt.y; fBorderRect.bottom += pt.y;
fLeftBorder.bottom += pt.y; fLeftBorder.bottom += pt.y;
fTopBorder.right += pt.x; fTopBorder.right += pt.x;
fRightBorder.OffsetBy(pt.x, 0.0); fRightBorder.OffsetBy(pt.x, 0.0);
fRightBorder.bottom += pt.y; fRightBorder.bottom += pt.y;
@@ -284,22 +284,22 @@ BeDecorator::ResizeBy(BPoint pt, BRegion* dirty)
if (dirty) { if (dirty) {
if (pt.x > 0.0) { if (pt.x > 0.0) {
BRect t(fRightBorder.left - pt.x, fTopBorder.top, BRect t(fRightBorder.left - pt.x, fTopBorder.top,
fRightBorder.right, fTopBorder.bottom); fRightBorder.right, fTopBorder.bottom);
dirty->Include(t); dirty->Include(t);
t.Set(fRightBorder.left - pt.x, fBottomBorder.top, t.Set(fRightBorder.left - pt.x, fBottomBorder.top,
fRightBorder.right, fBottomBorder.bottom); fRightBorder.right, fBottomBorder.bottom);
dirty->Include(t); dirty->Include(t);
dirty->Include(fRightBorder); dirty->Include(fRightBorder);
} else if (pt.x < 0.0) { } else if (pt.x < 0.0) {
dirty->Include(BRect(fRightBorder.left, fTopBorder.top, dirty->Include(BRect(fRightBorder.left, fTopBorder.top,
fRightBorder.right, fBottomBorder.bottom)); fRightBorder.right, fBottomBorder.bottom));
} }
if (pt.y > 0.0) { if (pt.y > 0.0) {
BRect t(fLeftBorder.left, fLeftBorder.bottom - pt.y, BRect t(fLeftBorder.left, fLeftBorder.bottom - pt.y,
fLeftBorder.right, fLeftBorder.bottom); fLeftBorder.right, fLeftBorder.bottom);
dirty->Include(t); dirty->Include(t);
t.Set(fRightBorder.left, fRightBorder.bottom - pt.y, t.Set(fRightBorder.left, fRightBorder.bottom - pt.y,
fRightBorder.right, fRightBorder.bottom); fRightBorder.right, fRightBorder.bottom);
dirty->Include(t); dirty->Include(t);
dirty->Include(fBottomBorder); dirty->Include(fBottomBorder);
} else if (pt.y < 0.0) { } else if (pt.y < 0.0) {
@@ -337,7 +337,8 @@ BeDecorator::ResizeBy(BPoint pt, BRegion* dirty)
if (fLook != kLeftTitledWindowLook && tabSize != fTabRect.Width()) { if (fLook != kLeftTitledWindowLook && tabSize != fTabRect.Width()) {
fTabRect.right = fTabRect.left + tabSize; fTabRect.right = fTabRect.left + tabSize;
} else if (fLook == kLeftTitledWindowLook && tabSize != fTabRect.Height()) { } else if (fLook == kLeftTitledWindowLook
&& tabSize != fTabRect.Height()) {
fTabRect.bottom = fTabRect.top + tabSize; fTabRect.bottom = fTabRect.top + tabSize;
} }
@@ -374,7 +375,8 @@ BeDecorator::SetTabLocation(float location, BRegion* updateRegion)
if (location < 0) if (location < 0)
location = 0; location = 0;
float maxLocation = fRightBorder.right - fLeftBorder.left - fTabRect.Width(); float maxLocation
= fRightBorder.right - fLeftBorder.left - fTabRect.Width();
if (location > maxLocation) if (location > maxLocation)
location = maxLocation; location = maxLocation;
@@ -433,40 +435,46 @@ BeDecorator::Draw(BRect update)
// 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 thumb, the borders,
// and the buttons // and the buttons
fDrawingEngine->SetDrawState(&fDrawState);
_DrawFrame(update); _DrawFrame(update);
_DrawTab(update); _DrawTab(update);
} }
// Draw
void void
BeDecorator::Draw() BeDecorator::Draw()
{ {
// Easy way to draw everything - no worries about drawing only certain // Easy way to draw everything - no worries about drawing only certain
// things // things
fDrawingEngine->SetDrawState(&fDrawState);
_DrawFrame(BRect(fTopBorder.LeftTop(), fBottomBorder.RightBottom())); _DrawFrame(BRect(fTopBorder.LeftTop(), fBottomBorder.RightBottom()));
_DrawTab(fTabRect); _DrawTab(fTabRect);
} }
// GetSizeLimits
void void
BeDecorator::GetSizeLimits(int32* minWidth, int32* minHeight, BeDecorator::GetSizeLimits(int32* minWidth, int32* minHeight,
int32* maxWidth, int32* maxHeight) const int32* maxWidth, int32* maxHeight) const
{ {
if (fTabRect.IsValid()) if (fTabRect.IsValid()) {
*minWidth = (int32)roundf(max_c(*minWidth, fMinTabSize - 2 * fBorderWidth)); *minWidth = (int32)roundf(max_c(*minWidth,
if (fResizeRect.IsValid()) fMinTabSize - 2 * fBorderWidth));
*minHeight = (int32)roundf(max_c(*minHeight, fResizeRect.Height() - fBorderWidth)); }
if (fResizeRect.IsValid()) {
*minHeight = (int32)roundf(max_c(*minHeight,
fResizeRect.Height() - fBorderWidth));
}
} }
// GetFootprint
void void
BeDecorator::GetFootprint(BRegion *region) BeDecorator::GetFootprint(BRegion* region)
{ {
STRACE(("BeDecorator: Get Footprint\n")); STRACE(("BeDecorator: Get Footprint\n"));
// This function calculates the decorator's footprint in coordinates // This function calculates the decorator's footprint in coordinates
// relative to the layer. This is most often used to set a WindowLayer // relative to the view. This is most often used to set a Window
// object's visible region. // object's visible region.
if (!region) if (!region)
return; return;
@@ -476,9 +484,9 @@ BeDecorator::GetFootprint(BRegion *region)
if (fLook == B_NO_BORDER_WINDOW_LOOK) if (fLook == B_NO_BORDER_WINDOW_LOOK)
return; return;
region->Include(fTopBorder);
region->Include(fLeftBorder); region->Include(fLeftBorder);
region->Include(fRightBorder); region->Include(fRightBorder);
region->Include(fTopBorder);
region->Include(fBottomBorder); region->Include(fBottomBorder);
if (fLook == B_BORDERED_WINDOW_LOOK) if (fLook == B_BORDERED_WINDOW_LOOK)
@@ -489,7 +497,7 @@ BeDecorator::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, region->Include(BRect(fFrame.right - 13.0f, fFrame.bottom - 13.0f,
fFrame.right, fFrame.bottom)); fFrame.right, fFrame.bottom));
} }
} }
@@ -499,19 +507,21 @@ BeDecorator::Clicked(BPoint pt, int32 buttons, int32 modifiers)
{ {
#ifdef DEBUG_DECORATOR #ifdef DEBUG_DECORATOR
printf("BeDecorator: Clicked\n"); printf("BeDecorator: Clicked\n");
printf("\tPoint: (%.1f,%.1f)\n", pt.x,pt.y); printf("\tPoint: (%.1f,%.1f)\n", pt.x, pt.y);
printf("\tButtons: %ld, Modifiers: 0x%lx\n", buttons, modifiers); printf("\tButtons: %ld, Modifiers: 0x%lx\n", buttons, modifiers);
#endif // DEBUG_DECORATOR #endif // DEBUG_DECORATOR
// TODO: have a real double-click mechanism, ie. take user settings into account // TODO: have a real double-click mechanism, ie. take user settings into
// account
bigtime_t now = system_time(); bigtime_t now = system_time();
if (buttons != 0) { if (buttons != 0) {
fWasDoubleClick = now - fLastClicked < 200000; fWasDoubleClick = now - fLastClicked < 200000;
fLastClicked = now; fLastClicked = now;
} }
// In checking for hit test stuff, we start with the smallest rectangles the user might // In checking for hit test stuff, we start with the smallest rectangles
// be clicking on and gradually work our way out into larger rectangles. // the user might be clicking on and gradually work our way out into larger
// rectangles.
if (!(fFlags & B_NOT_CLOSABLE) && fCloseRect.Contains(pt)) if (!(fFlags & B_NOT_CLOSABLE) && fCloseRect.Contains(pt))
return DEC_CLOSE; return DEC_CLOSE;
@@ -542,7 +552,7 @@ BeDecorator::Clicked(BPoint pt, int32 buttons, int32 modifiers)
|| fLook == B_MODAL_WINDOW_LOOK || fLook == B_MODAL_WINDOW_LOOK
|| fLook == kLeftTitledWindowLook)) { || fLook == kLeftTitledWindowLook)) {
BRect temp(BPoint(fBottomBorder.right - 18, fBottomBorder.bottom - 18), BRect temp(BPoint(fBottomBorder.right - 18, fBottomBorder.bottom - 18),
fBottomBorder.RightBottom()); fBottomBorder.RightBottom());
if (temp.Contains(pt)) if (temp.Contains(pt))
return DEC_RESIZE; return DEC_RESIZE;
} }
@@ -551,12 +561,13 @@ BeDecorator::Clicked(BPoint pt, int32 buttons, int32 modifiers)
} }
if (clicked) { if (clicked) {
// NOTE: On R5, windows are not moved to back if clicked inside the resize area // NOTE: On R5, windows are not moved to back if clicked inside the
// with the second mouse button. So we check this after the check above // resize area with the second mouse button. So we check this after
if (buttons == B_SECONDARY_MOUSE_BUTTON) // the check above
if ((buttons & B_SECONDARY_MOUSE_BUTTON) != 0)
return DEC_MOVETOBACK; return DEC_MOVETOBACK;
if (fWasDoubleClick) if (fWasDoubleClick && !(fFlags & B_NOT_MINIMIZABLE))
return DEC_MINIMIZE; return DEC_MINIMIZE;
return DEC_DRAG; return DEC_DRAG;
@@ -604,21 +615,23 @@ BeDecorator::_DoLayout()
if (hasTab) { if (hasTab) {
// distance from one item of the tab bar to another. // distance from one item of the tab bar to another.
// In this case the text and close/zoom rects // In this case the text and close/zoom rects
fTextOffset = (fLook == B_FLOATING_WINDOW_LOOK || fLook == kLeftTitledWindowLook) fTextOffset = (fLook == B_FLOATING_WINDOW_LOOK
? 10 : 18; || fLook == kLeftTitledWindowLook) ? 10 : 18;
font_height fontHeight; font_height fontHeight;
fDrawState.Font().GetHeight(fontHeight); fDrawState.Font().GetHeight(fontHeight);
if (fLook != kLeftTitledWindowLook) { if (fLook != kLeftTitledWindowLook) {
fTabRect.Set(fFrame.left - fBorderWidth, fTabRect.Set(fFrame.left - fBorderWidth,
fFrame.top - fBorderWidth - ceilf(fontHeight.ascent + fontHeight.descent + 7.0), fFrame.top - fBorderWidth
- ceilf(fontHeight.ascent + fontHeight.descent + 7.0),
((fFrame.right - fFrame.left) < 35.0 ? ((fFrame.right - fFrame.left) < 35.0 ?
fFrame.left + 35.0 : fFrame.right) + fBorderWidth, fFrame.left + 35.0 : fFrame.right) + fBorderWidth,
fFrame.top - fBorderWidth); fFrame.top - fBorderWidth);
} else { } else {
fTabRect.Set(fFrame.left - fBorderWidth - ceilf(fontHeight.ascent + fontHeight.descent + 5.0), fTabRect.Set(fFrame.left - fBorderWidth
fFrame.top - fBorderWidth, fFrame.left - fBorderWidth, - ceilf(fontHeight.ascent + fontHeight.descent + 5.0),
fFrame.top - fBorderWidth, fFrame.left - fBorderWidth,
fFrame.bottom + fBorderWidth); fFrame.bottom + fBorderWidth);
} }
@@ -640,14 +653,15 @@ BeDecorator::_DoLayout()
fMinTabSize += offset + size; fMinTabSize += offset + size;
// fMaxTabSize contains fMinWidth + the width required for the title // fMaxTabSize contains fMinWidth + the width required for the title
// TODO : check what escapement_delta is supposed to do fMaxTabSize = fDrawingEngine
fMaxTabSize = fDrawingEngine ? ceilf(fDrawingEngine->StringWidth(Title(), strlen(Title())/*, ? ceilf(fDrawingEngine->StringWidth(Title(), strlen(Title()),
&fDrawState*/)) : 0.0; fDrawState.Font())) : 0.0;
if (fMaxTabSize > 0.0) if (fMaxTabSize > 0.0)
fMaxTabSize += fTextOffset; fMaxTabSize += fTextOffset;
fMaxTabSize += fMinTabSize; fMaxTabSize += fMinTabSize;
float tabSize = fLook != kLeftTitledWindowLook ? fFrame.Width() : fFrame.Height(); float tabSize = fLook != kLeftTitledWindowLook
? fFrame.Width() : fFrame.Height();
if (tabSize < fMinTabSize) if (tabSize < fMinTabSize)
tabSize = fMinTabSize; tabSize = fMinTabSize;
if (tabSize > fMaxTabSize) if (tabSize > fMaxTabSize)
@@ -691,8 +705,14 @@ BeDecorator::_DoLayout()
} }
// calculate resize rect // calculate resize rect
fResizeRect.Set(fBottomBorder.right - 18.0, fBottomBorder.bottom - 18.0, if (fBorderWidth > 1) {
fBottomBorder.right, fBottomBorder.bottom); fResizeRect.Set(fBottomBorder.right - 18.0,
fBottomBorder.bottom - 18.0, fBottomBorder.right,
fBottomBorder.bottom);
} else {
// no border or one pixel border (menus and such)
fResizeRect.Set(0, 0, -1, -1);
}
if (hasTab) { if (hasTab) {
// make sure fTabOffset is within limits and apply it to // make sure fTabOffset is within limits and apply it to
@@ -700,8 +720,10 @@ BeDecorator::_DoLayout()
if (fTabOffset < 0) if (fTabOffset < 0)
fTabOffset = 0; fTabOffset = 0;
if (fTabLocation != 0.0 if (fTabLocation != 0.0
&& fTabOffset > (fRightBorder.right - fLeftBorder.left - fTabRect.Width())) && fTabOffset > (fRightBorder.right - fLeftBorder.left
fTabOffset = uint32(fRightBorder.right - fLeftBorder.left - fTabRect.Width()); - fTabRect.Width()))
fTabOffset = uint32(fRightBorder.right - fLeftBorder.left
- fTabRect.Width());
fTabRect.OffsetBy(fTabOffset, 0); fTabRect.OffsetBy(fTabOffset, 0);
// finally, layout the buttons and text within the tab rect // finally, layout the buttons and text within the tab rect
@@ -709,7 +731,7 @@ BeDecorator::_DoLayout()
} }
} }
// _DrawFrame
void void
BeDecorator::_DrawFrame(BRect invalid) BeDecorator::_DrawFrame(BRect invalid)
{ {
@@ -736,38 +758,38 @@ BeDecorator::_DrawFrame(BRect invalid)
if (invalid.Intersects(fTopBorder)) { if (invalid.Intersects(fTopBorder)) {
for (int8 i = 0; i < 5; i++) { for (int8 i = 0; i < 5; i++) {
fDrawingEngine->StrokeLine(BPoint(r.left + i, r.top + i), fDrawingEngine->StrokeLine(BPoint(r.left + i, r.top + i),
BPoint(r.right - i, r.top + i), BPoint(r.right - i, r.top + i), fFrameColors[i]);
fFrameColors[i]);
} }
if (fTabRect.IsValid()) { if (fTabRect.IsValid()) {
// grey along the bottom of the tab (overwrites "white" from frame) // grey along the bottom of the tab
fDrawingEngine->StrokeLine(BPoint(fTabRect.left + 2, fTabRect.bottom + 1), // (overwrites "white" from frame)
BPoint(fTabRect.right - 2, fTabRect.bottom + 1), fDrawingEngine->StrokeLine(
fFrameColors[2]); BPoint(fTabRect.left + 2, fTabRect.bottom + 1),
BPoint(fTabRect.right - 2, fTabRect.bottom + 1),
fFrameColors[2]);
} }
} }
// left // left
if (invalid.Intersects(fLeftBorder.InsetByCopy(0, -fBorderWidth))) { if (invalid.Intersects(fLeftBorder.InsetByCopy(0, -fBorderWidth))) {
for (int8 i = 0; i < 5; i++) { for (int8 i = 0; i < 5; i++) {
fDrawingEngine->StrokeLine(BPoint(r.left + i, r.top + i), fDrawingEngine->StrokeLine(BPoint(r.left + i, r.top + i),
BPoint(r.left + i, r.bottom - i), BPoint(r.left + i, r.bottom - i), fFrameColors[i]);
fFrameColors[i]);
} }
} }
// bottom // bottom
if (invalid.Intersects(fBottomBorder)) { if (invalid.Intersects(fBottomBorder)) {
for (int8 i = 0; i < 5; i++) { for (int8 i = 0; i < 5; i++) {
fDrawingEngine->StrokeLine(BPoint(r.left + i, r.bottom - i), fDrawingEngine->StrokeLine(BPoint(r.left + i, r.bottom - i),
BPoint(r.right - i, r.bottom - i), BPoint(r.right - i, r.bottom - i),
fFrameColors[(4 - i) == 4 ? 5 : (4 - i)]); fFrameColors[(4 - i) == 4 ? 5 : (4 - i)]);
} }
} }
// right // right
if (invalid.Intersects(fRightBorder.InsetByCopy(0, -fBorderWidth))) { if (invalid.Intersects(fRightBorder.InsetByCopy(0, -fBorderWidth))) {
for (int8 i = 0; i < 5; i++) { for (int8 i = 0; i < 5; i++) {
fDrawingEngine->StrokeLine(BPoint(r.right - i, r.top + i), fDrawingEngine->StrokeLine(BPoint(r.right - i, r.top + i),
BPoint(r.right - i, r.bottom - i), BPoint(r.right - i, r.bottom - i),
fFrameColors[(4 - i) == 4 ? 5 : (4 - i)]); fFrameColors[(4 - i) == 4 ? 5 : (4 - i)]);
} }
} }
break; break;
@@ -780,44 +802,46 @@ BeDecorator::_DrawFrame(BRect invalid)
if (invalid.Intersects(fTopBorder)) { if (invalid.Intersects(fTopBorder)) {
for (int8 i = 0; i < 3; i++) { for (int8 i = 0; i < 3; i++) {
fDrawingEngine->StrokeLine(BPoint(r.left + i, r.top + i), fDrawingEngine->StrokeLine(BPoint(r.left + i, r.top + i),
BPoint(r.right - i, r.top + i), BPoint(r.right - i, r.top + i), fFrameColors[i * 2]);
fFrameColors[i * 2]);
} }
if (fTabRect.IsValid() && fLook != kLeftTitledWindowLook) { if (fTabRect.IsValid() && fLook != kLeftTitledWindowLook) {
// grey along the bottom of the tab (overwrites "white" from frame) // grey along the bottom of the tab
fDrawingEngine->StrokeLine(BPoint(fTabRect.left + 2, fTabRect.bottom + 1), // (overwrites "white" from frame)
BPoint(fTabRect.right - 2, fTabRect.bottom + 1), fDrawingEngine->StrokeLine(
fFrameColors[2]); BPoint(fTabRect.left + 2, fTabRect.bottom + 1),
BPoint(fTabRect.right - 2, fTabRect.bottom + 1),
fFrameColors[2]);
} }
} }
// left // left
if (invalid.Intersects(fLeftBorder.InsetByCopy(0, -fBorderWidth))) { if (invalid.Intersects(fLeftBorder.InsetByCopy(0, -fBorderWidth))) {
for (int8 i = 0; i < 3; i++) { for (int8 i = 0; i < 3; i++) {
fDrawingEngine->StrokeLine(BPoint(r.left + i, r.top + i), fDrawingEngine->StrokeLine(BPoint(r.left + i, r.top + i),
BPoint(r.left + i, r.bottom - i), BPoint(r.left + i, r.bottom - i), fFrameColors[i * 2]);
fFrameColors[i * 2]);
} }
if (fLook == kLeftTitledWindowLook && fTabRect.IsValid()) { if (fLook == kLeftTitledWindowLook && fTabRect.IsValid()) {
// grey along the right side of the tab (overwrites "white" from frame) // grey along the right side of the tab
fDrawingEngine->StrokeLine(BPoint(fTabRect.right + 1, fTabRect.top + 2), // (overwrites "white" from frame)
BPoint(fTabRect.right + 1, fTabRect.bottom - 2), fDrawingEngine->StrokeLine(
fFrameColors[2]); BPoint(fTabRect.right + 1, fTabRect.top + 2),
BPoint(fTabRect.right + 1, fTabRect.bottom - 2),
fFrameColors[2]);
} }
} }
// bottom // bottom
if (invalid.Intersects(fBottomBorder)) { if (invalid.Intersects(fBottomBorder)) {
for (int8 i = 0; i < 3; i++) { for (int8 i = 0; i < 3; i++) {
fDrawingEngine->StrokeLine(BPoint(r.left + i, r.bottom - i), fDrawingEngine->StrokeLine(BPoint(r.left + i, r.bottom - i),
BPoint(r.right - i, r.bottom - i), BPoint(r.right - i, r.bottom - i),
fFrameColors[(2 - i) == 2 ? 5 : (2 - i) * 2]); fFrameColors[(2 - i) == 2 ? 5 : (2 - i) * 2]);
} }
} }
// right // right
if (invalid.Intersects(fRightBorder.InsetByCopy(0, -fBorderWidth))) { if (invalid.Intersects(fRightBorder.InsetByCopy(0, -fBorderWidth))) {
for (int8 i = 0; i < 3; i++) { for (int8 i = 0; i < 3; i++) {
fDrawingEngine->StrokeLine(BPoint(r.right - i, r.top + i), fDrawingEngine->StrokeLine(BPoint(r.right - i, r.top + i),
BPoint(r.right - i, r.bottom - i), BPoint(r.right - i, r.bottom - i),
fFrameColors[(2 - i) == 2 ? 5 : (2 - i) * 2]); fFrameColors[(2 - i) == 2 ? 5 : (2 - i) * 2]);
} }
} }
break; break;
@@ -860,8 +884,8 @@ BeDecorator::_DrawFrame(BRect invalid)
for (int8 i = 1; i <= 4; i++) { for (int8 i = 1; i <= 4; i++) {
for (int8 j = 1; j <= i; j++) { for (int8 j = 1; j <= i; j++) {
BPoint pt1(x - (3 * j) + 1, y - (3 * (5 - i)) + 1); BPoint pt1(x - (3 * j) + 1, y - (3 * (5 - i)) + 1);
BPoint pt2(x - (3 * j) + 2, y - (3 * (5 - i)) + 2); BPoint pt2(x - (3 * j) + 2, y - (3 * (5 - i)) + 2);
fDrawingEngine->StrokePoint(pt1, fFrameColors[0]); fDrawingEngine->StrokePoint(pt1, fFrameColors[0]);
fDrawingEngine->StrokePoint(pt2, fFrameColors[1]); fDrawingEngine->StrokePoint(pt2, fFrameColors[1]);
} }
@@ -875,16 +899,18 @@ BeDecorator::_DrawFrame(BRect invalid)
case kLeftTitledWindowLook: case kLeftTitledWindowLook:
{ {
if (!invalid.Intersects(BRect(fRightBorder.right - 22, if (!invalid.Intersects(BRect(fRightBorder.right - 22,
fBottomBorder.bottom - 22, fRightBorder.right - 1, fBottomBorder.bottom - 22, fRightBorder.right - 1,
fBottomBorder.bottom - 1))) fBottomBorder.bottom - 1)))
break; break;
fDrawingEngine->StrokeLine(BPoint(fRightBorder.left, fBottomBorder.bottom - 22), fDrawingEngine->StrokeLine(
BPoint(fRightBorder.right - 1, fBottomBorder.bottom - 22), BPoint(fRightBorder.left, fBottomBorder.bottom - 22),
fFrameColors[0]); BPoint(fRightBorder.right - 1, fBottomBorder.bottom - 22),
fDrawingEngine->StrokeLine(BPoint(fRightBorder.right - 22, fBottomBorder.top), fFrameColors[0]);
BPoint(fRightBorder.right - 22, fBottomBorder.bottom - 1), fDrawingEngine->StrokeLine(
fFrameColors[0]); BPoint(fRightBorder.right - 22, fBottomBorder.top),
BPoint(fRightBorder.right - 22, fBottomBorder.bottom - 1),
fFrameColors[0]);
break; break;
} }
@@ -895,7 +921,7 @@ BeDecorator::_DrawFrame(BRect invalid)
} }
} }
// _DrawTab
void void
BeDecorator::_DrawTab(BRect invalid) BeDecorator::_DrawTab(BRect invalid)
{ {
@@ -911,26 +937,34 @@ BeDecorator::_DrawTab(BRect invalid)
RGBColor tabColorShadow = RGBColor(tint_color(fTabColor.GetColor32(),B_DARKEN_2_TINT)); RGBColor tabColorShadow = RGBColor(tint_color(fTabColor.GetColor32(),B_DARKEN_2_TINT));
// outer frame // outer frame
fDrawingEngine->StrokeLine(fTabRect.LeftTop(), fTabRect.LeftBottom(), fFrameColors[0]); fDrawingEngine->StrokeLine(fTabRect.LeftTop(), fTabRect.LeftBottom(),
fDrawingEngine->StrokeLine(fTabRect.LeftTop(), fTabRect.RightTop(), fFrameColors[0]); fFrameColors[0]);
if (fLook != kLeftTitledWindowLook) fDrawingEngine->StrokeLine(fTabRect.LeftTop(), fTabRect.RightTop(),
fDrawingEngine->StrokeLine(fTabRect.RightTop(),fTabRect.RightBottom(), fFrameColors[5]); fFrameColors[0]);
else if (fLook != kLeftTitledWindowLook) {
fDrawingEngine->StrokeLine(fTabRect.LeftBottom(),fTabRect.RightBottom(), fFrameColors[5]); fDrawingEngine->StrokeLine(fTabRect.RightTop(), fTabRect.RightBottom(),
fFrameColors[5]);
} else {
fDrawingEngine->StrokeLine(fTabRect.LeftBottom(),
fTabRect.RightBottom(), fFrameColors[5]);
}
// bevel // bevel
fDrawingEngine->StrokeLine(BPoint(fTabRect.left + 1, fTabRect.top + 1), fDrawingEngine->StrokeLine(BPoint(fTabRect.left + 1, fTabRect.top + 1),
BPoint(fTabRect.left + 1, fTabRect.bottom - (fLook == kLeftTitledWindowLook ? 1 : 0)), BPoint(fTabRect.left + 1,
fTabRect.bottom - (fLook == kLeftTitledWindowLook ? 1 : 0)),
tabColorLight); tabColorLight);
fDrawingEngine->StrokeLine(BPoint(fTabRect.left + 1, fTabRect.top + 1), fDrawingEngine->StrokeLine(BPoint(fTabRect.left + 1, fTabRect.top + 1),
BPoint(fTabRect.right - (fLook == kLeftTitledWindowLook ? 0 : 1), fTabRect.top + 1), BPoint(fTabRect.right - (fLook == kLeftTitledWindowLook ? 0 : 1),
fTabRect.top + 1),
tabColorLight); tabColorLight);
if (fLook != kLeftTitledWindowLook) { if (fLook != kLeftTitledWindowLook) {
fDrawingEngine->StrokeLine(BPoint(fTabRect.right - 1, fTabRect.top + 2), fDrawingEngine->StrokeLine(BPoint(fTabRect.right - 1, fTabRect.top + 2),
BPoint(fTabRect.right - 1, fTabRect.bottom), tabColorShadow); BPoint(fTabRect.right - 1, fTabRect.bottom), tabColorShadow);
} else { } else {
fDrawingEngine->StrokeLine(BPoint(fTabRect.left + 2, fTabRect.bottom - 1), fDrawingEngine->StrokeLine(
BPoint(fTabRect.left + 2, fTabRect.bottom - 1),
BPoint(fTabRect.right, fTabRect.bottom - 1), tabColorShadow); BPoint(fTabRect.right, fTabRect.bottom - 1), tabColorShadow);
} }
@@ -952,7 +986,7 @@ BeDecorator::_DrawTab(BRect invalid)
_DrawZoom(fZoomRect); _DrawZoom(fZoomRect);
} }
// _DrawClose
void void
BeDecorator::_DrawClose(BRect r) BeDecorator::_DrawClose(BRect r)
{ {
@@ -961,14 +995,16 @@ BeDecorator::_DrawClose(BRect r)
_DrawBlendedRect(r, GetClose()); _DrawBlendedRect(r, GetClose());
} }
// _DrawTitle
void void
BeDecorator::_DrawTitle(BRect r) BeDecorator::_DrawTitle(BRect r)
{ {
STRACE(("_DrawTitle(%f,%f,%f,%f)\n", r.left, r.top, r.right, r.bottom)); STRACE(("_DrawTitle(%f,%f,%f,%f)\n", r.left, r.top, r.right, r.bottom));
fDrawState.SetHighColor(fTextColor); fDrawingEngine->SetDrawingMode(B_OP_OVER);
fDrawState.SetLowColor(fTabColor); fDrawingEngine->SetHighColor(fTextColor);
fDrawingEngine->SetLowColor(fTabColor);
fDrawingEngine->SetFont(fDrawState.Font());
// figure out position of text // figure out position of text
font_height fontHeight; font_height fontHeight;
@@ -978,19 +1014,24 @@ BeDecorator::_DrawTitle(BRect r)
if (fLook != kLeftTitledWindowLook) { if (fLook != kLeftTitledWindowLook) {
titlePos.x = fCloseRect.IsValid() ? fCloseRect.right + fTextOffset titlePos.x = fCloseRect.IsValid() ? fCloseRect.right + fTextOffset
: fTabRect.left + fTextOffset; : fTabRect.left + fTextOffset;
titlePos.y = floorf(((fTabRect.top + 2.0) + fTabRect.bottom + fontHeight.ascent titlePos.y = floorf(((fTabRect.top + 2.0) + fTabRect.bottom
+ fontHeight.descent) / 2.0 - fontHeight.descent + 0.5); + fontHeight.ascent + fontHeight.descent) / 2.0
- fontHeight.descent + 0.5);
} else { } else {
titlePos.x = floorf(((fTabRect.left + 2.0) + fTabRect.right + fontHeight.ascent titlePos.x = floorf(((fTabRect.left + 2.0) + fTabRect.right
+ fontHeight.descent) / 2.0 - fontHeight.descent + 0.5); + fontHeight.ascent + fontHeight.descent) / 2.0
- fontHeight.descent + 0.5);
titlePos.y = fZoomRect.IsValid() ? fZoomRect.top - fTextOffset titlePos.y = fZoomRect.IsValid() ? fZoomRect.top - fTextOffset
: fTabRect.bottom - fTextOffset; : fTabRect.bottom - fTextOffset;
} }
fDrawingEngine->DrawString(fTruncatedTitle.String(), fTruncatedTitleLength, titlePos/*, &fDrawState*/); fDrawingEngine->DrawString(fTruncatedTitle.String(), fTruncatedTitleLength,
titlePos);
fDrawingEngine->SetDrawingMode(B_OP_COPY);
} }
// _DrawZoom
void void
BeDecorator::_DrawZoom(BRect r) BeDecorator::_DrawZoom(BRect r)
{ {
@@ -1009,14 +1050,15 @@ BeDecorator::_DrawZoom(BRect r)
_DrawBlendedRect(zr, GetZoom()); _DrawBlendedRect(zr, GetZoom());
} }
// _SetFocus
void void
BeDecorator::_SetFocus() BeDecorator::_SetFocus()
{ {
// SetFocus() performs necessary duties for color swapping and // SetFocus() performs necessary duties for color swapping and
// other things when a window is deactivated or activated. // other things when a window is deactivated or activated.
if (IsFocus() || ((fLook == B_FLOATING_WINDOW_LOOK || fLook == kLeftTitledWindowLook) if (IsFocus()
|| ((fLook == B_FLOATING_WINDOW_LOOK || fLook == kLeftTitledWindowLook)
&& (fFlags & B_AVOID_FOCUS) != 0)) { && (fFlags & B_AVOID_FOCUS) != 0)) {
fTabColor = UIColor(B_WINDOW_TAB_COLOR); fTabColor = UIColor(B_WINDOW_TAB_COLOR);
fTextColor = UIColor(B_WINDOW_TEXT_COLOR); fTextColor = UIColor(B_WINDOW_TEXT_COLOR);
@@ -1044,7 +1086,7 @@ BeDecorator::_SetFocus()
} }
} }
// _SetColors
void void
BeDecorator::_SetColors() BeDecorator::_SetColors()
{ {
@@ -1168,7 +1210,7 @@ BeDecorator::_LayoutTabItems(const BRect& tabRect)
} }
// calculate room for title // calculate room for title
// ToDo: the +2 is there because the title often appeared // TODO: the +2 is there because the title often appeared
// truncated for no apparent reason - OTOH the title does // truncated for no apparent reason - OTOH the title does
// also not appear perfectly in the middle // also not appear perfectly in the middle
if (fLook != kLeftTitledWindowLook) if (fLook != kLeftTitledWindowLook)
@@ -1,8 +1,6 @@
#include <Point.h> #include <Point.h>
#include "DrawingEngine.h" #include "DrawingEngine.h"
#include <View.h> #include <View.h>
//#include "LayerData.h"
//#include "ColorUtils.h"
#include "MacDecorator.h" #include "MacDecorator.h"
#include "RGBColor.h" #include "RGBColor.h"
#include "PatternHandler.h" #include "PatternHandler.h"