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_COMPONENTS_TEXT_OVERLAY_TEXT_OVERLAY_ELEMENT_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_TEXT_OVERLAY_TEXT_OVERLAY_ELEMENT_H 18 19 #include "core/components/box/box_component.h" 20 #include "core/components/text_overlay/text_overlay_component.h" 21 #include "core/components/tween/tween_element.h" 22 #include "core/focus/focus_node.h" 23 #include "core/pipeline/base/sole_child_element.h" 24 25 namespace OHOS::Ace { 26 27 class TextOverlayElement : public SoleChildElement, public FocusGroup { 28 DECLARE_ACE_TYPE(TextOverlayElement, SoleChildElement, FocusGroup) 29 30 public: 31 void PerformBuild() override; 32 void OnFocus() override; 33 void OnBlur() override; 34 35 void RebuildChild(bool isSingleHandle, bool hasToolBar, bool hasMenu, bool hasIcon, bool hasAnimation, 36 bool buildToolBarOnly = false); 37 38 private: 39 bool RequestNextFocus(bool vertical, bool reverse, const Rect& rect) override; 40 41 void OnStartAnimation( 42 const TweenOption& outerOption, const TweenOption& innerOption, bool isSingleHandle, bool isIn); 43 // Init outer and inner tween element. 44 void InitTween(const RefPtr<Element>& element); 45 void AddListener(bool isSingleHandle, bool isIn); 46 47 bool hasFocusAnimation_ = false; 48 RefPtr<TextOverlayComponent> overlayComponent_; 49 RefPtr<TweenElement> outerTween_; 50 RefPtr<TweenElement> innerTween_; 51 }; 52 53 } // namespace OHOS::Ace 54 55 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_TEXT_OVERLAY_TEXT_OVERLAY_ELEMENT_H 56