The Button Gui-Element is a clickable, rectangular box with a label inside. When it is pressed and released you will be notified via the provided callback.
Use this value instead of x2, y2 in the BUTTON_STRUCT to autocalculate the button width/height.
Definition at line 65 of file button.h.
typedef void(* BUTTON_CALLBACK) (void *button) |
Prototype for Event Listeners (called when the button is pressed)
- Note
- You should NOT execute long running things in this callback nor should you update the gui. But you can call gui_screen_navigate() for instance.
- Parameters
-
button | The pointer to the BUTTON_STRUCT where to corresponding Button was pressed |
Definition at line 49 of file button.h.
Adds a button. Your Callback will be called from now on, if the button was pressed
- Parameters
-
- Returns
- true on success
Definition at line 133 of file button.c.
146 }
else if ((button->
base.
x2 - button->
base.
x1 + 1) < (strwidth + 2)) {
152 button->
base.
y2 = button->
base.
y1 - 1 + strheight + (strheight / 2);
153 }
else if ((button->
base.
y2 - button->
base.
y1 + 1) < (strheight + 2)) {
uint8_t tft_font_height(uint8_t fontnum)
bool touch_register_area(TOUCH_AREA_STRUCT *area)
const char * text
The label of the button.
uint8_t tft_font_width(uint8_t fontnum)
Receive an event when the pen goes down inside the region.
uint16_t y1
Top Left Y-Coordinate of Area.
uint16_t x1
Top Left X-Coordinate of Area.
TOUCH_AREA_STRUCT base
Basic geometry of the button. You only need to set the x1, y1, x2, y2 members of this struct...
uint16_t y2
Bottom Right Y-Coordinate of Area.
TOUCH_CALLBACK callback
Callback which is executed when an event occurred in this Area.
uint16_t x2
Bottom Right X-Coordinate of Area.
TOUCH_ACTION hookedActions
Actions to listen to.
bool touch_have_empty(unsigned char num)
uint8_t font
The number of the font to use.
Redraws the button. Call this method if you have to redraw the entire screen or if you want to draw a button on top of an image.
- Parameters
-
Definition at line 164 of file button.c.
169 uint16_t c_light, c_dark;
uint8_t tft_font_height(uint8_t fontnum)
const char * text
The label of the button.
uint8_t tft_font_width(uint8_t fontnum)
uint16_t txtcolor
The 16-bit text color.
void tft_draw_line(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color)
uint16_t y1
Top Left Y-Coordinate of Area.
void tft_print_line(uint16_t x, uint16_t y, uint16_t color, uint16_t bgcolor, uint8_t font, const char *text)
uint16_t x1
Top Left X-Coordinate of Area.
uint16_t bgcolor
The 16-bit background color of the button.
TOUCH_AREA_STRUCT base
Basic geometry of the button. You only need to set the x1, y1, x2, y2 members of this struct...
uint16_t y2
Bottom Right Y-Coordinate of Area.
uint16_t x2
Bottom Right X-Coordinate of Area.
void tft_fill_rectangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color)
uint8_t font
The number of the font to use.
Removes the button. You will no longer receive events for this button. This function will not overdraw the region where the button was located.
- Parameters
-
Definition at line 184 of file button.c.
void touch_unregister_area(TOUCH_AREA_STRUCT *area)