* Removed click_type enum. Introduced a private Action enum in
DefaultWindowBehavior instead. DefaultDecorator uses the more appropriate Decorator::Region. * DefaultWindowBehavior::MouseTrackingState: Generalized the fActivateOnMouseUp handling. It is now named fWindowActionOnMouseUp and the virtual method MouseUpWindowAction() is called. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39614 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -25,28 +25,6 @@ class ServerFont;
|
||||
class BRegion;
|
||||
|
||||
|
||||
enum click_type {
|
||||
CLICK_NONE = 0,
|
||||
CLICK_ZOOM,
|
||||
CLICK_CLOSE,
|
||||
CLICK_MINIMIZE,
|
||||
CLICK_TAB,
|
||||
CLICK_DRAG,
|
||||
CLICK_MOVE_TO_BACK,
|
||||
CLICK_SLIDE_TAB,
|
||||
|
||||
CLICK_RESIZE,
|
||||
CLICK_RESIZE_L,
|
||||
CLICK_RESIZE_T,
|
||||
CLICK_RESIZE_R,
|
||||
CLICK_RESIZE_B,
|
||||
CLICK_RESIZE_LT,
|
||||
CLICK_RESIZE_RT,
|
||||
CLICK_RESIZE_LB,
|
||||
CLICK_RESIZE_RB
|
||||
};
|
||||
|
||||
|
||||
class Decorator {
|
||||
public:
|
||||
enum Region {
|
||||
|
||||
@@ -673,8 +673,8 @@ DefaultDecorator::_DrawClose(BRect rect)
|
||||
int32 index = (fButtonFocus ? 0 : 1) + (GetClose() ? 0 : 2);
|
||||
ServerBitmap* bitmap = fCloseBitmaps[index];
|
||||
if (bitmap == NULL) {
|
||||
bitmap = _GetBitmapForButton(CLICK_CLOSE, GetClose(), fButtonFocus,
|
||||
rect.IntegerWidth(), rect.IntegerHeight(), this);
|
||||
bitmap = _GetBitmapForButton(REGION_CLOSE_BUTTON, GetClose(),
|
||||
fButtonFocus, rect.IntegerWidth(), rect.IntegerHeight(), this);
|
||||
fCloseBitmaps[index] = bitmap;
|
||||
}
|
||||
|
||||
@@ -726,8 +726,8 @@ DefaultDecorator::_DrawZoom(BRect rect)
|
||||
int32 index = (fButtonFocus ? 0 : 1) + (GetZoom() ? 0 : 2);
|
||||
ServerBitmap* bitmap = fZoomBitmaps[index];
|
||||
if (bitmap == NULL) {
|
||||
bitmap = _GetBitmapForButton(CLICK_ZOOM, GetZoom(), fButtonFocus,
|
||||
rect.IntegerWidth(), rect.IntegerHeight(), this);
|
||||
bitmap = _GetBitmapForButton(REGION_ZOOM_BUTTON, GetZoom(),
|
||||
fButtonFocus, rect.IntegerWidth(), rect.IntegerHeight(), this);
|
||||
fZoomBitmaps[index] = bitmap;
|
||||
}
|
||||
|
||||
@@ -1247,7 +1247,7 @@ DefaultDecorator::_InvalidateBitmaps()
|
||||
|
||||
|
||||
ServerBitmap*
|
||||
DefaultDecorator::_GetBitmapForButton(int32 item, bool down, bool focus,
|
||||
DefaultDecorator::_GetBitmapForButton(Region item, bool down, bool focus,
|
||||
int32 width, int32 height, DefaultDecorator* object)
|
||||
{
|
||||
// TODO: the list of shared bitmaps is never freed
|
||||
@@ -1294,14 +1294,14 @@ DefaultDecorator::_GetBitmapForButton(int32 item, bool down, bool focus,
|
||||
BRect rect(0, 0, width - 1, height - 1);
|
||||
|
||||
STRACE(("DefaultDecorator creating bitmap for %s %sfocus %s at size %ldx%ld\n",
|
||||
item == CLICK_CLOSE ? "close" : "zoom", focus ? "" : "non-",
|
||||
item == REGION_CLOSE_BUTTON ? "close" : "zoom", focus ? "" : "non-",
|
||||
down ? "down" : "up", width, height));
|
||||
switch (item) {
|
||||
case CLICK_CLOSE:
|
||||
case REGION_CLOSE_BUTTON:
|
||||
object->_DrawBlendedRect(sBitmapDrawingEngine, rect, down, focus);
|
||||
break;
|
||||
|
||||
case CLICK_ZOOM:
|
||||
case REGION_ZOOM_BUTTON:
|
||||
{
|
||||
// init the background
|
||||
sBitmapDrawingEngine->FillRect(rect, B_TRANSPARENT_COLOR);
|
||||
@@ -1321,6 +1321,9 @@ DefaultDecorator::_GetBitmapForButton(int32 item, bool down, bool focus,
|
||||
down, focus);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
UtilityBitmap* bitmap = sBitmapDrawingEngine->ExportToBitmap(width, height,
|
||||
|
||||
@@ -89,7 +89,7 @@ private:
|
||||
BRect rect, bool down, bool focus);
|
||||
void _LayoutTabItems(const BRect& tabRect);
|
||||
void _InvalidateBitmaps();
|
||||
static ServerBitmap* _GetBitmapForButton(int32 item, bool down,
|
||||
static ServerBitmap* _GetBitmapForButton(Region item, bool down,
|
||||
bool focus, int32 width, int32 height,
|
||||
DefaultDecorator* object);
|
||||
|
||||
|
||||
@@ -92,10 +92,10 @@ protected:
|
||||
|
||||
struct DefaultWindowBehaviour::MouseTrackingState : State {
|
||||
MouseTrackingState(DefaultWindowBehaviour& behavior, BPoint where,
|
||||
bool activateOnMouseUp, bool minimizeCheckOnMouseUp)
|
||||
bool windowActionOnMouseUp, bool minimizeCheckOnMouseUp)
|
||||
:
|
||||
State(behavior),
|
||||
fActivateOnMouseUp(activateOnMouseUp),
|
||||
fWindowActionOnMouseUp(windowActionOnMouseUp),
|
||||
fMinimizeCheckOnMouseUp(minimizeCheckOnMouseUp),
|
||||
fLastMousePosition(where),
|
||||
fMouseMoveDistance(0),
|
||||
@@ -122,14 +122,12 @@ struct DefaultWindowBehaviour::MouseTrackingState : State {
|
||||
}
|
||||
}
|
||||
|
||||
// In FFM mode, activate the window and bring it to front in case
|
||||
// this was a drag click but the mouse was not moved.
|
||||
if (fActivateOnMouseUp) {
|
||||
fActivateOnMouseUp = false;
|
||||
// on R5, there is a time window for this feature
|
||||
// ie, click and press too long, nothing will happen
|
||||
// Perform the window action in case the mouse was not moved.
|
||||
if (fWindowActionOnMouseUp) {
|
||||
// There is a time window for this feature, i.e. click and press
|
||||
// too long, nothing will happen.
|
||||
if (system_time() - fLastMoveTime < kWindowActivationTimeout)
|
||||
fDesktop->ActivateWindow(fWindow);
|
||||
MouseUpWindowAction();
|
||||
}
|
||||
|
||||
fBehavior._NextState(NULL);
|
||||
@@ -146,11 +144,11 @@ struct DefaultWindowBehaviour::MouseTrackingState : State {
|
||||
// the then current mouse position
|
||||
return;
|
||||
}
|
||||
if (fActivateOnMouseUp || fMinimizeCheckOnMouseUp) {
|
||||
if (fWindowActionOnMouseUp || fMinimizeCheckOnMouseUp) {
|
||||
if (now - fLastMoveTime >= kWindowActivationTimeout) {
|
||||
// This click is too long already for window activation/
|
||||
// minimizing.
|
||||
fActivateOnMouseUp = false;
|
||||
fWindowActionOnMouseUp = false;
|
||||
fMinimizeCheckOnMouseUp = false;
|
||||
fLastMoveTime = now;
|
||||
}
|
||||
@@ -168,10 +166,10 @@ struct DefaultWindowBehaviour::MouseTrackingState : State {
|
||||
|
||||
// If the window was moved enough, it doesn't come to
|
||||
// the front in FFM mode when the mouse is released.
|
||||
if (fActivateOnMouseUp || fMinimizeCheckOnMouseUp) {
|
||||
if (fWindowActionOnMouseUp || fMinimizeCheckOnMouseUp) {
|
||||
fMouseMoveDistance += delta.x * delta.x + delta.y * delta.y;
|
||||
if (fMouseMoveDistance > 16.0f) {
|
||||
fActivateOnMouseUp = false;
|
||||
fWindowActionOnMouseUp = false;
|
||||
fMinimizeCheckOnMouseUp = false;
|
||||
} else
|
||||
delta = B_ORIGIN;
|
||||
@@ -187,10 +185,18 @@ struct DefaultWindowBehaviour::MouseTrackingState : State {
|
||||
UpdateFFMFocus(isFake);
|
||||
}
|
||||
|
||||
virtual void MouseMovedAction(BPoint& delta, bigtime_t now) = 0;
|
||||
virtual void MouseMovedAction(BPoint& delta, bigtime_t now)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void MouseUpWindowAction()
|
||||
{
|
||||
// default is window activation
|
||||
fDesktop->ActivateWindow(fWindow);
|
||||
}
|
||||
|
||||
protected:
|
||||
bool fActivateOnMouseUp : 1;
|
||||
bool fWindowActionOnMouseUp : 1;
|
||||
bool fMinimizeCheckOnMouseUp : 1;
|
||||
|
||||
BPoint fLastMousePosition;
|
||||
@@ -538,7 +544,7 @@ DefaultWindowBehaviour::MouseDown(BMessage* message, BPoint where)
|
||||
Decorator* decorator = fWindow->Decorator();
|
||||
|
||||
Region hitRegion = REGION_NONE;
|
||||
click_type action = CLICK_NONE;
|
||||
Action action = ACTION_NONE;
|
||||
|
||||
bool inBorderRegion = false;
|
||||
if (decorator != NULL)
|
||||
@@ -575,48 +581,48 @@ DefaultWindowBehaviour::MouseDown(BMessage* message, BPoint where)
|
||||
// strange
|
||||
if (leftButton && (modifiers & B_SHIFT_KEY) != 0
|
||||
&& fWindow->Look() != kLeftTitledWindowLook) {
|
||||
action = CLICK_SLIDE_TAB;
|
||||
action = ACTION_SLIDE_TAB;
|
||||
break;
|
||||
}
|
||||
// otherwise fall through -- same handling as for the border...
|
||||
|
||||
case REGION_BORDER:
|
||||
if (leftButton)
|
||||
action = CLICK_DRAG;
|
||||
action = ACTION_DRAG;
|
||||
else if (rightButton)
|
||||
action = CLICK_MOVE_TO_BACK;
|
||||
action = ACTION_RESIZE_BORDER;
|
||||
break;
|
||||
|
||||
case REGION_CLOSE_BUTTON:
|
||||
if (leftButton) {
|
||||
action = (flags & B_NOT_CLOSABLE) == 0
|
||||
? CLICK_CLOSE : CLICK_DRAG;
|
||||
? ACTION_CLOSE : ACTION_DRAG;
|
||||
} else if (rightButton)
|
||||
action = CLICK_MOVE_TO_BACK;
|
||||
action = ACTION_RESIZE_BORDER;
|
||||
break;
|
||||
|
||||
case REGION_ZOOM_BUTTON:
|
||||
if (leftButton) {
|
||||
action = (flags & B_NOT_ZOOMABLE) == 0
|
||||
? CLICK_ZOOM : CLICK_DRAG;
|
||||
? ACTION_ZOOM : ACTION_DRAG;
|
||||
} else if (rightButton)
|
||||
action = CLICK_MOVE_TO_BACK;
|
||||
action = ACTION_RESIZE_BORDER;
|
||||
break;
|
||||
|
||||
case REGION_MINIMIZE_BUTTON:
|
||||
if (leftButton) {
|
||||
action = (flags & B_NOT_MINIMIZABLE) == 0
|
||||
? CLICK_MINIMIZE : CLICK_DRAG;
|
||||
? ACTION_MINIMIZE : ACTION_DRAG;
|
||||
} else if (rightButton)
|
||||
action = CLICK_MOVE_TO_BACK;
|
||||
action = ACTION_RESIZE_BORDER;
|
||||
break;
|
||||
|
||||
case REGION_RESIZE_CORNER:
|
||||
if (leftButton) {
|
||||
action = (flags & B_NOT_RESIZABLE) == 0
|
||||
? CLICK_RESIZE : CLICK_DRAG;
|
||||
? ACTION_RESIZE : ACTION_DRAG;
|
||||
} else if (rightButton)
|
||||
action = CLICK_MOVE_TO_BACK;
|
||||
action = ACTION_RESIZE_BORDER;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -631,7 +637,7 @@ DefaultWindowBehaviour::MouseDown(BMessage* message, BPoint where)
|
||||
fResetClickCount = 0;
|
||||
}
|
||||
|
||||
if (action == CLICK_NONE) {
|
||||
if (action == ACTION_NONE) {
|
||||
// No action -- if this is a click inside the window's contents,
|
||||
// let it be forwarded to the window.
|
||||
return inBorderRegion;
|
||||
@@ -642,13 +648,13 @@ DefaultWindowBehaviour::MouseDown(BMessage* message, BPoint where)
|
||||
// Ignore clicks on decorator buttons if the
|
||||
// non-floating window doesn't have focus
|
||||
if (!fWindow->IsFocus() && !fWindow->IsFloating()
|
||||
&& action != CLICK_MOVE_TO_BACK
|
||||
&& action != CLICK_RESIZE && action != CLICK_SLIDE_TAB)
|
||||
action = CLICK_DRAG;
|
||||
&& action != ACTION_RESIZE_BORDER
|
||||
&& action != ACTION_RESIZE && action != ACTION_SLIDE_TAB)
|
||||
action = ACTION_DRAG;
|
||||
}
|
||||
|
||||
bool activateOnMouseUp = false;
|
||||
if (action != CLICK_MOVE_TO_BACK) {
|
||||
if (action != ACTION_RESIZE_BORDER) {
|
||||
// activate window if in click to activate mode, else only focus it
|
||||
if (desktopSettings.MouseMode() == B_NORMAL_MOUSE) {
|
||||
fDesktop->ActivateWindow(fWindow);
|
||||
@@ -660,34 +666,34 @@ DefaultWindowBehaviour::MouseDown(BMessage* message, BPoint where)
|
||||
|
||||
// switch to the new state
|
||||
switch (action) {
|
||||
case CLICK_CLOSE:
|
||||
case CLICK_ZOOM:
|
||||
case CLICK_MINIMIZE:
|
||||
case ACTION_CLOSE:
|
||||
case ACTION_ZOOM:
|
||||
case ACTION_MINIMIZE:
|
||||
_NextState(
|
||||
new (std::nothrow) DecoratorButtonState(*this, hitRegion));
|
||||
STRACE_CLICK(("===> CLICK_CLOSE/ZOOM/MINIMIZE\n"));
|
||||
STRACE_CLICK(("===> ACTION_CLOSE/ZOOM/MINIMIZE\n"));
|
||||
break;
|
||||
|
||||
case CLICK_DRAG:
|
||||
case ACTION_DRAG:
|
||||
_NextState(new (std::nothrow) DragState(*this, where,
|
||||
activateOnMouseUp, clickCount == 2));
|
||||
STRACE_CLICK(("===> CLICK_DRAG\n"));
|
||||
STRACE_CLICK(("===> ACTION_DRAG\n"));
|
||||
break;
|
||||
|
||||
case CLICK_RESIZE:
|
||||
case ACTION_RESIZE:
|
||||
_NextState(new (std::nothrow) ResizeState(*this, where,
|
||||
activateOnMouseUp));
|
||||
STRACE_CLICK(("===> CLICK_RESIZE\n"));
|
||||
STRACE_CLICK(("===> ACTION_RESIZE\n"));
|
||||
break;
|
||||
|
||||
case CLICK_SLIDE_TAB:
|
||||
case ACTION_SLIDE_TAB:
|
||||
_NextState(new (std::nothrow) SlideTabState(*this, where));
|
||||
STRACE_CLICK(("===> CLICK_SLIDE_TAB\n"));
|
||||
STRACE_CLICK(("===> ACTION_SLIDE_TAB\n"));
|
||||
break;
|
||||
|
||||
case CLICK_MOVE_TO_BACK:
|
||||
case ACTION_RESIZE_BORDER:
|
||||
fDesktop->SendWindowBehind(fWindow);
|
||||
STRACE_CLICK(("===> CLICK_MOVE_TO_BACK\n"));
|
||||
STRACE_CLICK(("===> ACTION_RESIZE_BORDER\n"));
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
@@ -48,6 +48,18 @@ private:
|
||||
REGION_RESIZE_CORNER
|
||||
};
|
||||
|
||||
enum Action {
|
||||
ACTION_NONE,
|
||||
ACTION_ZOOM,
|
||||
ACTION_CLOSE,
|
||||
ACTION_MINIMIZE,
|
||||
ACTION_TAB,
|
||||
ACTION_DRAG,
|
||||
ACTION_SLIDE_TAB,
|
||||
ACTION_RESIZE,
|
||||
ACTION_RESIZE_BORDER
|
||||
};
|
||||
|
||||
struct State;
|
||||
struct MouseTrackingState;
|
||||
struct DragState;
|
||||
|
||||
Reference in New Issue
Block a user