From f56d45ced4856b2f8943d7e5c1b1de6a78be9f38 Mon Sep 17 00:00:00 2001 From: looncraz Date: Thu, 10 Dec 2015 12:54:05 -0600 Subject: [PATCH] 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 Patch 0041 from looncraz, unmodified. --- src/kits/shared/ToolBar.cpp | 45 ++++++++++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 6 deletions(-) diff --git a/src/kits/shared/ToolBar.cpp b/src/kits/shared/ToolBar.cpp index e29fe50005..7d01485dd3 100644 --- a/src/kits/shared/ToolBar.cpp +++ b/src/kits/shared/ToolBar.cpp @@ -14,7 +14,38 @@ 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: LockableButton(const char* name, const char* label, BMessage* message); @@ -26,7 +57,7 @@ public: LockableButton::LockableButton(const char* name, const char* label, BMessage* message) : - BButton(name, label, message) + ToolBarButton(name, label, message) { } @@ -40,10 +71,13 @@ LockableButton::MouseDown(BPoint point) SetBehavior(B_BUTTON_BEHAVIOR); Message()->SetInt32("behavior", Behavior()); - BButton::MouseDown(point); + ToolBarButton::MouseDown(point); } +//#pragma mark - + + BToolBar::BToolBar(BRect frame, orientation ont) : BGroupView(ont), @@ -94,11 +128,11 @@ BToolBar::AddAction(BMessage* message, BHandler* target, const BBitmap* icon, const char* toolTipText, const char* text, bool lockable) { - BButton* button; + ToolBarButton* button; if (lockable) button = new LockableButton(NULL, NULL, message); else - button = new BButton(NULL, NULL, message); + button = new ToolBarButton(NULL, NULL, message); button->SetIcon(icon); button->SetFlat(true); if (toolTipText != NULL) @@ -186,7 +220,6 @@ BToolBar::FindButton(uint32 command) const // #pragma mark - Private methods - void BToolBar::Pulse() {