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

View File

@ -343,11 +343,16 @@ DefaultDecorator::SetTabLocation(float location, BRegion* updateRegion)
STRACE(("DefaultDecorator: Set Tab Location(%.1f)\n", location));
if (!_tabrect.IsValid())
return false;
if (location < 0)
location = 0;
if (location > (fRightBorder.right - fLeftBorder.left - _tabrect.Width()))
location = (fRightBorder.right - fLeftBorder.left - _tabrect.Width());
float delta = location - fTabOffset;
if (delta == 0.0)
return false;
// redraw old rect (1 pix on the border also must be updated)
BRect trect(_tabrect);
trect.bottom++;

View File

@ -1575,16 +1575,16 @@ Desktop::ResizeWindowBy(WindowLayer* window, float x, float y)
UnlockAllWindows();
}
void
bool
Desktop::SetWindowTabLocation(WindowLayer* window, float location)
{
if (!LockAllWindows())
return;
return false;
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;
_RebuildClippingForAllWindows(stillAvailableOnScreen);
_SetBackground(stillAvailableOnScreen);
@ -1593,6 +1593,8 @@ Desktop::SetWindowTabLocation(WindowLayer* window, float location)
}
UnlockAllWindows();
return changed;
}

View File

@ -111,7 +111,7 @@ class Desktop : public MessageLooper, public ScreenOwner {
void MoveWindowBy(WindowLayer* window, float x, float y,
int32 workspace = -1);
void ResizeWindowBy(WindowLayer* window, float x, float y);
void SetWindowTabLocation(WindowLayer* window, float location);
bool SetWindowTabLocation(WindowLayer* window, float location);
void SetWindowWorkspaces(WindowLayer* window,
uint32 workspaces);

View File

@ -975,6 +975,14 @@ WindowLayer::MouseMoved(BMessage *message, BPoint where, int32* _viewToken,
}
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
if (fIsDragging) {
if (!(Flags() & B_NOT_MOVABLE)) {
@ -1009,8 +1017,10 @@ WindowLayer::MouseMoved(BMessage *message, BPoint where, int32* _viewToken,
float loc = TabLocation();
// TODO: change to [0:1]
loc += delta.x;
fDesktop->SetWindowTabLocation(this, loc);
delta.y = 0;
if (fDesktop->SetWindowTabLocation(this, loc))
delta.y = 0;
else
delta = BPoint(0, 0);
}
// NOTE: fLastMousePosition is currently only
@ -1210,7 +1220,7 @@ WindowLayer::SetTabLocation(float location, BRegion& dirty)
bool ret = false;
if (fDecorator) {
ret = fDecorator->SetTabLocation(location, &dirty);
fBorderRegionValid = false;
fBorderRegionValid = fBorderRegionValid && !ret;
// the border very likely changed
}
return ret;