mirror of
https://github.com/openharmony/ace_ace_engine.git
synced 2026-07-19 22:54:50 -04:00
!2194 fixbug:修改rating评分条focus态
Merge pull request !2194 from Yao.inhome/shf_rating_focus_0413
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -54,7 +54,7 @@ public:
|
||||
|
||||
bool OnKeyEvent(const KeyEvent& keyEvent) override
|
||||
{
|
||||
if (keyEvent.action != KeyAction::UP) {
|
||||
if (keyEvent.action != KeyAction::DOWN) {
|
||||
return false;
|
||||
}
|
||||
const auto& renderRating = AceType::DynamicCast<RenderRating>(renderNode_);
|
||||
|
||||
@@ -38,6 +38,10 @@ constexpr Dimension PRESS_BORDER_RADIUS = 4.0_vp;
|
||||
|
||||
constexpr uint32_t PRESS_COLOR = 0x19000000;
|
||||
|
||||
constexpr Dimension FOCUS_BODER_PADING = 2.0_vp;
|
||||
|
||||
constexpr uint32_t FOCUS_BODER_COLOR = 0xFF0A59F7;
|
||||
|
||||
enum class OperationEvent {
|
||||
RATING_TOUCH_EVENT = 0,
|
||||
RATING_KEY_EVENT,
|
||||
|
||||
@@ -44,6 +44,16 @@ void RosenRenderRating::Paint(RenderContext& context, const Offset& offset)
|
||||
double focusRadius = singleWidth_ - imageVerticalOffset * 2;
|
||||
RequestFocusAnimation(animationOffset + GetGlobalOffset(), Size(focusRadius, focusRadius), focusRadius);
|
||||
}
|
||||
|
||||
if ((SystemProperties::GetDeviceType() == DeviceType::TABLET || SystemProperties::GetDeviceType() ==
|
||||
DeviceType::PHONE) && !isIndicator_ && operationEvent_ == OperationEvent::RATING_KEY_EVENT) {
|
||||
Offset animationOffset = starOffset + Offset(offsetDeltaX, offsetDeltaY);
|
||||
PaintFocusForTABLET(animationOffset, focusBorderRadius_.Value(),
|
||||
Size(singleWidth_, ratingSize_.Height()), context);
|
||||
double focusRadius = singleWidth_;
|
||||
RequestFocusAnimation(animationOffset + GetGlobalOffset(), Size(focusRadius, focusRadius), focusRadius);
|
||||
}
|
||||
|
||||
if ((IsPhone() || IsTablet()) && !isIndicator_) {
|
||||
PaintHoverRect(canvas);
|
||||
}
|
||||
@@ -159,6 +169,24 @@ void RosenRenderRating::PaintFocus(
|
||||
canvas->drawRRect(rRect, paint);
|
||||
}
|
||||
|
||||
void RosenRenderRating::PaintFocusForTABLET(
|
||||
const Offset& offset, double rRectRadius, const Size& boardSize, RenderContext& context)
|
||||
{
|
||||
auto canvas = static_cast<RosenRenderContext*>(&context)->GetCanvas();
|
||||
if (!canvas) {
|
||||
LOGE("Paint canvas is null");
|
||||
return;
|
||||
}
|
||||
SkPaint paint;
|
||||
SkRRect rRect;
|
||||
paint.setColor(FOCUS_BODER_COLOR);
|
||||
paint.setStyle(SkPaint::Style::kStroke_Style);
|
||||
paint.setStrokeWidth(NormalizeToPx(FOCUS_BODER_PADING));
|
||||
rRect.setRectXY(SkRect::MakeWH(boardSize.Width(), boardSize.Height()), rRectRadius, rRectRadius);
|
||||
rRect.offset(offset.GetX(), offset.GetY());
|
||||
canvas->drawRRect(rRect, paint);
|
||||
}
|
||||
|
||||
void RosenRenderRating::PaintPress(
|
||||
const Offset& offset, double rRectRadius, const Size& boardSize, RenderContext& context)
|
||||
{
|
||||
|
||||
@@ -30,6 +30,7 @@ public:
|
||||
|
||||
void Paint(RenderContext& context, const Offset& offset) override;
|
||||
void PaintFocus(const Offset& offset, double rrectRadius, const Size& boardSize, RenderContext& context) override;
|
||||
void PaintFocusForTABLET(const Offset& offset, double rrectRadius, const Size& boardSize, RenderContext& context);
|
||||
void PaintPress(
|
||||
const Offset& offset, double rrectRadius, const Size& boardSize, RenderContext& context);
|
||||
void PaintRatingBar(RenderContext& context, SkCanvas* canvas);
|
||||
|
||||
Reference in New Issue
Block a user