[haiku-commits] r39640 - in haiku/trunk/src: add-ons/decorators/SATDecorator servers/app

  • From: ingo_weinhold@xxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Fri, 26 Nov 2010 02:03:27 +0100 (CET)

Author: bonefish
Date: 2010-11-26 02:03:27 +0100 (Fri, 26 Nov 2010)
New Revision: 39640
Changeset: http://dev.haiku-os.org/changeset/39640

Modified:
   haiku/trunk/src/add-ons/decorators/SATDecorator/SATDecorator.cpp
   haiku/trunk/src/add-ons/decorators/SATDecorator/SATDecorator.h
   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
Log:
* Decorator:
  - Added ExtendDirtyRegion(), given a decorator region it extends the given
    dirty region. Implemented only in DefaultDecorator yet.
  - Added [Set]RegionHighlight() which allows to set/get a highlight for a
    decorator region. The visual representation of the set highlight value
    is up to the derived classes. The only globally defined value is
    HIGHLIGHT_RESIZE_BORDER, though it's not implemented anywhere yet.
* DefaultDecorator: Added the highlight for the component as a parameter to
  GetComponentColors(). Added a wrapper _GetComponentColors() with the old
  interface, fetching the highlight from the base class.
* SATDecorator: Defines and interprets its own highlight value
  HIGHLIGHT_STACK_AND_TILE.


Modified: haiku/trunk/src/add-ons/decorators/SATDecorator/SATDecorator.cpp
===================================================================
--- haiku/trunk/src/add-ons/decorators/SATDecorator/SATDecorator.cpp    
2010-11-26 00:43:46 UTC (rev 39639)
+++ haiku/trunk/src/add-ons/decorators/SATDecorator/SATDecorator.cpp    
2010-11-26 01:03:27 UTC (rev 39640)
@@ -97,7 +97,14 @@
 void
 SATDecorator::HighlightTab(bool active, BRegion* dirty)
 {
-       dirty->Include(fTabRect);
+       if (active == fTabHighlighted)
+               return;
+
+       uint8 highlight = active ? HIGHLIGHT_STACK_AND_TILE : 0;
+       SetRegionHighlight(REGION_TAB, highlight, dirty);
+       SetRegionHighlight(REGION_CLOSE_BUTTON, highlight, dirty);
+       SetRegionHighlight(REGION_ZOOM_BUTTON, highlight, dirty);
+
        fTabHighlighted = active;
 }
 
@@ -105,11 +112,16 @@
 void
 SATDecorator::HighlightBorders(bool active, BRegion* dirty)
 {
-       dirty->Include(fLeftBorder);
-       dirty->Include(fRightBorder);
-       dirty->Include(fTopBorder);
-       dirty->Include(fBottomBorder);
-       dirty->Include(fResizeRect);
+       if (active == fBordersHighlighted)
+               return;
+
+       uint8 highlight = active ? HIGHLIGHT_STACK_AND_TILE : 0;
+       SetRegionHighlight(REGION_LEFT_BORDER, highlight, dirty);
+       SetRegionHighlight(REGION_RIGHT_BORDER, highlight, dirty);
+       SetRegionHighlight(REGION_TOP_BORDER, highlight, dirty);
+       SetRegionHighlight(REGION_BOTTOM_BORDER, highlight, dirty);
+       SetRegionHighlight(REGION_RIGHT_BOTTOM_CORNER, highlight, dirty);
+
        fBordersHighlighted = active;
 }
 
@@ -452,15 +464,17 @@
 
 
 void
-SATDecorator::GetComponentColors(Component component, ComponentColors _colors)
+SATDecorator::GetComponentColors(Component component, uint8 highlight,
+       ComponentColors _colors)
 {
+       // we handle only our own highlights
+       if (highlight != HIGHLIGHT_STACK_AND_TILE) {
+               DefaultDecorator::GetComponentColors(component, highlight, 
_colors);
+               return;
+       }
+
        switch (component) {
                case COMPONENT_TAB:
-                       if (!fTabHighlighted) {
-                               DefaultDecorator::GetComponentColors(component, 
_colors);
-                               return;
-                       }
-
                        _colors[COLOR_TAB_FRAME_LIGHT] = kFrameColors[0];
                        _colors[COLOR_TAB_FRAME_DARK] = kFrameColors[3];
                        _colors[COLOR_TAB] = kHighlightTabColor;
@@ -472,11 +486,6 @@
 
                case COMPONENT_CLOSE_BUTTON:
                case COMPONENT_ZOOM_BUTTON:
-                       if (!fTabHighlighted) {
-                               DefaultDecorator::GetComponentColors(component, 
_colors);
-                               return;
-                       }
-
                        _colors[COLOR_BUTTON] = kHighlightTabColor;
                        _colors[COLOR_BUTTON_LIGHT] = kHighlightTabColorLight;
                        break;
@@ -487,11 +496,6 @@
                case COMPONENT_BOTTOM_BORDER:
                case COMPONENT_RESIZE_CORNER:
                default:
-                       if (!fBordersHighlighted) {
-                               DefaultDecorator::GetComponentColors(component, 
_colors);
-                               return;
-                       }
-
                        _colors[0] = kHighlightFrameColors[0];
                        _colors[1] = kHighlightFrameColors[1];
                        _colors[2] = kHighlightFrameColors[2];

Modified: haiku/trunk/src/add-ons/decorators/SATDecorator/SATDecorator.h
===================================================================
--- haiku/trunk/src/add-ons/decorators/SATDecorator/SATDecorator.h      
2010-11-26 00:43:46 UTC (rev 39639)
+++ haiku/trunk/src/add-ons/decorators/SATDecorator/SATDecorator.h      
2010-11-26 01:03:27 UTC (rev 39640)
@@ -31,6 +31,11 @@
 
 class SATDecorator : public DefaultDecorator {
 public:
+                       enum {
+                               HIGHLIGHT_STACK_AND_TILE = 
HIGHLIGHT_USER_DEFINED
+                       };
+
+public:
                                                                
SATDecorator(DesktopSettings& settings,
                                                                        BRect 
frame, window_look look,
                                                                        uint32 
flags);
@@ -64,7 +69,7 @@
 
        virtual void                            DrawButtons(const BRect& 
invalid);
        virtual void                            GetComponentColors(Component 
component,
-                                                                       
ComponentColors _colors);
+                                                                        uint8 
highlight, ComponentColors _colors);
 
 private:
                        bool                            fTabHighlighted;

Modified: haiku/trunk/src/servers/app/Decorator.cpp
===================================================================
--- haiku/trunk/src/servers/app/Decorator.cpp   2010-11-26 00:43:46 UTC (rev 
39639)
+++ haiku/trunk/src/servers/app/Decorator.cpp   2010-11-26 01:03:27 UTC (rev 
39640)
@@ -57,6 +57,7 @@
 
        fFootprintValid(false)
 {
+       memset(&fRegionHighlights, HIGHLIGHT_NONE, sizeof(fRegionHighlights));
 }
 
 
@@ -421,7 +422,34 @@
 }
 
 
+/*!    \brief Sets a specific highlight for a decorator region.
+
+       Can be overridden by derived classes, but the base class version must be
+       called, if the highlight shall be applied.
+
+       \param region The decorator region.
+       \param highlight The value identifying the kind of highlight.
+       \param dirty The dirty region to be extended, if the highlight changes. 
Can
+               be \c NULL.
+       \return \c true, if the highlight could be applied.
+*/
 bool
+Decorator::SetRegionHighlight(Region region, uint8 highlight, BRegion* dirty)
+{
+       int32 index = (int32)region - 1;
+       if (index < 0 || index >= REGION_COUNT - 1)
+               return false;
+
+       fRegionHighlights[index] = highlight;
+
+       if (dirty != NULL)
+               ExtendDirtyRegion(region, *dirty);
+
+       return true;
+}
+
+
+bool
 Decorator::SetSettings(const BMessage& settings, BRegion* updateRegion)
 {
        if (_SetSettings(settings, updateRegion)) {
@@ -523,6 +551,19 @@
 }
 
 
+/*!    \brief Extends a dirty region by a decorator region.
+
+       Must be implemented by derived classes.
+
+       \param region The decorator region.
+       \param dirty The dirty region to be extended.
+*/
+void
+Decorator::ExtendDirtyRegion(Region region, BRegion& dirty)
+{
+}
+
+
 //! Function for calculating layout for the decorator
 void
 Decorator::_DoLayout()

Modified: haiku/trunk/src/servers/app/Decorator.h
===================================================================
--- haiku/trunk/src/servers/app/Decorator.h     2010-11-26 00:43:46 UTC (rev 
39639)
+++ haiku/trunk/src/servers/app/Decorator.h     2010-11-26 01:03:27 UTC (rev 
39640)
@@ -44,9 +44,18 @@
                                REGION_LEFT_TOP_CORNER,
                                REGION_LEFT_BOTTOM_CORNER,
                                REGION_RIGHT_TOP_CORNER,
-                               REGION_RIGHT_BOTTOM_CORNER
+                               REGION_RIGHT_BOTTOM_CORNER,
+
+                               REGION_COUNT
                        };
 
+                       enum {
+                               HIGHLIGHT_NONE,
+                               HIGHLIGHT_RESIZE_BORDER,
+
+                               HIGHLIGHT_USER_DEFINED
+                       };
+
 public:
                                                        
Decorator(DesktopSettings& settings, BRect rect,
                                                                window_look 
look, uint32 flags);
@@ -106,6 +115,10 @@
        virtual float                   TabLocation() const
                                                                { return 0.0; }
 
+       virtual bool                    SetRegionHighlight(Region region, uint8 
highlight,
+                                                               BRegion* dirty);
+       inline  uint8                   RegionHighlight(Region region) const;
+
                        bool                    SetSettings(const BMessage& 
settings,
                                                                BRegion* 
updateRegion = NULL);
        virtual bool                    GetSettings(BMessage* settings) const;
@@ -121,6 +134,8 @@
 
                        rgb_color               UIColor(color_which which);
 
+       virtual void                    ExtendDirtyRegion(Region region, 
BRegion& dirty);
+
 protected:
                        int32                   _TitleWidth() const
                                                                { return 
fTitle.CountChars(); }
@@ -184,6 +199,18 @@
 
                        BRegion                 fFootprint;
                        bool                    fFootprintValid : 1;
+
+                       uint8                   fRegionHighlights[REGION_COUNT 
- 1];
 };
 
+
+uint8
+Decorator::RegionHighlight(Region region) const
+{
+       int32 index = (int32)region - 1;
+       return index >= 0 && index < REGION_COUNT - 1
+               ? fRegionHighlights[index] : 0;
+}
+
+
 #endif // DECORATOR_H

Modified: haiku/trunk/src/servers/app/DefaultDecorator.cpp
===================================================================
--- haiku/trunk/src/servers/app/DefaultDecorator.cpp    2010-11-26 00:43:46 UTC 
(rev 39639)
+++ haiku/trunk/src/servers/app/DefaultDecorator.cpp    2010-11-26 01:03:27 UTC 
(rev 39640)
@@ -242,6 +242,51 @@
 }
 
 
+void
+DefaultDecorator::ExtendDirtyRegion(Region region, BRegion& dirty)
+{
+       switch (region) {
+               case REGION_TAB:
+                       dirty.Include(fTabRect);
+                       break;
+
+               case REGION_CLOSE_BUTTON:
+                       if ((fFlags & B_NOT_CLOSABLE) == 0)
+                               dirty.Include(fCloseRect);
+                       break;
+
+               case REGION_ZOOM_BUTTON:
+                       if ((fFlags & B_NOT_ZOOMABLE) == 0)
+                               dirty.Include(fZoomRect);
+                       break;
+
+               case REGION_LEFT_BORDER:
+                       dirty.Include(fLeftBorder);
+                       break;
+
+               case REGION_RIGHT_BORDER:
+                       dirty.Include(fRightBorder);
+                       break;
+
+               case REGION_TOP_BORDER:
+                       dirty.Include(fTopBorder);
+                       break;
+
+               case REGION_BOTTOM_BORDER:
+                       dirty.Include(fBottomBorder);
+                       break;
+
+               case REGION_RIGHT_BOTTOM_CORNER:
+                       if ((fFlags & B_NOT_RESIZABLE) == 0)
+                               dirty.Include(fResizeRect);
+                       break;
+
+               default:
+                       break;
+       }
+}
+
+
 float
 DefaultDecorator::BorderWidth()
 {
@@ -438,7 +483,7 @@
                        // top
                        if (invalid.Intersects(fTopBorder)) {
                                ComponentColors colors;
-                               GetComponentColors(COMPONENT_TOP_BORDER, 
colors);
+                               _GetComponentColors(COMPONENT_TOP_BORDER, 
colors);
 
                                for (int8 i = 0; i < 5; i++) {
                                        
fDrawingEngine->StrokeLine(BPoint(r.left + i, r.top + i),
@@ -456,7 +501,7 @@
                        // left
                        if (invalid.Intersects(fLeftBorder.InsetByCopy(0, 
-fBorderWidth))) {
                                ComponentColors colors;
-                               GetComponentColors(COMPONENT_LEFT_BORDER, 
colors);
+                               _GetComponentColors(COMPONENT_LEFT_BORDER, 
colors);
 
                                for (int8 i = 0; i < 5; i++) {
                                        
fDrawingEngine->StrokeLine(BPoint(r.left + i, r.top + i),
@@ -466,7 +511,7 @@
                        // bottom
                        if (invalid.Intersects(fBottomBorder)) {
                                ComponentColors colors;
-                               GetComponentColors(COMPONENT_BOTTOM_BORDER, 
colors);
+                               _GetComponentColors(COMPONENT_BOTTOM_BORDER, 
colors);
 
                                for (int8 i = 0; i < 5; i++) {
                                        
fDrawingEngine->StrokeLine(BPoint(r.left + i, r.bottom - i),
@@ -477,7 +522,7 @@
                        // right
                        if (invalid.Intersects(fRightBorder.InsetByCopy(0, 
-fBorderWidth))) {
                                ComponentColors colors;
-                               GetComponentColors(COMPONENT_RIGHT_BORDER, 
colors);
+                               _GetComponentColors(COMPONENT_RIGHT_BORDER, 
colors);
 
                                for (int8 i = 0; i < 5; i++) {
                                        
fDrawingEngine->StrokeLine(BPoint(r.right - i, r.top + i),
@@ -494,7 +539,7 @@
                        // top
                        if (invalid.Intersects(fTopBorder)) {
                                ComponentColors colors;
-                               GetComponentColors(COMPONENT_TOP_BORDER, 
colors);
+                               _GetComponentColors(COMPONENT_TOP_BORDER, 
colors);
 
                                for (int8 i = 0; i < 3; i++) {
                                        
fDrawingEngine->StrokeLine(BPoint(r.left + i, r.top + i),
@@ -512,7 +557,7 @@
                        // left
                        if (invalid.Intersects(fLeftBorder.InsetByCopy(0, 
-fBorderWidth))) {
                                ComponentColors colors;
-                               GetComponentColors(COMPONENT_LEFT_BORDER, 
colors);
+                               _GetComponentColors(COMPONENT_LEFT_BORDER, 
colors);
 
                                for (int8 i = 0; i < 3; i++) {
                                        
fDrawingEngine->StrokeLine(BPoint(r.left + i, r.top + i),
@@ -530,7 +575,7 @@
                        // bottom
                        if (invalid.Intersects(fBottomBorder)) {
                                ComponentColors colors;
-                               GetComponentColors(COMPONENT_BOTTOM_BORDER, 
colors);
+                               _GetComponentColors(COMPONENT_BOTTOM_BORDER, 
colors);
 
                                for (int8 i = 0; i < 3; i++) {
                                        
fDrawingEngine->StrokeLine(BPoint(r.left + i, r.bottom - i),
@@ -541,7 +586,7 @@
                        // right
                        if (invalid.Intersects(fRightBorder.InsetByCopy(0, 
-fBorderWidth))) {
                                ComponentColors colors;
-                               GetComponentColors(COMPONENT_RIGHT_BORDER, 
colors);
+                               _GetComponentColors(COMPONENT_RIGHT_BORDER, 
colors);
 
                                for (int8 i = 0; i < 3; i++) {
                                        
fDrawingEngine->StrokeLine(BPoint(r.right - i, r.top + i),
@@ -556,7 +601,7 @@
                {
                        // TODO: Draw the borders individually!
                        ComponentColors colors;
-                       GetComponentColors(COMPONENT_LEFT_BORDER, colors);
+                       _GetComponentColors(COMPONENT_LEFT_BORDER, colors);
 
                        fDrawingEngine->StrokeRect(r, colors[5]);
                        break;
@@ -572,7 +617,7 @@
                r = fResizeRect;
 
                ComponentColors colors;
-               GetComponentColors(COMPONENT_RESIZE_CORNER, colors);
+               _GetComponentColors(COMPONENT_RESIZE_CORNER, colors);
 
                switch (fLook) {
                        case B_DOCUMENT_WINDOW_LOOK:
@@ -658,7 +703,7 @@
                return;
 
        ComponentColors colors;
-       GetComponentColors(COMPONENT_TAB, colors);
+       _GetComponentColors(COMPONENT_TAB, colors);
 
        // outer frame
        fDrawingEngine->StrokeLine(fTabRect.LeftTop(), fTabRect.LeftBottom(),
@@ -740,7 +785,7 @@
        STRACE(("_DrawTitle(%f,%f,%f,%f)\n", r.left, r.top, r.right, r.bottom));
 
        ComponentColors colors;
-       GetComponentColors(COMPONENT_TAB, colors);
+       _GetComponentColors(COMPONENT_TAB, colors);
 
        fDrawingEngine->SetDrawingMode(B_OP_OVER);
        fDrawingEngine->SetHighColor(colors[COLOR_TAB_TEXT]);
@@ -1141,11 +1186,12 @@
        The meaning of the color array elements depends on the specified 
component.
        For some components some array elements are unused.
 
-       \param region The region for which to return the frame colors.
+       \param component The component for which to return the frame colors.
+       \param highlight The highlight set for the component.
        \param colors An array of colors to be initialized by the function.
 */
 void
-DefaultDecorator::GetComponentColors(Component component,
+DefaultDecorator::GetComponentColors(Component component, uint8 highlight,
        ComponentColors _colors)
 {
        switch (component) {
@@ -1369,7 +1415,7 @@
        static decorator_bitmap* sBitmapList = NULL;
 
        ComponentColors colors;
-       GetComponentColors(item, colors);
+       _GetComponentColors(item, colors);
 
        BAutolock locker(sBitmapListLock);
 
@@ -1452,3 +1498,41 @@
        sBitmapList = entry;
        return bitmap;
 }
+
+
+
+void
+DefaultDecorator::_GetComponentColors(Component component,
+       ComponentColors _colors)
+{
+       // get the highlight for our component
+       Region region;
+       switch (component) {
+               case COMPONENT_TAB:
+                       region = REGION_TAB;
+                       break;
+               case COMPONENT_CLOSE_BUTTON:
+                       region = REGION_CLOSE_BUTTON;
+                       break;
+               case COMPONENT_ZOOM_BUTTON:
+                       region = REGION_ZOOM_BUTTON;
+                       break;
+               case COMPONENT_LEFT_BORDER:
+                       region = REGION_LEFT_BORDER;
+                       break;
+               case COMPONENT_RIGHT_BORDER:
+                       region = REGION_RIGHT_BORDER;
+                       break;
+               case COMPONENT_TOP_BORDER:
+                       region = REGION_TOP_BORDER;
+                       break;
+               case COMPONENT_BOTTOM_BORDER:
+                       region = REGION_BOTTOM_BORDER;
+                       break;
+               case COMPONENT_RESIZE_CORNER:
+                       region = REGION_RIGHT_BOTTOM_CORNER;
+                       break;
+       }
+
+       return GetComponentColors(component, RegionHighlight(region), _colors);
+}

Modified: haiku/trunk/src/servers/app/DefaultDecorator.h
===================================================================
--- haiku/trunk/src/servers/app/DefaultDecorator.h      2010-11-26 00:43:46 UTC 
(rev 39639)
+++ haiku/trunk/src/servers/app/DefaultDecorator.h      2010-11-26 01:03:27 UTC 
(rev 39640)
@@ -40,6 +40,9 @@
 
        virtual Region                          RegionAt(BPoint where) const;
 
+       virtual void                            ExtendDirtyRegion(Region region,
+                                                                       
BRegion& dirty);
+
                        float                           BorderWidth();
                        float                           TabHeight();
 
@@ -116,7 +119,7 @@
        // DefaultDecorator customization points
        virtual void                            DrawButtons(const BRect& 
invalid);
        virtual void                            GetComponentColors(Component 
component,
-                                                                       
ComponentColors _colors);
+                                                                       uint8 
highlight, ComponentColors _colors);
 
 private:
                        void                            
_UpdateFont(DesktopSettings& settings);
@@ -130,6 +133,9 @@
                        ServerBitmap*           _GetBitmapForButton(Component 
item, bool down,
                                                                        int32 
width, int32 height);
 
+                       void                            
_GetComponentColors(Component component,
+                                                                       
ComponentColors _colors);
+
 protected:
        static  const rgb_color         kFrameColors[4];
        static  const rgb_color         kFocusFrameColors[2];


Other related posts:

  • » [haiku-commits] r39640 - in haiku/trunk/src: add-ons/decorators/SATDecorator servers/app - ingo_weinhold