added shadow support for buttons
This commit is contained in:
parent
de84bc984c
commit
2c95af7413
2 changed files with 11 additions and 2 deletions
10
gui.c
10
gui.c
|
@ -135,8 +135,9 @@ uint8_t guiDeleteElement(char *label) {
|
||||||
return deleteElement(label);
|
return deleteElement(label);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t guiDrawButton(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, char *str, uint16_t fontColor, uint16_t buttonColor, char *label, uint8_t *active, uint8_t *state) {
|
uint8_t guiDrawButton(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, char *str, uint16_t fontColor, uint16_t buttonColor, uint16_t shadow, char *label, uint8_t *active, uint8_t *state) {
|
||||||
struct guiNode_t *newNode;
|
struct guiNode_t *newNode;
|
||||||
|
uint16_t i;
|
||||||
|
|
||||||
newNode = chHeapAlloc(NULL, sizeof(struct guiNode_t));
|
newNode = chHeapAlloc(NULL, sizeof(struct guiNode_t));
|
||||||
if(newNode == NULL)
|
if(newNode == NULL)
|
||||||
|
@ -157,6 +158,13 @@ uint8_t guiDrawButton(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, char *
|
||||||
|
|
||||||
lcdDrawRectString(x0, y0, x1, y1, str, fontColor, buttonColor);
|
lcdDrawRectString(x0, y0, x1, y1, str, fontColor, buttonColor);
|
||||||
|
|
||||||
|
if(shadow != 0) {
|
||||||
|
for(i = 0; i < shadow; i++) {
|
||||||
|
lcdDrawLine(x1+i, y0-i, x1+i, y1-i-1, Black);
|
||||||
|
lcdDrawLine(x0+i, y0-i, x1+i, y0-i, Black);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
chHeapFree(newNode);
|
chHeapFree(newNode);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
3
gui.h
3
gui.h
|
@ -63,12 +63,13 @@ uint8_t guiDeleteElement(char *label);
|
||||||
* - str: string that gets drawn into the rectangle - button's lable
|
* - str: string that gets drawn into the rectangle - button's lable
|
||||||
* - fontColor: color of the lable
|
* - fontColor: color of the lable
|
||||||
* - buttonColor: color of the rectangle
|
* - buttonColor: color of the rectangle
|
||||||
|
* - shadow: draws a black shadow with N pixels size if != 0
|
||||||
* - active: pass pointer to variable which holds the state 'active' or 'inactive'
|
* - active: pass pointer to variable which holds the state 'active' or 'inactive'
|
||||||
* - state: pass pointer to variable whcih will keep the state of the button (pressed / unpressed)'
|
* - state: pass pointer to variable whcih will keep the state of the button (pressed / unpressed)'
|
||||||
*
|
*
|
||||||
* return: 1 if button successfully created
|
* return: 1 if button successfully created
|
||||||
*/
|
*/
|
||||||
uint8_t guiDrawButton(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, char *str, uint16_t fontColor, uint16_t buttonColor, char *label, uint8_t *active, uint8_t *state);
|
uint8_t guiDrawButton(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, char *str, uint16_t fontColor, uint16_t buttonColor, uint16_t shadow, char *label, uint8_t *active, uint8_t *state);
|
||||||
|
|
||||||
uint8_t guiDrawSlider(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint8_t orientation, uint16_t frameColor, uint16_t bkColor, uint16_t valueColor, char *label, uint8_t *active, uint8_t *value);
|
uint8_t guiDrawSlider(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint8_t orientation, uint16_t frameColor, uint16_t bkColor, uint16_t valueColor, char *label, uint8_t *active, uint8_t *value);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue