Removed background color from images - BeMail will now look much better if you have

a different panel background color.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14935 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2005-11-15 03:13:19 +00:00
parent 9a1d68e4aa
commit 60bddfface
2 changed files with 1174 additions and 1274 deletions

View File

@ -32,14 +32,19 @@ names are registered trademarks or trademarks of their respective holders.
All rights reserved. All rights reserved.
*/ */
#include "BmapButton.h" #include "BmapButton.h"
#include <BeBuild.h>
#include <Bitmap.h> #include <Bitmap.h>
#include <Autolock.h> #include <Autolock.h>
#include <Application.h> #include <Application.h>
#include <Resources.h> #include <Resources.h>
#include <stdlib.h> #include <stdlib.h>
#ifndef B_BEOS_VERSION_5_0_4
#ifndef B_BEOS_VERSION_DANO
static rgb_color static rgb_color
mix_color(rgb_color color1, rgb_color color2, float portion) mix_color(rgb_color color1, rgb_color color2, float portion)
{ {
@ -56,13 +61,12 @@ disable_color(rgb_color color, rgb_color background)
{ {
return mix_color(color, background, .5); return mix_color(color, background, .5);
} }
#endif // #ifndef B_BEOS_VERSION_5_0_4 #endif // #ifndef B_BEOS_VERSION_DANO
BList BmapButton::fBitmapCache; BList BmapButton::fBitmapCache;
BLocker BmapButton::fBmCacheLock; BLocker BmapButton::fBmCacheLock;
struct BitmapItem struct BitmapItem {
{
BBitmap *bm; BBitmap *bm;
int32 id; int32 id;
int32 openCount; int32 openCount;
@ -178,10 +182,11 @@ BmapButton::Draw(BRect updateRect)
{ {
BRect bounds(Bounds()); BRect bounds(Bounds());
float labelHeight, labelWidth; float labelHeight, labelWidth;
#if F_SHOW_GEOMETRY #if F_SHOW_GEOMETRY
StrokeRect(bounds); StrokeRect(bounds);
#endif #endif
// Draw Label // Draw Label
if (fShowLabel) { if (fShowLabel) {
font_height fheight; font_height fheight;
@ -199,18 +204,18 @@ BmapButton::Draw(BRect updateRect)
textRect.right = textRect.left+labelWidth; textRect.right = textRect.left+labelWidth;
textRect.bottom = bounds.bottom; textRect.bottom = bounds.bottom;
textRect.top = textRect.bottom-fheight.descent-fheight.ascent-1; textRect.top = textRect.bottom-fheight.descent-fheight.ascent-1;
// Only draw if it's within the update rect // Only draw if it's within the update rect
if (updateRect.Intersects(textRect)) { if (updateRect.Intersects(textRect)) {
float baseLine = textRect.bottom-fheight.descent; float baseLine = textRect.bottom-fheight.descent;
if (IsFocus() && fActive) if (IsFocus() && fActive)
SetHighColor(0, 0, 255); SetHighColor(0, 0, 255);
else else
SetHighColor(ViewColor()); SetHighColor(ViewColor());
StrokeLine(BPoint(textRect.left, baseLine), StrokeLine(BPoint(textRect.left, baseLine),
BPoint(textRect.right, baseLine)); BPoint(textRect.right, baseLine));
if (IsEnabled()) if (IsEnabled())
SetHighColor(0, 0, 0); SetHighColor(0, 0, 0);
else { else {
@ -219,13 +224,12 @@ BmapButton::Draw(BRect updateRect)
} }
MovePenTo(textRect.left, baseLine); MovePenTo(textRect.left, baseLine);
DrawString(Label()); DrawString(Label());
#if F_SHOW_GEOMETRY #if F_SHOW_GEOMETRY
FrameRect(textRect); FrameRect(textRect);
#endif #endif
} }
} } else {
else {
labelHeight = 0; labelHeight = 0;
labelWidth = 0; labelWidth = 0;
} }
@ -256,12 +260,17 @@ BmapButton::Draw(BRect updateRect)
fBitmapRect.OffsetBy((bounds.right-bounds.left-fBitmapRect.right-fBitmapRect.left)/2, fBitmapRect.OffsetBy((bounds.right-bounds.left-fBitmapRect.right-fBitmapRect.left)/2,
(bounds.bottom-bounds.top-labelHeight-fBitmapRect.bottom-fBitmapRect.top)/2); (bounds.bottom-bounds.top-labelHeight-fBitmapRect.bottom-fBitmapRect.top)/2);
// Update if within update rect // Update if within update rect
SetDrawingMode(B_OP_OVER);
if (updateRect.Intersects(fBitmapRect)) { if (updateRect.Intersects(fBitmapRect)) {
DrawBitmap(bm, fBitmapRect); DrawBitmap(bm, fBitmapRect);
#if F_SHOW_GEOMETRY #if F_SHOW_GEOMETRY
StrokeRect(fBitmapRect); StrokeRect(fBitmapRect);
#endif #endif
} }
SetDrawingMode(B_OP_COPY);
} }
} }

File diff suppressed because it is too large Load Diff