Set the background color in AttachedToWindow instead of repeatedly in Draw().

Try harder to avoid B_TRANSPARENT_COLOR of the parent.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36945 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus
2010-05-27 10:57:59 +00:00
parent 26fdf3bb32
commit 325a50a0c0
+10 -2
View File
@@ -69,6 +69,16 @@ IconButton::MessageReceived(BMessage* message)
void
IconButton::AttachedToWindow()
{
rgb_color background = B_TRANSPARENT_COLOR;
if (BView* parent = Parent()) {
background = parent->ViewColor();
if (background == B_TRANSPARENT_COLOR)
background = parent->LowColor();
}
if (background == B_TRANSPARENT_COLOR)
background = ui_color(B_PANEL_BACKGROUND_COLOR);
SetLowColor(background);
SetTarget(fTargetCache);
if (!Target())
SetTarget(Window());
@@ -79,8 +89,6 @@ void
IconButton::Draw(BRect area)
{
rgb_color background = LowColor();
if (BView* parent = Parent())
background = parent->LowColor();
BRect r(Bounds());