mirror of
https://github.com/openharmony/ace_ace_engine.git
synced 2026-07-19 22:54:50 -04:00
add hoverrect of rating
Signed-off-by: luoying_ace_admin <luoying19@huawei.com>
This commit is contained in:
@@ -502,6 +502,31 @@ void RenderRating::ConstrainScore(double& score, double lowerBoundary, double up
|
||||
}
|
||||
}
|
||||
|
||||
WeakPtr<RenderNode> RenderRating::CheckHoverNode()
|
||||
{
|
||||
return AceType::WeakClaim<RenderNode>(this);
|
||||
}
|
||||
|
||||
bool RenderRating::HandleMouseEvent(const MouseEvent& event)
|
||||
{
|
||||
OnMouseHoverEnterTest();
|
||||
if (NearZero(singleWidth_)) {
|
||||
return false;
|
||||
}
|
||||
auto localPoint = event.GetScreenOffset() - GetGlobalOffset();
|
||||
double offsetDeltaX = (GetLayoutSize().Width() - ratingSize_.Width()) / 2.0;
|
||||
int32_t starIndex = (int32_t)floor((localPoint.GetX() - offsetDeltaX) / singleWidth_);
|
||||
if (onHover_) {
|
||||
PlayEventEffectAnimation(starIndex);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void RenderRating::AnimateMouseHoverEnter()
|
||||
{
|
||||
OnMouseHoverEnterTest();
|
||||
}
|
||||
|
||||
void RenderRating::OnMouseHoverEnterTest()
|
||||
{
|
||||
operationEvent_ = OperationEvent::RATING_MOUSE_EVENT;
|
||||
@@ -511,6 +536,11 @@ void RenderRating::OnMouseHoverEnterTest()
|
||||
onHover_ = true;
|
||||
}
|
||||
|
||||
void RenderRating::AnimateMouseHoverExit()
|
||||
{
|
||||
OnMouseHoverExitTest();
|
||||
}
|
||||
|
||||
void RenderRating::OnMouseHoverExitTest()
|
||||
{
|
||||
operationEvent_ = OperationEvent::RATING_TOUCH_EVENT;
|
||||
|
||||
@@ -95,6 +95,10 @@ public:
|
||||
{
|
||||
return SystemProperties::GetDeviceType() == DeviceType::PHONE;
|
||||
}
|
||||
bool IsTablet() const
|
||||
{
|
||||
return SystemProperties::GetDeviceType() == DeviceType::TABLET;
|
||||
}
|
||||
void CalculateRatingSize();
|
||||
void FireChangeEvent();
|
||||
void SetFocusAnimation(const RefPtr<RenderFocusAnimation>& focusAnimation)
|
||||
@@ -134,6 +138,10 @@ protected:
|
||||
void OnMouseHoverEnterTest() override;
|
||||
void OnMouseHoverExitTest() override;
|
||||
bool MouseHoverTest(const Point& parentLocalPoint) override;
|
||||
void AnimateMouseHoverEnter() override;
|
||||
void AnimateMouseHoverExit() override;
|
||||
WeakPtr<RenderNode> CheckHoverNode() override;
|
||||
virtual bool HandleMouseEvent(const MouseEvent& event) override;
|
||||
virtual void PaintFocus(
|
||||
const Offset& offset, double rrectRadius, const Size& boardSize, RenderContext& context) {}
|
||||
virtual void PaintFocus(
|
||||
|
||||
@@ -44,7 +44,7 @@ void RosenRenderRating::Paint(RenderContext& context, const Offset& offset)
|
||||
double focusRadius = singleWidth_ - imageVerticalOffset * 2;
|
||||
RequestFocusAnimation(animationOffset + GetGlobalOffset(), Size(focusRadius, focusRadius), focusRadius);
|
||||
}
|
||||
if (IsPhone() && !isIndicator_) {
|
||||
if ((IsPhone() || IsTablet()) && !isIndicator_) {
|
||||
PaintHoverRect(canvas);
|
||||
}
|
||||
PaintRatingBar(context, canvas);
|
||||
|
||||
Reference in New Issue
Block a user