[haiku-commits] r42478 - haiku/trunk/src/servers/app

  • From: clemens.zeidler@xxxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Mon, 25 Jul 2011 03:09:27 +0200 (CEST)

Author: czeidler
Date: 2011-07-25 03:09:26 +0200 (Mon, 25 Jul 2011)
New Revision: 42478
Changeset: https://dev.haiku-os.org/changeset/42478
Ticket: https://dev.haiku-os.org/ticket/7796
Ticket: https://dev.haiku-os.org/ticket/7801

Modified:
   haiku/trunk/src/servers/app/DecorManager.cpp
   haiku/trunk/src/servers/app/Decorator.cpp
   haiku/trunk/src/servers/app/Decorator.h
   haiku/trunk/src/servers/app/DefaultDecorator.cpp
   haiku/trunk/src/servers/app/DefaultDecorator.h
   haiku/trunk/src/servers/app/DefaultWindowBehaviour.cpp
   haiku/trunk/src/servers/app/DefaultWindowBehaviour.h
   haiku/trunk/src/servers/app/Desktop.cpp
   haiku/trunk/src/servers/app/Desktop.h
   haiku/trunk/src/servers/app/DesktopListener.cpp
   haiku/trunk/src/servers/app/DesktopListener.h
   haiku/trunk/src/servers/app/Window.cpp
   haiku/trunk/src/servers/app/Window.h
   haiku/trunk/src/servers/app/WorkspacesView.cpp
Log:
Add multi tab support to the default decorator as discussed on the mailing 
list. Windows can be stacked on top of one another. All windows using the same 
decorator instance. This makes it easier to draw the stacked tabs and makes it 
possible to design more fancy looks for stacked windows. This also helps to fix 
some issues in S&T, e.g. when activating one window in a stacked group all 
windows have to be activated to ensure that all tabs are on top. This causes 
some flickering in tracker.

* Each Window has a reference counted WindowStack class which can be shared 
between stacked Windows. To keep the Decorator separated from Window there is 
another tab list in the Decorator now. The index of the stacked Window in the 
window stack is the same as the index of the tab in the Decorator. Properties 
like title or window focus are managed on a per tab basis now. This mean when 
you set the title in the Decorator you also have to specify the tab id which is 
equal to the window position in the stack.

* When drawing the decorator its important that only the top window is doing 
the drawing. Also the top window drawing engine should be used.
Actually that is only a problem directly after a window is stacked and the 
other window has still a none empty dirty region. In this case we clear the 
dirty region of this window and stop the drawing (the top window will draw 
everything).

* Track if shifting of a tab is still ongoing, i.e. mouse still down.

* The key event filter called the DesktopListener without holding the window 
write lock. This probably caused #7801 and #7796.

* Commented out assert's in Window::SetScreen and Window::Screen. Add TODO 
because I'm not sure about the screen access.

This breaks all existing decorators again, sorry guys! Haven't looked into any 
other then the default decorator (and the SAT decorator). Will not fix the 
others in the near future so go for it! Since applications should be able to 
rely on S&T features the other decorator must be able to handle multiple tabs 
as well. A simple solution would be to draw all title bars in multiple rows. 
That probably looks quit poorly. Think the better solution would be to draw a 
tab interface in the title bar, e.g. like in KDE.



Modified: haiku/trunk/src/servers/app/DecorManager.cpp
===================================================================
--- haiku/trunk/src/servers/app/DecorManager.cpp        2011-07-25 00:11:33 UTC 
(rev 42477)
+++ haiku/trunk/src/servers/app/DecorManager.cpp        2011-07-25 01:09:26 UTC 
(rev 42478)
@@ -65,15 +65,16 @@
        DesktopSettings settings(desktop);
        Decorator* decorator;
        decorator = _AllocateDecorator(settings, rect, look, flags);
-
        desktop->UnlockSingleWindow();
-
        if (!decorator)
                return NULL;
 
+       if (decorator->AddTab(title) == false) {
+               delete decorator;
+               return NULL;
+       }
+
        decorator->SetDrawingEngine(engine);
-       decorator->SetTitle(title);
-
        return decorator;
 }
 

Modified: haiku/trunk/src/servers/app/Decorator.cpp
===================================================================
--- haiku/trunk/src/servers/app/Decorator.cpp   2011-07-25 00:11:33 UTC (rev 
42477)
+++ haiku/trunk/src/servers/app/Decorator.cpp   2011-07-25 01:09:26 UTC (rev 
42478)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2001-2010, Haiku.
+ * Copyright 2001-2011, Haiku.
  * Distributed under the terms of the MIT License.
  *
  * Authors:
@@ -22,6 +22,22 @@
 #include "DrawingEngine.h"
 
 
+Decorator::Tab::Tab()
+       :
+       zoomRect(),
+       closeRect(),
+       minimizeRect(),
+
+       closePressed(false),
+       zoomPressed(false),
+       minimizePressed(false),
+       isFocused(false),
+       title("")
+{
+
+}
+
+
 /*!    \brief Constructor
 
        Does general initialization of internal data members and creates a 
colorset
@@ -41,19 +57,12 @@
        fLook(look),
        fFlags(flags),
 
-       fZoomRect(),
-       fCloseRect(),
-       fMinimizeRect(),
-       fTabRect(),
+       fTitleBarRect(),
        fFrame(rect),
        fResizeRect(),
        fBorderRect(),
 
-       fClosePressed(false),
-       fZoomPressed(false),
-       fMinimizePressed(false),
-       fIsFocused(false),
-       fTitle(""),
+       fTopTab(NULL),
 
        fFootprintValid(false)
 {
@@ -71,6 +80,89 @@
 }
 
 
+Decorator::Tab*
+Decorator::AddTab(const char* title, int32 index, BRegion* updateRegion)
+{
+       Decorator::Tab* tab = _AllocateNewTab();
+       if (tab == NULL)
+               return NULL;
+       tab->title = title;
+
+       bool ok = false;
+       if (index >= 0) {
+               if (fTabList.AddItem(tab, index) == true)
+                       ok = true;
+       } else if (fTabList.AddItem(tab) == true)
+               ok = true;
+
+       if (ok == false) {
+               delete tab;
+               return NULL;
+       }
+
+       if (_AddTab(index, updateRegion) == false) {
+               fTabList.RemoveItem(tab);
+               delete tab;
+               return NULL;
+       }
+
+       if (fTopTab == NULL)
+               fTopTab = tab;
+
+       _InvalidateFootprint();
+       return tab;
+}
+
+
+bool
+Decorator::RemoveTab(int32 index, BRegion* updateRegion)
+{
+       Decorator::Tab* tab = fTabList.RemoveItemAt(index);
+       if (tab == NULL)
+               return false;
+
+       _RemoveTab(index, updateRegion);
+
+       delete tab;
+       _InvalidateFootprint();
+       return true;
+}
+
+
+bool
+Decorator::MoveTab(int32 from, int32 to, bool isMoving, BRegion* updateRegion)
+{
+       if (_MoveTab(from, to, isMoving, updateRegion) == false)
+               return false;
+       if (fTabList.MoveItem(from, to) == false) {
+               // move the tab back
+               _MoveTab(from, to, isMoving, updateRegion);
+               return false;
+       }
+       return true;
+}
+
+
+int32
+Decorator::TabAt(const BPoint& where) const
+{
+       for (int32 i = 0; i < fTabList.CountItems(); i++) {
+               Decorator::Tab* tab = fTabList.ItemAt(i);
+               if (tab->tabRect.Contains(where))
+                       return i;
+       }
+
+       return -1;
+}
+
+
+void
+Decorator::SetTopTap(int32 tab)
+{
+       fTopTab = fTabList.ItemAt(tab);
+}
+
+
 /*!    \brief Assigns a display driver to the decorator
        \param driver A valid DrawingEngine object
 */
@@ -132,6 +224,63 @@
 }
 
 
+/*!    \brief Returns the decorator's window look
+       \return the decorator's window look
+*/
+window_look
+Decorator::Look() const
+{
+       return fLook;
+}
+
+
+/*!    \brief Returns the decorator's window flags
+       \return the decorator's window flags
+*/
+uint32
+Decorator::Flags() const
+{
+       return fFlags;
+}
+
+
+/*!    \brief Returns the decorator's border rectangle
+       \return the decorator's border rectangle
+*/
+BRect
+Decorator::BorderRect() const
+{
+       return fBorderRect;
+}
+
+
+BRect
+Decorator::TitleBarRect() const
+{
+       return fTitleBarRect;
+}
+
+
+/*!    \brief Returns the decorator's tab rectangle
+       \return the decorator's tab rectangle
+*/
+BRect
+Decorator::TabRect(int32 tab) const
+{
+       Decorator::Tab* decoratorTab = fTabList.ItemAt(tab);
+       if (decoratorTab == NULL)
+               return BRect();
+       return decoratorTab->tabRect;
+}
+
+
+BRect
+Decorator::TabRect(Decorator::Tab* tab) const
+{
+       return tab->tabRect;
+}
+
+
 /*!    \brief Sets the close button's value.
 
        Note that this does not update the button's look - it just updates the
@@ -140,11 +289,15 @@
        \param is_down Whether the button is down or not
 */
 void
-Decorator::SetClose(bool pressed)
+Decorator::SetClose(int32 tab, bool pressed)
 {
-       if (pressed != fClosePressed) {
-               fClosePressed = pressed;
-               DrawClose();
+       Decorator::Tab* decoratorTab = fTabList.ItemAt(tab);
+       if (decoratorTab == NULL)
+               return;
+
+       if (pressed != decoratorTab->closePressed) {
+               decoratorTab->closePressed = pressed;
+               DrawClose(tab);
        }
 }
 
@@ -156,11 +309,15 @@
        \param is_down Whether the button is down or not
 */
 void
-Decorator::SetMinimize(bool pressed)
+Decorator::SetMinimize(int32 tab, bool pressed)
 {
-       if (pressed != fMinimizePressed) {
-               fMinimizePressed = pressed;
-               DrawMinimize();
+       Decorator::Tab* decoratorTab = fTabList.ItemAt(tab);
+       if (decoratorTab == NULL)
+               return;
+
+       if (pressed != decoratorTab->minimizePressed) {
+               decoratorTab->minimizePressed = pressed;
+               DrawMinimize(tab);
        }
 }
 
@@ -172,11 +329,15 @@
        \param is_down Whether the button is down or not
 */
 void
-Decorator::SetZoom(bool pressed)
+Decorator::SetZoom(int32 tab, bool pressed)
 {
-       if (pressed != fZoomPressed) {
-               fZoomPressed = pressed;
-               DrawZoom();
+       Decorator::Tab* decoratorTab = fTabList.ItemAt(tab);
+       if (decoratorTab == NULL)
+               return;
+
+       if (pressed != decoratorTab->zoomPressed) {
+               decoratorTab->zoomPressed = pressed;
+               DrawZoom(tab);
        }
 }
 
@@ -185,11 +346,15 @@
        \param string New title value
 */
 void
-Decorator::SetTitle(const char* string, BRegion* updateRegion)
+Decorator::SetTitle(int32 tab, const char* string, BRegion* updateRegion)
 {
-       fTitle.SetTo(string);
-       _SetTitle(string, updateRegion);
+       Decorator::Tab* decoratorTab = fTabList.ItemAt(tab);
+       if (decoratorTab == NULL)
+               return;
 
+       decoratorTab->title.SetTo(string);
+       _SetTitle(decoratorTab, string, updateRegion);
+
        _InvalidateFootprint();
                // the border very likely changed
 
@@ -197,83 +362,75 @@
 }
 
 
-/*!    \brief Returns the decorator's window look
-       \return the decorator's window look
-*/
-window_look
-Decorator::Look() const
-{
-       return fLook;
-}
-
-
-/*!    \brief Returns the decorator's window flags
-       \return the decorator's window flags
-*/
-uint32
-Decorator::Flags() const
-{
-       return fFlags;
-}
-
-
 /*!    \brief Returns the decorator's title
        \return the decorator's title
 */
 const char*
-Decorator::Title() const
+Decorator::Title(int32 tab) const
 {
-       return fTitle.String();
+       Decorator::Tab* decoratorTab = fTabList.ItemAt(tab);
+       if (decoratorTab == NULL)
+               return "";
+       return decoratorTab->title;
 }
 
 
-/*!    \brief Returns the decorator's border rectangle
-       \return the decorator's border rectangle
-*/
-BRect
-Decorator::BorderRect() const
+const char*
+Decorator::Title(Decorator::Tab* tab) const
 {
-       return fBorderRect;
+       return tab->title;
 }
 
 
-/*!    \brief Returns the decorator's tab rectangle
-       \return the decorator's tab rectangle
-*/
-BRect
-Decorator::TabRect() const
+bool
+Decorator::SetTabLocation(int32 tab, float location, bool isShifting,
+       BRegion* updateRegion)
 {
-       return fTabRect;
+       Decorator::Tab* decoratorTab = fTabList.ItemAt(tab);
+       if (decoratorTab == NULL)
+               return false;
+       if (_SetTabLocation(decoratorTab, location, isShifting, updateRegion)) {
+               _InvalidateFootprint();
+               return true;
+       }
+       return false;
 }
 
+ 
 
-/*!    \brief Returns the value of the close button
-       \return true if down, false if up
+/*!    \brief Changes the focus value of the decorator
+
+       While this call will not update the screen, it will affect how future
+       updates work.
+
+       \param active True if active, false if not
 */
-bool
-Decorator::GetClose()
+void
+Decorator::SetFocus(int32 tab, bool active)
 {
-       return fClosePressed;
+       Decorator::Tab* decoratorTab = fTabList.ItemAt(tab);
+       if (decoratorTab == NULL)
+               return;
+       decoratorTab->isFocused = active;
+       _SetFocus(decoratorTab);
+       // TODO: maybe it would be cleaner to handle the redraw here.
 }
 
 
-/*!    \brief Returns the value of the minimize button
-       \return true if down, false if up
-*/
 bool
-Decorator::GetMinimize()
+Decorator::IsFocus(int32 tab) const
 {
-       return fMinimizePressed;
-}
+       Decorator::Tab* decoratorTab = fTabList.ItemAt(tab);
+       if (decoratorTab == NULL)
+               return false;
+       return decoratorTab->isFocused;
+};
 
 
-/*!    \brief Returns the value of the zoom button
-       \return true if down, false if up
-*/
 bool
-Decorator::GetZoom()
+Decorator::IsFocus(Decorator::Tab* tab) const
 {
-       return fZoomPressed;
+       return tab->isFocused;
 }
 
 
@@ -284,22 +441,6 @@
 }
 
 
-/*!    \brief Changes the focus value of the decorator
-
-       While this call will not update the screen, it will affect how future
-       updates work.
-
-       \param active True if active, false if not
-*/
-void
-Decorator::SetFocus(bool active)
-{
-       fIsFocused = active;
-       _SetFocus();
-       // TODO: maybe it would be cleaner to handle the redraw here.
-}
-
-
 //     #pragma mark - virtual methods
 
 
@@ -339,15 +480,26 @@
                - \c REGION_RIGHT_BOTTOM_CORNER The right-bottom corner.
 */
 Decorator::Region
-Decorator::RegionAt(BPoint where) const
+Decorator::RegionAt(BPoint where, int32& tabIndex) const
 {
-       if (fCloseRect.Contains(where))
-               return REGION_CLOSE_BUTTON;
-       if (fZoomRect.Contains(where))
-               return REGION_ZOOM_BUTTON;
-       if (fTabRect.Contains(where))
-               return REGION_TAB;
+       tabIndex = -1;
 
+       for (int32 i = 0; i < fTabList.CountItems(); i++) {
+               Decorator::Tab* tab = fTabList.ItemAt(i);
+               if (tab->closeRect.Contains(where)) {
+                       tabIndex = i;
+                       return REGION_CLOSE_BUTTON;
+               }
+               if (tab->zoomRect.Contains(where)) {
+                       tabIndex = i;
+                       return REGION_ZOOM_BUTTON;
+               }
+               if (tab->tabRect.Contains(where)) {
+                       tabIndex = i;
+                       return REGION_TAB;
+               }
+       }
+
        return REGION_NONE;
 }
 
@@ -411,17 +563,6 @@
 }
 
 
-bool
-Decorator::SetTabLocation(float location, BRegion* updateRegion)
-{
-       if (_SetTabLocation(location, updateRegion)) {
-               _InvalidateFootprint();
-               return true;
-       }
-       return false;
-}
-
-
 /*!    \brief Sets a specific highlight for a decorator region.
 
        Can be overridden by derived classes, but the base class version must be
@@ -434,7 +575,8 @@
        \return \c true, if the highlight could be applied.
 */
 bool
-Decorator::SetRegionHighlight(Region region, uint8 highlight, BRegion* dirty)
+Decorator::SetRegionHighlight(Region region, uint8 highlight, BRegion* dirty,
+       int32 tab)
 {
        int32 index = (int32)region - 1;
        if (index < 0 || index >= REGION_COUNT - 1)
@@ -479,7 +621,7 @@
 Decorator::Draw(BRect rect)
 {
        _DrawFrame(rect & fFrame);
-       _DrawTab(rect & fTabRect);
+       _DrawTabs(rect & fTitleBarRect);
 }
 
 
@@ -488,59 +630,75 @@
 Decorator::Draw()
 {
        _DrawFrame(fFrame);
-       _DrawTab(fTabRect);
+       _DrawTabs(fTitleBarRect);
 }
 
 
-//! Draws the close button
+//! draws the frame
 void
-Decorator::DrawClose()
+Decorator::DrawFrame()
 {
-       _DrawClose(fCloseRect);
+       _DrawFrame(fFrame);
 }
 
 
-//! draws the frame
+//! draws the tab, title, and buttons
 void
-Decorator::DrawFrame()
+Decorator::DrawTab(int32 tabIndex)
 {
-       _DrawFrame(fFrame);
+       Decorator::Tab* tab = fTabList.ItemAt(tabIndex);
+       if (tab == NULL)
+               return;
+
+       _DrawTab(tab, tab->tabRect);
+       _DrawZoom(tab, tab->zoomRect);
+       _DrawMinimize(tab, tab->minimizeRect);
+       _DrawTitle(tab, tab->tabRect);
+       _DrawClose(tab, tab->closeRect);
 }
 
 
-//! draws the minimize button
+//! Draws the close button
 void
-Decorator::DrawMinimize()
+Decorator::DrawClose(int32 tab)
 {
-       _DrawTab(fMinimizeRect);
+       Decorator::Tab* decoratorTab = fTabList.ItemAt(tab);
+       if (decoratorTab == NULL)
+               return;
+       _DrawClose(decoratorTab, decoratorTab->closeRect);
 }
 
 
-//! draws the tab, title, and buttons
+//! draws the minimize button
 void
-Decorator::DrawTab()
+Decorator::DrawMinimize(int32 tab)
 {
-       _DrawTab(fTabRect);
-       _DrawZoom(fZoomRect);
-       _DrawMinimize(fMinimizeRect);
-       _DrawTitle(fTabRect);
-       _DrawClose(fCloseRect);
+       Decorator::Tab* decoratorTab = fTabList.ItemAt(tab);
+       if (decoratorTab == NULL)
+               return;
+       _DrawTab(decoratorTab, decoratorTab->minimizeRect);
 }
 
 
 //! draws the title
 void
-Decorator::DrawTitle()
+Decorator::DrawTitle(int32 tab)
 {
-       _DrawTitle(fTabRect);
+       Decorator::Tab* decoratorTab = fTabList.ItemAt(tab);
+       if (decoratorTab == NULL)
+               return;
+       _DrawTitle(decoratorTab, decoratorTab->tabRect);
 }
 
 
 //! draws the zoom button
 void
-Decorator::DrawZoom()
+Decorator::DrawZoom(int32 tab)
 {
-       _DrawZoom(fZoomRect);
+       Decorator::Tab* decoratorTab = fTabList.ItemAt(tab);
+       if (decoratorTab == NULL)
+               return;
+       _DrawZoom(decoratorTab, decoratorTab->zoomRect);
 }
 
 
@@ -582,6 +740,24 @@
 }
 
 
+
+void
+Decorator::_DrawTabs(BRect rect)
+{
+       Decorator::Tab* focusTab = NULL;
+       for (int32 i = 0; i < fTabList.CountItems(); i++) {
+               Decorator::Tab* tab = fTabList.ItemAt(i);
+               if (tab->isFocused) {
+                       focusTab = tab;
+                       continue;
+               }
+               _DrawTab(tab, rect);
+       }
+       if (focusTab != NULL)
+               _DrawTab(focusTab, rect);
+}
+
+
 /*!    \brief Actually draws the tab
 
        This function is called when the tab itself needs drawn. Other items,
@@ -590,7 +766,7 @@
        \param rect Area of the tab to update
 */
 void
-Decorator::_DrawTab(BRect rect)
+Decorator::_DrawTab(Decorator::Tab* tab, BRect rect)
 {
 }
 
@@ -603,7 +779,7 @@
        \param rect Area of the button to update
 */
 void
-Decorator::_DrawClose(BRect rect)
+Decorator::_DrawClose(Decorator::Tab* tab, BRect rect)
 {
 }
 
@@ -618,7 +794,7 @@
        \param rect area of the title to update
 */
 void
-Decorator::_DrawTitle(BRect rect)
+Decorator::_DrawTitle(Decorator::Tab* tab, BRect rect)
 {
 }
 
@@ -631,7 +807,7 @@
        \param rect Area of the button to update
 */
 void
-Decorator::_DrawZoom(BRect rect)
+Decorator::_DrawZoom(Decorator::Tab* tab, BRect rect)
 {
 }
 
@@ -644,14 +820,22 @@
        \param rect Area of the button to update
 */
 void
-Decorator::_DrawMinimize(BRect rect)
+Decorator::_DrawMinimize(Decorator::Tab* tab, BRect rect)
 {
 }
 
 
+bool
+Decorator::_SetTabLocation(Decorator::Tab* tab, float location, bool 
isShifting,
+       BRegion* /*updateRegion*/)
+{
+       return false;
+}
+
+
 //! Hook function called when the decorator changes focus
 void
-Decorator::_SetFocus()
+Decorator::_SetFocus(Decorator::Tab* tab)
 {
 }
 
@@ -680,11 +864,15 @@
 void
 Decorator::_MoveBy(BPoint offset)
 {
-       fZoomRect.OffsetBy(offset);
-       fCloseRect.OffsetBy(offset);
-       fMinimizeRect.OffsetBy(offset);
-       fMinimizeRect.OffsetBy(offset);
-       fTabRect.OffsetBy(offset);
+       for (int32 i = 0; i < fTabList.CountItems(); i++) {
+               Decorator::Tab* tab = fTabList.ItemAt(i);
+
+               tab->zoomRect.OffsetBy(offset);
+               tab->closeRect.OffsetBy(offset);
+               tab->minimizeRect.OffsetBy(offset);
+               tab->tabRect.OffsetBy(offset);
+       }
+       fTitleBarRect.OffsetBy(offset);
        fFrame.OffsetBy(offset);
        fResizeRect.OffsetBy(offset);
        fBorderRect.OffsetBy(offset);

Modified: haiku/trunk/src/servers/app/Decorator.h
===================================================================
--- haiku/trunk/src/servers/app/Decorator.h     2011-07-25 00:11:33 UTC (rev 
42477)
+++ haiku/trunk/src/servers/app/Decorator.h     2011-07-25 01:09:26 UTC (rev 
42478)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2001-2010, Haiku.
+ * Copyright 2001-2011, Haiku.
  * Distributed under the terms of the MIT License.
  *
  * Authors:
@@ -27,6 +27,25 @@
 
 class Decorator {
 public:
+                       class Tab {
+                       public:
+                                                               Tab();
+                               virtual                 ~Tab() {}
+
+                               BRect                   zoomRect;
+                               BRect                   closeRect;
+                               BRect                   minimizeRect;
+                               BRect                   tabRect;
+
+                               bool                    closePressed : 1;
+                               bool                    zoomPressed : 1;
+                               bool                    minimizePressed : 1;
+
+                               bool                    isFocused : 1;
+
+                               BString                 title;
+                       };
+
                        enum Region {
                                REGION_NONE,
 
@@ -61,6 +80,19 @@
                                                                window_look 
look, uint32 flags);
        virtual                                 ~Decorator();
 
+       virtual Decorator::Tab* AddTab(const char* title, 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)
+                                                               { return 
fTabList.ItemAt(index); }
+                       int32                   CountTabs() const
+                                                               { return 
fTabList.CountItems(); }
+                       void                    SetTopTap(int32 tab);
+
                        void                    SetDrawingEngine(DrawingEngine 
*driver);
        inline  DrawingEngine*  GetDrawingEngine() const
                                                                { return 
fDrawingEngine; }
@@ -72,52 +104,50 @@
                        void                    SetFlags(uint32 flags,
                                                                BRegion* 
updateRegion = NULL);
 
-                       void                    SetClose(bool pressed);
-                       void                    SetMinimize(bool pressed);
-                       void                    SetZoom(bool pressed);
+                       window_look             Look() const;
+                       uint32                  Flags() const;
 
-                       void                    SetTitle(const char* string,
+                       BRect                   BorderRect() const;
+                       BRect                   TitleBarRect() const;
+                       BRect                   TabRect(int32 tab) const;
+                       BRect                   TabRect(Decorator::Tab* tab) 
const;
+
+                       void                    SetClose(int32 tab, bool 
pressed);
+                       void                    SetMinimize(int32 tab, bool 
pressed);
+                       void                    SetZoom(int32 tab, bool 
pressed);
+
+                       const char*             Title(int32 tab) const;
+                       const char*             Title(Decorator::Tab* tab) 
const;
+                       void                    SetTitle(int32 tab, const char* 
string,
                                                                BRegion* 
updateRegion = NULL);
 
-                       window_look             Look() const;
-                       uint32                  Flags() const;
+                       void                    SetFocus(int32 tab, bool 
focussed);
+                       bool                    IsFocus(int32 tab) const;
+                       bool                    IsFocus(Decorator::Tab* tab) 
const;
 
-                       const char*             Title() const;
+                       /*! \return true if tab location updated, false if out 
of bounds
+                       or unsupported */
+                       bool                    SetTabLocation(int32 tab, float 
location,
+                                                               bool 
isShifting, BRegion* updateRegion = NULL);
+       virtual float                   TabLocation(int32 tab) const
+                                                               { return 0.0; }
 
-                       BRect                   BorderRect() const;
-                       BRect                   TabRect() const;
+       virtual Region                  RegionAt(BPoint where, int32& tab) 
const;
 
-                       bool                    GetClose();
-                       bool                    GetMinimize();
-                       bool                    GetZoom();
-
        virtual void                    GetSizeLimits(int32* minWidth, int32* 
minHeight,
                                                                int32* 
maxWidth, int32* maxHeight) const;
 
-                       void                    SetFocus(bool focussed);
-                       bool                    IsFocus()
-                                                               { return 
fIsFocused; };
-
                        const BRegion&  GetFootprint();
 
-       virtual Region                  RegionAt(BPoint where) const;
-
                        void                    MoveBy(float x, float y);
                        void                    MoveBy(BPoint offset);
                        void                    ResizeBy(float x, float y, 
BRegion* dirty);
                        void                    ResizeBy(BPoint offset, 
BRegion* dirty);
 
-       /*! \return true if tab location updated, false if out of bounds
-               or unsupported
-       */
-                       bool                    SetTabLocation(float location,
-                                                               BRegion* 
/*updateRegion*/ = NULL);
-       virtual float                   TabLocation() const
-                                                               { return 0.0; }
-
        virtual bool                    SetRegionHighlight(Region region, uint8 
highlight,
-                                                               BRegion* dirty);
-       inline  uint8                   RegionHighlight(Region region) const;
+                                                               BRegion* dirty, 
int32 tab = -1);
+       inline  uint8                   RegionHighlight(Region region,
+                                                               int32 tab = -1) 
const;
 
                        bool                    SetSettings(const BMessage& 
settings,
                                                                BRegion* 
updateRegion = NULL);
@@ -125,31 +155,40 @@
 
        virtual void                    Draw(BRect rect);
        virtual void                    Draw();
-       virtual void                    DrawClose();
+       virtual void                    DrawClose(int32 tab);
+       virtual void                    DrawMinimize(int32 tab);
+       virtual void                    DrawTab(int32 tab);
+       virtual void                    DrawTitle(int32 tab);
+       virtual void                    DrawZoom(int32 tab);
        virtual void                    DrawFrame();
-       virtual void                    DrawMinimize();
-       virtual void                    DrawTab();
-       virtual void                    DrawTitle();
-       virtual void                    DrawZoom();
 
                        rgb_color               UIColor(color_which which);
 
        virtual void                    ExtendDirtyRegion(Region region, 
BRegion& dirty);
 
 protected:
-                       int32                   _TitleWidth() const
-                                                               { return 
fTitle.CountChars(); }
-
        virtual void                    _DoLayout();
 
        virtual void                    _DrawFrame(BRect rect);
-       virtual void                    _DrawTab(BRect rect);
 
-       virtual void                    _DrawClose(BRect rect);
-       virtual void                    _DrawTitle(BRect rect);
-       virtual void                    _DrawZoom(BRect rect);
-       virtual void                    _DrawMinimize(BRect rect);
+       virtual void                    _DrawTabs(BRect rect);
+       virtual void                    _DrawTab(Decorator::Tab* tab, BRect 
rect);
+       virtual void                    _DrawClose(Decorator::Tab* tab, BRect 
rect);
+       virtual void                    _DrawTitle(Decorator::Tab* tab, BRect 
rect);
+       virtual void                    _DrawZoom(Decorator::Tab* tab, BRect 
rect);
+       virtual void                    _DrawMinimize(Decorator::Tab* tab, 
BRect rect);
 
+       virtual Decorator::Tab* _AllocateNewTab() = 0;
+
+       virtual void                    _SetTitle(Decorator::Tab* tab, const 
char* string,
+                                                               BRegion* 
updateRegion = NULL) = 0;
+                       int32                   _TitleWidth(Decorator::Tab* 
tab) const
+                                                               { return 
tab->title.CountChars(); }
+
+       virtual bool                    _SetTabLocation(Decorator::Tab* tab, 
float location,
+                                                               bool 
isShifting, BRegion* updateRegion = NULL);
+       virtual void                    _SetFocus(Decorator::Tab* tab);
+
        virtual void                    _FontsChanged(DesktopSettings& settings,
                                                                BRegion* 
updateRegion = NULL);
        virtual void                    _SetLook(DesktopSettings& settings,
@@ -157,20 +196,19 @@
        virtual void                    _SetFlags(uint32 flags,
                                                                BRegion* 
updateRegion = NULL);
 
-       virtual void                    _SetTitle(const char* string,
-                                                               BRegion* 
updateRegion = NULL) = 0;
-
-       virtual void                    _SetFocus();
        virtual void                    _MoveBy(BPoint offset);
        virtual void                    _ResizeBy(BPoint offset, BRegion* 
dirty) = 0;
 
-       virtual bool                    _SetTabLocation(float location,
-                                                               BRegion* 
/*updateRegion*/ = NULL)
-                                                               { return false; 
}
-
        virtual bool                    _SetSettings(const BMessage& settings,
                                                                BRegion* 
updateRegion = NULL);
 
+       virtual bool                    _AddTab(int32 index = -1,
+                                                               BRegion* 
updateRegion = NULL) = 0;
+       virtual bool                    _RemoveTab(int32 index,
+                                                               BRegion* 
updateRegion = NULL) = 0;
+       virtual bool                    _MoveTab(int32 from, int32 to, bool 
isMoving,
+                                                               BRegion* 
updateRegion = NULL) = 0;
+
        virtual void                    _GetFootprint(BRegion *region);
                        void                    _InvalidateFootprint();
 
@@ -180,23 +218,14 @@
                        window_look             fLook;
                        uint32                  fFlags;
 
-                       BRect                   fZoomRect;
-                       BRect                   fCloseRect;
-                       BRect                   fMinimizeRect;
-                       BRect                   fTabRect;
+                       BRect                   fTitleBarRect;
                        BRect                   fFrame;
                        BRect                   fResizeRect;
                        BRect                   fBorderRect;
 
+                       Decorator::Tab* fTopTab;
+                       BObjectList<Decorator::Tab>     fTabList;
 private:
-                       bool                    fClosePressed : 1;
-                       bool                    fZoomPressed : 1;
-                       bool                    fMinimizePressed : 1;
-
-                       bool                    fIsFocused : 1;
-
-                       BString                 fTitle;
-
                        BRegion                 fFootprint;
                        bool                    fFootprintValid : 1;
 
@@ -205,7 +234,7 @@
 
 
 uint8
-Decorator::RegionHighlight(Region region) const
+Decorator::RegionHighlight(Region region, int32 tab) const
 {
        int32 index = (int32)region - 1;
        return index >= 0 && index < REGION_COUNT - 1

Modified: haiku/trunk/src/servers/app/DefaultDecorator.cpp
===================================================================
--- haiku/trunk/src/servers/app/DefaultDecorator.cpp    2011-07-25 00:11:33 UTC 
(rev 42477)
+++ haiku/trunk/src/servers/app/DefaultDecorator.cpp    2011-07-25 01:09:26 UTC 
(rev 42478)

[... truncated: 2829 lines follow ...]

Other related posts:

  • » [haiku-commits] r42478 - haiku/trunk/src/servers/app - clemens . zeidler