Bind
C++ UI toolkit for Arduino
 
Loading...
Searching...
No Matches
BindCanvasSettings.hpp
1#ifndef __BINDCANVASSETTINGS_HPP
2#define __BINDCANVASSETTINGS_HPP
3#include "BindView.hpp"
4#include "BindUtils.hpp"
5
6// Screen orientation is not set or specified.
7#define SCREEN_ORIENTATION_UNSET -2
8// Screen orientation is unspecified, allowing the system to decide.
9#define SCREEN_ORIENTATION_UNSPECIFIED -1
10// Landscape mode: screen width > height.
11#define SCREEN_ORIENTATION_LANDSCAPE 0
12// Portrait mode: screen height > width.
13#define SCREEN_ORIENTATION_PORTRAIT 1
14// User-defined orientation.
15#define SCREEN_ORIENTATION_USER 2
16// Based on the previous activity's orientation.
17#define SCREEN_ORIENTATION_BEHIND 3
18// Orientation determined by device sensors.
19#define SCREEN_ORIENTATION_SENSOR 4
20// Disable sensor-based orientation.
21#define SCREEN_ORIENTATION_NOSENSOR 5
22// Landscape orientation based on sensors.
23#define SCREEN_ORIENTATION_SENSOR_LANDSCAPE 6
24// Portrait orientation based on sensors.
25#define SCREEN_ORIENTATION_SENSOR_PORTRAIT 7
26// Reverse landscape orientation.
27#define SCREEN_ORIENTATION_REVERSE_LANDSCAPE 8
28// Reverse portrait orientation.
29#define SCREEN_ORIENTATION_REVERSE_PORTRAIT 9
30// Full sensor-based control over orientation.
31#define SCREEN_ORIENTATION_FULL_SENSOR 10
32// User-defined landscape orientation.
33#define SCREEN_ORIENTATION_USER_LANDSCAPE 11
34// User-defined portrait orientation.
35#define SCREEN_ORIENTATION_USER_PORTRAIT 12
36// Full user control over orientation, including reverse.
37#define SCREEN_ORIENTATION_FULL_USER 13
38// Lock the current screen orientation.
39#define SCREEN_ORIENTATION_LOCKED 14
40
59{
60public:
65 {
66 setlabel("BindApp");
67 }
68
69 int8_t screenOrientation = 0;
70 int32_t backColor;
72 bool resetScreen = false;
73
80 void setlabel(const char *cstr)
81 {
82 str = cstr;
83 }
84
98 uint16_t getBytes(uint8_t *out, int8_t _screenOrientation, int32_t _backColor, int32_t _actionBarColor, const char *cstr)
99 {
100 screenOrientation = _screenOrientation;
101 backColor = _backColor;
102 actionBarColor = _actionBarColor;
103 str = cstr;
104 return getBytes(out);
105 }
106
116 uint16_t getBytes(uint8_t *out) override
117 {
118 offset = 0;
119 strLength = strlen(str);
120 if (strLength > MAX_STRING_LENGTH_TERMINAL)
121 {
122 strLength = MAX_STRING_LENGTH_TERMINAL;
123 }
124 copyAndOffset(out, &offset, &objID, sizeof(objID));
125 copyAndOffset(out, &offset, &screenOrientation, sizeof(screenOrientation));
126 copyAndOffset(out, &offset, &backColor, sizeof(backColor));
127 copyAndOffset(out, &offset, &actionBarColor, sizeof(actionBarColor));
128 copyAndOffset(out, &offset, &resetScreen, sizeof(resetScreen));
129 copyAndOffset(out, &offset, str, strLength);
130 resetScreen = false;
131 return offset;
132 }
133
134private:
135 uint8_t objID = BIND_ID_SETTINGS;
136 uint16_t offset = 0;
137 int strLength = 0;
138 const char *str;
139};
140#endif /* __BINDCANVASSETTINGS_HPP */
Represents the configuration settings for a BindCanvas application screen.
Definition BindCanvasSettings.hpp:59
int32_t backColor
Background color in 32-bit format.
Definition BindCanvasSettings.hpp:70
BindCanvasSettings()
Constructs a BindCanvasSettings object with default label "BindApp.".
Definition BindCanvasSettings.hpp:64
int32_t actionBarColor
Action bar color in 32-bit format.
Definition BindCanvasSettings.hpp:71
int8_t screenOrientation
Screen orientation value.
Definition BindCanvasSettings.hpp:69
uint16_t getBytes(uint8_t *out, int8_t _screenOrientation, int32_t _backColor, int32_t _actionBarColor, const char *cstr)
Generates and returns the byte data representing the screen configuration.
Definition BindCanvasSettings.hpp:98
void setlabel(const char *cstr)
Sets the label for the BindCanvas application screen.
Definition BindCanvasSettings.hpp:80
bool resetScreen
Flag to reset the screen.
Definition BindCanvasSettings.hpp:72
uint16_t getBytes(uint8_t *out) override
Generates and returns the byte data representing the screen configuration.
Definition BindCanvasSettings.hpp:116
Definition BindView.hpp:22