1 /* 2 * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_FOCUS_ANIMATION_RENDER_FOCUS_ANIMATION_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_FOCUS_ANIMATION_RENDER_FOCUS_ANIMATION_H 18 19 #include "core/animation/animator.h" 20 #include "core/animation/curve_animation.h" 21 #include "core/components/focus_animation/focus_animation_component.h" 22 #include "core/pipeline/base/render_node.h" 23 24 namespace OHOS::Ace { 25 26 class RenderFocusAnimation : public RenderNode { 27 DECLARE_ACE_TYPE(RenderFocusAnimation, RenderNode); 28 29 public: RenderFocusAnimation()30 RenderFocusAnimation() : RenderNode(true) {} 31 ~RenderFocusAnimation() override = default; 32 static RefPtr<RenderNode> Create(); 33 void PerformLayout() override; 34 void Update(const RefPtr<Component>& component) override; 35 bool MarkNeedRenderSpecial() override; 36 void SetFocusAnimationProperties(const RRect& rrect, const Color& color, const Offset& offset, bool isIndented); 37 void SetFocusAnimationProperties(const RRect& rrect, const Color& color, const Offset& offset, 38 const Rect& clipRect); 39 void SetFocusAnimationProperties(const RRect& rrect, const Offset& offset); 40 void CancelFocusAnimation(); 41 void StopFocusAnimation(); 42 void StartFocusAnimation(); 43 void SetIsKeyEvent(bool isKeyEvent); MouseHoverTest(const Point & parentLocalPoint)44 bool MouseHoverTest(const Point& parentLocalPoint) override 45 { 46 // this node is not require hover state. 47 return false; 48 } IsRepaintBoundary()49 bool IsRepaintBoundary() const override 50 { 51 return true; 52 } 53 IsRoot()54 bool IsRoot() const 55 { 56 return isRoot_; 57 } 58 59 protected: 60 float progress_ = 0.0f; 61 Dimension blurMaskRadius_ = 8.0_vp; 62 bool isRoot_ = false; 63 bool isDisplay_ = false; 64 bool isIndented_ = false; 65 bool isNeedClip_ = false; 66 bool isKeyEvent_ = false; 67 bool animationParamsSet_ = false; 68 Rect clipRect_; 69 RRect rrect_; 70 Offset offset_; 71 Size layoutSize_; 72 Color pathColor_; 73 RefPtr<FocusAnimationTheme> focusTheme_; 74 RefPtr<CurveAnimation<float>> focusAnimation_; 75 RefPtr<Animator> animator_; 76 }; 77 78 } // namespace OHOS::Ace 79 80 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_FOCUS_ANIMATION_RENDER_FOCUS_ANIMATION_H 81