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:
parent
cd4ee847c4
commit
681c2e4425
|
@ -71,6 +71,7 @@ public:
|
||||||
virtual void DrawButtonFrame(BView* view, BRect& rect,
|
virtual void DrawButtonFrame(BView* view, BRect& rect,
|
||||||
const BRect& updateRect,
|
const BRect& updateRect,
|
||||||
const rgb_color& base,
|
const rgb_color& base,
|
||||||
|
const rgb_color& background,
|
||||||
uint32 flags = 0,
|
uint32 flags = 0,
|
||||||
uint32 borders = B_ALL_BORDERS);
|
uint32 borders = B_ALL_BORDERS);
|
||||||
|
|
||||||
|
@ -91,6 +92,7 @@ public:
|
||||||
virtual void DrawMenuFieldFrame(BView* view, BRect& rect,
|
virtual void DrawMenuFieldFrame(BView* view, BRect& rect,
|
||||||
const BRect& updateRect,
|
const BRect& updateRect,
|
||||||
const rgb_color& base,
|
const rgb_color& base,
|
||||||
|
const rgb_color& background,
|
||||||
uint32 flags = 0,
|
uint32 flags = 0,
|
||||||
uint32 borders = B_ALL_BORDERS);
|
uint32 borders = B_ALL_BORDERS);
|
||||||
|
|
||||||
|
@ -242,6 +244,7 @@ protected:
|
||||||
void _DrawButtonFrame(BView* view, BRect& rect,
|
void _DrawButtonFrame(BView* view, BRect& rect,
|
||||||
const BRect& updateRect,
|
const BRect& updateRect,
|
||||||
const rgb_color& base,
|
const rgb_color& base,
|
||||||
|
const rgb_color& background,
|
||||||
float contrast, float brightness = 1.0,
|
float contrast, float brightness = 1.0,
|
||||||
uint32 flags = 0,
|
uint32 flags = 0,
|
||||||
uint32 borders = B_ALL_BORDERS);
|
uint32 borders = B_ALL_BORDERS);
|
||||||
|
|
|
@ -95,7 +95,8 @@ IconButton::Draw(BRect area)
|
||||||
flags |= BControlLook::B_ACTIVATED;
|
flags |= BControlLook::B_ACTIVATED;
|
||||||
|
|
||||||
if (DrawBorder()) {
|
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,
|
be_control_look->DrawButtonBackground(this, r, area, background,
|
||||||
flags);
|
flags);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -129,6 +129,11 @@ _BMCMenuBar_::AttachedToWindow()
|
||||||
|
|
||||||
if (fFixedSize && (Flags() & B_SUPPORTS_LAYOUT) == 0)
|
if (fFixedSize && (Flags() & B_SUPPORTS_LAYOUT) == 0)
|
||||||
SetResizingMode(B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
|
SetResizingMode(B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
|
||||||
|
|
||||||
|
if (Parent() != NULL)
|
||||||
|
SetLowColor(Parent()->LowColor());
|
||||||
|
else
|
||||||
|
SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -105,12 +105,17 @@ BButton::Draw(BRect updateRect)
|
||||||
{
|
{
|
||||||
if (be_control_look != NULL) {
|
if (be_control_look != NULL) {
|
||||||
BRect rect(Bounds());
|
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();
|
rgb_color base = LowColor();
|
||||||
uint32 flags = be_control_look->Flags(this);
|
uint32 flags = be_control_look->Flags(this);
|
||||||
if (IsDefault())
|
if (IsDefault())
|
||||||
flags |= BControlLook::B_DEFAULT_BUTTON;
|
flags |= BControlLook::B_DEFAULT_BUTTON;
|
||||||
be_control_look->DrawButtonFrame(this, rect, updateRect,
|
be_control_look->DrawButtonFrame(this, rect, updateRect,
|
||||||
base, flags);
|
base, background, flags);
|
||||||
be_control_look->DrawButtonBackground(this, rect, updateRect,
|
be_control_look->DrawButtonBackground(this, rect, updateRect,
|
||||||
base, flags);
|
base, flags);
|
||||||
|
|
||||||
|
|
|
@ -66,9 +66,11 @@ BControlLook::Flags(BControl* control) const
|
||||||
|
|
||||||
void
|
void
|
||||||
BControlLook::DrawButtonFrame(BView* view, BRect& rect, const BRect& updateRect,
|
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
|
void
|
||||||
BControlLook::DrawMenuFieldFrame(BView* view, BRect& rect, const BRect& updateRect,
|
BControlLook::DrawMenuFieldFrame(BView* view, BRect& rect,
|
||||||
const rgb_color& base, uint32 flags, uint32 borders)
|
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
|
void
|
||||||
BControlLook::_DrawButtonFrame(BView* view, BRect& rect,
|
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)
|
float contrast, float brightness, uint32 flags, uint32 borders)
|
||||||
{
|
{
|
||||||
// colors
|
// colors
|
||||||
|
@ -1667,7 +1671,7 @@ BControlLook::_DrawButtonFrame(BView* view, BRect& rect,
|
||||||
borders);
|
borders);
|
||||||
} else {
|
} else {
|
||||||
// bevel around external border
|
// bevel around external border
|
||||||
_DrawOuterResessedFrame(view, rect, base,
|
_DrawOuterResessedFrame(view, rect, background,
|
||||||
contrast * ((flags & B_DISABLED) ? 0.0 : 1.0), brightness * 1.0,
|
contrast * ((flags & B_DISABLED) ? 0.0 : 1.0), brightness * 1.0,
|
||||||
borders);
|
borders);
|
||||||
}
|
}
|
||||||
|
|
|
@ -269,13 +269,15 @@ BMenuField::Draw(BRect update)
|
||||||
|
|
||||||
if (be_control_look != NULL) {
|
if (be_control_look != NULL) {
|
||||||
frame.InsetBy(-kVMargin, -kVMargin);
|
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;
|
uint32 flags = 0;
|
||||||
if (!fMenuBar->IsEnabled())
|
if (!fMenuBar->IsEnabled())
|
||||||
flags |= BControlLook::B_DISABLED;
|
flags |= BControlLook::B_DISABLED;
|
||||||
if (active)
|
if (active)
|
||||||
flags |= BControlLook::B_FOCUSED;
|
flags |= BControlLook::B_FOCUSED;
|
||||||
be_control_look->DrawMenuFieldFrame(this, frame, update, base, flags);
|
be_control_look->DrawMenuFieldFrame(this, frame, update, base,
|
||||||
|
background, flags);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -275,6 +275,7 @@ KeyboardLayoutView::Draw(BRect updateRect)
|
||||||
rect.left += rect.Width() / 4;
|
rect.left += rect.Width() / 4;
|
||||||
rect.right -= rect.Width() / 3;
|
rect.right -= rect.Width() / 3;
|
||||||
|
|
||||||
|
rgb_color background = ui_color(B_PANEL_BACKGROUND_COLOR);
|
||||||
rgb_color base;
|
rgb_color base;
|
||||||
if ((fModifiers & indicator->modifier) != 0)
|
if ((fModifiers & indicator->modifier) != 0)
|
||||||
base = kLitIndicatorColor;
|
base = kLitIndicatorColor;
|
||||||
|
@ -282,7 +283,7 @@ KeyboardLayoutView::Draw(BRect updateRect)
|
||||||
base = kDarkColor;
|
base = kDarkColor;
|
||||||
|
|
||||||
be_control_look->DrawButtonFrame(this, rect, updateRect, base,
|
be_control_look->DrawButtonFrame(this, rect, updateRect, base,
|
||||||
BControlLook::B_DISABLED);
|
background, BControlLook::B_DISABLED);
|
||||||
be_control_look->DrawButtonBackground(this, rect, updateRect,
|
be_control_look->DrawButtonBackground(this, rect, updateRect,
|
||||||
base, BControlLook::B_DISABLED);
|
base, BControlLook::B_DISABLED);
|
||||||
}
|
}
|
||||||
|
@ -378,10 +379,10 @@ KeyboardLayoutView::_LayoutKeyboard()
|
||||||
|
|
||||||
void
|
void
|
||||||
KeyboardLayoutView::_DrawKeyButton(BView* view, BRect rect, BRect updateRect,
|
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,
|
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,
|
be_control_look->DrawButtonBackground(view, rect, updateRect,
|
||||||
base, pressed ? BControlLook::B_ACTIVATED : 0);
|
base, pressed ? BControlLook::B_ACTIVATED : 0);
|
||||||
}
|
}
|
||||||
|
@ -392,6 +393,7 @@ KeyboardLayoutView::_DrawKey(BView* view, BRect updateRect, const Key* key,
|
||||||
BRect rect, bool pressed)
|
BRect rect, bool pressed)
|
||||||
{
|
{
|
||||||
rgb_color base = key->dark ? kDarkColor : kBrightColor;
|
rgb_color base = key->dark ? kDarkColor : kBrightColor;
|
||||||
|
rgb_color background = ui_color(B_PANEL_BACKGROUND_COLOR);
|
||||||
key_kind keyKind = kNormalKey;
|
key_kind keyKind = kNormalKey;
|
||||||
int32 deadKey = 0;
|
int32 deadKey = 0;
|
||||||
bool secondDeadKey = false;
|
bool secondDeadKey = false;
|
||||||
|
@ -415,7 +417,7 @@ KeyboardLayoutView::_DrawKey(BView* view, BRect updateRect, const Key* key,
|
||||||
base = kDeadKeyColor;
|
base = kDeadKeyColor;
|
||||||
|
|
||||||
if (key->shape == kRectangleKeyShape) {
|
if (key->shape == kRectangleKeyShape) {
|
||||||
_DrawKeyButton(view, rect, updateRect, base, pressed);
|
_DrawKeyButton(view, rect, updateRect, base, background, pressed);
|
||||||
|
|
||||||
rect.InsetBy(1, 1);
|
rect.InsetBy(1, 1);
|
||||||
|
|
||||||
|
@ -434,7 +436,7 @@ KeyboardLayoutView::_DrawKey(BView* view, BRect updateRect, const Key* key,
|
||||||
region.Exclude(missingRect);
|
region.Exclude(missingRect);
|
||||||
ConstrainClippingRegion(®ion);
|
ConstrainClippingRegion(®ion);
|
||||||
|
|
||||||
_DrawKeyButton(view, rect, updateRect, base, pressed);
|
_DrawKeyButton(view, rect, updateRect, base, background, pressed);
|
||||||
|
|
||||||
rect.left = missingRect.right;
|
rect.left = missingRect.right;
|
||||||
be_control_look->DrawLabel(view, text, rect, updateRect,
|
be_control_look->DrawLabel(view, text, rect, updateRect,
|
||||||
|
@ -447,7 +449,7 @@ KeyboardLayoutView::_DrawKey(BView* view, BRect updateRect, const Key* key,
|
||||||
|
|
||||||
rect = originalRect;
|
rect = originalRect;
|
||||||
rect.bottom = missingRect.top + 2;
|
rect.bottom = missingRect.top + 2;
|
||||||
_DrawKeyButton(view, rect, updateRect, base, pressed);
|
_DrawKeyButton(view, rect, updateRect, base, background, pressed);
|
||||||
|
|
||||||
missingRect.left = missingRect.right;
|
missingRect.left = missingRect.right;
|
||||||
missingRect.right++;
|
missingRect.right++;
|
||||||
|
@ -458,7 +460,7 @@ KeyboardLayoutView::_DrawKey(BView* view, BRect updateRect, const Key* key,
|
||||||
rect = originalRect;
|
rect = originalRect;
|
||||||
rect.left = missingRect.right - 2;
|
rect.left = missingRect.right - 2;
|
||||||
rect.top = missingRect.top - 2;
|
rect.top = missingRect.top - 2;
|
||||||
_DrawKeyButton(view, rect, updateRect, base, pressed);
|
_DrawKeyButton(view, rect, updateRect, base, background, pressed);
|
||||||
|
|
||||||
ConstrainClippingRegion(NULL);
|
ConstrainClippingRegion(NULL);
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,8 @@ private:
|
||||||
|
|
||||||
void _LayoutKeyboard();
|
void _LayoutKeyboard();
|
||||||
void _DrawKeyButton(BView* view, BRect rect,
|
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,
|
void _DrawKey(BView* view, BRect updateRect,
|
||||||
const Key* key, BRect frame, bool pressed);
|
const Key* key, BRect frame, bool pressed);
|
||||||
const char* _SpecialKeyLabel(const key_map& map, uint32 code);
|
const char* _SpecialKeyLabel(const key_map& map, uint32 code);
|
||||||
|
|
Loading…
Reference in New Issue