1 /* 2 * Copyright (c) 2021 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_COMMON_FOCUS_ANIMATION_MANAGER_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_FOCUS_ANIMATION_MANAGER_H 18 19 #include <stack> 20 21 #include "base/geometry/rrect.h" 22 #include "base/memory/ace_type.h" 23 #include "core/components/common/properties/color.h" 24 25 namespace OHOS::Ace { 26 27 class Element; 28 class RenderFocusAnimation; 29 class RenderShadow; 30 31 class FocusAnimationManager : public virtual AceType { 32 DECLARE_ACE_TYPE(FocusAnimationManager, AceType); 33 34 public: 35 FocusAnimationManager() = default; 36 ~FocusAnimationManager() override = default; 37 38 void SetFocusAnimationProperties( 39 const RRect& rrect, const Color& color, const Offset& offset, bool isIndented) const; 40 void SetFocusAnimationProperties( 41 const RRect& rrect, const Color& color, const Offset& offset, const Rect& clipRect) const; 42 void SetAvailableRect(const Rect& paintRect); 43 void CancelFocusAnimation() const; 44 void PushFocusAnimationElement(const RefPtr<Element>& element); 45 void PopFocusAnimationElement(); 46 void PopRootFocusAnimationElement(); 47 void PushShadow(const RefPtr<Element>& element); 48 void PopShadow(); 49 void StartFocusAnimation() const; 50 void StopFocusAnimation() const; 51 void SetShadowProperties(const RRect& rrect, const Offset& offset); 52 void SetShadowProperties(const RRect& rrect, const Offset& offset, const Rect& clipRect); 53 void CancelShadow() const; 54 void SetUseRoot(bool useRoot); 55 void SetIsKeyEvent(bool isKeyEvent); 56 RefPtr<RenderFocusAnimation> GetRenderFocusAnimation() const; 57 58 private: 59 Rect availableRect_; 60 bool useRoot_ = false; 61 std::stack<WeakPtr<RenderFocusAnimation>> rootFocusAnimationStack_; 62 std::stack<WeakPtr<RenderFocusAnimation>> focusAnimationStack_; 63 std::stack<WeakPtr<RenderShadow>> shadowStack_; 64 }; 65 66 } // namespace OHOS::Ace 67 68 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_FOCUS_ANIMATION_MANAGER_H 69