OHOS::UIList

Overview

Related Modules:

Graphic

Description:

Represents a scrollable list which is used with the adapter AbstractAdapter to implement scrolling, inertial scrolling, automatic alignment, and invoking of a callback when a child view is selected at the preset position as this list scrolls.

You need to override AbstractAdapter to implement functions for setting and saving data, obtaining data quantity, and creating child views. UIList is used when there is a large number of child views with a fixed format. This list automatically reclaims the child views removed out of the current view as it scrolls so that as many as child views can be displayed with a lower memory consumption.

Since:

1.0

Version:

1.0

Summary

Public Member Functions

Public Member Function Name

Description

UIList ()

 

A constructor used to create a UIList instance in the vertical direction.

UIList (uint8_t direction)

 

A constructor used to create a UIList instance in the specified direction.

~UIList ()

virtual 

A destructor used to delete the UIList instance.

GetViewType () const override

UIViewType 

Obtains the view type.

OnDragEvent (const DragEvent &event) override

bool 

Called when the view is being dragged.

OnDragEndEvent (const DragEvent &event) override

bool 

Called when the view stops dragging.

OnPressEvent (const PressEvent &event) override

void 

Called when the view is pressed.

SetAdapter (AbstractAdapter adapter)

void 

Sets the adapter for this list. The content of this list is initialized when the adapter is set.

MoveChildByOffset (int16_t x, int16_t y) override

virtual void 

Moves the position of all child views.

ScrollTo (uint16_t index)

void 

Scrolls to change the index of the first row or column of the current view.

ScrollBy (int16_t distance)

void 

Scrolls the content in this list.

SetStartIndex (uint16_t index)

void 

Sets the start index for this list.

GetStartIndex () const

uint16_t 

Obtains the start index of this list. The default value is 0.

SetLoopState (bool state)

void 

Sets the loop state for this list, in which a loop scroll is possible since the top and bottom of the list are connected together.

GetLoopState () const

bool 

Checks whether this list is in a loop state.

SetSelectPosition (uint16_t position)

void 

Sets the position where a child view is selected as this list scrolls.

GetSelectView ()

UIView  

Obtains the child view being selected at the preset position.

SetScrollStateListener (ListScrollListener scrollListener)

void 

Sets the listener that contains a callback to be invoked when a child view is selected as this list scrolls.

RefreshList ()

void 

Refreshes this list. The number of child views in the current view is fixed and the positions of those reserved child views as this list scrolls remain unchanged.

EnableAutoAlign (bool state)

void 

Sets the automatic alignment state for this list. When a scroll stops, a child view is selected and its position is automatically aligned with the preset position.

RemoveAll () override

void 

Removes all child views.

UIAbstractScroll ()

 

A constructor used to create a UIAbstractScroll instance.

~UIAbstractScroll ()

virtual 

A destructor used to delete the UIAbstractScroll instance.

GetDirection () const

uint8_t 

Obtains the scroll direction.

SetScrollBlankSize (uint16_t size)

void 

Sets the blank size for this scroll view.

SetMaxScrollDistance (uint16_t distance)

void 

Sets the maximum scroll distance after a finger lifts the screen.

SetReboundSize (uint16_t size)

void 

Sets the rebound size, which is the distance a knob moves after being released when it reaches the end of a scrollbar.

GetMaxScrollDistance () const

uint16_t 

Obtains the maximum scroll distance after a finger lifts the screen.

SetDragFunc (EasingFunc func)

void 

Sets the easing function that specifies a scroll animation after a finger lifts the screen.

SetThrowDrag (bool throwDrag)

void 

Sets whether to continue scrolling after a finger lifts the screen.

SetDragACCLevel (uint16_t value)

void 

Sets the drag acceleration.

GetDragACCLevel () const

uint8_t 

Obtains the drag acceleration.

SetSwipeACCLevel (uint16_t value)

void 

Sets the compensation distance after a finger lifts the screen.

GetSwipeACCLevel () const

uint8_t 

Obtains the compensation distance after a finger lifts the screen.

UIViewGroup ()

 

A default constructor used to create a UIViewGroup instance.

~UIViewGroup ()

virtual 

A destructor used to delete the UIViewGroup instance.

GetViewType () const override

UIViewType 

Obtains the view type.

Add (UIView view)

virtual void 

Adds a child view.

Insert (UIView prevView, UIView insertView)

virtual void 

Inserts a new child view behind the current one.

Remove (UIView view)

virtual void 

Removes a child view.

GetTargetView (const Point &point, UIView **last) override

virtual void 

Obtains the target child view that is visible and can respond to touch events based on given coordinates.

GetChildrenHead () const

UIView  

Obtains the first child view in this view group.

GetChildrenTail () const

UIView  

Obtains the last child view in this view group.

SetDisallowIntercept (bool flag)

void 

Sets whether this view group is intercepted upon touch events.

GetChildById (const char id) const override

UIView  

Obtains the target child view with a specified ID.

SetAutoSize (bool state)

void 

Sets whether the size of this view group is adaptive to that of all child views.

UIView ()

 

A default constructor used to create an UIView instance.

UIView (const char id)

 

A constructor used to create an UIView instance.

~UIView ()

virtual 

A destructor used to delete the UIView instance.

OnPreDraw (const Rect &invalidatedArea)

virtual bool 

Called before a view is drawn. This function is used to check whether the parent view of this view needs to be redrawn so as to optimize the drawing process.

OnDraw (const Rect &invalidatedArea)

virtual void 

Called when a view is drawn.

OnPostDraw (const Rect &invalidatedArea)

virtual void 

Called after a view is drawn.

ReMeasure ()

virtual void 

Remeasures the view size.

Invalidate ()

void 

Refreshes the invalidated area of the view.

InvalidateRect (const Rect &invalidatedArea)

void 

Refreshes a view in a specified invalidated area.

OnLongPressEvent (const LongPressEvent &event)

virtual bool 

Called when the view is long pressed.

OnDragStartEvent (const DragEvent &event)

virtual bool 

Called when the view starts to drag.

OnClickEvent (const ClickEvent &event)

virtual void 

Called when the view is clicked.

OnReleaseEvent (const ReleaseEvent &event)

virtual void 

Called when the view is released.

OnCancelEvent (const CancelEvent &event)

virtual void 

Called when a click event on the view is canceled.

SetOnDragListener (OnDragListener onDragListener)

void 

Sets a drag event listener for the view.

GetOnDragListener ()

OnDragListener

Obtains the drag event listener for the view.

SetOnClickListener (OnClickListener onClickListener)

void 

Sets a click event listener for the view.

GetOnClickListener ()

OnClickListener

Obtains the click event listener for the view.

SetOnLongPressListener (OnLongPressListener onLongPressListener)

void 

Sets a long-press event listener for the view.

GetOnLongPressListener ()

OnLongPressListener

Obtains the long-press event listener for the view.

SetOnTouchListener (OnTouchListener onTouchListener)

void 

Sets a touch event listener for the view.

GetTouchListener ()

OnTouchListener

Obtains the touch event listener for the view.

SetParent (UIView parent)

void 

Sets the parent view for the view.

GetParent () const

UIView  

Obtains the parent view of the view.

SetNextSibling (UIView sibling)

void 

Sets the next sibling view for the view.

GetNextSibling () const

UIView  

Obtains the next sibling view of the view.

SetVisible (bool visible)

virtual void 

Sets whether the view is visible.

IsVisible () const

bool 

Checks whether the view is visible.

SetTouchable (bool touch)

void 

Sets whether the view is touchable.

IsTouchable () const

bool 

Checks whether the view is touchable.

SetDraggable (bool draggable)

void 

Sets whether the view is draggable.

IsDraggable () const

bool 

Checks whether the view is draggable.

SetDragParentInstead (bool dragParentInstead)

void 

Sets whether to transfer the drag event to the parent view for processing when the view is being dragged.

IsDragParentInstead () const

bool 

Obtains whether the view transfers a drag event to the parent view for processing.

GetRect () const

Rect 

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.

GetVisibleRect () const

Rect 

Obtains the visible absolute rectangle area of the view.

GetMaskedRect () const

Rect 

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.

GetOrigRect () const

Rect 

Obtains the absolute rectangle area of the view.

GetContentRect ()

virtual Rect 

Obtains the content of the absolute rectangle area of the view. This area excludes padding.

GetRelativeRect () const

Rect 

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.

ResizeVisibleArea (int16_t x, int16_t y, int16_t width, int16_t height)

void 

Adjusts the size of the visible area. This operation may affect the final display size.

SetWidth (int16_t width)

virtual void 

Sets the width for the view.

GetWidth ()

virtual int16_t 

Obtains the width for the view.

SetHeight (int16_t height)

virtual void 

Sets the height for the view.

GetHeight ()

virtual int16_t 

Obtains the height for the view.

Resize (int16_t width, int16_t height)

virtual void 

Adjusts the size of the view.

SetX (int16_t x)

virtual void 

Sets the x-coordinate for the view.

GetX () const

int16_t 

Obtains the x-coordinate for the view.

SetY (int16_t y)

virtual void 

Sets the y-coordinate for the view.

GetY () const

int16_t 

Obtains the y-coordinate for the view.

SetPosition (int16_t x, int16_t y)

virtual void 

Sets the position for the view.

SetPosition (int16_t x, int16_t y, int16_t width, int16_t height)

virtual void 

Adjusts the position and size of the view.

IsViewGroup () const

bool 

Checks whether the view is a container view.

SetIntercept (bool isIntercept)

void 

Sets whether to intercept the drag event. If intercepted, the view does not transfer the drag event to the parent view after local processing.

SetTransformMap (const TransformMap &transMap)

void 

Sets the affine transformation matrix.

GetTransformMap ()

TransformMap

Obtains an affine transformation matrix.

SetViewId (const char id)

void 

Sets the view ID.

GetViewId () const

const char  

Obtains the view ID.

SetViewIndex (int16_t index)

void 

Sets the view index.

GetViewIndex () const

int16_t 

Obtains the view index.

LayoutChildren (bool neeInvalidate=false)

virtual void 

Lays out all child views according to the preset arrangement mode.

LayoutCenterOfParent (int16_t xOffSet=0, int16_t yOffset=0)

void 

Lays out the view in the center of the parent view.

LayoutLeftOfParent (int16_t offset=0)

void 

Lays out the view on the left of the parent view.

LayoutRightOfParent (int16_t offset=0)

void 

Lays out the view on the right of the parent view.

LayoutTopOfParent (int16_t offset=0)

void 

Lays out the view on the top of the parent view.

LayoutBottomOfParent (int16_t offset=0)

void 

Lays out the view on the bottom of the parent view.

AlignLeftToSibling (const char id, int16_t offset=0)

void 

Aligns the view with the left of a sibling view.

AlignRightToSibling (const char id, int16_t offset=0)

void 

Aligns the view with the right of a sibling view.

AlignTopToSibling (const char id, int16_t offset=0)

void 

Aligns the view with the top of a sibling view.

AlignBottomToSibling (const char id, int16_t offset=0)

void 

Aligns the view with the bottom of a sibling view.

AlignHorCenterToSibling (const char id, int16_t offset=0)

void 

Aligns the view with the center of a sibling view in the x-axis.

AlignVerCenterToSibling (const char id, int16_t offset=0)

void 

Aligns the view with the center of a sibling view in the y-axis.

LayoutLeftToSibling (const char id, int16_t offset=0)

void 

Lays out the view on the left of a sibling view.

LayoutRightToSibling (const char id, int16_t offset=0)

void 

Lays out the view on the right of a sibling view.

LayoutTopToSibling (const char id, int16_t offset=0)

void 

Lays out the view on the above of a sibling view.

LayoutBottomToSibling (const char id, int16_t offset=0)

void 

Lays out the view on the below of a sibling view.

SetStyle (Style &style)

virtual void 

Sets the view style.

SetStyle (uint8_t key, int64_t value)

virtual void 

Sets a style.

GetStyle (uint8_t key) const

virtual int64_t 

Obtains the value of a style.

GetStyleConst () const

const Style

Obtains the view style. This function applies to scenarios where the style does not need to be modified, which saves memory.

operator new (size_t size)

void  

Overrides the new function.

operator delete (void p)

void 

Overrides the delete function.

Additional Inherited Members

Additional Inherited Member Name

Description

GetAllChildRelativeRect () const

Obtains the rectangle area of a new view group after being adaptive to the size of all child views.

OnChildChanged ()

Performs operations needed after a child view is added or removed.

childrenHead

Indicates the pointer to the first child view of this view group.

childrenTail

Indicates the pointer to the last child view of this view group.

childrenNum

Represents the number of child views.

isDragging

Specifies the sliding state of this view group.

disallowIntercept

Specifies whether this view group is intercepted upon touch events.

isAutoSize

Specifies whether the size of this view group is adaptive to that of all child views.