BMCMenuBar: Add hover effect, like on buttons
Fixes #19671
Change-Id: I2ef001666ac4fa88364c7c5d5c95b0d96d5a090a
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9605
Reviewed-by: Stefano Ceccherini <stefano.ceccherini@gmail.com>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Diff
headers/private/interface/BMCPrivate.h | 4 +++-
src/kits/interface/BMCPrivate.cpp | 22 ++++++++++++++++++++--
2 files changed, 22 insertions(+), 4 deletions(-)
@@ -45,6 +45,7 @@
virtual void AttachedToWindow();
virtual void Draw(BRect updateRect);
virtual void MouseMoved(BPoint where, uint32 code, const BMessage* dragMessage);
virtual void FrameResized(float width, float height);
virtual void MakeFocus(bool focused = true);
virtual void MessageReceived(BMessage* message);
@@ -65,8 +66,9 @@
void _Init();
BMenuField* fMenuField;
bool fFixedSize;
bool fFixedSize;
bool fShowPopUpMarker;
bool fIsInside;
float fPreviousWidth;
};
@@ -99,7 +99,8 @@
!fixedSize),
fMenuField(menuField),
fFixedSize(fixedSize),
fShowPopUpMarker(true)
fShowPopUpMarker(true),
fIsInside(false)
{
_Init();
}
@@ -110,7 +111,8 @@
BMenuBar("_mc_mb_", B_ITEMS_IN_ROW),
fMenuField(menuField),
fFixedSize(true),
fShowPopUpMarker(true)
fShowPopUpMarker(true),
fIsInside(false)
{
_Init();
}
@@ -121,7 +123,8 @@
BMenuBar(data),
fMenuField(NULL),
fFixedSize(true),
fShowPopUpMarker(true)
fShowPopUpMarker(true),
fIsInside(false)
{
SetFlags(Flags() | B_FRAME_EVENTS);
@@ -195,11 +198,24 @@
flags |= BControlLook::B_DISABLED;
if (IsFocus())
flags |= BControlLook::B_FOCUSED;
if (fIsInside)
flags |= BControlLook::B_HOVER;
be_control_look->DrawMenuFieldBackground(this, rect,
updateRect, LowColor(), fShowPopUpMarker, flags);
DrawItems(updateRect);
}
void
_BMCMenuBar_::MouseMoved(BPoint where, uint32 code, const BMessage* dragMessage)
{
bool inside = (code != B_EXITED_VIEW) && Bounds().Contains(where);
if (inside != fIsInside) {
fIsInside = inside;
Invalidate();
}
}