gigawidgets 0.3.55
A wxWidgets-style UI library for the Arduino Giga Display Shield.
 
Loading...
Searching...
No Matches
input.hpp
Go to the documentation of this file.
1
2#pragma once
3
4#include "panel.hpp"
5#include "text.hpp"
6
7namespace ui {
8
15class Input : public Panel {
17 int cursor;
19 time_t lastRender;
21 bool showCursor;
22
24 void drawCursor() const;
25
26public:
38 Input(fontsize_t scale, color_t textColor, color_t backgroundColor, const Size &size = {0, 0}, radius_t borderRadius = 0, const Position &pos = {0, 0}, const Alignment &align = {ALIGN_LEFT, ALIGN_TOP}, const Padding &padding = {0});
39
51 Input(const GFXfont &font, color_t textColor, color_t backgroundColor, const Size &size = {0, 0}, radius_t borderRadius = 0, const Position &pos = {0, 0}, const Alignment &align = {ALIGN_LEFT, ALIGN_TOP}, const Padding &padding = {0});
52
57 void setText(const String &text);
58
63 const String &getText() const;
64
69 void insert(char c);
70
75 int getCursor() const;
76
84 void setCursor(int index);
85
91 int nearestCursor(const Coords &coords) const;
92
93 void draw() const override;
94 void update(time_t time) override;
95
96 DERIVE_EVENT_HANDLERS(Input)
97};
98
99} // namespace ui
An interactive class of Widget for handling text input.
Definition input.hpp:15
void setCursor(int index)
Set the position of the cursor.
const String & getText() const
Get the currently stored text.
Input(const GFXfont &font, color_t textColor, color_t backgroundColor, const Size &size={0, 0}, radius_t borderRadius=0, const Position &pos={0, 0}, const Alignment &align={ALIGN_LEFT, ALIGN_TOP}, const Padding &padding={0})
Construct an Input widget with a specific font.
int getCursor() const
Get the current cursor position.
void insert(char c)
Insert a character at the current cursor position.
int nearestCursor(const Coords &coords) const
Get the nearest cursor position to a given set of screen coordinates.
Input(fontsize_t scale, color_t textColor, color_t backgroundColor, const Size &size={0, 0}, radius_t borderRadius=0, const Position &pos={0, 0}, const Alignment &align={ALIGN_LEFT, ALIGN_TOP}, const Padding &padding={0})
Construct an Input widget with the default font.
void setText(const String &text)
Replace the stored text with a new string.
void update(time_t time) override
Update any internal state of the widget, and check if it needs to be re-rendered.
void draw() const override
Render the widget to the screen.
A basic widget that displays a rounded rectangle behind another widget.
Definition panel.hpp:18
Size size() const override
Get the size of the widget.
Padding padding
The padding that will be applied to any child widgets.
Definition widget.hpp:51
uint16_t color_t
An RGB565 color value. 5 bits red, 6 bits green, 5 bits blue.
Definition color.hpp:13
uint16_t fontsize_t
A non-negative integer for font sizes.
Definition fontsize.hpp:12
uint16_t radius_t
A non-negative size for the pixel radius of curved shapes.
Definition radius.hpp:12
A struct for storing the pixel coordinates of various UI elements.
Definition coords.hpp:17
A struct that holds the normalized position of a widget.
Definition position.hpp:15
A struct that holds the number of pixels that a widget would take up on the screen.
Definition size.hpp:17