From 6de89c6cdf03a6041663bc3ffaddc130c145e941 Mon Sep 17 00:00:00 2001 From: nipos Date: Sun, 24 Aug 2025 09:54:09 +0200 Subject: [PATCH] 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 Reviewed-by: waddlesplash Tested-by: Commit checker robot --- headers/private/interface/BMCPrivate.h | 4 +++- src/kits/interface/BMCPrivate.cpp | 22 ++++++++++++++++++++-- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/headers/private/interface/BMCPrivate.h b/headers/private/interface/BMCPrivate.h index 609cdbd..2c229be 100644 --- a/headers/private/interface/BMCPrivate.h +++ b/headers/private/interface/BMCPrivate.h @@ -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; }; diff --git a/src/kits/interface/BMCPrivate.cpp b/src/kits/interface/BMCPrivate.cpp index 26209f1..3ac4862 100644 --- a/src/kits/interface/BMCPrivate.cpp +++ b/src/kits/interface/BMCPrivate.cpp @@ -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(); + } } -- gitore 0.2.3