[haiku-commits] r42552 - in haiku/trunk/src/servers/app: . decorator stackandtile

Author: czeidler
Date: 2011-08-03 03:36:50 +0200 (Wed, 03 Aug 2011)
New Revision: 42552
Changeset: https://dev.haiku-os.org/changeset/42552

Modified:
   haiku/trunk/src/servers/app/Window.cpp
   haiku/trunk/src/servers/app/decorator/DecorManager.cpp
   haiku/trunk/src/servers/app/decorator/DecorManager.h
   haiku/trunk/src/servers/app/decorator/Decorator.cpp
   haiku/trunk/src/servers/app/decorator/Decorator.h
   haiku/trunk/src/servers/app/decorator/DefaultDecorator.cpp
   haiku/trunk/src/servers/app/decorator/DefaultDecorator.h
   haiku/trunk/src/servers/app/stackandtile/SATDecorator.cpp
   haiku/trunk/src/servers/app/stackandtile/SATDecorator.h
   haiku/trunk/src/servers/app/stackandtile/SATWindow.cpp
Log:
Move flags and look into the tab too. The flags are needed to determine e.g. 
whether or not the zoom button should be drawn.



Modified: haiku/trunk/src/servers/app/Window.cpp
===================================================================
--- haiku/trunk/src/servers/app/Window.cpp      2011-08-02 23:13:45 UTC (rev 
42551)
+++ haiku/trunk/src/servers/app/Window.cpp      2011-08-03 01:36:50 UTC (rev 
42552)
@@ -1221,20 +1221,20 @@
        if (fCurrentStack.Get() == NULL)
                return;
 
+       int32 stackPosition = PositionInStack();
+
        ::Decorator* decorator = Decorator();
        if (decorator == NULL && look != B_NO_BORDER_WINDOW_LOOK) {
                // we need a new decorator
                decorator = gDecorManager.AllocateDecorator(this);
                fCurrentStack->SetDecorator(decorator);
-               if (IsFocus()) {
-                       int32 index = PositionInStack();
-                       decorator->SetFocus(index, true);
-               }
+               if (IsFocus())
+                       decorator->SetFocus(stackPosition, true);
        }
 
        if (decorator != NULL) {
                DesktopSettings settings(fDesktop);
-               decorator->SetLook(settings, look, updateRegion);
+               decorator->SetLook(stackPosition, settings, look, updateRegion);
 
                // we might need to resize the window!
                decorator->GetSizeLimits(&fMinWidth, &fMinHeight, &fMaxWidth,
@@ -1288,7 +1288,8 @@
        if (decorator == NULL)
                return;
 
-       decorator->SetFlags(flags, updateRegion);
+       int32 stackPosition = PositionInStack();
+       decorator->SetFlags(stackPosition, flags, updateRegion);
 
        // we might need to resize the window!
        decorator->GetSizeLimits(&fMinWidth, &fMinHeight, &fMaxWidth, 
&fMaxHeight);
@@ -2101,7 +2102,6 @@
                        
decorator->SetDrawingEngine(remainingTop->fDrawingEngine);
                // propagate focus to the decorator
                remainingTop->SetFocus(remainingTop->IsFocus());
-               remainingTop->SetFeel(remainingTop->Feel());
                remainingTop->SetLook(remainingTop->Look(), &dirty);
        }
 
@@ -2145,8 +2145,11 @@
        window->DetachFromWindowStack(false);
        window->fCurrentStack.SetTo(stack);
 
-       if (decorator != NULL)
-               decorator->AddTab(window->Title(), position, &dirty);
+       if (decorator != NULL) {
+               DesktopSettings settings(fDesktop);
+               decorator->AddTab(settings, window->Title(), window->Look(),
+                       window->Flags(), position, &dirty);
+       }
 
        window->SetLook(window->Look(), &dirty);
        fDesktop->RebuildAndRedrawAfterWindowChange(TopLayerStackWindow(), 
dirty);
@@ -2196,7 +2199,6 @@
        if (decorator == NULL)
                return false;
        decorator->SetDrawingEngine(fDrawingEngine);
-       DesktopSettings settings(fDesktop);
        SetLook(Look(), NULL);
        decorator->SetTopTap(PositionInStack());
        return fCurrentStack->MoveToTopLayer(this);

Modified: haiku/trunk/src/servers/app/decorator/DecorManager.cpp
===================================================================
--- haiku/trunk/src/servers/app/decorator/DecorManager.cpp      2011-08-02 
23:13:45 UTC (rev 42551)
+++ haiku/trunk/src/servers/app/decorator/DecorManager.cpp      2011-08-03 
01:36:50 UTC (rev 42552)
@@ -63,12 +63,12 @@
 
        DesktopSettings settings(desktop);
        Decorator* decorator;
-       decorator = _AllocateDecorator(settings, rect, look, flags);
+       decorator = _AllocateDecorator(settings, rect);
        desktop->UnlockSingleWindow();
        if (!decorator)
                return NULL;
 
-       if (decorator->AddTab(title) == false) {
+       if (decorator->AddTab(settings, title, look, flags) == false) {
                delete decorator;
                return NULL;
        }
@@ -94,10 +94,9 @@
 
 
 Decorator*
-DecorAddOn::_AllocateDecorator(DesktopSettings& settings, BRect rect,
-       window_look look, uint32 flags)
+DecorAddOn::_AllocateDecorator(DesktopSettings& settings, BRect rect)
 {
-       return new (std::nothrow)SATDecorator(settings, rect, look, flags);
+       return new (std::nothrow)SATDecorator(settings, rect);
 }
 
 

Modified: haiku/trunk/src/servers/app/decorator/DecorManager.h
===================================================================
--- haiku/trunk/src/servers/app/decorator/DecorManager.h        2011-08-02 
23:13:45 UTC (rev 42551)
+++ haiku/trunk/src/servers/app/decorator/DecorManager.h        2011-08-03 
01:36:50 UTC (rev 42552)
@@ -52,7 +52,7 @@
 
 protected:
        virtual Decorator*                      
_AllocateDecorator(DesktopSettings& settings,
-                                                                       BRect 
rect, window_look look, uint32 flags);
+                                                                       BRect 
rect);
 
                        DesktopListenerList     fDesktopListeners;
 

Modified: haiku/trunk/src/servers/app/decorator/Decorator.cpp
===================================================================
--- haiku/trunk/src/servers/app/decorator/Decorator.cpp 2011-08-02 23:13:45 UTC 
(rev 42551)
+++ haiku/trunk/src/servers/app/decorator/Decorator.cpp 2011-08-03 01:36:50 UTC 
(rev 42552)
@@ -31,6 +31,9 @@
        closePressed(false),
        zoomPressed(false),
        minimizePressed(false),
+
+       look(B_TITLED_WINDOW_LOOK),
+       flags(0),
        isFocused(false),
        title("")
 {
@@ -48,15 +51,11 @@
        \param wfeel style of window feel. See Window.h
        \param wflags various window flags. See Window.h
 */
-Decorator::Decorator(DesktopSettings& settings, BRect rect, window_look look,
-               uint32 flags)
+Decorator::Decorator(DesktopSettings& settings, BRect rect)
        :
        fDrawingEngine(NULL),
        fDrawState(),
 
-       fLook(look),
-       fFlags(flags),
-
        fTitleBarRect(),
        fFrame(rect),
        fResizeRect(),
@@ -81,12 +80,15 @@
 
 
 Decorator::Tab*
-Decorator::AddTab(const char* title, int32 index, BRegion* updateRegion)
+Decorator::AddTab(DesktopSettings& settings, const char* title,
+       window_look look, uint32 flags, int32 index, BRegion* updateRegion)
 {
        Decorator::Tab* tab = _AllocateNewTab();
        if (tab == NULL)
                return NULL;
        tab->title = title;
+       tab->look = look;
+       tab->flags = flags;
 
        bool ok = false;
        if (index >= 0) {
@@ -100,14 +102,15 @@
                return NULL;
        }
 
-       if (_AddTab(index, updateRegion) == false) {
+       Decorator::Tab* oldTop = fTopTab;
+       fTopTab = tab;
+       if (_AddTab(settings, index, updateRegion) == false) {
                fTabList.RemoveItem(tab);
                delete tab;
+               fTopTab = oldTop;
                return NULL;
        }
 
-       fTopTab = tab;
-
        _InvalidateFootprint();
        return tab;
 }
@@ -184,7 +187,7 @@
        \param flags New value for the flags
 */
 void
-Decorator::SetFlags(uint32 flags, BRegion* updateRegion)
+Decorator::SetFlags(int32 tab, uint32 flags, BRegion* updateRegion)
 {
        // we're nice to our subclasses - we make sure B_NOT_{H|V|}_RESIZABLE
        // are in sync (it's only a semantical simplification, not a necessity)
@@ -194,7 +197,10 @@
        if (flags & B_NOT_RESIZABLE)
                flags |= B_NOT_H_RESIZABLE | B_NOT_V_RESIZABLE;
 
-       _SetFlags(flags, updateRegion);
+       Decorator::Tab* decoratorTab = fTabList.ItemAt(tab);
+       if (decoratorTab == NULL)
+               return;
+       _SetFlags(decoratorTab, flags, updateRegion);
        _InvalidateFootprint();
                // the border might have changed (smaller/larger tab)
 }
@@ -214,10 +220,13 @@
        \param look New value for the look
 */
 void
-Decorator::SetLook(DesktopSettings& settings, window_look look,
+Decorator::SetLook(int32 tab, DesktopSettings& settings, window_look look,
        BRegion* updateRect)
 {
-       _SetLook(settings, look, updateRect);
+       Decorator::Tab* decoratorTab = fTabList.ItemAt(tab);
+       if (decoratorTab == NULL)
+               return;
+       _SetLook(decoratorTab, settings, look, updateRect);
        _InvalidateFootprint();
                // the border very likely changed
 }
@@ -227,9 +236,9 @@
        \return the decorator's window look
 */
 window_look
-Decorator::Look() const
+Decorator::Look(int32 tab) const
 {
-       return fLook;
+       return TabAt(tab)->look;
 }
 
 
@@ -237,9 +246,9 @@
        \return the decorator's window flags
 */
 uint32
-Decorator::Flags() const
+Decorator::Flags(int32 tab) const
 {
-       return fFlags;
+       return TabAt(tab)->flags;
 }
 
 
@@ -846,17 +855,17 @@
 
 
 void
-Decorator::_SetLook(DesktopSettings& settings, window_look look,
-       BRegion* updateRect)
+Decorator::_SetLook(Decorator::Tab* tab, DesktopSettings& settings,
+       window_look look, BRegion* updateRect)
 {
-       fLook = look;
+       tab->look = look;
 }
 
 
 void
-Decorator::_SetFlags(uint32 flags, BRegion* updateRegion)
+Decorator::_SetFlags(Decorator::Tab* tab, uint32 flags, BRegion* updateRegion)
 {
-       fFlags = flags;
+       tab->flags = flags;
 }
 
 

Modified: haiku/trunk/src/servers/app/decorator/Decorator.h
===================================================================
--- haiku/trunk/src/servers/app/decorator/Decorator.h   2011-08-02 23:13:45 UTC 
(rev 42551)
+++ haiku/trunk/src/servers/app/decorator/Decorator.h   2011-08-03 01:36:50 UTC 
(rev 42552)
@@ -41,6 +41,8 @@
                                bool                    zoomPressed : 1;
                                bool                    minimizePressed : 1;
 
+                               window_look             look;
+                               uint32                  flags;
                                bool                    isFocused : 1;
 
                                BString                 title;
@@ -76,18 +78,18 @@
                        };
 
 public:
-                                                       
Decorator(DesktopSettings& settings, BRect rect,
-                                                               window_look 
look, uint32 flags);
+                                                       
Decorator(DesktopSettings& settings, BRect rect);
        virtual                                 ~Decorator();
 
-       virtual Decorator::Tab* AddTab(const char* title, int32 index = -1,
-                                                               BRegion* 
updateRegion = NULL);
+       virtual Decorator::Tab* AddTab(DesktopSettings& settings, const char* 
title,
+                                                               window_look 
look, uint32 flags,
+                                                               int32 index = 
-1, BRegion* updateRegion = NULL);
        virtual bool                    RemoveTab(int32 index,
                                                                BRegion* 
updateRegion = NULL);
        virtual bool                    MoveTab(int32 from, int32 to, bool 
isMoving,
                                                                BRegion* 
updateRegion = NULL);
        virtual int32                   TabAt(const BPoint& where) const;
-                       Decorator::Tab* TabAt(int32 index)
+                       Decorator::Tab* TabAt(int32 index) const 
                                                                { return 
fTabList.ItemAt(index); }
                        int32                   CountTabs() const
                                                                { return 
fTabList.CountItems(); }
@@ -99,13 +101,13 @@
 
                        void                    FontsChanged(DesktopSettings& 
settings,
                                                                BRegion* 
updateRegion = NULL);
-                       void                    SetLook(DesktopSettings& 
settings, window_look look,
+                       void                    SetLook(int32 tab, 
DesktopSettings& settings,
+                                                               window_look 
look, BRegion* updateRegion = NULL);
+                       void                    SetFlags(int32 tab, uint32 
flags,
                                                                BRegion* 
updateRegion = NULL);
-                       void                    SetFlags(uint32 flags,
-                                                               BRegion* 
updateRegion = NULL);
 
-                       window_look             Look() const;
-                       uint32                  Flags() const;
+                       window_look             Look(int32 tab) const;
+                       uint32                  Flags(int32 tab) const;
 
                        BRect                   BorderRect() const;
                        BRect                   TitleBarRect() const;
@@ -195,10 +197,11 @@
 
        virtual void                    _FontsChanged(DesktopSettings& settings,
                                                                BRegion* 
updateRegion = NULL);
-       virtual void                    _SetLook(DesktopSettings& settings,
-                                                               window_look 
look, BRegion* updateRegion = NULL);
-       virtual void                    _SetFlags(uint32 flags,
+       virtual void                    _SetLook(Decorator::Tab* tab,
+                                                               
DesktopSettings& settings, window_look look,
                                                                BRegion* 
updateRegion = NULL);
+       virtual void                    _SetFlags(Decorator::Tab* tab, uint32 
flags,
+                                                               BRegion* 
updateRegion = NULL);
 
        virtual void                    _MoveBy(BPoint offset);
        virtual void                    _ResizeBy(BPoint offset, BRegion* 
dirty) = 0;
@@ -206,7 +209,8 @@
        virtual bool                    _SetSettings(const BMessage& settings,
                                                                BRegion* 
updateRegion = NULL);
 
-       virtual bool                    _AddTab(int32 index = -1,
+       virtual bool                    _AddTab(DesktopSettings& settings,
+                                                               int32 index = 
-1,
                                                                BRegion* 
updateRegion = NULL) = 0;
        virtual bool                    _RemoveTab(int32 index,
                                                                BRegion* 
updateRegion = NULL) = 0;
@@ -219,9 +223,6 @@
                        DrawingEngine*  fDrawingEngine;
                        DrawState               fDrawState;
 
-                       window_look             fLook;
-                       uint32                  fFlags;
-
                        BRect                   fTitleBarRect;
                        BRect                   fFrame;
                        BRect                   fResizeRect;

Modified: haiku/trunk/src/servers/app/decorator/DefaultDecorator.cpp
===================================================================
--- haiku/trunk/src/servers/app/decorator/DefaultDecorator.cpp  2011-08-02 
23:13:45 UTC (rev 42551)
+++ haiku/trunk/src/servers/app/decorator/DefaultDecorator.cpp  2011-08-03 
01:36:50 UTC (rev 42552)
@@ -101,10 +101,9 @@
 
 // TODO: get rid of DesktopSettings here, and introduce private accessor
 //     methods to the Decorator base class
-DefaultDecorator::DefaultDecorator(DesktopSettings& settings, BRect rect,
-       window_look look, uint32 flags)
+DefaultDecorator::DefaultDecorator(DesktopSettings& settings, BRect rect)
        :
-       Decorator(settings, rect, look, flags),
+       Decorator(settings, rect),
        // focus color constants
        kFocusTabColor(settings.UIColor(B_WINDOW_TAB_COLOR)),
        kFocusTabColorLight(tint_color(kFocusTabColor,
@@ -124,11 +123,6 @@
 
        fOldMovingTab(0, 0, -1, -1)
 {
-       _UpdateFont(settings);
-
-       // Do initial decorator setup
-       _DoLayout();
-
        // TODO: If the decorator was created with a frame too small, it should
        // resize itself!
 
@@ -234,7 +228,7 @@
                return region;
 
        // check the resize corner
-       if (fLook == B_DOCUMENT_WINDOW_LOOK && fResizeRect.Contains(where))
+       if (fTopTab->look == B_DOCUMENT_WINDOW_LOOK && 
fResizeRect.Contains(where))
                return REGION_RIGHT_BOTTOM_CORNER;
 
        // hit-test the borders
@@ -253,11 +247,11 @@
                return REGION_NONE;
 
        // check resize area
-       if ((fFlags & B_NOT_RESIZABLE) == 0
-               && (fLook == B_TITLED_WINDOW_LOOK
-                       || fLook == B_FLOATING_WINDOW_LOOK
-                       || fLook == B_MODAL_WINDOW_LOOK
-                       || fLook == kLeftTitledWindowLook)) {
+       if ((fTopTab->flags & B_NOT_RESIZABLE) == 0
+               && (fTopTab->look == B_TITLED_WINDOW_LOOK
+                       || fTopTab->look == B_FLOATING_WINDOW_LOOK
+                       || fTopTab->look == B_MODAL_WINDOW_LOOK
+                       || fTopTab->look == kLeftTitledWindowLook)) {
                BRect resizeRect(BPoint(fBottomBorder.right - 
kBorderResizeLength,
                        fBottomBorder.bottom - kBorderResizeLength),
                        fBottomBorder.RightBottom());
@@ -305,13 +299,13 @@
                        break;
 
                case REGION_CLOSE_BUTTON:
-                       if ((fFlags & B_NOT_CLOSABLE) == 0)
+                       if ((fTopTab->flags & B_NOT_CLOSABLE) == 0)
                                for (int32 i = 0; i < fTabList.CountItems(); 
i++)
                                        
dirty.Include(fTabList.ItemAt(i)->closeRect);
                        break;
 
                case REGION_ZOOM_BUTTON:
-                       if ((fFlags & B_NOT_ZOOMABLE) == 0)
+                       if ((fTopTab->flags & B_NOT_ZOOMABLE) == 0)
                                for (int32 i = 0; i < fTabList.CountItems(); 
i++)
                                        
dirty.Include(fTabList.ItemAt(i)->zoomRect);
                        break;
@@ -347,7 +341,7 @@
                        break;
 
                case REGION_RIGHT_BOTTOM_CORNER:
-                       if ((fFlags & B_NOT_RESIZABLE) == 0)
+                       if ((fTopTab->flags & B_NOT_RESIZABLE) == 0)
                                dirty.Include(fResizeRect);
                        break;
 
@@ -382,7 +376,7 @@
 
        bool hasTab = false;
 
-       switch ((int)Look()) {
+       switch ((int)fTopTab->look) {
                case B_MODAL_WINDOW_LOOK:
                        fBorderWidth = 5;
                        break;
@@ -471,7 +465,7 @@
                font_height fontHeight;
                fDrawState.Font().GetHeight(fontHeight);
 
-               if (fLook != kLeftTitledWindowLook) {
+               if (tab->look != kLeftTitledWindowLook) {
                        tabRect.Set(fFrame.left - fBorderWidth,
                                fFrame.top - fBorderWidth
                                        - ceilf(fontHeight.ascent + 
fontHeight.descent + 7.0),
@@ -486,7 +480,7 @@
                }
 
                // format tab rect for a floating window - make the rect smaller
-               if (fLook == B_FLOATING_WINDOW_LOOK) {
+               if (tab->look == B_FLOATING_WINDOW_LOOK) {
                        tabRect.InsetBy(0, 2);
                        tabRect.OffsetBy(0, 2);
                }
@@ -498,9 +492,9 @@
 
                // tab->minTabSize contains just the room for the buttons
                tab->minTabSize = inset * 2 + tab->textOffset;
-               if ((fFlags & B_NOT_CLOSABLE) == 0)
+               if ((tab->flags & B_NOT_CLOSABLE) == 0)
                        tab->minTabSize += offset + size;
-               if ((fFlags & B_NOT_ZOOMABLE) == 0)
+               if ((tab->flags & B_NOT_ZOOMABLE) == 0)
                        tab->minTabSize += offset + size;
 
                // tab->maxTabSize contains tab->minTabSize + the width 
required for the
@@ -512,7 +506,7 @@
                        tab->maxTabSize += tab->textOffset;
                tab->maxTabSize += tab->minTabSize;
 
-               float tabSize = (fLook != kLeftTitledWindowLook
+               float tabSize = (tab->look != kLeftTitledWindowLook
                        ? fFrame.Width() : fFrame.Height()) + fBorderWidth * 2;
                if (tabSize < tab->minTabSize)
                        tabSize = tab->minTabSize;
@@ -520,7 +514,7 @@
                        tabSize = tab->maxTabSize;
 
                // layout buttons and truncate text
-               if (fLook != kLeftTitledWindowLook)
+               if (tab->look != kLeftTitledWindowLook)
                        tabRect.right = tabRect.left + tabSize;
                else
                        tabRect.bottom = tabRect.top + tabSize;
@@ -651,7 +645,7 @@
        // NOTE: the DrawingEngine needs to be locked for the entire
        // time for the clipping to stay valid for this decorator
 
-       if (fLook == B_NO_BORDER_WINDOW_LOOK)
+       if (fTopTab->look == B_NO_BORDER_WINDOW_LOOK)
                return;
 
        if (fBorderWidth <= 0)
@@ -659,7 +653,7 @@
 
        // Draw the border frame
        BRect r = BRect(fTopBorder.LeftTop(), fBottomBorder.RightBottom());
-       switch ((int)fLook) {
+       switch ((int)fTopTab->look) {
                case B_TITLED_WINDOW_LOOK:
                case B_DOCUMENT_WINDOW_LOOK:
                case B_MODAL_WINDOW_LOOK:
@@ -731,7 +725,8 @@
                                        
fDrawingEngine->StrokeLine(BPoint(r.left + i, r.top + i),
                                                BPoint(r.right - i, r.top + i), 
colors[i * 2]);
                                }
-                               if (fTitleBarRect.IsValid() && fLook != 
kLeftTitledWindowLook) {
+                               if (fTitleBarRect.IsValid()
+                                       && fTopTab->look != 
kLeftTitledWindowLook) {
                                        // grey along the bottom of the tab
                                        // (overwrites "white" from frame)
                                        fDrawingEngine->StrokeLine(
@@ -750,7 +745,8 @@
                                        
fDrawingEngine->StrokeLine(BPoint(r.left + i, r.top + i),
                                                BPoint(r.left + i, r.bottom - 
i), colors[i * 2]);
                                }
-                               if (fLook == kLeftTitledWindowLook && 
fTitleBarRect.IsValid()) {
+                               if (fTopTab->look == kLeftTitledWindowLook
+                                       && fTitleBarRect.IsValid()) {
                                        // grey along the right side of the tab
                                        // (overwrites "white" from frame)
                                        fDrawingEngine->StrokeLine(
@@ -801,13 +797,13 @@
        }
 
        // Draw the resize knob if we're supposed to
-       if (!(fFlags & B_NOT_RESIZABLE)) {
+       if (!(fTopTab->flags & B_NOT_RESIZABLE)) {
                r = fResizeRect;
 
                ComponentColors colors;
                _GetComponentColors(COMPONENT_RESIZE_CORNER, colors);
 
-               switch ((int)fLook) {
+               switch ((int)fTopTab->look) {
                        case B_DOCUMENT_WINDOW_LOOK:
                        {
                                if (!invalid.Intersects(r))
@@ -899,7 +895,7 @@
                colors[COLOR_TAB_FRAME_LIGHT]);
        fDrawingEngine->StrokeLine(tabRect.LeftTop(), tabRect.RightTop(),
                colors[COLOR_TAB_FRAME_LIGHT]);
-       if (fLook != kLeftTitledWindowLook) {
+       if (tab->look != kLeftTitledWindowLook) {
                fDrawingEngine->StrokeLine(tabRect.RightTop(), 
tabRect.RightBottom(),
                        colors[COLOR_TAB_FRAME_DARK]);
        } else {
@@ -914,14 +910,14 @@
        // bevel
        fDrawingEngine->StrokeLine(BPoint(tabRect.left + 1, tabRect.top + 1),
                BPoint(tabRect.left + 1,
-                       tabBotton - (fLook == kLeftTitledWindowLook ? 1 : 0)),
+                       tabBotton - (tab->look == kLeftTitledWindowLook ? 1 : 
0)),
                colors[COLOR_TAB_BEVEL]);
        fDrawingEngine->StrokeLine(BPoint(tabRect.left + 1, tabRect.top + 1),
-               BPoint(tabRect.right - (fLook == kLeftTitledWindowLook ? 0 : 1),
+               BPoint(tabRect.right - (tab->look == kLeftTitledWindowLook ? 0 
: 1),
                        tabRect.top + 1),
                colors[COLOR_TAB_BEVEL]);
 
-       if (fLook != kLeftTitledWindowLook) {
+       if (tab->look != kLeftTitledWindowLook) {
                fDrawingEngine->StrokeLine(BPoint(tabRect.right - 1, 
tabRect.top + 2),
                        BPoint(tabRect.right - 1, tabBotton),
                        colors[COLOR_TAB_SHADOW]);
@@ -938,7 +934,7 @@
        gradient.AddColor(colors[COLOR_TAB_LIGHT], 0);
        gradient.AddColor(colors[COLOR_TAB], 255);
 
-       if (fLook != kLeftTitledWindowLook) {
+       if (tab->look != kLeftTitledWindowLook) {
                gradient.SetEnd(tabRect.LeftBottom());
                fDrawingEngine->FillRect(BRect(tabRect.left + 2, tabRect.top + 
2,
                        tabRect.right - 2, tabBotton), gradient);
@@ -997,7 +993,7 @@
        fDrawState.Font().GetHeight(fontHeight);
 
        BPoint titlePos;
-       if (fLook != kLeftTitledWindowLook) {
+       if (tab->look != kLeftTitledWindowLook) {
                titlePos.x = closeRect.IsValid() ? closeRect.right + 
tab->textOffset
                        : tabRect.left + tab->textOffset;
                titlePos.y = floorf(((tabRect.top + 2.0) + tabRect.bottom
@@ -1080,8 +1076,8 @@
 
 
 void
-DefaultDecorator::_SetLook(DesktopSettings& settings, window_look look,
-       BRegion* updateRegion)
+DefaultDecorator::_SetLook(Decorator::Tab* tab, DesktopSettings& settings,
+       window_look look, BRegion* updateRegion)
 {
        // TODO: we could be much smarter about the update region
 
@@ -1089,7 +1085,7 @@
        if (updateRegion != NULL)
                updateRegion->Include(&GetFootprint());
 
-       fLook = look;
+       tab->look = look;
 
        _UpdateFont(settings);
        _InvalidateBitmaps();
@@ -1102,7 +1098,8 @@
 
 
 void
-DefaultDecorator::_SetFlags(uint32 flags, BRegion* updateRegion)
+DefaultDecorator::_SetFlags(Decorator::Tab* tab, uint32 flags,
+       BRegion* updateRegion)
 {
        // TODO: we could be much smarter about the update region
 
@@ -1110,7 +1107,7 @@
        if (updateRegion != NULL)
                updateRegion->Include(&GetFootprint());
 
-       fFlags = flags;
+       tab->flags = flags;
        _DoLayout();
 
        _InvalidateFootprint();
@@ -1124,8 +1121,9 @@
 {
        DefaultDecorator::Tab* tab = static_cast<DefaultDecorator::Tab*>(_tab);
        tab->buttonFocus = IsFocus(tab)
-               || ((fLook == B_FLOATING_WINDOW_LOOK || fLook == 
kLeftTitledWindowLook)
-                       && (fFlags & B_AVOID_FOCUS) != 0);
+               || ((tab->look == B_FLOATING_WINDOW_LOOK
+                       || tab->look == kLeftTitledWindowLook)
+                       && (tab->flags & B_AVOID_FOCUS) != 0);
        if (CountTabs() > 1)
                _LayoutTabItems(tab, tab->tabRect);
 }
@@ -1165,9 +1163,9 @@
        fFrame.bottom += offset.y;
 
        // Handle invalidation of resize rect
-       if (dirty && !(fFlags & B_NOT_RESIZABLE)) {
+       if (dirty && !(fTopTab->flags & B_NOT_RESIZABLE)) {
                BRect realResizeRect;
-               switch ((int)fLook) {
+               switch ((int)fTopTab->look) {
                        case B_DOCUMENT_WINDOW_LOOK:
                                realResizeRect = fResizeRect;
                                // Resize rect at old location
@@ -1261,7 +1259,7 @@
 
                float delta = tabOffset - tab->tabOffset;
                tab->tabOffset = (uint32)tabOffset;
-               if (fLook != kLeftTitledWindowLook)
+               if (fTopTab->look != kLeftTitledWindowLook)
                        tabRect.OffsetBy(delta, 0.0);
                else
                        tabRect.OffsetBy(0.0, delta);
@@ -1271,9 +1269,10 @@
                if (tabSize > tab->maxTabSize)
                        tabSize = tab->maxTabSize;
 
-               if (fLook != kLeftTitledWindowLook && tabSize != 
tabRect.Width()) {
+               if (fTopTab->look != kLeftTitledWindowLook
+                       && tabSize != tabRect.Width()) {
                        tabRect.right = tabRect.left + tabSize;
-               } else if (fLook == kLeftTitledWindowLook
+               } else if (fTopTab->look == kLeftTitledWindowLook
                        && tabSize != tabRect.Height()) {
                        tabRect.bottom = tabRect.top + tabSize;
                }
@@ -1289,7 +1288,7 @@
                                BRect redraw(tabRect);
                                if (delta != 0.0) {
                                        redraw = redraw | oldTabRect;
-                                       if (fLook != kLeftTitledWindowLook)
+                                       if (fTopTab->look != 
kLeftTitledWindowLook)
                                                redraw.bottom++;
                                        else
                                                redraw.right++;
@@ -1382,8 +1381,11 @@
 
 
 bool
-DefaultDecorator::_AddTab(int32 index, BRegion* updateRegion)
+DefaultDecorator::_AddTab(DesktopSettings& settings, int32 index,
+       BRegion* updateRegion)
 {
+       _UpdateFont(settings);
+
        _DoLayout();
        if (updateRegion != NULL)
                updateRegion->Include(fTitleBarRect);
@@ -1443,7 +1445,7 @@
 
        region->MakeEmpty();
 
-       if (fLook == B_NO_BORDER_WINDOW_LOOK)
+       if (fTopTab->look == B_NO_BORDER_WINDOW_LOOK)
                return;
 
        region->Include(fTopBorder);
@@ -1451,12 +1453,12 @@
        region->Include(fRightBorder);
        region->Include(fBottomBorder);
 
-       if (fLook == B_BORDERED_WINDOW_LOOK)
+       if (fTopTab->look == B_BORDERED_WINDOW_LOOK)
                return;
 
        region->Include(&fTabsRegion);
 
-       if (fLook == B_DOCUMENT_WINDOW_LOOK) {
+       if (fTopTab->look == B_DOCUMENT_WINDOW_LOOK) {
                // include the rectangular resize knob on the bottom right
                float knobSize = kResizeKnobSize - fBorderWidth;
                region->Include(BRect(fFrame.right - knobSize, fFrame.bottom - 
knobSize,
@@ -1469,9 +1471,9 @@
 DefaultDecorator::DrawButtons(Decorator::Tab* tab, const BRect& invalid)
 {
        // Draw the buttons if we're supposed to
-       if (!(fFlags & B_NOT_CLOSABLE) && invalid.Intersects(tab->closeRect))
+       if (!(tab->flags & B_NOT_CLOSABLE) && 
invalid.Intersects(tab->closeRect))
                _DrawClose(tab, false, tab->closeRect);
-       if (!(fFlags & B_NOT_ZOOMABLE) && invalid.Intersects(tab->zoomRect))
+       if (!(tab->flags & B_NOT_ZOOMABLE) && invalid.Intersects(tab->zoomRect))
                _DrawZoom(tab, false, tab->zoomRect);
 }
 
@@ -1555,9 +1557,10 @@
 DefaultDecorator::_UpdateFont(DesktopSettings& settings)
 {
        ServerFont font;
-       if (fLook == B_FLOATING_WINDOW_LOOK || fLook == kLeftTitledWindowLook) {
+       if (fTopTab->look == B_FLOATING_WINDOW_LOOK
+               || fTopTab->look == kLeftTitledWindowLook) {
                settings.GetDefaultPlainFont(font);
-               if (fLook == kLeftTitledWindowLook)
+               if (fTopTab->look == kLeftTitledWindowLook)
                        font.SetRotation(90.0f);
        } else
                settings.GetDefaultBoldFont(font);
@@ -1623,11 +1626,11 @@
 DefaultDecorator::_GetButtonSizeAndOffset(const BRect& tabRect, float* _offset,
        float* _size, float* _inset) const
 {
-       float tabSize = fLook == kLeftTitledWindowLook ?
+       float tabSize = fTopTab->look == kLeftTitledWindowLook ?
                tabRect.Width() : tabRect.Height();
 
-       bool smallTab = fLook == B_FLOATING_WINDOW_LOOK
-               || fLook == kLeftTitledWindowLook;
+       bool smallTab = fTopTab->look == B_FLOATING_WINDOW_LOOK
+               || fTopTab->look == kLeftTitledWindowLook;
 
        *_offset = smallTab ? floorf(fDrawState.Font().Size() / 2.6)
                : floorf(fDrawState.Font().Size() / 2.3);
@@ -1657,7 +1660,7 @@
        BRect& zoomRect = tab->zoomRect;
 
        // calulate close rect based on the tab rectangle
-       if (fLook != kLeftTitledWindowLook) {
+       if (tab->look != kLeftTitledWindowLook) {
                closeRect.Set(tabRect.left + offset, tabRect.top + offset,
                        tabRect.left + offset + size, tabRect.top + offset + 
size);
 
@@ -1665,9 +1668,9 @@
                        tabRect.right - offset, tabRect.top + offset + size);
 
                // hidden buttons have no width
-               if ((Flags() & B_NOT_CLOSABLE) != 0)
+               if ((tab->flags & B_NOT_CLOSABLE) != 0)
                        closeRect.right = closeRect.left - offset;
-               if ((Flags() & B_NOT_ZOOMABLE) != 0)
+               if ((tab->flags & B_NOT_ZOOMABLE) != 0)
                        zoomRect.left = zoomRect.right + offset;
        } else {
                closeRect.Set(tabRect.left + offset, tabRect.top + offset,
@@ -1677,9 +1680,9 @@
                        tabRect.left + size + offset, tabRect.bottom - offset);
 
                // hidden buttons have no height
-               if ((Flags() & B_NOT_CLOSABLE) != 0)
+               if ((tab->flags & B_NOT_CLOSABLE) != 0)
                        closeRect.bottom = closeRect.top - offset;
-               if ((Flags() & B_NOT_ZOOMABLE) != 0)
+               if ((tab->flags & B_NOT_ZOOMABLE) != 0)
                        zoomRect.top = zoomRect.bottom + offset;
        }
 
@@ -1687,7 +1690,7 @@
        // TODO: the +2 is there because the title often appeared
        //      truncated for no apparent reason - OTOH the title does
        //      also not appear perfectly in the middle
-       if (fLook != kLeftTitledWindowLook)
+       if (tab->look != kLeftTitledWindowLook)
                size = (zoomRect.left - closeRect.right) - tab->textOffset * 2 
+ inset;
        else
                size = (zoomRect.top - closeRect.bottom) - tab->textOffset * 2 
+ inset;
@@ -1878,8 +1881,8 @@
 float
 DefaultDecorator::_DefaultTextOffset() const
 {
-       return (fLook == B_FLOATING_WINDOW_LOOK
-               || fLook == kLeftTitledWindowLook) ? 10 : 18;
+       return (fTopTab->look == B_FLOATING_WINDOW_LOOK
+               || fTopTab->look == kLeftTitledWindowLook) ? 10 : 18;
 }
 
 
@@ -1887,7 +1890,7 @@
 DefaultDecorator::_SingleTabOffsetAndSize(float& tabSize)
 {
        float maxLocation;
-       if (fLook != kLeftTitledWindowLook) {
+       if (fTopTab->look != kLeftTitledWindowLook) {
                tabSize = fRightBorder.right - fLeftBorder.left;
        } else {
                tabSize = fBottomBorder.bottom - fTopBorder.top;

Modified: haiku/trunk/src/servers/app/decorator/DefaultDecorator.h
===================================================================
--- haiku/trunk/src/servers/app/decorator/DefaultDecorator.h    2011-08-02 
23:13:45 UTC (rev 42551)
+++ haiku/trunk/src/servers/app/decorator/DefaultDecorator.h    2011-08-03 
01:36:50 UTC (rev 42552)
@@ -44,8 +44,7 @@
        };
 
                                                                
DefaultDecorator(DesktopSettings& settings,
-                                                                       BRect 
frame, window_look look,
-                                                                       uint32 
flags);
+                                                                       BRect 
frame);
        virtual                                         ~DefaultDecorator();
 
        virtual float                           TabLocation(int32 tab) const;
@@ -126,10 +125,10 @@
 
        virtual void                            _FontsChanged(DesktopSettings& 
settings,
                                                                        
BRegion* updateRegion);
-       virtual void                            _SetLook(DesktopSettings& 
settings,
-                                                                       
window_look look,
+       virtual void                            _SetLook(Decorator::Tab* tab,
+                                                                       
DesktopSettings& settings, window_look look,
                                                                        
BRegion* updateRegion = NULL);
-       virtual void                            _SetFlags(uint32 flags,
+       virtual void                            _SetFlags(Decorator::Tab* tab, 
uint32 flags,
                                                                        
BRegion* updateRegion = NULL);
 
        virtual void                            _MoveBy(BPoint offset);
@@ -142,7 +141,8 @@
        virtual bool                            _SetSettings(const BMessage& 
settings,
                                                                        
BRegion* updateRegion = NULL);
 
-       virtual bool                            _AddTab(int32 index = -1,
+       virtual bool                            _AddTab(DesktopSettings& 
settings,
+                                                                       int32 
index = -1,
                                                                        
BRegion* updateRegion = NULL);
        virtual bool                            _RemoveTab(int32 index,
                                                                        
BRegion* updateRegion = NULL);

Modified: haiku/trunk/src/servers/app/stackandtile/SATDecorator.cpp
===================================================================
--- haiku/trunk/src/servers/app/stackandtile/SATDecorator.cpp   2011-08-02 
23:13:45 UTC (rev 42551)
+++ haiku/trunk/src/servers/app/stackandtile/SATDecorator.cpp   2011-08-03 
01:36:50 UTC (rev 42552)
@@ -49,10 +49,9 @@
        (B_DARKEN_1_TINT + B_NO_TINT) / 2);
 
 
-SATDecorator::SATDecorator(DesktopSettings& settings, BRect frame,
-       window_look look, uint32 flags)
+SATDecorator::SATDecorator(DesktopSettings& settings, BRect frame)
        :
-       DefaultDecorator(settings, frame, look, flags)
+       DefaultDecorator(settings, frame)
 {
 
 }

Modified: haiku/trunk/src/servers/app/stackandtile/SATDecorator.h
===================================================================
--- haiku/trunk/src/servers/app/stackandtile/SATDecorator.h     2011-08-02 
23:13:45 UTC (rev 42551)
+++ haiku/trunk/src/servers/app/stackandtile/SATDecorator.h     2011-08-03 
01:36:50 UTC (rev 42552)
@@ -23,8 +23,7 @@
 
 public:
                                                                
SATDecorator(DesktopSettings& settings,
-                                                                       BRect 
frame, window_look look,
-                                                                       uint32 
flags);
+                                                                       BRect 
frame);
 
 protected:
        virtual void                            GetComponentColors(Component 
component,

Modified: haiku/trunk/src/servers/app/stackandtile/SATWindow.cpp
===================================================================
--- haiku/trunk/src/servers/app/stackandtile/SATWindow.cpp      2011-08-02 
23:13:45 UTC (rev 42551)
+++ haiku/trunk/src/servers/app/stackandtile/SATWindow.cpp      2011-08-03 
01:36:50 UTC (rev 42552)
@@ -379,6 +379,8 @@
                fWindow->Title());
 
        _RestoreOriginalSize(stayBelowMouse);
+       if (group->CountItems() == 1)
+               group->WindowAt(0)->_RestoreOriginalSize(false);
 
        if (fShutdown) {
                fGroupCookie->Uninit();


Other related posts:

  • » [haiku-commits] r42552 - in haiku/trunk/src/servers/app: . decorator stackandtile - clemens . zeidler