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 <[email protected]> Reviewed-by: waddlesplash <[email protected]> Tested-by: Commit checker robot <[email protected]>
This commit is contained in:
@@ -45,6 +45,7 @@ public:
|
|||||||
|
|
||||||
virtual void AttachedToWindow();
|
virtual void AttachedToWindow();
|
||||||
virtual void Draw(BRect updateRect);
|
virtual void Draw(BRect updateRect);
|
||||||
|
virtual void MouseMoved(BPoint where, uint32 code, const BMessage* dragMessage);
|
||||||
virtual void FrameResized(float width, float height);
|
virtual void FrameResized(float width, float height);
|
||||||
virtual void MakeFocus(bool focused = true);
|
virtual void MakeFocus(bool focused = true);
|
||||||
virtual void MessageReceived(BMessage* message);
|
virtual void MessageReceived(BMessage* message);
|
||||||
@@ -65,8 +66,9 @@ private:
|
|||||||
void _Init();
|
void _Init();
|
||||||
|
|
||||||
BMenuField* fMenuField;
|
BMenuField* fMenuField;
|
||||||
bool fFixedSize;
|
bool fFixedSize;
|
||||||
bool fShowPopUpMarker;
|
bool fShowPopUpMarker;
|
||||||
|
bool fIsInside;
|
||||||
float fPreviousWidth;
|
float fPreviousWidth;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -99,7 +99,8 @@ _BMCMenuBar_::_BMCMenuBar_(BRect frame, bool fixedSize, BMenuField* menuField)
|
|||||||
!fixedSize),
|
!fixedSize),
|
||||||
fMenuField(menuField),
|
fMenuField(menuField),
|
||||||
fFixedSize(fixedSize),
|
fFixedSize(fixedSize),
|
||||||
fShowPopUpMarker(true)
|
fShowPopUpMarker(true),
|
||||||
|
fIsInside(false)
|
||||||
{
|
{
|
||||||
_Init();
|
_Init();
|
||||||
}
|
}
|
||||||
@@ -110,7 +111,8 @@ _BMCMenuBar_::_BMCMenuBar_(BMenuField* menuField)
|
|||||||
BMenuBar("_mc_mb_", B_ITEMS_IN_ROW),
|
BMenuBar("_mc_mb_", B_ITEMS_IN_ROW),
|
||||||
fMenuField(menuField),
|
fMenuField(menuField),
|
||||||
fFixedSize(true),
|
fFixedSize(true),
|
||||||
fShowPopUpMarker(true)
|
fShowPopUpMarker(true),
|
||||||
|
fIsInside(false)
|
||||||
{
|
{
|
||||||
_Init();
|
_Init();
|
||||||
}
|
}
|
||||||
@@ -121,7 +123,8 @@ _BMCMenuBar_::_BMCMenuBar_(BMessage* data)
|
|||||||
BMenuBar(data),
|
BMenuBar(data),
|
||||||
fMenuField(NULL),
|
fMenuField(NULL),
|
||||||
fFixedSize(true),
|
fFixedSize(true),
|
||||||
fShowPopUpMarker(true)
|
fShowPopUpMarker(true),
|
||||||
|
fIsInside(false)
|
||||||
{
|
{
|
||||||
SetFlags(Flags() | B_FRAME_EVENTS);
|
SetFlags(Flags() | B_FRAME_EVENTS);
|
||||||
|
|
||||||
@@ -195,6 +198,8 @@ _BMCMenuBar_::Draw(BRect updateRect)
|
|||||||
flags |= BControlLook::B_DISABLED;
|
flags |= BControlLook::B_DISABLED;
|
||||||
if (IsFocus())
|
if (IsFocus())
|
||||||
flags |= BControlLook::B_FOCUSED;
|
flags |= BControlLook::B_FOCUSED;
|
||||||
|
if (fIsInside)
|
||||||
|
flags |= BControlLook::B_HOVER;
|
||||||
|
|
||||||
be_control_look->DrawMenuFieldBackground(this, rect,
|
be_control_look->DrawMenuFieldBackground(this, rect,
|
||||||
updateRect, LowColor(), fShowPopUpMarker, flags);
|
updateRect, LowColor(), fShowPopUpMarker, flags);
|
||||||
@@ -203,6 +208,17 @@ _BMCMenuBar_::Draw(BRect 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
_BMCMenuBar_::FrameResized(float width, float height)
|
_BMCMenuBar_::FrameResized(float width, float height)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user