* Cleanup.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26962 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2008-08-13 12:59:18 +00:00
parent f1efe9b3d2
commit 345d8c9ff0
3 changed files with 74 additions and 69 deletions
+61 -56
View File
@@ -217,31 +217,31 @@ DefaultDecorator::SetFlags(uint32 flags, BRegion* updateRegion)
void void
DefaultDecorator::MoveBy(BPoint pt) DefaultDecorator::MoveBy(BPoint offset)
{ {
STRACE(("DefaultDecorator: Move By (%.1f, %.1f)\n",pt.x,pt.y)); STRACE(("DefaultDecorator: Move By (%.1f, %.1f)\n", offset.x, offset.y));
// Move all internal rectangles the appropriate amount // Move all internal rectangles the appropriate amount
fFrame.OffsetBy(pt); fFrame.OffsetBy(offset);
fCloseRect.OffsetBy(pt); fCloseRect.OffsetBy(offset);
fTabRect.OffsetBy(pt); fTabRect.OffsetBy(offset);
fResizeRect.OffsetBy(pt); fResizeRect.OffsetBy(offset);
fZoomRect.OffsetBy(pt); fZoomRect.OffsetBy(offset);
fBorderRect.OffsetBy(pt); fBorderRect.OffsetBy(offset);
fLeftBorder.OffsetBy(pt); fLeftBorder.OffsetBy(offset);
fRightBorder.OffsetBy(pt); fRightBorder.OffsetBy(offset);
fTopBorder.OffsetBy(pt); fTopBorder.OffsetBy(offset);
fBottomBorder.OffsetBy(pt); fBottomBorder.OffsetBy(offset);
} }
void void
DefaultDecorator::ResizeBy(BPoint pt, BRegion* dirty) DefaultDecorator::ResizeBy(BPoint offset, BRegion* dirty)
{ {
STRACE(("DefaultDecorator: Resize By (%.1f, %.1f)\n", pt.x, pt.y)); STRACE(("DefaultDecorator: Resize By (%.1f, %.1f)\n", offset.x, offset.y));
// Move all internal rectangles the appropriate amount // Move all internal rectangles the appropriate amount
fFrame.right += pt.x; fFrame.right += offset.x;
fFrame.bottom += pt.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)) {
@@ -251,7 +251,7 @@ DefaultDecorator::ResizeBy(BPoint pt, BRegion* dirty)
realResizeRect = fResizeRect; realResizeRect = fResizeRect;
// resize rect at old location // resize rect at old location
dirty->Include(realResizeRect); dirty->Include(realResizeRect);
realResizeRect.OffsetBy(pt); realResizeRect.OffsetBy(offset);
// resize rect at new location // resize rect at new location
dirty->Include(realResizeRect); dirty->Include(realResizeRect);
break; break;
@@ -263,7 +263,7 @@ DefaultDecorator::ResizeBy(BPoint pt, BRegion* dirty)
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(offset);
// resize rect at new location // resize rect at new location
dirty->Include(realResizeRect); dirty->Include(realResizeRect);
@@ -271,7 +271,7 @@ DefaultDecorator::ResizeBy(BPoint pt, BRegion* dirty)
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(offset);
// resize rect at new location // resize rect at new location
dirty->Include(realResizeRect); dirty->Include(realResizeRect);
break; break;
@@ -280,42 +280,42 @@ DefaultDecorator::ResizeBy(BPoint pt, BRegion* dirty)
} }
} }
fResizeRect.OffsetBy(pt); fResizeRect.OffsetBy(offset);
fBorderRect.right += pt.x; fBorderRect.right += offset.x;
fBorderRect.bottom += pt.y; fBorderRect.bottom += offset.y;
fLeftBorder.bottom += pt.y; fLeftBorder.bottom += offset.y;
fTopBorder.right += pt.x; fTopBorder.right += offset.x;
fRightBorder.OffsetBy(pt.x, 0.0); fRightBorder.OffsetBy(offset.x, 0.0);
fRightBorder.bottom += pt.y; fRightBorder.bottom += offset.y;
fBottomBorder.OffsetBy(0.0, pt.y); fBottomBorder.OffsetBy(0.0, offset.y);
fBottomBorder.right += pt.x; fBottomBorder.right += offset.x;
if (dirty) { if (dirty) {
if (pt.x > 0.0) { if (offset.x > 0.0) {
BRect t(fRightBorder.left - pt.x, fTopBorder.top, BRect t(fRightBorder.left - offset.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 - offset.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 (offset.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 (offset.y > 0.0) {
BRect t(fLeftBorder.left, fLeftBorder.bottom - pt.y, BRect t(fLeftBorder.left, fLeftBorder.bottom - offset.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 - offset.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 (offset.y < 0.0) {
dirty->Include(fBottomBorder); dirty->Include(fBottomBorder);
} }
} }
@@ -516,44 +516,46 @@ DefaultDecorator::GetFootprint(BRegion* region)
click_type click_type
DefaultDecorator::Clicked(BPoint pt, int32 buttons, int32 modifiers) DefaultDecorator::Clicked(BPoint point, int32 buttons, int32 modifiers)
{ {
#ifdef DEBUG_DECORATOR #ifdef DEBUG_DECORATOR
printf("DefaultDecorator: Clicked\n"); printf("DefaultDecorator: Clicked\n");
printf("\tPoint: (%.1f,%.1f)\n", pt.x,pt.y); printf("\tPoint: (%.1f,%.1f)\n", point.x, point.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
if (!(fFlags & B_NOT_CLOSABLE) && fCloseRect.Contains(pt)) // rectangles.
if (!(fFlags & B_NOT_CLOSABLE) && fCloseRect.Contains(point))
return DEC_CLOSE; return DEC_CLOSE;
if (!(fFlags & B_NOT_ZOOMABLE) && fZoomRect.Contains(pt)) if (!(fFlags & B_NOT_ZOOMABLE) && fZoomRect.Contains(point))
return DEC_ZOOM; return DEC_ZOOM;
if (fLook == B_DOCUMENT_WINDOW_LOOK && fResizeRect.Contains(pt)) if (fLook == B_DOCUMENT_WINDOW_LOOK && fResizeRect.Contains(point))
return DEC_RESIZE; return DEC_RESIZE;
bool clicked = false; bool clicked = false;
// Clicking in the tab? // Clicking in the tab?
if (fTabRect.Contains(pt)) { if (fTabRect.Contains(point)) {
// tab sliding in any case if either shift key is held down // tab sliding in any case if either shift key is held down
// except sliding up-down by moving mouse left-right would look strange // except sliding up-down by moving mouse left-right would look strange
if ((modifiers & B_SHIFT_KEY) && (fLook != kLeftTitledWindowLook)) if ((modifiers & B_SHIFT_KEY) && (fLook != kLeftTitledWindowLook))
return DEC_SLIDETAB; return DEC_SLIDETAB;
clicked = true; clicked = true;
} else if (fLeftBorder.Contains(pt) || fRightBorder.Contains(pt) } else if (fLeftBorder.Contains(point) || fRightBorder.Contains(point)
|| fTopBorder.Contains(pt) || fBottomBorder.Contains(pt)) { || fTopBorder.Contains(point) || fBottomBorder.Contains(point)) {
// Clicked on border // Clicked on border
// check resize area // check resize area
@@ -564,7 +566,7 @@ DefaultDecorator::Clicked(BPoint pt, int32 buttons, int32 modifiers)
|| fLook == kLeftTitledWindowLook)) { || fLook == kLeftTitledWindowLook)) {
BRect temp(BPoint(fBottomBorder.right - 18, BRect temp(BPoint(fBottomBorder.right - 18,
fBottomBorder.bottom - 18), fBottomBorder.RightBottom()); fBottomBorder.bottom - 18), fBottomBorder.RightBottom());
if (temp.Contains(pt)) if (temp.Contains(point))
return DEC_RESIZE; return DEC_RESIZE;
} }
@@ -572,8 +574,9 @@ DefaultDecorator::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
// the check above
if (buttons == B_SECONDARY_MOUSE_BUTTON) if (buttons == B_SECONDARY_MOUSE_BUTTON)
return DEC_MOVETOBACK; return DEC_MOVETOBACK;
@@ -671,7 +674,8 @@ DefaultDecorator::_DoLayout()
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)
@@ -1081,8 +1085,7 @@ DefaultDecorator::_SetFocus()
fTabColorLight = tint_color(fTabColor, fTabColorLight = tint_color(fTabColor,
(B_LIGHTEN_2_TINT + B_LIGHTEN_MAX_TINT) / 2); (B_LIGHTEN_2_TINT + B_LIGHTEN_MAX_TINT) / 2);
fTabColorShadow = tint_color(fTabColor, fTabColorShadow = tint_color(fTabColor, B_DARKEN_2_TINT);
B_DARKEN_2_TINT);
} }
@@ -1217,7 +1220,7 @@ DefaultDecorator::_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)
@@ -1289,13 +1292,15 @@ DefaultDecorator::_GetBitmapForButton(int32 item, bool down, bool focus,
BRect zoomRect(rect); BRect zoomRect(rect);
zoomRect.left += inset; zoomRect.left += inset;
zoomRect.top += inset; zoomRect.top += inset;
object->_DrawBlendedRect(sBitmapDrawingEngine, zoomRect, down, focus); object->_DrawBlendedRect(sBitmapDrawingEngine, zoomRect, down,
focus);
inset = floorf(width / 2.1); inset = floorf(width / 2.1);
zoomRect = rect; zoomRect = rect;
zoomRect.right -= inset; zoomRect.right -= inset;
zoomRect.bottom -= inset; zoomRect.bottom -= inset;
object->_DrawBlendedRect(sBitmapDrawingEngine, zoomRect, down, focus); object->_DrawBlendedRect(sBitmapDrawingEngine, zoomRect, down,
focus);
break; break;
} }
} }
+1 -1
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2001-2006, Haiku. * Copyright 2001-2008, Haiku.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
+2 -2
View File
@@ -263,8 +263,8 @@ ServerApp::_HasWindowUnderMouse()
\brief Sets the ServerApp's active status \brief Sets the ServerApp's active status
\param value The new status of the ServerApp. \param value The new status of the ServerApp.
This changes an internal flag and also sets the current cursor to the one specified by This changes an internal flag and also sets the current cursor to the one
the application specified by the application
*/ */
void void
ServerApp::Activate(bool value) ServerApp::Activate(bool value)