/*
 * Copyright (c) 2020-2021 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
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * @addtogroup UI_Components
 * @{
 *
 * @brief Defines UI components such as buttons, texts, images, lists, and progress bars.
 *
 * @since 1.0
 * @version 1.0
 */

/**
 * @file ui_view.h
 *
 * @brief Declares the base class of a view, providing basic view attributes and operations. All views are derived
 *        from this class.
 *
 * @since 1.0
 * @version 1.0
 */

#ifndef GRAPHIC_LITE_UI_VIEW_H
#define GRAPHIC_LITE_UI_VIEW_H

#include "events/cancel_event.h"
#include "events/click_event.h"
#include "events/drag_event.h"
#include "events/event.h"
#include "events/long_press_event.h"
#include "events/press_event.h"
#include "events/release_event.h"
#if ENABLE_ROTATE_INPUT
#include "events/rotate_event.h"
#endif
#include "gfx_utils/color.h"
#include "gfx_utils/geometry2d.h"
#include "gfx_utils/graphic_buffer.h"
#include "gfx_utils/graphic_log.h"
#include "gfx_utils/heap_base.h"
#include "gfx_utils/image_info.h"
#include "gfx_utils/style.h"
#include "gfx_utils/transform.h"
#if defined(CONFIG_DYNAMIC_LAYOUT) && (CONFIG_DYNAMIC_LAYOUT == 1)
#include "gfx_utils/list.h"
#endif

namespace OHOS {
/* Enumerates view types. */
enum UIViewType : uint8_t {
    UI_ROOT_VIEW = 0,
    UI_VIEW_GROUP,
    UI_LABEL,
    UI_ARC_LABEL,
    UI_EDIT_TEXT,
    UI_LABEL_BUTTON,
    UI_CHECK_BOX,
    UI_TOGGLE_BUTTON,
    UI_RADIO_BUTTON,
    UI_IMAGE_VIEW,
    UI_BOX_PROGRESS,
    UI_SLIDER,
    UI_CIRCLE_PROGRESS,
    UI_SCROLL_VIEW,
    UI_LIST,
    UI_DIGITAL_CLOCK,
    UI_ANALOG_CLOCK,
    UI_PICKER,
    UI_SWIPE_VIEW,
    UI_TIME_PICKER,
    UI_ABSTRACT_CLOCK,
    UI_ABSTRACT_PROGRESS,
    UI_ABSTRACT_SCROLL,
    UI_AXIS,
    UI_BUTTON,
    UI_CANVAS,
    UI_CHART,
    UI_IMAGE_ANIMATOR_VIEW,
    UI_REPEAT_BUTTON,
    UI_TEXTURE_MAPPER,
    UI_DIALOG,
    UI_QRCODE,
    UI_FLEXLAYOUT,
    UI_MAP_CANVAS,
    UI_NUMBER_MAX
};

#if defined(CONFIG_DYNAMIC_LAYOUT) && (CONFIG_DYNAMIC_LAYOUT == 1)
enum RelativeLayoutType : uint8_t  {
    LAYOUT_CENTER_OF_PARENT = 0,
    LAYOUT_LEFT_OF_PARENT,
    LAYOUT_RIGHT_OF_PARENT,
    LAYOUT_TOP_OF_PARENT,
    LAYOUT_BOTTOM_OF_PARENT,
    ALIGN_LEFT_TO_SIBLING,
    ALIGN_RIGHT_TO_SIBLING,
    ALIGN_TOP_TO_SIBLING,
    ALIGN_BOTTOM_TO_SIBLING,
    ALIGN_HOR_CENTER_TO_SIBLING,
    ALIGN_VER_CENTER_TO_SIBLING,
    LAYOUT_LEFT_TO_SIBLING,
    LAYOUT_RIGHT_TO_SIBLING,
    LAYOUT_TOP_TO_SIBLING,
    LAYOUT_BOTTOM_TO_SIBLING,
    LAYOUT_MAX
};

struct RelativeLayoutInfo {
    RelativeLayoutType type; // Layout type
    const char* viewId; // Depend on viewId
    int16_t offsetX; // If the value is LAYOUT_CENTER_OF_PARENT, the offset is in the X direction
                        // Otherwise, the offset is the offset distance
    int16_t offsetY; // If the layout is LAYOUT_CENTER_OF_PARENT, this value indicates the offset in the Y direction.
                        // This value is meaningless for other layout modes
    RelativeLayoutInfo()
    {
        type = LAYOUT_MAX;
        viewId = nullptr;
        offsetX = 0;
        offsetY = 0;
    }
};
#endif

#if ENABLE_DEBUG
const char* const VIEW_TYPE_STRING[UI_NUMBER_MAX] = {
    "RootView",         "UIViewGroup",        "UILabel",          "UIArcLabel",
    "UIEditText",       "UILabelButton",      "UICheckBox",       "UIToggleButton",
    "UIRadioButton",    "UIImageView",        "UIBoxProgress",    "UISlider",
    "UICircleProgress", "UIScrollView",       "UIList",           "UIDigitalClock",
    "UIAnalogClock",    "UIPicker",           "UISwipeView",      "UITimePicker",
    "UIAbstractClock",  "UIAbstractProgress", "UIAbstractScroll", "UIAxis",
    "UIButton",         "UICanvas",           "UIChart",          "UIImageAnimatorView",
    "UIRepeatButton",   "UITextureMapper",    "UIDialog",         "UIQrcode",
};
#endif // ENABLE_DEBUG

/**
 * @brief Defines the base class of a view, providing basic view attributes and operations. All views are derived
 *        from this class.
 *
 * @since 1.0
 * @version 1.0
 */
class UIView : public HeapBase {
public:
    /**
     * @brief Defines a click event listener. You need to register this listener with the view to listen to
     *        click events.
     *
     * @since 1.0
     * @version 1.0
     */
    class OnClickListener : public HeapBase {
    public:
        /**
         * @brief Called when a view is clicked.
         * @param view Indicates the view clicked.
         * @param event Indicates the click event.
         * @return Returns <b>true</b> if the event is consumed; returns <b>false</b> otherwise.
         *         (If an event is consumed, it is not transferred to the parent view. If an event is not consumed,
         *         it is transferred to the parent view after local processing is complete.)
         * @since 1.0
         * @version 1.0
         */
        virtual bool OnClick(UIView& view, const ClickEvent& event)
        {
            return false;
        }

        /**
         * @brief A destructor used to delete the <b>OnClickListener</b> instance.
         * @since 1.0
         * @version 1.0
         */
        virtual ~OnClickListener() {}
    };

    /**
     * @brief Defines a long-press event listener. You need to register this listener with the view to listen to
     *        long-press events.
     *
     * @since 1.0
     * @version 1.0
     */
    class OnLongPressListener : public HeapBase {
    public:
        /**
         * @brief Called when a view is long pressed.
         * @param view Indicates the view long pressed.
         * @param event Indicates the long-press event.
         * @return Returns <b>true</b> if the event is consumed; returns <b>false</b> otherwise.
         *         (If an event is consumed, it is not transferred to the parent view. If an event is not consumed,
         *         it is transferred to the parent view after local processing is complete.)
         * @since 1.0
         * @version 1.0
         */
        virtual bool OnLongPress(UIView& view, const LongPressEvent& event)
        {
            return false;
        }

        /**
         * @brief A destructor used to delete the <b>OnLongPressListener</b> instance.
         * @since 1.0
         * @version 1.0
         */
        virtual ~OnLongPressListener() {}
    };

    /**
     * @brief Defines a drag event listener. You need to register this listener with the view to listen to drag events.
     *
     * @since 1.0
     * @version 1.0
     */
    class OnDragListener : public HeapBase {
    public:
        /**
         * @brief Called when a view starts to drag.
         * @param view Indicates the view dragged.
         * @param event Indicates the drag event.
         * @return Returns <b>true</b> if the event is consumed; returns <b>false</b> otherwise.
         *         (If an event is consumed, it is not transferred to the parent view. If an event is not consumed,
         *         it is transferred to the parent view after local processing is complete.)
         * @since 1.0
         * @version 1.0
         */
        virtual bool OnDragStart(UIView& view, const DragEvent& event)
        {
            return false;
        }

        /**
         * @brief Called when a view is being dragged.
         * @param view Indicates the view dragged.
         * @param event Indicates the drag event.
         * @return Returns <b>true</b> if the event is consumed; returns <b>false</b> otherwise.
         *         (If an event is consumed, it is not transferred to the parent view. If an event is not consumed,
         *         it is transferred to the parent view after local processing is complete.)
         * @since 1.0
         * @version 1.0
         */
        virtual bool OnDrag(UIView& view, const DragEvent& event)
        {
            return false;
        }

        /**
         * @brief Called when a view stops dragging.
         * @param view Indicates the view dragged.
         * @param event Indicates the drag event.
         * @return Returns <b>true</b> if the event is consumed; returns <b>false</b> otherwise.
         *         (If an event is consumed, it is not transferred to the parent view. If an event is not consumed,
         *         it is transferred to the parent view after local processing is complete.)
         * @since 1.0
         * @version 1.0
         */
        virtual bool OnDragEnd(UIView& view, const DragEvent& event)
        {
            return false;
        }

        /**
         * @brief A destructor used to delete the <b>OnDragListener</b> instance.
         * @since 1.0
         * @version 1.0
         */
        virtual ~OnDragListener() {}
    };

    /**
     * @brief Defines a touch event listener. You need to register this listener with the view to listen to touch
     *        events.
     *
     * @since 1.0
     * @version 1.0
     */
    class OnTouchListener : public HeapBase {
    public:
        /**
         * @brief Called when a view is pressed.
         * @param view Indicates the view pressed.
         * @param event Indicates the press event.
         * @return Returns <b>true</b> if the event is consumed; returns <b>false</b> otherwise.
         *         (If an event is consumed, it is not transferred to the parent view. If an event is not consumed,
         *         it is transferred to the parent view after local processing is complete.)
         * @since 1.0
         * @version 1.0
         */
        virtual bool OnPress(UIView& view, const PressEvent& event)
        {
            return false;
        }

        /**
         * @brief Called when a view is released.
         * @param view Indicates the view released.
         * @param event Indicates the release event.
         * @return Returns <b>true</b> if the event is consumed; returns <b>false</b> otherwise.
         *         (If an event is consumed, it is not transferred to the parent view. If an event is not consumed,
         *         it is transferred to the parent view after local processing is complete.)
         * @since 1.0
         * @version 1.0
         */
        virtual bool OnRelease(UIView& view, const ReleaseEvent& event)
        {
            return false;
        }

        /**
         * @brief Called when a click event on a view is canceled.
         * @param view Indicates the view on which a click event is canceled.
         * @param event Indicates the cancel event.
         * @return Returns <b>true</b> if the event is consumed; returns <b>false</b> otherwise.
         *         (If an event is consumed, it is not transferred to the parent view. If an event is not consumed,
         *         it is transferred to the parent view after local processing is complete.)
         * @since 1.0
         * @version 1.0
         */
        virtual bool OnCancel(UIView& view, const CancelEvent& event)
        {
            return false;
        }

        /**
         * @brief A destructor used to delete the <b>OnTouchListener</b> instance.
         * @since 1.0
         * @version 1.0
         */
        virtual ~OnTouchListener() {}
    };

#if ENABLE_ROTATE_INPUT
    /**
     * @brief Defines a rotation event listener.
     *        You need to register this listener with the view to listen for rotation events.
     * @since 5.0
     * @version 3.0
     */
    class OnRotateListener : public HeapBase {
    public:
        /**
         * @brief Called when the view starts to rotate.
         * @param view Indicates the view that responds to the rotation event.
         * @param event Indicates the rotation event.
         * @return Returns <b>true</b> if the rotation event is consumed; returns <b>false</b> otherwise.
         * @since 6
         */
        virtual bool OnRotateStart(UIView& view, const RotateEvent& event)
        {
            return false;
        }

        /**
         * @brief Called when a rotation event occurs on a view.
         * @param view Indicates the view that responds to the rotation event.
         * @param event Indicates the rotation event.
         * @return Returns <b>true</b> if the rotation event is consumed; returns <b>false</b> otherwise.
         * @since 5.0
         * @version 3.0
         */
        virtual bool OnRotate(UIView& view, const RotateEvent& event)
        {
            return false;
        }

        /**
         * @brief Called when the view stops rotating.
         * @param view Indicates the view that responds to the rotation event.
         * @param event Indicates the rotation event.
         * @return Returns <b>true</b> if the rotation event is consumed; returns <b>false</b> otherwise.
         * @since 6
         */
        virtual bool OnRotateEnd(UIView& view, const RotateEvent& event)
        {
            return false;
        }

        /**
         * @brief A destructor used to delete an <b>OnRotateListener</b> instance.
         * @since 5.0
         * @version 3.0
         */
        virtual ~OnRotateListener() {}
    };

    /**
     * @brief Called when the view starts to rotate.
     * @param event Indicates the rotation event.
     * @since 6
     */
    virtual bool OnRotateStartEvent(const RotateEvent& event);

    /**
     * @brief Called when a rotation event occurs on the view.
     * @param event Indicates the rotation event.
     * @since 5.0
     * @version 3.0
     */
    virtual bool OnRotateEvent(const RotateEvent& event);

    /**
     * @brief Called when the view stops rotating.
     * @param event Indicates the rotation event.
     * @since 6
     */
    virtual bool OnRotateEndEvent(const RotateEvent& event);

    /**
     * @brief Sets a rotation event listener for the view.
     * @param onRotateListener Indicates the pointer to the rotation event listener to set.
     * @since 5.0
     * @version 3.0
     */
    void SetOnRotateListener(OnRotateListener* onRotateListener);

    /**
     * @brief Obtains the rotation event listener for the view.
     * @return Returns the rotation event listener.
     * @since 5.0
     * @version 3.0
     */
    OnRotateListener*& GetOnRotateListener()
    {
        return onRotateListener_;
    }
#endif

    /**
     * @brief Stores extra information about a <b>UIView</b> instance.
     * @param elementPtr Indicates the void pointer to the extra information about the <b>UIView</b> instance.
     * @since 5.0
     * @version 3.0
     */
    struct ViewExtraMsg {
        void* elementPtr;
    };

    /**
     * @brief A default constructor used to create an <b>UIView</b> instance.
     * @since 1.0
     * @version 1.0
     */
    UIView();

    /**
     * @brief A constructor used to create an <b>UIView</b> instance.
     * @param id Indicates the pointer to the view ID.
     * @since 1.0
     * @version 1.0
     */
    explicit UIView(const char* id) : UIView()
    {
        id_ = id;
    }

    /**
     * @brief A destructor used to delete the <b>UIView</b> instance.
     * @since 1.0
     * @version 1.0
     */
    virtual ~UIView();

    /**
     * @brief Called before a view is drawn. This function is used to check whether the invalidated area
     *        can be fully cover by this view so as to optimize the drawing process.
     * @param invalidatedArea Indicates the area to judge and returns the covered area when partly coverd.
     * @return Returns <b>true</b> if the invalidated area is fully covered; returns <b>false</b> otherwise.
     * @since 1.0
     * @version 1.0
     */
    virtual bool OnPreDraw(Rect& invalidatedArea) const;

    /**
     * @brief Called when a view is drawn.
     * @param invalidatedArea Indicates the area to draw.
     * @since 1.0
     * @version 1.0
     */
    virtual void OnDraw(BufferInfo& gfxDstBuffer, const Rect& invalidatedArea);

    /**
     * @brief Called after a view is drawn.
     * @param invalidatedArea Indicates the area in which the view is drawn.
     * @since 1.0
     * @version 1.0
     */
    virtual void OnPostDraw(BufferInfo& gfxDstBuffer, const Rect& invalidatedArea);

    /**
     * @brief Remeasures the view size.
     * @since 1.0
     * @version 1.0
     */
#if defined(CONFIG_DYNAMIC_LAYOUT) && (CONFIG_DYNAMIC_LAYOUT == 1)
    virtual void ReMeasure();
#else
    virtual void ReMeasure() {}
#endif

    /**
     * @brief Refreshes the invalidated area of the view.
     * @since 1.0
     * @version 1.0
     */
    void Invalidate();

    /**
     * @brief Refreshes a view in a specified invalidated area.
     * @param invalidatedArea Indicates the area to refresh.
     * @since 1.0
     * @version 1.0
     */
    void InvalidateRect(const Rect& invalidatedArea, UIView* view = nullptr);

    /**
     * @brief Called when the view is long pressed.
     * @param event Indicates the long-press event.
     * @return Returns <b>true</b> if the event is consumed; returns <b>false</b> otherwise.
     *         (If an event is consumed, it is not transferred to the parent view. If an event is not consumed,
     *         it is transferred to the parent view after local processing is complete.)
     * @since 1.0
     * @version 1.0
     */
    virtual bool OnLongPressEvent(const LongPressEvent& event);

    /**
     * @brief Called when the view starts to drag.
     * @param event Indicates the drag event.
     * @return Returns <b>true</b> if the event is consumed; returns <b>false</b> otherwise.
     *         (If an event is consumed, it is not transferred to the parent view. If an event is not consumed,
     *         it is transferred to the parent view after local processing is complete.)
     * @since 1.0
     * @version 1.0
     */
    virtual bool OnDragStartEvent(const DragEvent& event);

    /**
     * @brief Called when the view is being dragged.
     * @param event Indicates the drag event.
     * @return Returns <b>true</b> if the event is consumed; returns <b>false</b> otherwise.
     *         (If an event is consumed, it is not transferred to the parent view. If an event is not consumed,
     *         it is transferred to the parent view after local processing is complete.)
     * @since 1.0
     * @version 1.0
     */
    virtual bool OnDragEvent(const DragEvent& event);

    /**
     * @brief Called when the view stops dragging.
     * @param event Indicates the drag event.
     * @return Returns <b>true</b> if the event is consumed; returns <b>false</b> otherwise.
     *         (If an event is consumed, it is not transferred to the parent view. If an event is not consumed,
     *         it is transferred to the parent view after local processing is complete.)
     * @since 1.0
     * @version 1.0
     */
    virtual bool OnDragEndEvent(const DragEvent& event);

    /**
     * @brief Called when the view is clicked.
     * @param event Indicates the click event.
     * @return Returns <b>true</b> if the event is consumed; returns <b>false</b> otherwise.
     *         (If an event is consumed, it is not transferred to the parent view. If an event is not consumed,
     *         it is transferred to the parent view after local processing is complete.)
     * @since 1.0
     * @version 1.0
     */
    virtual bool OnClickEvent(const ClickEvent& event);

    /**
     * @brief Called when the view is pressed.
     * @param event Indicates the press event.
     * @return Returns <b>true</b> if the event is consumed; returns <b>false</b> otherwise.
     *         (If an event is consumed, it is not transferred to the parent view. If an event is not consumed,
     *         it is transferred to the parent view after local processing is complete.)
     * @since 1.0
     * @version 1.0
     */
    virtual bool OnPressEvent(const PressEvent& event);

    /**
     * @brief Called when the view is released.
     * @param event Indicates the release event.
     * @return Returns <b>true</b> if the event is consumed; returns <b>false</b> otherwise.
     *         (If an event is consumed, it is not transferred to the parent view. If an event is not consumed,
     *         it is transferred to the parent view after local processing is complete.)
     * @since 1.0
     * @version 1.0
     */
    virtual bool OnReleaseEvent(const ReleaseEvent& event);

    /**
     * @brief Called when a click event on the view is canceled.
     * @param event Indicates the cancel event.
     * @return Returns <b>true</b> if the event is consumed; returns <b>false</b> otherwise.
     *         (If an event is consumed, it is not transferred to the parent view. If an event is not consumed,
     *         it is transferred to the parent view after local processing is complete.)
     * @since 1.0
     * @version 1.0
     */
    virtual bool OnCancelEvent(const CancelEvent& event);

    /**
     * @brief Sets a drag event listener for the view.
     * @param onDragListener Indicates the pointer to the drag event listener to set.
     * @since 1.0
     * @version 1.0
     */
    void SetOnDragListener(OnDragListener* onDragListener);

    /**
     * @brief Obtains the drag event listener for the view.
     * @return Returns the drag event listener.
     * @since 1.0
     * @version 1.0
     */
    OnDragListener*& GetOnDragListener();

    /**
     * @brief Sets a click event listener for the view.
     * @param onClickListener Indicates the pointer to the click event listener to set.
     * @since 1.0
     * @version 1.0
     */
    void SetOnClickListener(OnClickListener* onClickListener);

    /**
     * @brief Obtains the click event listener for the view.
     * @return Returns the click event listener.
     * @since 1.0
     * @version 1.0
     */
    OnClickListener*& GetOnClickListener();

    /**
     * @brief Sets a long-press event listener for the view.
     * @param onLongPressListener Indicates the pointer to the long-press event listener to set.
     * @since 1.0
     * @version 1.0
     */
    void SetOnLongPressListener(OnLongPressListener* onLongPressListener);

    /**
     * @brief Obtains the long-press event listener for the view.
     * @return Returns the long-press event listener.
     * @since 1.0
     * @version 1.0
     */
    OnLongPressListener*& GetOnLongPressListener();

    /**
     * @brief Sets a touch event listener for the view.
     * @param onTouchListener Indicates the pointer to the touch event listener to set.
     * @since 1.0
     * @version 1.0
     */
    void SetOnTouchListener(OnTouchListener* onTouchListener);

    /**
     * @brief Obtains the touch event listener for the view.
     * @return Returns the touch event listener.
     * @since 1.0
     * @version 1.0
     */
    OnTouchListener*& GetTouchListener();

    /**
     * @brief Obtains the top-level view based on specified coordinates.
     * @param point Indicates the coordinates to specify.
     * @param last Indicates the double pointer to the view that contains the specified coordinates.
     * @since 1.0
     * @version 1.0
     */
    virtual void GetTargetView(const Point& point, UIView** last);

    /**
     * @brief Obtains the current view and target view based on specified coordinates. The obtained current view must
     *        include the specified coordinates and is a visible top view that can respond to touch events, and the
     *        obtained target view must be the top view that includes the specified coordinates.
     * @param point Indicates the specified coordinates.
     * @param current Indicates the double pointer to the current view to obtain.
     *        <b>nullptr</b> indicates that the target view fails to be obtained.
     * @param target Indicates the double pointer to the target view to obtain.
     *        <b>nullptr</b> indicates that the target view fails to be obtained.
     * @since 5.0
     * @version 3.0
     */
    virtual void GetTargetView(const Point& point, UIView** current, UIView** target);

    /**
     * @brief Sets the parent view for the view.
     * @param parent Indicates the pointer to the parent view to set.
     * @since 1.0
     * @version 1.0
     */
    void SetParent(UIView* parent);

    /**
     * @brief Obtains the parent view of the view.
     * @return Returns the pointer to the parent view.
     * @since 1.0
     * @version 1.0
     */
    UIView* GetParent() const;

    /**
     * @brief Sets the next sibling view for the view.
     * @param sibling Indicates the pointer to the next sibling view to set.
     * @since 1.0
     * @version 1.0
     */
    void SetNextSibling(UIView* sibling);

    /**
     * @brief Obtains the next sibling view of the view.
     * @return Returns the pointer to the next sibling view.
     * @since 1.0
     * @version 1.0
     */
    UIView* GetNextSibling() const;

    /**
     * @brief Sets whether the view is visible.
     * @param visible Specifies whether to set the view visible. Value <b>true</b> means to set the view visible,
     *                and <b>false</b> means the opposite.
     * @since 1.0
     * @version 1.0
     */
    virtual void SetVisible(bool visible);

    /**
     * @brief Checks whether the view is visible.
     * @return Returns <b>true</b> if the view is visible; returns <b>false</b> otherwise.
     * @since 1.0
     * @version 1.0
     */
    bool IsVisible() const;

    /**
     * @brief Sets whether the view is touchable.
     * @param touchable Specifies whether to set the view touchable. Value <b>true</b> means to set the view touchable,
     *                  and <b>false</b> means the opposite.
     * @since 1.0
     * @version 1.0
     */
    void SetTouchable(bool touch);

    /**
     * @brief Checks whether the view is touchable.
     * @return Returns <b>true</b> if the view is touchable; returns <b>false</b> otherwise.
     * @since 1.0
     * @version 1.0
     */
    bool IsTouchable() const;

    /**
     * @brief Sets whether the view is draggable.
     * @param draggable Specifies whether to set the view draggable. Value <b>true</b> means to set the view draggable,
     *                  and <b>false</b> means the opposite.
     * @since 1.0
     * @version 1.0
     */
    void SetDraggable(bool draggable);

    /**
     * @brief Checks whether the view is draggable.
     * @return Returns <b>true</b> if the view is draggable; returns <b>false</b> otherwise.
     * @since 1.0
     * @version 1.0
     */
    bool IsDraggable() const;

    /**
     * @brief Sets whether to transfer the drag event to the parent view for processing when the view is being dragged.
     * @param dragParentInstead Specifies whether to transfer the event to the parent view for processing.
     *                          Value <b>true</b> means to transfer the event to the parent view for processing,
     *                          and <b>false</b> means the opposite.
     * @since 1.0
     * @version 1.0
     */
    void SetDragParentInstead(bool dragParentInstead);

    /**
     * @brief Obtains whether the view transfers a drag event to the parent view for processing.
     * @return Returns <b>true</b> if the view transfers the event to the parent view for processing;
     *         returns <b>false</b> otherwise.
     * @since 1.0
     * @version 1.0
     */
    bool IsDragParentInstead() const;

    /**
     * @brief Obtains the absolute rectangle area of the view. When the view has deformation such as rotation,
     *        the rectangle area is the intersection set of the absolute rectangle area and deformation matrix.
     * @return Returns the absolute rectangle area.
     * @since 1.0
     * @version 1.0
     */
    Rect GetRect() const;

    /**
     * @brief Obtains the visible absolute rectangle area of the view.
     * @return Returns the visible absolute rectangle area.
     * @since 1.0
     * @version 1.0
     */
    Rect GetVisibleRect() const;

    /**
     * @brief Obtains the valid absolute rectangle area of the view. The valid area refers to the area where the view
     *        can be displayed. Generally, the valid area is the same as the visible view area, but they may be
     *        different in the grid layout.
     * @return Returns the valid absolute rectangle area.
     * @since 1.0
     * @version 1.0
     */
    Rect GetMaskedRect() const;

    /**
     * @brief Obtains the absolute rectangle area of the view.
     * @return Returns the absolute rectangle area.
     * @since 1.0
     * @version 1.0
     */
    Rect GetOrigRect() const;

    /**
     * @brief Obtains the content of the absolute rectangle area of the view. This area excludes padding.
     * @return Returns the content of the absolute rectangle area.
     * @since 1.0
     * @version 1.0
     */
    virtual Rect GetContentRect();

    virtual Rect GetOrigContentRect();

    /**
     * @brief Obtains the rectangular area of the view relative to the parent view, that is, the rectangular area
     *        relative to the coordinates of the parent view.
     * @return Returns the rectangle area relative to the parent view.
     * @since 1.0
     * @version 1.0
     */
    Rect GetRelativeRect() const;

    /**
     * @brief Adjusts the size of the visible area. This operation may affect the final display size.
     * @param x Indicates the new x-coordinate.
     * @param y Indicates the new y-coordinate.
     * @param width Indicates the new width.
     * @param height Indicates the new height.
     * @since 1.0
     * @version 1.0
     */
    void ResizeVisibleArea(int16_t x, int16_t y, int16_t width, int16_t height);

    /**
     * @brief Sets the width for the view.
     * @param width Indicates the width to set.
     * @since 1.0
     * @version 1.0
     */
    virtual void SetWidth(int16_t width);

    /**
     * @brief Sets a percentage that represents the proportion of the view's width to the parent view's width.
     * @param widthPercent Indicates the percentage to set, the decimal form of which ranges from 0 to 1.
     * @since 5.0
     * @version 3.0
     */
    virtual void SetWidthPercent(float widthPercent);

    /**
     * @brief Obtains the width for the view.
     * @return Returns the view width.
     * @since 1.0
     * @version 1.0
     */
    virtual int16_t GetWidth();

    /**
     * @brief Sets the height for the view.
     * @param height Indicates the height to set.
     * @since 1.0
     * @version 1.0
     */
    virtual void SetHeight(int16_t height);

    /**
     * @brief Sets a percentage that represents the proportion of the view's hieght to the parent view's hieght.
     * @param widthPercent Indicates the percentage to set, the decimal form of which ranges from 0 to 1.
     * @since 5.0
     * @version 3.0
     */
    virtual void SetHeightPercent(float heightPercent);

    /**
     * @brief Obtains the height for the view.
     * @return Returns the view height.
     * @since 1.0
     * @version 1.0
     */
    virtual int16_t GetHeight();

    /**
     * @brief Adjusts the size of the view.
     * @param width Indicates the new width.
     * @param height Indicates the new height.
     * @since 1.0
     * @version 1.0
     */
    virtual void Resize(int16_t width, int16_t height);

    /**
     * @brief Adjusts the size of the view based on specified percentages.
     * @param widthPercent Indicates the percentage that represents the proportion of the view's width
     *        to the parent view's width to set, the decimal form of which ranges from 0 to 1.
     * @param heightPercent Indicates the percentage that represents the proportion of the view's height
     *        to the parent view's height to set, the decimal form of which ranges from 0 to 1.
     * @since 5.0
     * @version 3.0
     */
    virtual void ResizePercent(float widthPercent, float heightPercent);

    /**
     * @brief Sets the x-coordinate for the view.
     * @param x Indicates the x-coordinate to set.
     * @since 1.0
     * @version 1.0
     */
    virtual void SetX(int16_t x);

    /**
     * @brief Sets a percentage that represents the proportion of the view's x-coordinate
     *        to the parent view's x-coordinate.
     * @param xPercent Indicates the percentage to set, the decimal form of which ranges from 0 to 1.
     * @since 5.0
     * @version 3.0
     */
    virtual void SetXPercent(float xPercent);

    /**
     * @brief Obtains the x-coordinate for the view.
     * @return Returns the x-coordinate.
     * @since 1.0
     * @version 1.0
     */
    int16_t GetX() const;

    /**
     * @brief Sets the y-coordinate for the view.
     * @param y Indicates the y-coordinate to set.
     * @since 1.0
     * @version 1.0
     */
    virtual void SetY(int16_t y);

    /**
     * @brief Sets a percentage that represents the proportion of the view's y-coordinate
     *        to the parent view's y-coordinate.
     * @param yPercent Indicates the percentage to set, the decimal form of which ranges from 0 to 1.
     * @since 5.0
     * @version 3.0
     */
    virtual void SetYPercent(float yPercent);

    /**
     * @brief Obtains the y-coordinate for the view.
     * @return Returns the y-coordinate.
     * @since 1.0
     * @version 1.0
     */
    int16_t GetY() const;

    /**
     * @brief 获取组件设置margin属性后margin的宽度,包括组件宽度加marginLeft 加 marginRight.
     * @return margin的宽度
     * @since 6
     */
    int16_t GetWidthWithMargin();

    /**
     * @brief 获取组件设置margin属性后margin的高度度,包括组件宽度加marginTop 加 marginBottom.
     * @return margin的高度
     * @since 6
     */
    int16_t GetHeightWithMargin();

    /**
     * @brief Sets the position for the view.
     * @param x Indicates the x-coordinate to set.
     * @param y Indicates the y-coordinate to set.
     * @since 1.0
     * @version 1.0
     */
    virtual void SetPosition(int16_t x, int16_t y);

    /**
     * @brief Sets the position percentages for the view.
     * @param xPercent Indicates the percentage that represents the proportion of the view's x-coordinate
     *        to the parent view's x-coordinate to set, the decimal form of which ranges from 0 to 1.
     * @param yPercent Indicates the percentage that represents the proportion of the view's y-coordinate
     *        to the parent view's y-coordinate to set, the decimal form of which ranges from 0 to 1.
     * @since 5.0
     * @version 3.0
     */
    virtual void SetPositionPercent(float xPercent, float yPercent);

    /**
     * @brief Adjusts the position and size of the view.
     * @param x Indicates the new x-coordinate.
     * @param y Indicates the new y-coordinate.
     * @param width Indicates the new width.
     * @param height Indicates the new height.
     * @since 1.0
     * @version 1.0
     */
    virtual void SetPosition(int16_t x, int16_t y, int16_t width, int16_t height);

    /**
     * @brief Sets the position and size percentages for the view.
     * @param xPercent Indicates the percentage that represents the proportion of the view's x-coordinate
     *        to the parent view's x-coordinate to set, the decimal form of which ranges from 0 to 1.
     * @param yPercent Indicates the percentage that represents the proportion of the view's y-coordinate
     *        to the parent view's y-coordinate, the decimal form of which ranges from 0 to 1.
     * @param widthPercent Indicates the percentage that represents the proportion of the view's width
     *        to the parent view's width, the decimal form of which ranges from 0 to 1.
     * @param heightPercent Indicates the percentage that represents the proportion of the view's height
     *        to the parent view's height, the decimal form of which ranges from 0 to 1.
     * @since 5.0
     * @version 3.0
     */
    virtual void SetPositionPercent(float xPercent, float yPercent, float widthPercent, float heightPercent);

    /**
     * @brief Checks whether the view is a container view.
     * @return Returns <b>true</b> if the view is a container view; returns <b>false</b> otherwise.
     * @since 1.0
     * @version 1.0
     */
    bool IsViewGroup() const;

    /**
     * @brief Sets whether to intercept the input event. If intercepted, the view does not transfer the input event to
     *        the parent view after local processing.
     * @param isIntercept Specifies whether to intercept the input event. Value <b>true</b> means to intercept the input
     *                    event, and <b>false</b> means the opposite.
     * @since 1.0
     * @version 1.0
     */
    void SetIntercept(bool isIntercept);

    /**
     * @brief Gets whether to intercept the input event. If intercepted, the view does not transfer the input event to
     *        the parent view after local processing.
     * @return Returns <b>true</b> if intercept the input event, and <b>false</b> means the opposite.
     * @since 1.0
     * @version 1.0
     */
    bool IsIntercept();

    /**
     * @brief Sets the affine transformation matrix.
     * @param transMap Indicates the transformation matrix.
     * @since 1.0
     * @version 1.0
     */
    void SetTransformMap(const TransformMap& transMap);

    /**
     * @brief Obtains an affine transformation matrix.
     * @return Returns the transform matrix.
     * @since 1.0
     * @version 1.0
     */
    TransformMap& GetTransformMap();

    /**
     * @brief Obtains the child view of a specified ID.
     * @return Returns the pointer to the child view.
     * @since 1.0
     * @version 1.0
     */
    virtual UIView* GetChildById(const char* id) const;

    /**
     * @brief Sets the view ID.
     * @param id Indicates the pointer to the view ID.
     * @since 1.0
     * @version 1.0
     */
    void SetViewId(const char* id);

    /**
     * @brief Obtains the view ID.
     * @return Returns the pointer to the view ID.
     * @since 1.0
     * @version 1.0
     */
    const char* GetViewId() const;

    /**
     * @brief Sets the view index.
     * @param index Indicates the view index to set.
     * @since 1.0
     * @version 1.0
     */
    void SetViewIndex(int16_t index);

    /**
     * @brief Obtains the view index.
     * @return Returns the view index.
     * @since 1.0
     * @version 1.0
     */
    int16_t GetViewIndex() const;

    /**
     * @brief Obtains the view type.
     * @return Returns the view type.
     * @since 1.0
     * @version 1.0
     */
    virtual UIViewType GetViewType() const;

    /**
     * @brief Lays out all child views according to the preset arrangement mode.
     * @param needInvalidate Specifies whether to refresh the invalidated area after the layout is complete.
     *                       Value <b>true</b> means to refresh the invalidated area after the layout is complete,
     *                       and <b>false</b> means the opposite.
     * @since 1.0
     * @version 1.0
     */
    virtual void LayoutChildren(bool neeInvalidate = false) {}

    /**
     * @brief Lays out the view in the center of the parent view.
     * @param xOffset Indicates the offset added to the x-axis after the view is placed. A positive number indicates
     *                the offset to the right, and a negative number indicates the offset to the left.
     * @param yOffset Indicates the offset added to the y-axis after the view is placed. A positive number indicates
     *                the offset to the bottom, and a negative number indicates the offset to the top.
     * @since 1.0
     * @version 1.0
     */
    void LayoutCenterOfParent(int16_t xOffSet = 0, int16_t yOffset = 0);

    /**
     * @brief Lays out the view on the left of the parent view.
     * @param offset Indicates the offset added to the x-axis after the view is placed. A positive number indicates
     *               the offset to the right, and a negative number indicates the offset to the left.
     * @since 1.0
     * @version 1.0
     */
    void LayoutLeftOfParent(int16_t offset = 0);

    /**
     * @brief Lays out the view on the right of the parent view.
     * @param offset Indicates the offset added to the x-axis after the view is placed. A positive number indicates
     *               the offset to the left, and a negative number indicates the offset to the right.
     * @since 1.0
     * @version 1.0
     */
    void LayoutRightOfParent(int16_t offset = 0);

    /**
     * @brief Lays out the view on the top of the parent view.
     * @param offset Indicates the offset added to the y-axis after the view is placed. A positive number indicates
     *               the offset to the bottom, and a negative number indicates the offset to the top.
     * @since 1.0
     * @version 1.0
     */
    void LayoutTopOfParent(int16_t offset = 0);

    /**
     * @brief Lays out the view on the bottom of the parent view.
     * @param offset Indicates the offset added to the y-axis after the view is placed. A positive number indicates
     *               the offset to the top, and a negative number indicates the offset to the bottom.
     * @since 1.0
     * @version 1.0
     */
    void LayoutBottomOfParent(int16_t offset = 0);

    /**
     * @brief Aligns the view with the left of a sibling view.
     * @param id Indicates the pointer to the ID of the sibling view.
     * @param offset Indicates the offset added to the x-axis after the view is placed. A positive number indicates
     *               the offset to the right, and a negative number indicates the offset to the left.
     * @since 1.0
     * @version 1.0
     */
    void AlignLeftToSibling(const char* id, int16_t offset = 0);

    /**
     * @brief Aligns the view with the right of a sibling view.
     * @param id Indicates the pointer to the ID of the sibling view.
     * @param offset Indicates the offset added to the x-axis after the view is placed. A positive number indicates
     *               the offset to the left, and a negative number indicates the offset to the right.
     * @since 1.0
     * @version 1.0
     */
    void AlignRightToSibling(const char* id, int16_t offset = 0);

    /**
     * @brief Aligns the view with the top of a sibling view.
     * @param id Indicates the pointer to the ID of the sibling view.
     * @param offset Indicates the offset added to the y-axis after the view is placed. A positive number indicates
     *               the offset to the bottom, and a negative number indicates the offset to the top.
     * @since 1.0
     * @version 1.0
     */
    void AlignTopToSibling(const char* id, int16_t offset = 0);

    /**
     * @brief Aligns the view with the bottom of a sibling view.
     * @param id Indicates the pointer to the ID of the sibling view.
     * @param offset Indicates the offset added to the y-axis after the view is placed. A positive number indicates
     *               the offset to the top, and a negative number indicates the offset to the bottom.
     * @since 1.0
     * @version 1.0
     */
    void AlignBottomToSibling(const char* id, int16_t offset = 0);

    /**
     * @brief Aligns the view with the center of a sibling view in the x-axis.
     * @param id Indicates the pointer to the ID of the sibling view.
     * @param offset Indicates the offset added to the x-axis after the view is placed. A positive number indicates
     *               the offset to the right, and a negative number indicates the offset to the left.
     * @since 1.0
     * @version 1.0
     */
    void AlignHorCenterToSibling(const char* id, int16_t offset = 0);

    /**
     * @brief Aligns the view with the center of a sibling view in the y-axis.
     * @param id Indicates the pointer to the ID of the sibling view.
     * @param offset Indicates the offset added to the y-axis after the view is placed. A positive number indicates
     *               the offset to the bottom, and a negative number indicates the offset to the top.
     * @since 1.0
     * @version 1.0
     */
    void AlignVerCenterToSibling(const char* id, int16_t offset = 0);

    /**
     * @brief Lays out the view on the left of a sibling view.
     * @param id Indicates the pointer to the ID of the sibling view.
     * @param offset Indicates the offset added to the x-axis after the view is placed. A positive number indicates
     *               the offset to the left, and a negative number indicates the offset to the right.
     * @since 1.0
     * @version 1.0
     */
    void LayoutLeftToSibling(const char* id, int16_t offset = 0);

    /**
     * @brief Lays out the view on the right of a sibling view.
     * @param id Indicates the pointer to the ID of the sibling view.
     * @param offset Indicates the offset added to the x-axis after the view is placed. A positive number indicates
     *               the offset to the right, and a negative number indicates the offset to the left.
     * @since 1.0
     * @version 1.0
     */
    void LayoutRightToSibling(const char* id, int16_t offset = 0);

    /**
     * @brief Lays out the view on the above of a sibling view.
     * @param id Indicates the pointer to the ID of the sibling view.
     * @param offset Indicates the offset added to the y-axis after the view is placed. A positive number indicates
     *               the offset to the top, and a negative number indicates the offset to the bottom.
     * @since 1.0
     * @version 1.0
     */
    void LayoutTopToSibling(const char* id, int16_t offset = 0);

    /**
     * @brief Lays out the view on the below of a sibling view.
     * @param id Indicates the pointer to the ID of the sibling view.
     * @param offset Indicates the offset added to the y-axis after the view is placed. A positive number indicates
     *               the offset to the bottom, and a negative number indicates the offset to the top.
     * @since 1.0
     * @version 1.0
     */
    void LayoutBottomToSibling(const char* id, int16_t offset = 0);

    /**
     * @brief Sets the view style.
     * @param style Indicates the view style.
     * @since 1.0
     * @version 1.0
     */
    virtual void SetStyle(Style& style);

    /**
     * @brief Sets a style.
     *
     * @param key Indicates the key of the style to set.
     * @param value Indicates the value matching the key.
     * @since 1.0
     * @version 1.0
     */
    virtual void SetStyle(uint8_t key, int64_t value);

    /**
     * @brief Obtains the value of a style.
     *
     * @param key Indicates the key of the style.
     * @return Returns the value of the style.
     * @since 1.0
     * @version 1.0
     */
    virtual int64_t GetStyle(uint8_t key) const;

    /**
     * @brief Obtains the view style. This function applies to scenarios where the style does not need to be modified,
     *        which saves memory.
     * @return Returns the view style.
     * @since 1.0
     * @version 1.0
     */
    const Style& GetStyleConst() const;

    /**
     * @brief Sets the opacity for the view.
     *
     * @param opaScale Indicates the opacity to set.
     * @since 1.0
     * @version 1.0
     */
    void SetOpaScale(uint8_t opaScale);

    /**
     * @brief Obtains the view opacity.
     *
     * @return Returns the view opacity.
     * @since 1.0
     * @version 1.0
     */
    uint8_t GetOpaScale() const;

    /**
     * @brief Obtains the extra message about a <b>UIView</b> instance. This field is ignored by the graphics
     *        framework and can be anything you set.
     *
     * @return Returns the pointer to the extra message about the <b>UIView</b> instance.
     * @since 5.0
     * @version 3.0
     */
    ViewExtraMsg* GetExtraMsg();

    /**
     * @brief Sets the extra message about a <b>UIView</b> instance. This field is ignored by the graphics
     *        framework and can be anything you set.
     *
     * @param extraMsg Indicates the extra message to set.
     * @since 5.0
     * @version 3.0
     */
    void SetExtraMsg(ViewExtraMsg* extraMsg);

    /**
     * @brief Rotates the view in 2d.
     * @param angle Indicates the rotation angle.
     * @param pivot Indicates the coordinates of the rotation pivot.
     * @since 5.0
     * @version 3.0
     */
    void Rotate(int16_t angle, const Vector2<float>& pivot);

    /**
     * @brief Rotates the view in 3d.
     * @param angle Indicates the rotation angle.
     * @param pivotStart Indicates the coordinates of the rotation start pivot.
     * @param pivotEnd Indicates the coordinates of the rotation end pivot.
     * @since 5.0
     * @version 3.0
     */
    void Rotate(int16_t angle, const Vector3<float>& pivotStart, const Vector3<float>& pivotEnd);

    /**
     * @brief Scales the view in 2d.
     *
     * @param scale Indicates the scale factor on x- and y- axes.
     * @param pivot Indicates the scaling pivot.
     * @since 5.0
     * @version 3.0
     */
    void Scale(const Vector2<float>& scale, const Vector2<float>& pivot);

    /**
     * @brief Scales the view in 3d.
     *
     * @param scale Indicates the scale factor on x- and y- axes.
     * @param pivot Indicates the scaling pivot.
     * @since 5.0
     * @version 3.0
     */
    void Scale(const Vector3<float>& scale, const Vector3<float>& pivot);

    /**
     * @brief Shears the view in 3d.
     *
     * @param shearX Indicates the shear parameters around x- axes,
     *               which means many it shears in y and z direction(current invalid).
     * @param shearY Indicates the shear parameters around y- axes,
     *               which means many it shears in x and z direction(current invalid).
     * @param shaerZ Indicates the shear parameters around z- axes,
     *               which means many it shears in x and y.
     * @since 5.0
     * @version 3.0
     */
    void Shear(const Vector2<float>& shearX, const Vector2<float>& shearY, const Vector2<float>& shearZ);

    void Translate(const Vector2<int16_t>& trans);

    void Translate(const Vector3<int16_t>& trans);

    bool IsTransInvalid();

    void SetCameraDistance(int16_t distance);

    void SetCameraPosition(const Vector2<float>& position);

    void ResetTransParameter();

#if ENABLE_ROTATE_INPUT
    /**
     * @brief Requests the focus on the view.
     *
     * @since 5.0
     * @version 3.0
     */
    virtual void RequestFocus();

    /**
     * @brief Clears the focus on the view.
     *
     * @since 5.0
     * @version 3.0
     */
    virtual void ClearFocus();
#endif
#if ENABLE_FOCUS_MANAGER
    /**
     * @brief 设置视图是否可获焦.
     *
     * @param focusable 是否可获焦.
     * @since 5.0
     * @version 3.0
     */
    void SetFocusable(bool focusable);

    /**
     * @brief 获取视图是否可获焦.
     *
     * @return 是否可获焦.
     * @since 5.0
     * @version 3.0
     */
    bool IsFocusable() const;

    /**
     * @brief 组件获焦响应
     *
     * @since 5.0
     * @version 3.0
     */
    virtual void Focus();

    /**
     * @brief 组件失焦响应
     *
     * @since 5.0
     * @version 3.0
     */
    virtual void Blur();

    /**
     * @brief 焦点改变事件监听类,开发者需要向视图组件注册该类实现事件的监听.
     *
     * @since 5.0
     * @version 3.0
     */
    class OnFocusListener : public HeapBase {
    public:
        /**
         * @brief 回调函数,视图获焦时触发.
         * @param view 获焦的视图
         * @since 5.0
         * @version 3.0
         */
        virtual bool OnFocus(UIView& view)
        {
            return false;
        }

        /**
         * @brief 回调函数,视图失焦时触发.
         * @param view 失焦的视图
         * @since 5.0
         * @version 3.0
         */
        virtual bool OnBlur(UIView& view)
        {
            return false;
        }

        /**
         * @brief 析构函数.
         * @since 5.0
         * @version 3.0
         */
        virtual ~OnFocusListener() {}
    };

    /**
     * @brief 设置当前视图焦点改变事件监听者.
     * @param onFocusListener 焦点改变事件监听者.
     * @since 5.0
     * @version 3.0
     */
    void SetOnFocusListener(OnFocusListener* onFocusListener);

    /**
     * @brief 获取当前视图焦点改变事件监听者.
     * @return 焦点改变事件监听者.
     * @since 5.0
     * @version 3.0
     */
    OnFocusListener* GetOnFocusListener() const;
#endif

    /**
     * @brief 获取当前视图的bitmap截图.请注意该接口会申请内存,请在需要释放时使用{@link ImageCacheFree()}接口.
     * @param info bitmap存储对象,获取的截图将被存到该引用中.
     * @param colorMode 截图格式,默认状态下为带透明度的ARGB8888.
     * @return bitmap是否获取成功.
     * @since 5.0
     * @version 3.0
     */
    bool GetBitmap(ImageInfo& bitmap, ColorMode colorMode = ARGB8888);

    bool IsOnViewTree();

    /**
     * @brief Set view zIndex order
     * @param zIndex specifies the stack order of an view. The default is zero.
     *               The greater order is in front of the lower order.
     */
    void SetZIndex(int16_t zIndex);

    /**
     * @brief Get zIndex value of the view
     * @return the zIndex order value
     */
    int16_t GetZIndex();

    /**
     * @brief Sets the next render sibling view for the view.
     * @param sibling Indicates the pointer to the next render sibling view to set.
     */
    void SetNextRenderSibling(UIView* renderSibling);

    /**
     * @brief Obtains the next render sibling view of the view.
     * @return Returns the pointer to the next render sibling view.
     */
    UIView* GetNextRenderSibling() const;

protected:
    bool touchable_ : 1;
    bool visible_ : 1;
    bool draggable_ : 1;
    bool dragParentInstead_ : 1;
    bool isViewGroup_ : 1;
    bool needRedraw_ : 1;
    bool styleAllocFlag_ : 1;
    bool isIntercept_ : 1;
#if ENABLE_FOCUS_MANAGER
    bool focusable_ : 1;
#endif
#if defined(CONFIG_DYNAMIC_LAYOUT) && (CONFIG_DYNAMIC_LAYOUT == 1)
    bool isRemeasure_ : 1;
#endif
    uint8_t opaScale_;
    int16_t index_;
    int16_t zIndex_;
    const char* id_;
    UIView* parent_;
    UIView* nextSibling_;
    UIView* nextRenderSibling_;
    Style* style_;
    TransformMap* transMap_;
    OnClickListener* onClickListener_;
    OnLongPressListener* onLongPressListener_;
    OnDragListener* onDragListener_;
    OnTouchListener* onTouchListener_;
#if ENABLE_FOCUS_MANAGER
    OnFocusListener* onFocusListener_;
#endif
#if ENABLE_ROTATE_INPUT
    OnRotateListener* onRotateListener_;
#endif
    ViewExtraMsg* viewExtraMsg_;

    uint8_t GetMixOpaScale() const;
    bool IsInvalid(float percent);
    void DrawViewBounds(BufferInfo& gfxDstBuffer, const Rect& invalidatedArea);
    void UpdateRectInfo(uint8_t key, const Rect& rect);

private:
    Rect rect_;
    Rect* visibleRect_;
    void SetupThemeStyles();
#if defined(CONFIG_DYNAMIC_LAYOUT) && (CONFIG_DYNAMIC_LAYOUT == 1)
    List<RelativeLayoutInfo> layoutList_;
    Point *originalPos_; // Original location.
    void AddRelativeInfo(RelativeLayoutType type, const char* viewId, int16_t xOffset, int16_t yOffset = 0);
    void LayoutOfParent(const RelativeLayoutInfo &layoutInfo);
    void AlignToSibling(const RelativeLayoutInfo &layoutInfo);
    void LayoutToSibling(const RelativeLayoutInfo &layoutInfo);
#endif
};
} // namespace OHOS
#endif // GRAPHIC_LITE_UI_VIEW_H