From 63bf94e27372d3b52e08035516de4144f74153fa Mon Sep 17 00:00:00 2001 From: Clemens Zeidler Date: Mon, 4 Jul 2011 21:10:10 +0000 Subject: [PATCH] The complete S&T group has an additional, surrounding magnetic border now. Fixes #7437. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42378 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../decorators/SATDecorator/SATDecorator.cpp | 42 +++++++++++++++++++ .../decorators/SATDecorator/SATDecorator.h | 17 ++++++++ .../decorators/SATDecorator/SATWindow.h | 4 ++ 3 files changed, 63 insertions(+) diff --git a/src/add-ons/decorators/SATDecorator/SATDecorator.cpp b/src/add-ons/decorators/SATDecorator/SATDecorator.cpp index f049def54e..a70af2a16c 100644 --- a/src/add-ons/decorators/SATDecorator/SATDecorator.cpp +++ b/src/add-ons/decorators/SATDecorator/SATDecorator.cpp @@ -16,6 +16,7 @@ #include #include "DrawingEngine.h" +#include "SATWindow.h" //#define DEBUG_SATDECORATOR @@ -66,6 +67,13 @@ SATDecorAddOn::InitCheck() const } +WindowBehaviour* +SATDecorAddOn::AllocateWindowBehaviour(Window* window) +{ + return new (std::nothrow)SATWindowBehaviour(window, &fStackAndTile); +} + + Decorator* SATDecorAddOn::_AllocateDecorator(DesktopSettings& settings, BRect rect, window_look look, uint32 flags) @@ -467,6 +475,40 @@ SATDecorator::GetComponentColors(Component component, uint8 highlight, } +SATWindowBehaviour::SATWindowBehaviour(Window* window, StackAndTile* sat) + : + DefaultWindowBehaviour(window), + + fStackAndTile(sat) +{ +} + + +bool +SATWindowBehaviour::AlterDeltaForSnap(Window* window, BPoint& delta, + bigtime_t now) +{ + if (DefaultWindowBehaviour::AlterDeltaForSnap(window, delta, now) == true) + return true; + + SATWindow* satWindow = fStackAndTile->GetSATWindow(window); + if (satWindow == NULL) + return false; + SATGroup* group = satWindow->GetGroup(); + if (group == NULL) + return false; + + BRect groupFrame = group->WindowAt(0)->CompleteWindowFrame(); + for (int32 i = 1; i < group->CountItems(); i++) + groupFrame = groupFrame | group->WindowAt(i)->CompleteWindowFrame(); + + fMagneticBorder.AlterDeltaForSnap(window->Screen(), + groupFrame, delta, now); + + return true; +} + + extern "C" DecorAddOn* (instantiate_decor_addon)(image_id id, const char* name) { return new (std::nothrow)SATDecorAddOn(id, name); diff --git a/src/add-ons/decorators/SATDecorator/SATDecorator.h b/src/add-ons/decorators/SATDecorator/SATDecorator.h index e722625df9..514f6dfa6c 100644 --- a/src/add-ons/decorators/SATDecorator/SATDecorator.h +++ b/src/add-ons/decorators/SATDecorator/SATDecorator.h @@ -11,6 +11,7 @@ #include "DecorManager.h" #include "DefaultDecorator.h" +#include "DefaultWindowBehaviour.h" #include "StackAndTile.h" @@ -20,6 +21,8 @@ public: virtual status_t InitCheck() const; + virtual WindowBehaviour* AllocateWindowBehaviour(Window* window); + protected: virtual Decorator* _AllocateDecorator(DesktopSettings& settings, BRect rect, window_look look, uint32 flags); @@ -71,4 +74,18 @@ private: }; +class SATWindowBehaviour : public DefaultWindowBehaviour { +public: + SATWindowBehaviour(Window* window, + StackAndTile* sat); + +protected: + virtual bool AlterDeltaForSnap(Window* window, BPoint& delta, + bigtime_t now); + +private: + StackAndTile* fStackAndTile; +}; + + #endif diff --git a/src/add-ons/decorators/SATDecorator/SATWindow.h b/src/add-ons/decorators/SATDecorator/SATWindow.h index 5f11fb976a..07815b1aa8 100644 --- a/src/add-ons/decorators/SATDecorator/SATWindow.h +++ b/src/add-ons/decorators/SATDecorator/SATWindow.h @@ -10,6 +10,8 @@ #include + +#include "MagneticBorder.h" #include "SATDecorator.h" #include "Stacking.h" #include "Tiling.h" @@ -63,6 +65,8 @@ private: Constraint* fKeepMaxHeightConstraint; Constraint* fWidthConstraint; Constraint* fHeightConstraint; + + MagneticBorder fMagneticBorder; };