BToolBar: Convert to using Set*UIColor.

This was a bigger change than many others as BButton now defaults to using
control background colors, and we can not do that here without the buttons
not appearing as we desire (blending in with the toolbar).

Using the control background color for the toolbar would be unacceptable.

Signed-off-by: Augustin Cavalier <waddlesplash@gmail.com>
Patch 0041 from looncraz, unmodified.
This commit is contained in:
looncraz 2015-12-10 12:54:05 -06:00 committed by Augustin Cavalier
parent c5b4dc4007
commit f56d45ced4

View File

@ -14,7 +14,38 @@
namespace BPrivate { namespace BPrivate {
class LockableButton: public BButton {
// Button to adopt backgrond color of toolbar
class ToolBarButton : public BButton {
public:
ToolBarButton(const char* name, const char* label,
BMessage* message);
void AttachedToWindow();
};
ToolBarButton::ToolBarButton(const char* name, const char* label,
BMessage* message)
:
BButton(name, label, message)
{}
void
ToolBarButton::AttachedToWindow()
{
BButton::AttachedToWindow();
SetLowUIColor(B_PANEL_BACKGROUND_COLOR);
SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
// have to remove the darkening caused by BButton's drawing
}
//# pragma mark -
class LockableButton: public ToolBarButton {
public: public:
LockableButton(const char* name, const char* label, LockableButton(const char* name, const char* label,
BMessage* message); BMessage* message);
@ -26,7 +57,7 @@ public:
LockableButton::LockableButton(const char* name, const char* label, LockableButton::LockableButton(const char* name, const char* label,
BMessage* message) BMessage* message)
: :
BButton(name, label, message) ToolBarButton(name, label, message)
{ {
} }
@ -40,10 +71,13 @@ LockableButton::MouseDown(BPoint point)
SetBehavior(B_BUTTON_BEHAVIOR); SetBehavior(B_BUTTON_BEHAVIOR);
Message()->SetInt32("behavior", Behavior()); Message()->SetInt32("behavior", Behavior());
BButton::MouseDown(point); ToolBarButton::MouseDown(point);
} }
//#pragma mark -
BToolBar::BToolBar(BRect frame, orientation ont) BToolBar::BToolBar(BRect frame, orientation ont)
: :
BGroupView(ont), BGroupView(ont),
@ -94,11 +128,11 @@ BToolBar::AddAction(BMessage* message, BHandler* target,
const BBitmap* icon, const char* toolTipText, const char* text, const BBitmap* icon, const char* toolTipText, const char* text,
bool lockable) bool lockable)
{ {
BButton* button; ToolBarButton* button;
if (lockable) if (lockable)
button = new LockableButton(NULL, NULL, message); button = new LockableButton(NULL, NULL, message);
else else
button = new BButton(NULL, NULL, message); button = new ToolBarButton(NULL, NULL, message);
button->SetIcon(icon); button->SetIcon(icon);
button->SetFlat(true); button->SetFlat(true);
if (toolTipText != NULL) if (toolTipText != NULL)
@ -186,7 +220,6 @@ BToolBar::FindButton(uint32 command) const
// #pragma mark - Private methods // #pragma mark - Private methods
void void
BToolBar::Pulse() BToolBar::Pulse()
{ {