Iridescence 1.00
Embedded Graphic Framework
Loading...
Searching...
No Matches
ds_list.h
1/* Copyright (C) 2017 - 2024, Thornwave Labs Inc - All Rights Reserved.
2 * Unauthorized copying of this file, via any medium is strictly prohibited.
3 * Proprietary and confidential.
4 * Written by Razvan Turiac <razvan.turiac@thornwave.com>
5*/
6
7#ifndef _DS_LIST_H
8#define _DS_LIST_H
9
10
11#include <ds_view.h>
12#include <ds_selection_base.h>
13
14
25class DsList: public DsView, public DsSelectionBase
26{
27public:
32 {
33 public:
40 virtual int32_t onListGetLength(DsList* object) = 0;
41
42
51 virtual void onListGetView(DsList* object, DsView* holder, int32_t index, bool is_selected) = 0;
52 };
53
54
62 DsList(DsView* parent, const DsPoint &pos, const DsSize &size);
63
64
73 void addViewHolder(DsView* holder);
74
75
81 void setListener(Listener* listener);
82
83
89 void setRowGap(uint32_t gap);
90
91
97 void setMargin(uint32_t margin);
98
99
106
107
114 void setCursorColor(DsColor color, bool always_visible);
115
116
117private:
118 struct link_t
119 {
120 DsView* holder;
121 int32_t index;
122 link_t* next;
123 link_t* prev;
124 };
125
126 link_t* mFreeViewHolders;
127 link_t* mUsedViewHoldersHead;
128 link_t* mUsedViewHoldersTail;
129
130 DsRect mCursorRegion;
131 DsColor mCursorColor;
132
133 int32_t mRowHeight;
134 int32_t mRowGapTop;
135 int32_t mRowGapBottom;
136 int32_t mMargin;
137
138 DsRect mActiveAreaRegion;
139
140 Listener* mListener;
141
142 struct
143 {
144 uint8_t mIsTouchActive: 1;
145 uint8_t mCursorIsAlwaysVisible: 1;
146 };
147
148 void onShow(void) override final;
149
150 void onPaint(DsRenderer &renderer) override final;
151 void onPaintOver(DsRenderer &renderer) override final;
152 bool onTouch(const DsTouchEvent &event) override final;
153 void onSizeChange(void) override final;
154 int32_t onSelectionChange(int32_t selection) override final;
155 void getSelectionCount(void) override final;
156
157 void saturateScrollPosition(bool extended);
158 void update(void);
159
160 void removeLinkHead(void);
161 void removeLinkTail(void);
162 void insertLinkHead(link_t* link);
163 void insertLinkTail(link_t* link);
164 link_t* allocLink(void);
165 void freeLink(link_t* link);
166};
167
168#endif
DsColor is a class that represents a 4 channel color (Alpha, Red, Green, Blue).
Definition ds_color.h:53
Listener is an interface class that receives events from the list view.
Definition ds_list.h:32
virtual int32_t onListGetLength(DsList *object)=0
Called when the DsList view requires to know the number of items in the list.
virtual void onListGetView(DsList *object, DsView *holder, int32_t index, bool is_selected)=0
Called when the DsList view requires to have a view holder initialized with data for a specific row.
DsList is a class that implements a list that allows the user to view and select a specifc entry.
Definition ds_list.h:26
void setScrollbarColor(DsColor color)
Sets the color of the scroll bar.
void setRowGap(uint32_t gap)
Sets gap between list rows.
void setMargin(uint32_t margin)
Sets margin in between the list outlines and the contents.
void addViewHolder(DsView *holder)
Adds a view holder to the list.
void setListener(Listener *listener)
Sets the DsList event listener.
void setCursorColor(DsColor color, bool always_visible)
Enables / disables the cursor and sets its color.
DsList(DsView *parent, const DsPoint &pos, const DsSize &size)
Creates a DsList object.
DsPoint is a class that represents the X and Y 2D coordinates of a point as integer numbers.
Definition ds_geometry.h:24
DsRect is a class that represents a 2D rectangle (X, Y, W, H)
Definition ds_geometry.h:1507
DsRenderer is a class that implements all the drawing operations.
Definition ds_renderer.h:42
DsSelectionBase is a base class that contains a selection value.
Definition ds_selection_base.h:19
DsSize is class that represents the 2D size of a graphic object (width, height) as integer values.
Definition ds_geometry.h:780
DsView is a base class that represents any view on the screen.
Definition ds_view.h:40
This structure implements a touch event.
Definition ds_event.h:25