diff --git a/headers/private/servers/app/Decorator.h b/headers/private/servers/app/Decorator.h index 3e56e4cc76..c1502a91d3 100644 --- a/headers/private/servers/app/Decorator.h +++ b/headers/private/servers/app/Decorator.h @@ -57,13 +57,13 @@ class Decorator { void SetFeel(int32 wfeel); void SetFont(ServerFont *font); void SetLook(int32 wlook); - - void SetClose(bool is_down); - void SetMinimize(bool is_down); - void SetZoom(bool is_down); - virtual void SetTitle(const char *string); - + void SetClose(bool pressed); + void SetMinimize(bool pressed); + void SetZoom(bool pressed); + + virtual void SetTitle(const char* string, BRegion* updateRegion = NULL); + int32 GetLook() const; int32 GetFeel() const; int32 GetFlags() const; diff --git a/src/servers/app/Decorator.cpp b/src/servers/app/Decorator.cpp index b6947dae17..ea623f262d 100644 --- a/src/servers/app/Decorator.cpp +++ b/src/servers/app/Decorator.cpp @@ -190,18 +190,20 @@ Decorator::SetZoom(bool is_down) } } + /*! \brief Updates the value of the decorator title \param string New title value */ void -Decorator::SetTitle(const char *string) +Decorator::SetTitle(const char* string, BRegion* updateRegion) { fTitle.SetTo(string); _DoLayout(); // TODO: redraw? } + /*! \brief Returns the decorator's window look \return the decorator's window look diff --git a/src/servers/app/DefaultDecorator.cpp b/src/servers/app/DefaultDecorator.cpp index eb96477301..bf09c669b8 100644 --- a/src/servers/app/DefaultDecorator.cpp +++ b/src/servers/app/DefaultDecorator.cpp @@ -72,18 +72,44 @@ DefaultDecorator::DefaultDecorator(DesktopSettings& settings, BRect rect, rect.left, rect.top, rect.right, rect.bottom)); } -DefaultDecorator::~DefaultDecorator(void) + +DefaultDecorator::~DefaultDecorator() { STRACE(("DefaultDecorator: ~DefaultDecorator()\n")); delete [] fFrameColors; } + +void +DefaultDecorator::SetTitle(const char* string, BRegion* updateRegion) +{ + BRect rect = GetTabRect(); + + Decorator::SetTitle(string); + + if (updateRegion == NULL) + return; + + BRect updatedRect = GetTabRect(); + if (rect.left > updatedRect.left) + rect.left = updatedRect.left; + if (rect.right < updatedRect.right) + rect.right = updatedRect.right; + + rect.bottom++; + // the border will look differently when the title is adjacent + + updateRegion->Set(rect); +} + + void DefaultDecorator::MoveBy(float x, float y) { MoveBy(BPoint(x,y)); } + void DefaultDecorator::MoveBy(BPoint pt) { diff --git a/src/servers/app/DefaultDecorator.h b/src/servers/app/DefaultDecorator.h index b4aafaf0a0..182fdd49e9 100644 --- a/src/servers/app/DefaultDecorator.h +++ b/src/servers/app/DefaultDecorator.h @@ -22,6 +22,8 @@ public: int32 look, int32 feel, int32 flags); virtual ~DefaultDecorator(); + virtual void SetTitle(const char* string, BRegion* updateRegion = NULL); + virtual void MoveBy(float x, float y); virtual void MoveBy(BPoint pt); virtual void ResizeBy(float x, float y); diff --git a/src/servers/app/WinBorder.cpp b/src/servers/app/WinBorder.cpp index 7cddb37c3b..94856a885e 100644 --- a/src/servers/app/WinBorder.cpp +++ b/src/servers/app/WinBorder.cpp @@ -289,20 +289,14 @@ WinBorder::SetName(const char* name) // and redraw it. if (fDecorator) { - // before the change - BRegion invalid(fDecorator->GetTabRect()); + BRegion updateRegion; + fDecorator->SetTitle(name, &updateRegion); - fDecorator->SetTitle(name); - - // after the change - invalid.Include(fDecorator->GetTabRect()); - - // TODO: still doesn't look good (visually), but at least it works fRebuildDecRegion = true; - GetRootLayer()->MarkForRebuild(invalid); + GetRootLayer()->MarkForRebuild(updateRegion); GetRootLayer()->TriggerRebuild(); - GetRootLayer()->MarkForRedraw(invalid); + GetRootLayer()->MarkForRedraw(updateRegion); GetRootLayer()->TriggerRedraw(); } } @@ -443,7 +437,7 @@ WinBorder::MouseDown(const BMessage *msg) action = DEC_DRAG; // set decorator internals - switch(action) { + switch (action) { case DEC_CLOSE: fIsClosing = true; fDecorator->SetClose(true);