sorry, I couldn't resist...

* added a few very small changes to make the tab sliding work perfectly
* added a comment on the purpose of WindowLayer::fLastMousePosition and
  how it is supposed to be used to have the mouse cursor stick to what
  is being dragged
* TODO: the tab offset doesn't necessarily have to be on [0..1], as long
  as we update it during window resizing to keep the relative position


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17577 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus
2006-05-24 11:05:25 +00:00
parent 2af6c95389
commit 46fb2d73be
4 changed files with 25 additions and 8 deletions
+5
View File
@@ -343,11 +343,16 @@ DefaultDecorator::SetTabLocation(float location, BRegion* updateRegion)
STRACE(("DefaultDecorator: Set Tab Location(%.1f)\n", location)); STRACE(("DefaultDecorator: Set Tab Location(%.1f)\n", location));
if (!_tabrect.IsValid()) if (!_tabrect.IsValid())
return false; return false;
if (location < 0) if (location < 0)
location = 0; location = 0;
if (location > (fRightBorder.right - fLeftBorder.left - _tabrect.Width())) if (location > (fRightBorder.right - fLeftBorder.left - _tabrect.Width()))
location = (fRightBorder.right - fLeftBorder.left - _tabrect.Width()); location = (fRightBorder.right - fLeftBorder.left - _tabrect.Width());
float delta = location - fTabOffset; float delta = location - fTabOffset;
if (delta == 0.0)
return false;
// redraw old rect (1 pix on the border also must be updated) // redraw old rect (1 pix on the border also must be updated)
BRect trect(_tabrect); BRect trect(_tabrect);
trect.bottom++; trect.bottom++;
+6 -4
View File
@@ -1575,16 +1575,16 @@ Desktop::ResizeWindowBy(WindowLayer* window, float x, float y)
UnlockAllWindows(); UnlockAllWindows();
} }
void bool
Desktop::SetWindowTabLocation(WindowLayer* window, float location) Desktop::SetWindowTabLocation(WindowLayer* window, float location)
{ {
if (!LockAllWindows()) if (!LockAllWindows())
return; return false;
BRegion dirty; BRegion dirty;
window->SetTabLocation(location, dirty); bool changed = window->SetTabLocation(location, dirty);
if (window->IsVisible() && dirty.CountRects() > 0) { if (changed && window->IsVisible() && dirty.CountRects() > 0) {
BRegion stillAvailableOnScreen; BRegion stillAvailableOnScreen;
_RebuildClippingForAllWindows(stillAvailableOnScreen); _RebuildClippingForAllWindows(stillAvailableOnScreen);
_SetBackground(stillAvailableOnScreen); _SetBackground(stillAvailableOnScreen);
@@ -1593,6 +1593,8 @@ Desktop::SetWindowTabLocation(WindowLayer* window, float location)
} }
UnlockAllWindows(); UnlockAllWindows();
return changed;
} }
+1 -1
View File
@@ -111,7 +111,7 @@ class Desktop : public MessageLooper, public ScreenOwner {
void MoveWindowBy(WindowLayer* window, float x, float y, void MoveWindowBy(WindowLayer* window, float x, float y,
int32 workspace = -1); int32 workspace = -1);
void ResizeWindowBy(WindowLayer* window, float x, float y); void ResizeWindowBy(WindowLayer* window, float x, float y);
void SetWindowTabLocation(WindowLayer* window, float location); bool SetWindowTabLocation(WindowLayer* window, float location);
void SetWindowWorkspaces(WindowLayer* window, void SetWindowWorkspaces(WindowLayer* window,
uint32 workspaces); uint32 workspaces);
+13 -3
View File
@@ -975,6 +975,14 @@ WindowLayer::MouseMoved(BMessage *message, BPoint where, int32* _viewToken,
} }
BPoint delta = where - fLastMousePosition; BPoint delta = where - fLastMousePosition;
// NOTE: "delta" is later used to change fLastMousePosition.
// If for some reason no change should take effect, delta
// is to be set to (0, 0) so that fLastMousePosition is not
// adjusted. This way the relative mouse position to the
// item being changed (border during resizing, tab during
// sliding...) stays fixed when the mouse is moved so that
// changes are taking effect again.
// moving // moving
if (fIsDragging) { if (fIsDragging) {
if (!(Flags() & B_NOT_MOVABLE)) { if (!(Flags() & B_NOT_MOVABLE)) {
@@ -1009,8 +1017,10 @@ WindowLayer::MouseMoved(BMessage *message, BPoint where, int32* _viewToken,
float loc = TabLocation(); float loc = TabLocation();
// TODO: change to [0:1] // TODO: change to [0:1]
loc += delta.x; loc += delta.x;
fDesktop->SetWindowTabLocation(this, loc); if (fDesktop->SetWindowTabLocation(this, loc))
delta.y = 0; delta.y = 0;
else
delta = BPoint(0, 0);
} }
// NOTE: fLastMousePosition is currently only // NOTE: fLastMousePosition is currently only
@@ -1210,7 +1220,7 @@ WindowLayer::SetTabLocation(float location, BRegion& dirty)
bool ret = false; bool ret = false;
if (fDecorator) { if (fDecorator) {
ret = fDecorator->SetTabLocation(location, &dirty); ret = fDecorator->SetTabLocation(location, &dirty);
fBorderRegionValid = false; fBorderRegionValid = fBorderRegionValid && !ret;
// the border very likely changed // the border very likely changed
} }
return ret; return ret;