From dacf06e66531f333ad5cc1c640d57d8d68120c1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Mon, 17 Aug 2009 17:09:38 +0000 Subject: [PATCH] * The cached button bitmaps were not invalidated on font or look change, causing incorrect buttons to be shown. * Fixed coding style violations. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32472 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/servers/app/DefaultDecorator.cpp | 21 ++++++++++++++++----- src/servers/app/DefaultDecorator.h | 7 ++++--- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/servers/app/DefaultDecorator.cpp b/src/servers/app/DefaultDecorator.cpp index 240144217d..3f8f7c821e 100644 --- a/src/servers/app/DefaultDecorator.cpp +++ b/src/servers/app/DefaultDecorator.cpp @@ -148,6 +148,7 @@ DefaultDecorator::FontsChanged(DesktopSettings& settings, BRegion* updateRegion) } _UpdateFont(settings); + _InvalidateBitmaps(); _DoLayout(); if (updateRegion != NULL) { @@ -174,6 +175,7 @@ DefaultDecorator::SetLook(DesktopSettings& settings, window_look look, fLook = look; _UpdateFont(settings); + _InvalidateBitmaps(); _DoLayout(); if (updateRegion != NULL) { @@ -887,7 +889,7 @@ DefaultDecorator::_DrawFrame(BRect invalid) gradient.SetEnd(bg.RightBottom()); gradient.AddColor(fFrameColors[1], 0); gradient.AddColor(fFrameColors[2], 255); - + fDrawingEngine->FillRect(bg, gradient); fDrawingEngine->StrokeLine(BPoint(x - 15, y - 15), @@ -1019,7 +1021,7 @@ DefaultDecorator::_DrawClose(BRect rect) rect.bottom)); int32 index = (fButtonFocus ? 0 : 1) + (GetClose() ? 0 : 2); - ServerBitmap *bitmap = fCloseBitmaps[index]; + ServerBitmap* bitmap = fCloseBitmaps[index]; if (bitmap == NULL) { bitmap = _GetBitmapForButton(DEC_CLOSE, GetClose(), fButtonFocus, rect.IntegerWidth(), rect.IntegerHeight(), this); @@ -1072,7 +1074,7 @@ DefaultDecorator::_DrawZoom(BRect rect) rect.bottom)); int32 index = (fButtonFocus ? 0 : 1) + (GetZoom() ? 0 : 2); - ServerBitmap *bitmap = fZoomBitmaps[index]; + ServerBitmap* bitmap = fZoomBitmaps[index]; if (bitmap == NULL) { bitmap = _GetBitmapForButton(DEC_ZOOM, GetZoom(), fButtonFocus, rect.IntegerWidth(), rect.IntegerHeight(), this); @@ -1153,8 +1155,7 @@ DefaultDecorator::_DrawButtonBitmap(ServerBitmap* bitmap, BRect rect) } -/*! - \brief Draws a framed rectangle with a gradient. +/*! \brief Draws a framed rectangle with a gradient. \param down The rectangle should be drawn recessed or not */ void @@ -1259,6 +1260,16 @@ DefaultDecorator::_LayoutTabItems(const BRect& tabRect) } +void +DefaultDecorator::_InvalidateBitmaps() +{ + for (int32 index = 0; index < 4; index++) { + fCloseBitmaps[index] = NULL; + fZoomBitmaps[index] = NULL; + } +} + + ServerBitmap* DefaultDecorator::_GetBitmapForButton(int32 item, bool down, bool focus, int32 width, int32 height, DefaultDecorator* object) diff --git a/src/servers/app/DefaultDecorator.h b/src/servers/app/DefaultDecorator.h index 9a749466ef..d58aea8812 100644 --- a/src/servers/app/DefaultDecorator.h +++ b/src/servers/app/DefaultDecorator.h @@ -1,5 +1,5 @@ /* - * Copyright 2001-2008, Haiku. + * Copyright 2001-2009, Haiku. * Distributed under the terms of the MIT License. * * Authors: @@ -79,6 +79,7 @@ private: float* offset, float* size, float* inset) const; void _LayoutTabItems(const BRect& tabRect); + void _InvalidateBitmaps(); static ServerBitmap* _GetBitmapForButton(int32 item, bool down, bool focus, int32 width, int32 height, @@ -102,8 +103,8 @@ private: rgb_color fNonFocusFrameColors[2]; bool fButtonFocus; - ServerBitmap * fCloseBitmaps[4]; - ServerBitmap * fZoomBitmaps[4]; + ServerBitmap* fCloseBitmaps[4]; + ServerBitmap* fZoomBitmaps[4]; // Individual rects for handling window frame // rendering the proper way