* Got rid of the home brewn double click detection - we're now simply using the

"clicks" field of the mouse message as everywhere else.
* Renamed Decorator::Clicked() to MouseAction().
* Minor style cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37996 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2010-08-10 09:14:46 +00:00
parent cb7ce9a32f
commit 3a5082aa46
11 changed files with 117 additions and 111 deletions
@@ -9,7 +9,7 @@
*/ */
// This one is more like the classic R5 look //! This one is more like the classic R5 look
#include "BeDecorator.h" #include "BeDecorator.h"
@@ -117,7 +117,7 @@ BeDecorator::BeDecorator(DesktopSettings& settings, BRect rect,
Decorator(settings, rect, look, flags), Decorator(settings, rect, look, flags),
fTabOffset(0), fTabOffset(0),
fTabLocation(0.0), fTabLocation(0.0),
fLastClicked(0) fWasDoubleClick(false)
{ {
_UpdateFont(settings); _UpdateFont(settings);
SetLook(settings, look); SetLook(settings, look);
@@ -215,7 +215,8 @@ BeDecorator::GetSizeLimits(int32* minWidth, int32* minHeight,
click_type click_type
BeDecorator::Clicked(BPoint point, int32 buttons, int32 modifiers) BeDecorator::MouseAction(const BMessage* message, BPoint point, int32 buttons,
int32 modifiers)
{ {
#ifdef DEBUG_DECORATOR #ifdef DEBUG_DECORATOR
printf("BeDecorator: Clicked\n"); printf("BeDecorator: Clicked\n");
@@ -223,13 +224,8 @@ BeDecorator::Clicked(BPoint point, 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 if (buttons != 0)
// account fWasDoubleClick = message->FindInt32("clicks") == 2;
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 // 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 // the user might be clicking on and gradually work our way out into larger
@@ -263,9 +259,10 @@ BeDecorator::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 - kBorderResizeLength, BRect resizeRect(BPoint(fBottomBorder.right - kBorderResizeLength,
fBottomBorder.bottom - kBorderResizeLength), fBottomBorder.RightBottom()); fBottomBorder.bottom - kBorderResizeLength),
if (temp.Contains(point)) fBottomBorder.RightBottom());
if (resizeRect.Contains(point))
return CLICK_RESIZE; return CLICK_RESIZE;
} }
@@ -24,7 +24,8 @@ class BeDecorAddOn : public DecorAddOn {
public: public:
BeDecorAddOn(image_id id, const char* name); BeDecorAddOn(image_id id, const char* name);
float Version(); float Version();
protected: protected:
virtual Decorator* _AllocateDecorator(DesktopSettings& settings, virtual Decorator* _AllocateDecorator(DesktopSettings& settings,
BRect rect, window_look look, uint32 flags); BRect rect, window_look look, uint32 flags);
@@ -49,8 +50,9 @@ public:
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 click_type Clicked(BPoint pt, int32 buttons, virtual click_type MouseAction(const BMessage* message,
int32 modifiers); BPoint pointt, int32 buttons,
int32 modifiers);
protected: protected:
virtual void _DoLayout(); virtual void _DoLayout();
@@ -94,6 +96,7 @@ private:
float* offset, float*size) const; float* offset, float*size) const;
void _LayoutTabItems(const BRect& tabRect); void _LayoutTabItems(const BRect& tabRect);
private:
RGBColor fButtonHighColor; RGBColor fButtonHighColor;
RGBColor fButtonLowColor; RGBColor fButtonLowColor;
RGBColor fTextColor; RGBColor fTextColor;
@@ -118,9 +121,9 @@ private:
float fMaxTabSize; float fMaxTabSize;
BString fTruncatedTitle; BString fTruncatedTitle;
int32 fTruncatedTitleLength; int32 fTruncatedTitleLength;
bigtime_t fLastClicked;
bool fWasDoubleClick; bool fWasDoubleClick;
}; };
#endif // DEFAULT_DECORATOR_H #endif // DEFAULT_DECORATOR_H
@@ -118,7 +118,8 @@ MacDecorator::Draw()
click_type click_type
MacDecorator::Clicked(BPoint point, int32 buttons, int32 modifiers) MacDecorator::MouseAction(const BMessage* message, BPoint point, int32 buttons,
int32 modifiers)
{ {
if (!(fFlags & B_NOT_CLOSABLE) && fCloseRect.Contains(point)) { if (!(fFlags & B_NOT_CLOSABLE) && fCloseRect.Contains(point)) {
STRACE(("MacDecorator():Clicked() - Close\n")); STRACE(("MacDecorator():Clicked() - Close\n"));
@@ -133,8 +134,8 @@ MacDecorator::Clicked(BPoint point, int32 buttons, int32 modifiers)
// Clicking in the tab? // Clicking in the tab?
if (fTabRect.Contains(point)) { if (fTabRect.Contains(point)) {
// Here's part of our window management stuff // Here's part of our window management stuff
/* TODO This is missing CLICK_MOVETOFRONT /* TODO: This is missing CLICK_MOVETOFRONT
if(buttons==B_PRIMARY_MOUSE_BUTTON && !IsFocus()) if(buttons == B_PRIMARY_MOUSE_BUTTON && !IsFocus())
return CLICK_MOVETOFRONT; return CLICK_MOVETOFRONT;
*/ */
return CLICK_DRAG; return CLICK_DRAG;
@@ -1,7 +1,7 @@
/* /*
Copyright 2009, Haiku. * Copyright 2009-2010, Haiku.
Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
#ifndef _MAC_DECORATOR_H_ #ifndef _MAC_DECORATOR_H_
#define _MAC_DECORATOR_H_ #define _MAC_DECORATOR_H_
@@ -10,12 +10,12 @@
#include "RGBColor.h" #include "RGBColor.h"
class MacDecorAddOn : public DecorAddOn class MacDecorAddOn : public DecorAddOn {
{
public: public:
MacDecorAddOn(image_id id, const char* name); MacDecorAddOn(image_id id, const char* name);
float Version(); float Version();
protected: protected:
virtual Decorator* _AllocateDecorator(DesktopSettings& settings, virtual Decorator* _AllocateDecorator(DesktopSettings& settings,
BRect rect, window_look look, uint32 flags); BRect rect, window_look look, uint32 flags);
@@ -32,7 +32,8 @@ public:
void Draw(BRect updateRect); void Draw(BRect updateRect);
void Draw(); void Draw();
click_type Clicked(BPoint pt, int32 buttons, click_type MouseAction(const BMessage* message,
BPoint point, int32 buttons,
int32 modifiers); int32 modifiers);
protected: protected:
@@ -120,7 +120,8 @@ WinDecorator::Draw()
click_type click_type
WinDecorator::Clicked(BPoint where, int32 buttons, int32 modifiers) WinDecorator::MouseAction(const BMessage* message, BPoint where, int32 buttons,
int32 modifiers)
{ {
if (!(fFlags & B_NOT_CLOSABLE) && fCloseRect.Contains(where)) if (!(fFlags & B_NOT_CLOSABLE) && fCloseRect.Contains(where))
return CLICK_CLOSE; return CLICK_CLOSE;
@@ -131,8 +132,8 @@ WinDecorator::Clicked(BPoint where, int32 buttons, int32 modifiers)
// Clicking in the tab? // Clicking in the tab?
if (fTabRect.Contains(where)) { if (fTabRect.Contains(where)) {
// Here's part of our window management stuff // Here's part of our window management stuff
/* TODO This is missing CLICK_MOVETOFRONT /* TODO: This is missing CLICK_MOVETOFRONT
if(buttons==B_PRIMARY_MOUSE_BUTTON && !IsFocus()) if(buttons == B_PRIMARY_MOUSE_BUTTON && !IsFocus())
return CLICK_MOVETOFRONT; return CLICK_MOVETOFRONT;
*/ */
return CLICK_DRAG; return CLICK_DRAG;
@@ -1,29 +1,28 @@
/* /*
Copyright 2009-2010, Haiku. * Copyright 2009-2010, Haiku.
Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
#ifndef _BEOS_DECORATOR_H_ #ifndef _WINDOWS_DECORATOR_H_
#define _BEOS_DECORATOR_H_ #define _WINDOWS_DECORATOR_H_
#include "DecorManager.h" #include "DecorManager.h"
#include "RGBColor.h" #include "RGBColor.h"
class WinDecorAddOn : public DecorAddOn class WinDecorAddOn : public DecorAddOn {
{
public: public:
WinDecorAddOn(image_id id, const char* name); WinDecorAddOn(image_id id, const char* name);
float Version(); float Version();
protected: protected:
virtual Decorator* _AllocateDecorator(DesktopSettings& settings, virtual Decorator* _AllocateDecorator(DesktopSettings& settings,
BRect rect, window_look look, uint32 flags); BRect rect, window_look look, uint32 flags);
}; };
class WinDecorator: public Decorator class WinDecorator: public Decorator {
{
public: public:
WinDecorator(DesktopSettings& settings, WinDecorator(DesktopSettings& settings,
BRect frame, window_look wlook, BRect frame, window_look wlook,
@@ -33,7 +32,8 @@ public:
void Draw(BRect r); void Draw(BRect r);
void Draw(); void Draw();
click_type Clicked(BPoint pt, int32 buttons, click_type MouseAction(const BMessage* message,
BPoint point, int32 buttons,
int32 modifiers); int32 modifiers);
protected: protected:
@@ -70,27 +70,28 @@ private:
void _UpdateFont(DesktopSettings& settings); void _UpdateFont(DesktopSettings& settings);
void _DrawBeveledRect(BRect r, bool down); void _DrawBeveledRect(BRect r, bool down);
private:
uint32 taboffset; uint32 taboffset;
rgb_color tab_highcol; rgb_color tab_highcol;
rgb_color tab_lowcol; rgb_color tab_lowcol;
rgb_color frame_highcol; rgb_color frame_highcol;
rgb_color frame_midcol; rgb_color frame_midcol;
rgb_color frame_lowcol; rgb_color frame_lowcol;
rgb_color frame_lowercol; rgb_color frame_lowercol;
rgb_color textcol; rgb_color textcol;
rgb_color fFocusTabColor; rgb_color fFocusTabColor;
rgb_color fNonFocusTabColor; rgb_color fNonFocusTabColor;
rgb_color fFocusTextColor; rgb_color fFocusTextColor;
rgb_color fNonFocusTextColor; rgb_color fNonFocusTextColor;
uint64 solidhigh, solidlow; uint64 solidhigh, solidlow;
BString fTruncatedTitle; BString fTruncatedTitle;
int32 fTruncatedTitleLength; int32 fTruncatedTitleLength;
bool slidetab; bool slidetab;
int textoffset; int textoffset;
}; };
#endif
#endif // _WINDOWS_DECORATOR_H_
+23 -20
View File
@@ -8,8 +8,10 @@
* Clemens Zeidler <haiku@clemens-zeidler.de> * Clemens Zeidler <haiku@clemens-zeidler.de>
*/ */
/*! Base class for window decorators */ /*! Base class for window decorators */
#include "Decorator.h" #include "Decorator.h"
#include <stdio.h> #include <stdio.h>
@@ -315,38 +317,39 @@ Decorator::GetFootprint()
/*! \brief Performs hit-testing for the decorator /*! \brief Performs hit-testing for the decorator
Clicked is called whenever it has been determined that the window has Clicked is called whenever it has been determined that the window has
received a mouse click. The default version returns DEC_NONE. A subclass received a mouse click. The default version returns CLICK_NONE. A subclass
may use any or all of them. may use any or all of them.
Click type : Action taken by the server Click type : Action taken by the server
- \c DEC_NONE : Do nothing - \c CLICK_NONE: Do nothing
- \c DEC_ZOOM : Handles the zoom button (setting states, etc) - \c CLICK_ZOOM: Handles the zoom button (setting states, etc)
- \c DEC_CLOSE : Handles the close button (setting states, etc) - \c CLICK_CLOSE: Handles the close button (setting states, etc)
- \c DEC_MINIMIZE : Handles the minimize button (setting states, etc) - \c CLICK_MINIMIZE: Handles the minimize button (setting states, etc)
- \c DEC_TAB : Currently unused - \c CLICK_TAB: Currently unused
- \c DEC_DRAG : Moves the window to the front and prepares to move the - \c CLICK_DRAG: Moves the window to the front and prepares to move the
window window
- \c DEC_MOVETOBACK : Moves the window to the back of the stack - \c CLICK_MOVE_TO_BACK: Moves the window to the back of the stack
- \c DEC_MOVETOFRONT : Moves the window to the front of the stack - \c CLICK_MOVE_TO_FRONT: Moves the window to the front of the stack
- \c DEC_SLIDETAB : Initiates tab-sliding - \c CLICK_SLIDE_TAB: Initiates tab-sliding
- \c DEC_RESIZE : Handle window resizing as appropriate - \c CLICK_RESIZE: Handle window resizing as appropriate
- \c DEC_RESIZE_L - \c CLICK_RESIZE_L
- \c DEC_RESIZE_T - \c CLICK_RESIZE_T
- \c DEC_RESIZE_R - \c CLICK_RESIZE_R
- \c DEC_RESIZE_B - \c CLICK_RESIZE_B
- \c DEC_RESIZE_LT - \c CLICK_RESIZE_LT
- \c DEC_RESIZE_RT - \c CLICK_RESIZE_RT
- \c DEC_RESIZE_LB - \c CLICK_RESIZE_LB
- \c DEC_RESIZE_RB - \c CLICK_RESIZE_RB
This function is required by all subclasses. This function is required by all subclasses.
\return The type of area clicked \return The type of area clicked
*/ */
click_type click_type
Decorator::Clicked(BPoint point, int32 buttons, int32 modifiers) Decorator::MouseAction(const BMessage* message, BPoint point, int32 buttons,
int32 modifiers)
{ {
return CLICK_NONE; return CLICK_NONE;
} }
+2 -2
View File
@@ -91,8 +91,8 @@ public:
const BRegion& GetFootprint(); const BRegion& GetFootprint();
virtual click_type Clicked(BPoint where, int32 buttons, virtual click_type MouseAction(const BMessage* message, BPoint where,
int32 modifiers); int32 buttons, int32 modifiers);
void MoveBy(float x, float y); void MoveBy(float x, float y);
void MoveBy(BPoint offset); void MoveBy(BPoint offset);
+12 -14
View File
@@ -66,13 +66,12 @@ blend_color_value(uint8 a, uint8 b, float position)
// TODO: get rid of DesktopSettings here, and introduce private accessor // TODO: get rid of DesktopSettings here, and introduce private accessor
// methods to the Decorator base class // methods to the Decorator base class
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),
fTabOffset(0), fTabOffset(0),
fTabLocation(0.0), fTabLocation(0.0),
fLastClicked(0) fWasDoubleClick(false)
{ {
_UpdateFont(settings); _UpdateFont(settings);
@@ -182,7 +181,8 @@ DefaultDecorator::GetSizeLimits(int32* minWidth, int32* minHeight,
click_type click_type
DefaultDecorator::Clicked(BPoint point, int32 buttons, int32 modifiers) DefaultDecorator::MouseAction(const BMessage* message, BPoint point,
int32 buttons, int32 modifiers)
{ {
#ifdef DEBUG_DECORATOR #ifdef DEBUG_DECORATOR
printf("DefaultDecorator: Clicked\n"); printf("DefaultDecorator: Clicked\n");
@@ -190,13 +190,8 @@ DefaultDecorator::Clicked(BPoint point, 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 if (buttons != 0)
// account fWasDoubleClick = message->FindInt32("clicks") == 2;
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 // 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 // the user might be clicking on and gradually work our way out into larger
@@ -218,7 +213,7 @@ DefaultDecorator::Clicked(BPoint point, int32 buttons, int32 modifiers)
// 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) != 0 && fLook != kLeftTitledWindowLook)
return CLICK_SLIDE_TAB; return CLICK_SLIDE_TAB;
} else if (fLeftBorder.Contains(point) || fRightBorder.Contains(point) } else if (fLeftBorder.Contains(point) || fRightBorder.Contains(point)
|| fTopBorder.Contains(point) || fBottomBorder.Contains(point)) { || fTopBorder.Contains(point) || fBottomBorder.Contains(point)) {
@@ -230,9 +225,10 @@ 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 - kBorderResizeLength, BRect resizeRect(BPoint(fBottomBorder.right - kBorderResizeLength,
fBottomBorder.bottom - kBorderResizeLength), fBottomBorder.RightBottom()); fBottomBorder.bottom - kBorderResizeLength),
if (temp.Contains(point)) fBottomBorder.RightBottom());
if (resizeRect.Contains(point))
return CLICK_RESIZE; return CLICK_RESIZE;
} }
} else { } else {
@@ -240,6 +236,8 @@ DefaultDecorator::Clicked(BPoint point, int32 buttons, int32 modifiers)
return CLICK_NONE; return CLICK_NONE;
} }
// Either tab or border was clicked
if (fWasDoubleClick && !(fFlags & B_NOT_MINIMIZABLE)) if (fWasDoubleClick && !(fFlags & B_NOT_MINIMIZABLE))
return CLICK_MINIMIZE; return CLICK_MINIMIZE;
+3 -2
View File
@@ -37,7 +37,8 @@ public:
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 click_type Clicked(BPoint pt, int32 buttons, virtual click_type MouseAction(const BMessage* message,
BPoint point, int32 buttons,
int32 modifiers); int32 modifiers);
protected: protected:
@@ -132,8 +133,8 @@ protected:
int32 fTruncatedTitleLength; int32 fTruncatedTitleLength;
private: private:
bigtime_t fLastClicked;
bool fWasDoubleClick; bool fWasDoubleClick;
}; };
#endif // DEFAULT_DECORATOR_H #endif // DEFAULT_DECORATOR_H
+9 -9
View File
@@ -302,7 +302,7 @@ DefaultWindowBehaviour::MouseMoved(BMessage *message, BPoint where, bool isFake)
fLastMoveTime = now; fLastMoveTime = now;
} }
if (decorator) { if (decorator != NULL) {
BRegion* visibleBorder = fWindow->RegionPool()->GetRegion(); BRegion* visibleBorder = fWindow->RegionPool()->GetRegion();
fWindow->GetBorderRegion(visibleBorder); fWindow->GetBorderRegion(visibleBorder);
visibleBorder->IntersectWith(&fWindow->VisibleRegion()); visibleBorder->IntersectWith(&fWindow->VisibleRegion());
@@ -311,13 +311,13 @@ DefaultWindowBehaviour::MouseMoved(BMessage *message, BPoint where, bool isFake)
engine->LockParallelAccess(); engine->LockParallelAccess();
engine->ConstrainClippingRegion(visibleBorder); engine->ConstrainClippingRegion(visibleBorder);
if (fIsZooming) { click_type type = _ActionFor(message);
decorator->SetZoom(_ActionFor(message) == CLICK_ZOOM); if (fIsZooming)
} else if (fIsClosing) { decorator->SetZoom(type == CLICK_ZOOM);
decorator->SetClose(_ActionFor(message) == CLICK_CLOSE); else if (fIsClosing)
} else if (fIsMinimizing) { decorator->SetClose(type == CLICK_CLOSE);
decorator->SetMinimize(_ActionFor(message) == CLICK_MINIMIZE); else if (fIsMinimizing)
} decorator->SetMinimize(type == CLICK_MINIMIZE);
engine->UnlockParallelAccess(); engine->UnlockParallelAccess();
fWindow->RegionPool()->Recycle(visibleBorder); fWindow->RegionPool()->Recycle(visibleBorder);
@@ -445,7 +445,7 @@ DefaultWindowBehaviour::_ActionFor(const BMessage* message, int32 buttons,
if (message->FindPoint("where", &where) != B_OK) if (message->FindPoint("where", &where) != B_OK)
return CLICK_NONE; return CLICK_NONE;
return decorator->Clicked(where, buttons, modifiers); return decorator->MouseAction(message, where, buttons, modifiers);
} }