Iridescence 1.00
Embedded Graphic Framework
Loading...
Searching...
No Matches
ds_book_view.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_BOOK_VIEW_H
8#define _DS_BOOK_VIEW_H
9
10
11#include <ds_view.h>
12
19class DsBookView: public DsView
20{
21public:
34 DsBookView(DsView* parent, const DsPoint &pos, const DsSize &size, uint32_t button_width, uint32_t dot_radius, bool overlap_buttons = false);
35
36
42 void addPage(DsView* view);
43
44
51 void enablePage(uint32_t index, bool enable);
52
53
59 void setPage(uint32_t index);
60
61
67 void setOnPageChangeCallback(const lambda<void(uint32_t)> &cb);
68
69
75 uint32_t getPageCount(void) const;
76
77
85 void enableLock(bool enable);
86
87
96
97
103 void enableDots(bool enable);
104
105
106private:
107 struct link_t
108 {
109 DsView* view;
110 bool active;
111 link_t* next;
112 };
113
114 uint32_t mPageCount;
115 uint32_t mActivePageCount;
116 uint32_t mPageIndex;
117
118 int32_t mDotRadius;
119 bool mDotsEnabled;
120
121 DsView* mLeftButton;
122 DsView* mRightButton;
123 DsView* mClientView;
124 link_t* mClientPagesHead;
125 link_t* mClientPagesTail;
126
127 bool mIsLocked;
128 bool mIsClosedLoop;
129
130 lambda<void(uint32_t)> mOnPageChangeCallback;
131
132 void onPaint(DsRenderer &renderer) override final;
133 void onSizeChange(void) override final;
134
135 void update(void);
136
137 int32_t availableLeft(void);
138 int32_t availableRight(void);
139};
140
141
142#endif
DsBookView is a class representing a container that arranges it's views as pages of a book.
Definition ds_book_view.h:20
void addPage(DsView *view)
Add a page to the BookView.
void enableLock(bool enable)
Enables or disables the page lock.
void enableDots(bool enable)
Enables or disables the active page dot indicators.
DsBookView(DsView *parent, const DsPoint &pos, const DsSize &size, uint32_t button_width, uint32_t dot_radius, bool overlap_buttons=false)
Creates a DsBookView object.
void enablePage(uint32_t index, bool enable)
Enables or disables a page.
void setOnPageChangeCallback(const lambda< void(uint32_t)> &cb)
Sets the lambda to be executed when the user changes the active page.
void enableClosedLoop(bool enable)
Enables or disables the closed loop mode.
void setPage(uint32_t index)
Sets the active page.
uint32_t getPageCount(void) const
Returns the number of pages in the DsView.
DsPoint is a class that represents the X and Y 2D coordinates of a point as integer numbers.
Definition ds_geometry.h:24
DsRenderer is a class that implements all the drawing operations.
Definition ds_renderer.h:42
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
void enable(bool state)
Enables or disables the view.
Definition ds_types_lambda.h:24