* 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

View File

@ -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"
@ -117,7 +117,7 @@ BeDecorator::BeDecorator(DesktopSettings& settings, BRect rect,
Decorator(settings, rect, look, flags),
fTabOffset(0),
fTabLocation(0.0),
fLastClicked(0)
fWasDoubleClick(false)
{
_UpdateFont(settings);
SetLook(settings, look);
@ -215,7 +215,8 @@ BeDecorator::GetSizeLimits(int32* minWidth, int32* minHeight,
click_type
BeDecorator::Clicked(BPoint point, int32 buttons, int32 modifiers)
BeDecorator::MouseAction(const BMessage* message, BPoint point, int32 buttons,
int32 modifiers)
{
#ifdef DEBUG_DECORATOR
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);
#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;
}
if (buttons != 0)
fWasDoubleClick = message->FindInt32("clicks") == 2;
// 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
@ -263,9 +259,10 @@ BeDecorator::Clicked(BPoint point, int32 buttons, int32 modifiers)
|| fLook == B_FLOATING_WINDOW_LOOK
|| fLook == B_MODAL_WINDOW_LOOK
|| fLook == kLeftTitledWindowLook)) {
BRect temp(BPoint(fBottomBorder.right - kBorderResizeLength,
fBottomBorder.bottom - kBorderResizeLength), fBottomBorder.RightBottom());
if (temp.Contains(point))
BRect resizeRect(BPoint(fBottomBorder.right - kBorderResizeLength,
fBottomBorder.bottom - kBorderResizeLength),
fBottomBorder.RightBottom());
if (resizeRect.Contains(point))
return CLICK_RESIZE;
}

View File

@ -24,7 +24,8 @@ class BeDecorAddOn : public DecorAddOn {
public:
BeDecorAddOn(image_id id, const char* name);
float Version();
float Version();
protected:
virtual Decorator* _AllocateDecorator(DesktopSettings& settings,
BRect rect, window_look look, uint32 flags);
@ -49,8 +50,9 @@ public:
virtual void GetSizeLimits(int32* minWidth, int32* minHeight,
int32* maxWidth, int32* maxHeight) const;
virtual click_type Clicked(BPoint pt, int32 buttons,
int32 modifiers);
virtual click_type MouseAction(const BMessage* message,
BPoint pointt, int32 buttons,
int32 modifiers);
protected:
virtual void _DoLayout();
@ -94,6 +96,7 @@ private:
float* offset, float*size) const;
void _LayoutTabItems(const BRect& tabRect);
private:
RGBColor fButtonHighColor;
RGBColor fButtonLowColor;
RGBColor fTextColor;
@ -118,9 +121,9 @@ private:
float fMaxTabSize;
BString fTruncatedTitle;
int32 fTruncatedTitleLength;
bigtime_t fLastClicked;
bool fWasDoubleClick;
};
#endif // DEFAULT_DECORATOR_H

View File

@ -118,7 +118,8 @@ MacDecorator::Draw()
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)) {
STRACE(("MacDecorator():Clicked() - Close\n"));
@ -133,8 +134,8 @@ MacDecorator::Clicked(BPoint point, int32 buttons, int32 modifiers)
// Clicking in the tab?
if (fTabRect.Contains(point)) {
// Here's part of our window management stuff
/* TODO This is missing CLICK_MOVETOFRONT
if(buttons==B_PRIMARY_MOUSE_BUTTON && !IsFocus())
/* TODO: This is missing CLICK_MOVETOFRONT
if(buttons == B_PRIMARY_MOUSE_BUTTON && !IsFocus())
return CLICK_MOVETOFRONT;
*/
return CLICK_DRAG;

View File

@ -1,7 +1,7 @@
/*
Copyright 2009, Haiku.
Distributed under the terms of the MIT License.
*/
* Copyright 2009-2010, Haiku.
* Distributed under the terms of the MIT License.
*/
#ifndef _MAC_DECORATOR_H_
#define _MAC_DECORATOR_H_
@ -10,12 +10,12 @@
#include "RGBColor.h"
class MacDecorAddOn : public DecorAddOn
{
class MacDecorAddOn : public DecorAddOn {
public:
MacDecorAddOn(image_id id, const char* name);
float Version();
float Version();
protected:
virtual Decorator* _AllocateDecorator(DesktopSettings& settings,
BRect rect, window_look look, uint32 flags);
@ -32,7 +32,8 @@ public:
void Draw(BRect updateRect);
void Draw();
click_type Clicked(BPoint pt, int32 buttons,
click_type MouseAction(const BMessage* message,
BPoint point, int32 buttons,
int32 modifiers);
protected:

View File

@ -120,7 +120,8 @@ WinDecorator::Draw()
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))
return CLICK_CLOSE;
@ -131,8 +132,8 @@ WinDecorator::Clicked(BPoint where, int32 buttons, int32 modifiers)
// Clicking in the tab?
if (fTabRect.Contains(where)) {
// Here's part of our window management stuff
/* TODO This is missing CLICK_MOVETOFRONT
if(buttons==B_PRIMARY_MOUSE_BUTTON && !IsFocus())
/* TODO: This is missing CLICK_MOVETOFRONT
if(buttons == B_PRIMARY_MOUSE_BUTTON && !IsFocus())
return CLICK_MOVETOFRONT;
*/
return CLICK_DRAG;

View File

@ -1,29 +1,28 @@
/*
Copyright 2009-2010, Haiku.
Distributed under the terms of the MIT License.
*/
#ifndef _BEOS_DECORATOR_H_
#define _BEOS_DECORATOR_H_
* Copyright 2009-2010, Haiku.
* Distributed under the terms of the MIT License.
*/
#ifndef _WINDOWS_DECORATOR_H_
#define _WINDOWS_DECORATOR_H_
#include "DecorManager.h"
#include "RGBColor.h"
class WinDecorAddOn : public DecorAddOn
{
class WinDecorAddOn : public DecorAddOn {
public:
WinDecorAddOn(image_id id, const char* name);
float Version();
float Version();
protected:
virtual Decorator* _AllocateDecorator(DesktopSettings& settings,
BRect rect, window_look look, uint32 flags);
};
class WinDecorator: public Decorator
{
class WinDecorator: public Decorator {
public:
WinDecorator(DesktopSettings& settings,
BRect frame, window_look wlook,
@ -33,7 +32,8 @@ public:
void Draw(BRect r);
void Draw();
click_type Clicked(BPoint pt, int32 buttons,
click_type MouseAction(const BMessage* message,
BPoint point, int32 buttons,
int32 modifiers);
protected:
@ -70,27 +70,28 @@ private:
void _UpdateFont(DesktopSettings& settings);
void _DrawBeveledRect(BRect r, bool down);
uint32 taboffset;
rgb_color tab_highcol;
rgb_color tab_lowcol;
rgb_color frame_highcol;
rgb_color frame_midcol;
rgb_color frame_lowcol;
rgb_color frame_lowercol;
rgb_color textcol;
rgb_color fFocusTabColor;
rgb_color fNonFocusTabColor;
rgb_color fFocusTextColor;
rgb_color fNonFocusTextColor;
uint64 solidhigh, solidlow;
BString fTruncatedTitle;
int32 fTruncatedTitleLength;
bool slidetab;
int textoffset;
private:
uint32 taboffset;
rgb_color tab_highcol;
rgb_color tab_lowcol;
rgb_color frame_highcol;
rgb_color frame_midcol;
rgb_color frame_lowcol;
rgb_color frame_lowercol;
rgb_color textcol;
rgb_color fFocusTabColor;
rgb_color fNonFocusTabColor;
rgb_color fFocusTextColor;
rgb_color fNonFocusTextColor;
uint64 solidhigh, solidlow;
BString fTruncatedTitle;
int32 fTruncatedTitleLength;
bool slidetab;
int textoffset;
};
#endif
#endif // _WINDOWS_DECORATOR_H_

View File

@ -8,8 +8,10 @@
* Clemens Zeidler <haiku@clemens-zeidler.de>
*/
/*! Base class for window decorators */
#include "Decorator.h"
#include <stdio.h>
@ -315,38 +317,39 @@ Decorator::GetFootprint()
/*! \brief Performs hit-testing for the decorator
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.
Click type : Action taken by the server
- \c DEC_NONE : Do nothing
- \c DEC_ZOOM : Handles the zoom button (setting states, etc)
- \c DEC_CLOSE : Handles the close button (setting states, etc)
- \c DEC_MINIMIZE : Handles the minimize button (setting states, etc)
- \c DEC_TAB : Currently unused
- \c DEC_DRAG : Moves the window to the front and prepares to move the
- \c CLICK_NONE: Do nothing
- \c CLICK_ZOOM: Handles the zoom button (setting states, etc)
- \c CLICK_CLOSE: Handles the close button (setting states, etc)
- \c CLICK_MINIMIZE: Handles the minimize button (setting states, etc)
- \c CLICK_TAB: Currently unused
- \c CLICK_DRAG: Moves the window to the front and prepares to move the
window
- \c DEC_MOVETOBACK : Moves the window to the back of the stack
- \c DEC_MOVETOFRONT : Moves the window to the front of the stack
- \c DEC_SLIDETAB : Initiates tab-sliding
- \c CLICK_MOVE_TO_BACK: Moves the window to the back of the stack
- \c CLICK_MOVE_TO_FRONT: Moves the window to the front of the stack
- \c CLICK_SLIDE_TAB: Initiates tab-sliding
- \c DEC_RESIZE : Handle window resizing as appropriate
- \c DEC_RESIZE_L
- \c DEC_RESIZE_T
- \c DEC_RESIZE_R
- \c DEC_RESIZE_B
- \c DEC_RESIZE_LT
- \c DEC_RESIZE_RT
- \c DEC_RESIZE_LB
- \c DEC_RESIZE_RB
- \c CLICK_RESIZE: Handle window resizing as appropriate
- \c CLICK_RESIZE_L
- \c CLICK_RESIZE_T
- \c CLICK_RESIZE_R
- \c CLICK_RESIZE_B
- \c CLICK_RESIZE_LT
- \c CLICK_RESIZE_RT
- \c CLICK_RESIZE_LB
- \c CLICK_RESIZE_RB
This function is required by all subclasses.
\return The type of area clicked
*/
click_type
Decorator::Clicked(BPoint point, int32 buttons, int32 modifiers)
Decorator::MouseAction(const BMessage* message, BPoint point, int32 buttons,
int32 modifiers)
{
return CLICK_NONE;
}

View File

@ -91,8 +91,8 @@ public:
const BRegion& GetFootprint();
virtual click_type Clicked(BPoint where, int32 buttons,
int32 modifiers);
virtual click_type MouseAction(const BMessage* message, BPoint where,
int32 buttons, int32 modifiers);
void MoveBy(float x, float y);
void MoveBy(BPoint offset);

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
// methods to the Decorator base class
DefaultDecorator::DefaultDecorator(DesktopSettings& settings, BRect rect,
window_look look, uint32 flags)
: Decorator(settings, rect, look, flags),
fTabOffset(0),
fTabLocation(0.0),
fLastClicked(0)
fWasDoubleClick(false)
{
_UpdateFont(settings);
@ -182,7 +181,8 @@ DefaultDecorator::GetSizeLimits(int32* minWidth, int32* minHeight,
click_type
DefaultDecorator::Clicked(BPoint point, int32 buttons, int32 modifiers)
DefaultDecorator::MouseAction(const BMessage* message, BPoint point,
int32 buttons, int32 modifiers)
{
#ifdef DEBUG_DECORATOR
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);
#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;
}
if (buttons != 0)
fWasDoubleClick = message->FindInt32("clicks") == 2;
// 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
@ -218,7 +213,7 @@ DefaultDecorator::Clicked(BPoint point, int32 buttons, int32 modifiers)
// tab sliding in any case if either shift key is held down
// 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;
} else if (fLeftBorder.Contains(point) || fRightBorder.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_MODAL_WINDOW_LOOK
|| fLook == kLeftTitledWindowLook)) {
BRect temp(BPoint(fBottomBorder.right - kBorderResizeLength,
fBottomBorder.bottom - kBorderResizeLength), fBottomBorder.RightBottom());
if (temp.Contains(point))
BRect resizeRect(BPoint(fBottomBorder.right - kBorderResizeLength,
fBottomBorder.bottom - kBorderResizeLength),
fBottomBorder.RightBottom());
if (resizeRect.Contains(point))
return CLICK_RESIZE;
}
} else {
@ -240,6 +236,8 @@ DefaultDecorator::Clicked(BPoint point, int32 buttons, int32 modifiers)
return CLICK_NONE;
}
// Either tab or border was clicked
if (fWasDoubleClick && !(fFlags & B_NOT_MINIMIZABLE))
return CLICK_MINIMIZE;

View File

@ -37,7 +37,8 @@ public:
virtual void GetSizeLimits(int32* minWidth, int32* minHeight,
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);
protected:
@ -132,8 +133,8 @@ protected:
int32 fTruncatedTitleLength;
private:
bigtime_t fLastClicked;
bool fWasDoubleClick;
};
#endif // DEFAULT_DECORATOR_H

View File

@ -302,7 +302,7 @@ DefaultWindowBehaviour::MouseMoved(BMessage *message, BPoint where, bool isFake)
fLastMoveTime = now;
}
if (decorator) {
if (decorator != NULL) {
BRegion* visibleBorder = fWindow->RegionPool()->GetRegion();
fWindow->GetBorderRegion(visibleBorder);
visibleBorder->IntersectWith(&fWindow->VisibleRegion());
@ -311,13 +311,13 @@ DefaultWindowBehaviour::MouseMoved(BMessage *message, BPoint where, bool isFake)
engine->LockParallelAccess();
engine->ConstrainClippingRegion(visibleBorder);
if (fIsZooming) {
decorator->SetZoom(_ActionFor(message) == CLICK_ZOOM);
} else if (fIsClosing) {
decorator->SetClose(_ActionFor(message) == CLICK_CLOSE);
} else if (fIsMinimizing) {
decorator->SetMinimize(_ActionFor(message) == CLICK_MINIMIZE);
}
click_type type = _ActionFor(message);
if (fIsZooming)
decorator->SetZoom(type == CLICK_ZOOM);
else if (fIsClosing)
decorator->SetClose(type == CLICK_CLOSE);
else if (fIsMinimizing)
decorator->SetMinimize(type == CLICK_MINIMIZE);
engine->UnlockParallelAccess();
fWindow->RegionPool()->Recycle(visibleBorder);
@ -445,7 +445,7 @@ DefaultWindowBehaviour::_ActionFor(const BMessage* message, int32 buttons,
if (message->FindPoint("where", &where) != B_OK)
return CLICK_NONE;
return decorator->Clicked(where, buttons, modifiers);
return decorator->MouseAction(message, where, buttons, modifiers);
}