The button and menu field draw routines take a background color into account,

which makes the resessed frame blend better with the surroundings. This can
be seen best in Keymap, where a different color is set on some buttons, but
the resessed frame should still be the same across all those buttons.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29716 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus 2009-03-25 23:34:19 +00:00
parent cd4ee847c4
commit 681c2e4425
8 changed files with 42 additions and 19 deletions

View File

@ -71,6 +71,7 @@ public:
virtual void DrawButtonFrame(BView* view, BRect& rect,
const BRect& updateRect,
const rgb_color& base,
const rgb_color& background,
uint32 flags = 0,
uint32 borders = B_ALL_BORDERS);
@ -91,6 +92,7 @@ public:
virtual void DrawMenuFieldFrame(BView* view, BRect& rect,
const BRect& updateRect,
const rgb_color& base,
const rgb_color& background,
uint32 flags = 0,
uint32 borders = B_ALL_BORDERS);
@ -242,6 +244,7 @@ protected:
void _DrawButtonFrame(BView* view, BRect& rect,
const BRect& updateRect,
const rgb_color& base,
const rgb_color& background,
float contrast, float brightness = 1.0,
uint32 flags = 0,
uint32 borders = B_ALL_BORDERS);

View File

@ -95,7 +95,8 @@ IconButton::Draw(BRect area)
flags |= BControlLook::B_ACTIVATED;
if (DrawBorder()) {
be_control_look->DrawButtonFrame(this, r, area, background, flags);
be_control_look->DrawButtonFrame(this, r, area, background,
background, flags);
be_control_look->DrawButtonBackground(this, r, area, background,
flags);
} else {

View File

@ -129,6 +129,11 @@ _BMCMenuBar_::AttachedToWindow()
if (fFixedSize && (Flags() & B_SUPPORTS_LAYOUT) == 0)
SetResizingMode(B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
if (Parent() != NULL)
SetLowColor(Parent()->LowColor());
else
SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));
}

View File

@ -105,12 +105,17 @@ BButton::Draw(BRect updateRect)
{
if (be_control_look != NULL) {
BRect rect(Bounds());
rgb_color background = B_TRANSPARENT_COLOR;
if (Parent())
background = Parent()->ViewColor();
if (background == B_TRANSPARENT_COLOR)
background = ui_color(B_PANEL_BACKGROUND_COLOR);
rgb_color base = LowColor();
uint32 flags = be_control_look->Flags(this);
if (IsDefault())
flags |= BControlLook::B_DEFAULT_BUTTON;
be_control_look->DrawButtonFrame(this, rect, updateRect,
base, flags);
base, background, flags);
be_control_look->DrawButtonBackground(this, rect, updateRect,
base, flags);

View File

@ -66,9 +66,11 @@ BControlLook::Flags(BControl* control) const
void
BControlLook::DrawButtonFrame(BView* view, BRect& rect, const BRect& updateRect,
const rgb_color& base, uint32 flags, uint32 borders)
const rgb_color& base, const rgb_color& background, uint32 flags,
uint32 borders)
{
_DrawButtonFrame(view, rect, updateRect, base, 1.0, 1.0, flags, borders);
_DrawButtonFrame(view, rect, updateRect, base, background, 1.0, 1.0, flags,
borders);
}
@ -220,10 +222,12 @@ BControlLook::DrawMenuBarBackground(BView* view, BRect& rect,
void
BControlLook::DrawMenuFieldFrame(BView* view, BRect& rect, const BRect& updateRect,
const rgb_color& base, uint32 flags, uint32 borders)
BControlLook::DrawMenuFieldFrame(BView* view, BRect& rect,
const BRect& updateRect, const rgb_color& base,
const rgb_color& background, uint32 flags, uint32 borders)
{
_DrawButtonFrame(view, rect, updateRect, base, 0.6, 1.0, flags, borders);
_DrawButtonFrame(view, rect, updateRect, base, background, 0.6, 1.0, flags,
borders);
}
@ -1606,7 +1610,7 @@ BControlLook::DrawLabel(BView* view, const char* label, BRect rect,
void
BControlLook::_DrawButtonFrame(BView* view, BRect& rect,
const BRect& updateRect, const rgb_color& base,
const BRect& updateRect, const rgb_color& base, const rgb_color& background,
float contrast, float brightness, uint32 flags, uint32 borders)
{
// colors
@ -1667,7 +1671,7 @@ BControlLook::_DrawButtonFrame(BView* view, BRect& rect,
borders);
} else {
// bevel around external border
_DrawOuterResessedFrame(view, rect, base,
_DrawOuterResessedFrame(view, rect, background,
contrast * ((flags & B_DISABLED) ? 0.0 : 1.0), brightness * 1.0,
borders);
}

View File

@ -269,13 +269,15 @@ BMenuField::Draw(BRect update)
if (be_control_look != NULL) {
frame.InsetBy(-kVMargin, -kVMargin);
rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR);
rgb_color base = fMenuBar->LowColor();
rgb_color background = LowColor();
uint32 flags = 0;
if (!fMenuBar->IsEnabled())
flags |= BControlLook::B_DISABLED;
if (active)
flags |= BControlLook::B_FOCUSED;
be_control_look->DrawMenuFieldFrame(this, frame, update, base, flags);
be_control_look->DrawMenuFieldFrame(this, frame, update, base,
background, flags);
return;
}

View File

@ -275,6 +275,7 @@ KeyboardLayoutView::Draw(BRect updateRect)
rect.left += rect.Width() / 4;
rect.right -= rect.Width() / 3;
rgb_color background = ui_color(B_PANEL_BACKGROUND_COLOR);
rgb_color base;
if ((fModifiers & indicator->modifier) != 0)
base = kLitIndicatorColor;
@ -282,7 +283,7 @@ KeyboardLayoutView::Draw(BRect updateRect)
base = kDarkColor;
be_control_look->DrawButtonFrame(this, rect, updateRect, base,
BControlLook::B_DISABLED);
background, BControlLook::B_DISABLED);
be_control_look->DrawButtonBackground(this, rect, updateRect,
base, BControlLook::B_DISABLED);
}
@ -378,10 +379,10 @@ KeyboardLayoutView::_LayoutKeyboard()
void
KeyboardLayoutView::_DrawKeyButton(BView* view, BRect rect, BRect updateRect,
rgb_color base, bool pressed)
rgb_color base, rgb_color background, bool pressed)
{
be_control_look->DrawButtonFrame(view, rect, updateRect, base,
pressed ? BControlLook::B_ACTIVATED : 0);
background, pressed ? BControlLook::B_ACTIVATED : 0);
be_control_look->DrawButtonBackground(view, rect, updateRect,
base, pressed ? BControlLook::B_ACTIVATED : 0);
}
@ -392,6 +393,7 @@ KeyboardLayoutView::_DrawKey(BView* view, BRect updateRect, const Key* key,
BRect rect, bool pressed)
{
rgb_color base = key->dark ? kDarkColor : kBrightColor;
rgb_color background = ui_color(B_PANEL_BACKGROUND_COLOR);
key_kind keyKind = kNormalKey;
int32 deadKey = 0;
bool secondDeadKey = false;
@ -415,7 +417,7 @@ KeyboardLayoutView::_DrawKey(BView* view, BRect updateRect, const Key* key,
base = kDeadKeyColor;
if (key->shape == kRectangleKeyShape) {
_DrawKeyButton(view, rect, updateRect, base, pressed);
_DrawKeyButton(view, rect, updateRect, base, background, pressed);
rect.InsetBy(1, 1);
@ -434,7 +436,7 @@ KeyboardLayoutView::_DrawKey(BView* view, BRect updateRect, const Key* key,
region.Exclude(missingRect);
ConstrainClippingRegion(&region);
_DrawKeyButton(view, rect, updateRect, base, pressed);
_DrawKeyButton(view, rect, updateRect, base, background, pressed);
rect.left = missingRect.right;
be_control_look->DrawLabel(view, text, rect, updateRect,
@ -447,7 +449,7 @@ KeyboardLayoutView::_DrawKey(BView* view, BRect updateRect, const Key* key,
rect = originalRect;
rect.bottom = missingRect.top + 2;
_DrawKeyButton(view, rect, updateRect, base, pressed);
_DrawKeyButton(view, rect, updateRect, base, background, pressed);
missingRect.left = missingRect.right;
missingRect.right++;
@ -458,7 +460,7 @@ KeyboardLayoutView::_DrawKey(BView* view, BRect updateRect, const Key* key,
rect = originalRect;
rect.left = missingRect.right - 2;
rect.top = missingRect.top - 2;
_DrawKeyButton(view, rect, updateRect, base, pressed);
_DrawKeyButton(view, rect, updateRect, base, background, pressed);
ConstrainClippingRegion(NULL);
}

View File

@ -52,7 +52,8 @@ private:
void _LayoutKeyboard();
void _DrawKeyButton(BView* view, BRect rect,
BRect updateRect, rgb_color base, bool pressed);
BRect updateRect, rgb_color base,
rgb_color background, bool pressed);
void _DrawKey(BView* view, BRect updateRect,
const Key* key, BRect frame, bool pressed);
const char* _SpecialKeyLabel(const key_map& map, uint32 code);