* A double click on the window border now minimizes the window - has a fixed

double click time, though.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16631 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2006-03-07 15:23:35 +00:00
parent 9b9d1e82f4
commit 14fb2b690b
3 changed files with 105 additions and 95 deletions
+35 -21
View File
@@ -39,8 +39,9 @@
DefaultDecorator::DefaultDecorator(DesktopSettings& settings, BRect rect, DefaultDecorator::DefaultDecorator(DesktopSettings& settings, BRect rect,
window_look look, uint32 flags) window_look look, uint32 flags)
: Decorator(settings, rect, look, flags) : Decorator(settings, rect, look, flags),
fLastClicked(0)
{ {
DefaultDecorator::SetLook(settings, look); DefaultDecorator::SetLook(settings, look);
@@ -358,6 +359,13 @@ DefaultDecorator::Clicked(BPoint pt, int32 buttons, int32 modifiers)
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
bigtime_t now = system_time();
if (buttons != 0) {
fWasDoubleClick = now - fLastClicked < 200000;
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 the user might
// be clicking on and gradually work our way out into larger rectangles. // be clicking on and gradually work our way out into larger rectangles.
if (!(fFlags & B_NOT_CLOSABLE) && _closerect.Contains(pt)) if (!(fFlags & B_NOT_CLOSABLE) && _closerect.Contains(pt))
@@ -369,20 +377,19 @@ DefaultDecorator::Clicked(BPoint pt, int32 buttons, int32 modifiers)
if (fLook == B_DOCUMENT_WINDOW_LOOK && _resizerect.Contains(pt)) if (fLook == B_DOCUMENT_WINDOW_LOOK && _resizerect.Contains(pt))
return DEC_RESIZE; return DEC_RESIZE;
bool clicked = false;
// Clicking in the tab? // Clicking in the tab?
if (_tabrect.Contains(pt)) { if (_tabrect.Contains(pt)) {
// tab sliding in any case if either shift key is held down // tab sliding in any case if either shift key is held down
if (modifiers & B_SHIFT_KEY) if (modifiers & B_SHIFT_KEY)
return DEC_SLIDETAB; return DEC_SLIDETAB;
// Here's part of our window management stuff
if (buttons == B_SECONDARY_MOUSE_BUTTON)
return DEC_MOVETOBACK;
return DEC_DRAG;
}
// We got this far, so user is clicking on the border? clicked = true;
if (fLeftBorder.Contains(pt) || fRightBorder.Contains(pt) } else if (fLeftBorder.Contains(pt) || fRightBorder.Contains(pt)
|| fTopBorder.Contains(pt) || fBottomBorder.Contains(pt)) { || fTopBorder.Contains(pt) || fBottomBorder.Contains(pt)) {
// Clicked on border
// check resize area // check resize area
if (!(fFlags & B_NOT_RESIZABLE) if (!(fFlags & B_NOT_RESIZABLE)
&& (fLook == B_TITLED_WINDOW_LOOK && (fLook == B_TITLED_WINDOW_LOOK
@@ -394,11 +401,18 @@ DefaultDecorator::Clicked(BPoint pt, int32 buttons, int32 modifiers)
return DEC_RESIZE; return DEC_RESIZE;
} }
// NOTE: On R5, windows are not moved to back if clicked inside the resize area with clicked = true;
// the second mouse button. So we check this after the check above }
if (clicked) {
// NOTE: On R5, windows are not moved to back if clicked inside the 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;
if (fWasDoubleClick)
return DEC_MINIMIZE;
return DEC_DRAG; return DEC_DRAG;
} }
@@ -750,7 +764,7 @@ DefaultDecorator::_DrawClose(BRect r)
{ {
STRACE(("_DrawClose(%f,%f,%f,%f)\n", r.left, r.top, r.right, r.bottom)); STRACE(("_DrawClose(%f,%f,%f,%f)\n", r.left, r.top, r.right, r.bottom));
// Just like DrawZoom, but for a close button // Just like DrawZoom, but for a close button
_DrawBlendedRect( r, GetClose()); _DrawBlendedRect(r, GetClose());
} }
// _DrawTitle // _DrawTitle
@@ -835,14 +849,14 @@ DefaultDecorator::_SetColors()
_SetFocus(); _SetFocus();
} }
// _DrawBlendedRect
/*!
\brief Draws a framed rectangle with a gradient.
\param down The rectangle should be drawn recessed or not
*/
void void
DefaultDecorator::_DrawBlendedRect(BRect r, bool down) DefaultDecorator::_DrawBlendedRect(BRect r, bool down)
{ {
// This bad boy is used to draw a rectangle with a gradient.
// Note that it is not part of the Decorator API - it's specific
// to just the BeDecorator. Called by DrawZoom and DrawClose
// Actually just draws a blended square // Actually just draws a blended square
int32 w = r.IntegerWidth(); int32 w = r.IntegerWidth();
int32 h = r.IntegerHeight(); int32 h = r.IntegerHeight();
@@ -854,11 +868,11 @@ DefaultDecorator::_DrawBlendedRect(BRect r, bool down)
int steps = (w < h) ? w : h; int steps = (w < h) ? w : h;
if (down) { if (down) {
startcol = fButtonLowColor.GetColor32(); startcol = fButtonLowColor.GetColor32();
endcol = fButtonHighColor.GetColor32(); endcol = fButtonHighColor.GetColor32();
} else { } else {
startcol = fButtonHighColor.GetColor32(); startcol = fButtonHighColor.GetColor32();
endcol = fButtonLowColor.GetColor32(); endcol = fButtonLowColor.GetColor32();
} }
halfcol = MakeBlendColor(startcol,endcol,0.5); halfcol = MakeBlendColor(startcol,endcol,0.5);
+53 -50
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2001-2005, Haiku. * Copyright 2001-2006, Haiku.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@@ -17,72 +17,75 @@ class Desktop;
class DefaultDecorator: public Decorator { class DefaultDecorator: public Decorator {
public: public:
DefaultDecorator(DesktopSettings& settings, BRect frame, DefaultDecorator(DesktopSettings& settings, BRect frame,
window_look look, uint32 flags); window_look look, uint32 flags);
virtual ~DefaultDecorator(); virtual ~DefaultDecorator();
virtual void SetTitle(const char* string, BRegion* updateRegion = NULL); virtual void SetTitle(const char* string, BRegion* updateRegion = NULL);
virtual void SetLook(DesktopSettings& settings, virtual void SetLook(DesktopSettings& settings,
window_look look, BRegion* updateRegion = NULL); window_look look, BRegion* updateRegion = NULL);
virtual void SetFlags(uint32 flags, BRegion* updateRegion = NULL); virtual void SetFlags(uint32 flags, BRegion* updateRegion = NULL);
virtual void MoveBy(BPoint pt); virtual void MoveBy(BPoint pt);
virtual void ResizeBy(BPoint pt, BRegion* dirty); virtual void ResizeBy(BPoint pt, BRegion* dirty);
virtual void Draw(BRect r); virtual void Draw(BRect r);
virtual void Draw(); virtual void Draw();
virtual void GetSizeLimits(int32* minWidth, int32* minHeight, virtual void GetSizeLimits(int32* minWidth, int32* minHeight,
int32* maxWidth, int32* maxHeight) const; int32* maxWidth, int32* maxHeight) const;
virtual void GetFootprint(BRegion *region); virtual void GetFootprint(BRegion *region);
virtual click_type Clicked(BPoint pt, int32 buttons, virtual click_type Clicked(BPoint pt, int32 buttons,
int32 modifiers); int32 modifiers);
protected: protected:
virtual void _DoLayout(); virtual void _DoLayout();
virtual void _DrawFrame(BRect r); virtual void _DrawFrame(BRect r);
virtual void _DrawTab(BRect r); virtual void _DrawTab(BRect r);
virtual void _DrawClose(BRect r); virtual void _DrawClose(BRect r);
virtual void _DrawTitle(BRect r); virtual void _DrawTitle(BRect r);
virtual void _DrawZoom(BRect r); virtual void _DrawZoom(BRect r);
virtual void _SetFocus(); virtual void _SetFocus();
virtual void _SetColors(); virtual void _SetColors();
private: private:
void _DrawBlendedRect(BRect r, bool down); void _DrawBlendedRect(BRect r, bool down);
void _GetButtonSizeAndOffset(const BRect& tabRect, void _GetButtonSizeAndOffset(const BRect& tabRect,
float* offset, float*size) const; float* offset, float*size) const;
void _LayoutTabItems(const BRect& tabRect); void _LayoutTabItems(const BRect& tabRect);
RGBColor fButtonHighColor; RGBColor fButtonHighColor;
RGBColor fButtonLowColor; RGBColor fButtonLowColor;
RGBColor fTextColor; RGBColor fTextColor;
RGBColor fTabColor; RGBColor fTabColor;
RGBColor* fFrameColors; RGBColor* fFrameColors;
// Individual rects for handling window frame
// rendering the proper way
BRect fRightBorder;
BRect fLeftBorder;
BRect fTopBorder;
BRect fBottomBorder;
int32 fBorderWidth; // Individual rects for handling window frame
// rendering the proper way
BRect fRightBorder;
BRect fLeftBorder;
BRect fTopBorder;
BRect fBottomBorder;
uint32 fTabOffset; int32 fBorderWidth;
float fTextOffset;
float fMinTabWidth; uint32 fTabOffset;
float fMaxTabWidth; float fTextOffset;
BString fTruncatedTitle;
int32 fTruncatedTitleLength; float fMinTabWidth;
float fMaxTabWidth;
BString fTruncatedTitle;
int32 fTruncatedTitleLength;
bigtime_t fLastClicked;
bool fWasDoubleClick;
}; };
#endif /* DEFAULT_DECORATOR_H */ #endif /* DEFAULT_DECORATOR_H */
+17 -24
View File
@@ -756,19 +756,16 @@ WindowLayer::MouseDown(BMessage* message, BPoint where, int32* _viewToken)
switch (action) { switch (action) {
case DEC_CLOSE: case DEC_CLOSE:
fIsClosing = true; fIsClosing = true;
fDecorator->SetClose(true);
STRACE_CLICK(("===> DEC_CLOSE\n")); STRACE_CLICK(("===> DEC_CLOSE\n"));
break; break;
case DEC_ZOOM: case DEC_ZOOM:
fIsZooming = true; fIsZooming = true;
fDecorator->SetZoom(true);
STRACE_CLICK(("===> DEC_ZOOM\n")); STRACE_CLICK(("===> DEC_ZOOM\n"));
break; break;
case DEC_MINIMIZE: case DEC_MINIMIZE:
fIsMinimizing = true; fIsMinimizing = true;
fDecorator->SetMinimize(true);
STRACE_CLICK(("===> DEC_MINIMIZE\n")); STRACE_CLICK(("===> DEC_MINIMIZE\n"));
break; break;
@@ -794,7 +791,7 @@ WindowLayer::MouseDown(BMessage* message, BPoint where, int32* _viewToken)
break; break;
} }
// redraw decoratpr // redraw decorator
BRegion visibleBorder; BRegion visibleBorder;
GetBorderRegion(&visibleBorder); GetBorderRegion(&visibleBorder);
visibleBorder.IntersectWith(&VisibleRegion()); visibleBorder.IntersectWith(&VisibleRegion());
@@ -805,7 +802,7 @@ WindowLayer::MouseDown(BMessage* message, BPoint where, int32* _viewToken)
if (fIsZooming) { if (fIsZooming) {
fDecorator->SetZoom(true); fDecorator->SetZoom(true);
} else if (fIsClosing) { } else if (fIsClosing) {
fDecorator->SetClose(true); //fDecorator->SetClose(true);
} else if (fIsMinimizing) { } else if (fIsMinimizing) {
fDecorator->SetMinimize(true); fDecorator->SetMinimize(true);
} }
@@ -855,7 +852,7 @@ WindowLayer::MouseUp(BMessage* msg, BPoint where, int32* _viewToken)
if (fDecorator) { if (fDecorator) {
click_type action = _ActionFor(msg); click_type action = _ActionFor(msg);
// redraw decoratpr // redraw decorator
BRegion visibleBorder; BRegion visibleBorder;
GetBorderRegion(&visibleBorder); GetBorderRegion(&visibleBorder);
visibleBorder.IntersectWith(&VisibleRegion()); visibleBorder.IntersectWith(&VisibleRegion());
@@ -863,14 +860,6 @@ WindowLayer::MouseUp(BMessage* msg, BPoint where, int32* _viewToken)
fDrawingEngine->Lock(); fDrawingEngine->Lock();
fDrawingEngine->ConstrainClippingRegion(&visibleBorder); fDrawingEngine->ConstrainClippingRegion(&visibleBorder);
if (fIsZooming) {
fDecorator->SetZoom(true);
} else if (fIsClosing) {
fDecorator->SetClose(true);
} else if (fIsMinimizing) {
fDecorator->SetMinimize(true);
}
if (fIsZooming) { if (fIsZooming) {
fIsZooming = false; fIsZooming = false;
fDecorator->SetZoom(false); fDecorator->SetZoom(false);
@@ -1853,21 +1842,25 @@ WindowLayer::_UpdateContentRegion()
click_type click_type
WindowLayer::_ActionFor(const BMessage* msg) const WindowLayer::_ActionFor(const BMessage* msg) const
{ {
BPoint where(0, 0); if (fDecorator == NULL)
int32 buttons = 0; return DEC_NONE;
int32 modifiers = 0;
msg->FindPoint("where", &where); BPoint where;
msg->FindInt32("buttons", &buttons); if (msg->FindPoint("where", &where) != B_OK)
msg->FindInt32("modifiers", &modifiers); return DEC_NONE;
if (fDecorator) int32 buttons;
return fDecorator->Clicked(where, buttons, modifiers); if (msg->FindInt32("buttons", &buttons) != B_OK)
buttons = 0;
return DEC_NONE; int32 modifiers;
if (msg->FindInt32("modifiers", &modifiers) != B_OK)
modifiers = 0;
return fDecorator->Clicked(where, buttons, modifiers);
} }
// _ObeySizeLimits
void void
WindowLayer::_ObeySizeLimits() WindowLayer::_ObeySizeLimits()
{ {