The return of the long awaited for Sliding Tabs, that even Linux users envy!
Needs some cleanup, passed values should be inside [0:1]. Need to make sure changing the title doesn't reset the tab to left. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17571 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -95,7 +95,9 @@ class Decorator {
|
|||||||
void ResizeBy(float x, float y, BRegion* dirty);
|
void ResizeBy(float x, float y, BRegion* dirty);
|
||||||
virtual void ResizeBy(BPoint pt, BRegion* dirty) = 0;
|
virtual void ResizeBy(BPoint pt, BRegion* dirty) = 0;
|
||||||
|
|
||||||
virtual void SetTabLocation(float location) {}
|
/*! \return true if tab location updated, false if out of bounds or unsupported */
|
||||||
|
virtual bool SetTabLocation(float location, BRegion* updateRegion = NULL)
|
||||||
|
{ (void)updateRegion; return false; }
|
||||||
virtual float TabLocation() const
|
virtual float TabLocation() const
|
||||||
{ return 0.0; }
|
{ return 0.0; }
|
||||||
|
|
||||||
|
|||||||
@@ -337,6 +337,31 @@ DefaultDecorator::ResizeBy(BPoint pt, BRegion* dirty)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
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;
|
||||||
|
// redraw old rect (1 pix on the border also must be updated)
|
||||||
|
BRect trect(_tabrect);
|
||||||
|
trect.bottom++;
|
||||||
|
updateRegion->Include(trect);
|
||||||
|
_tabrect.OffsetBy(delta, 0);
|
||||||
|
fTabOffset = (int32)location;
|
||||||
|
_LayoutTabItems(_tabrect);
|
||||||
|
// redraw new rect as well
|
||||||
|
trect = _tabrect;
|
||||||
|
trect.bottom++;
|
||||||
|
updateRegion->Include(trect);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// Draw
|
// Draw
|
||||||
void
|
void
|
||||||
DefaultDecorator::Draw(BRect update)
|
DefaultDecorator::Draw(BRect update)
|
||||||
@@ -439,7 +464,8 @@ DefaultDecorator::Clicked(BPoint pt, int32 buttons, int32 modifiers)
|
|||||||
// Clicking in the tab?
|
// Clicking in the tab?
|
||||||
if (_tabrect.Contains(pt)) {
|
if (_tabrect.Contains(pt)) {
|
||||||
// tab sliding in any case if either shift key is held down
|
// tab sliding in any case if either shift key is held down
|
||||||
if (modifiers & B_SHIFT_KEY)
|
// except sliding up-down by moving mouse left-right would look strange
|
||||||
|
if ((modifiers & B_SHIFT_KEY) && (fLook != kLeftTitledWindowLook))
|
||||||
return DEC_SLIDETAB;
|
return DEC_SLIDETAB;
|
||||||
|
|
||||||
clicked = true;
|
clicked = true;
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ class DefaultDecorator: public Decorator {
|
|||||||
|
|
||||||
virtual void MoveBy(BPoint pt);
|
virtual void MoveBy(BPoint pt);
|
||||||
virtual void ResizeBy(BPoint pt, BRegion* dirty);
|
virtual void ResizeBy(BPoint pt, BRegion* dirty);
|
||||||
|
virtual bool SetTabLocation(float location, BRegion* updateRegion = NULL);
|
||||||
|
virtual float TabLocation() const { return (float)fTabOffset;; }
|
||||||
|
|
||||||
virtual void Draw(BRect r);
|
virtual void Draw(BRect r);
|
||||||
virtual void Draw();
|
virtual void Draw();
|
||||||
|
|||||||
@@ -1575,6 +1575,26 @@ Desktop::ResizeWindowBy(WindowLayer* window, float x, float y)
|
|||||||
UnlockAllWindows();
|
UnlockAllWindows();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Desktop::SetWindowTabLocation(WindowLayer* window, float location)
|
||||||
|
{
|
||||||
|
if (!LockAllWindows())
|
||||||
|
return;
|
||||||
|
|
||||||
|
BRegion dirty;
|
||||||
|
window->SetTabLocation(location, dirty);
|
||||||
|
|
||||||
|
if (window->IsVisible() && dirty.CountRects() > 0) {
|
||||||
|
BRegion stillAvailableOnScreen;
|
||||||
|
_RebuildClippingForAllWindows(stillAvailableOnScreen);
|
||||||
|
_SetBackground(stillAvailableOnScreen);
|
||||||
|
|
||||||
|
_TriggerWindowRedrawing(dirty);
|
||||||
|
}
|
||||||
|
|
||||||
|
UnlockAllWindows();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Updates the workspaces of all subset windows with regard to the
|
Updates the workspaces of all subset windows with regard to the
|
||||||
|
|||||||
@@ -111,6 +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);
|
||||||
|
|
||||||
void SetWindowWorkspaces(WindowLayer* window,
|
void SetWindowWorkspaces(WindowLayer* window,
|
||||||
uint32 workspaces);
|
uint32 workspaces);
|
||||||
|
|||||||
@@ -1006,7 +1006,11 @@ WindowLayer::MouseMoved(BMessage *message, BPoint where, int32* _viewToken,
|
|||||||
}
|
}
|
||||||
// sliding tab
|
// sliding tab
|
||||||
if (fIsSlidingTab) {
|
if (fIsSlidingTab) {
|
||||||
// TODO: implement
|
float loc = TabLocation();
|
||||||
|
// TODO: change to [0:1]
|
||||||
|
loc += delta.x;
|
||||||
|
fDesktop->SetWindowTabLocation(this, loc);
|
||||||
|
delta.y = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: fLastMousePosition is currently only
|
// NOTE: fLastMousePosition is currently only
|
||||||
@@ -1200,11 +1204,16 @@ WindowLayer::GetSizeLimits(int32* minWidth, int32* maxWidth,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
bool
|
||||||
WindowLayer::SetTabLocation(float location)
|
WindowLayer::SetTabLocation(float location, BRegion& dirty)
|
||||||
{
|
{
|
||||||
if (fDecorator)
|
bool ret = false;
|
||||||
fDecorator->SetTabLocation(location);
|
if (fDecorator) {
|
||||||
|
ret = fDecorator->SetTabLocation(location, &dirty);
|
||||||
|
fBorderRegionValid = false;
|
||||||
|
// the border very likely changed
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -169,7 +169,7 @@ class WindowLayer {
|
|||||||
int32* minHeight, int32* maxHeight) const;
|
int32* minHeight, int32* maxHeight) const;
|
||||||
|
|
||||||
// 0.0 -> left .... 1.0 -> right
|
// 0.0 -> left .... 1.0 -> right
|
||||||
void SetTabLocation(float location);
|
bool SetTabLocation(float location, BRegion& dirty);
|
||||||
float TabLocation() const;
|
float TabLocation() const;
|
||||||
|
|
||||||
void HighlightDecorator(bool active);
|
void HighlightDecorator(bool active);
|
||||||
|
|||||||
Reference in New Issue
Block a user