Draw images as blue roundrects; Add labels to non-imagery widgets, if they are set
This commit is contained in:
@ -4,6 +4,8 @@
|
||||
#include "mgos.h"
|
||||
#include "mgos_pwm.h"
|
||||
#include "mongoose-touch.h"
|
||||
#include "fonts/FreeSerifBold9pt7b.h"
|
||||
#include "fonts/FreeMonoBold9pt7b.h"
|
||||
|
||||
struct screen_t *screen = NULL;
|
||||
|
||||
|
@ -1,18 +1,37 @@
|
||||
#include "mgos.h"
|
||||
#include "mongoose-touch.h"
|
||||
|
||||
extern GFXfont FreeSerifBold9pt7b;
|
||||
|
||||
static void widget_default_draw(struct widget_t *w, uint16_t color) {
|
||||
if (!w)
|
||||
return;
|
||||
mgos_ili9341_set_window(w->x, w->y, w->x+w->w-1, w->y+w->h-1);
|
||||
|
||||
mgos_ili9341_set_fgcolor565(color);
|
||||
mgos_ili9341_drawRoundRect(0, 0, w->w, w->h, 8);
|
||||
|
||||
/*
|
||||
if (w->img)
|
||||
mgos_ili9341_png(0, 0, w->img);
|
||||
*/
|
||||
if (w->img) {
|
||||
mgos_ili9341_set_fgcolor565(ILI9341_BLUE);
|
||||
mgos_ili9341_drawRoundRect(0, 0, w->w, w->h, 16);
|
||||
} else if (w->label) {
|
||||
int16_t text_width, text_height;
|
||||
uint16_t x, y;
|
||||
|
||||
mgos_ili9341_drawRoundRect(0, 0, w->w, w->h, 8);
|
||||
mgos_ili9341_set_font(&FreeSerifBold9pt7b);
|
||||
text_width=mgos_ili9341_getStringWidth(w->label);
|
||||
text_height=mgos_ili9341_getStringHeight(w->label);
|
||||
if (text_width>w->w)
|
||||
x=0;
|
||||
else
|
||||
x=(w->w-text_width)/2;
|
||||
if (text_height>w->h)
|
||||
y=0;
|
||||
else
|
||||
y=(w->h-text_height)/2;
|
||||
mgos_ili9341_print(x, y, w->label);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void widget_default_ev(int ev, struct widget_t *w, void *ev_data) {
|
||||
|
@ -3,7 +3,6 @@
|
||||
#include "mgos_wifi.h"
|
||||
#include "mgos_net.h"
|
||||
#include "mongoose-touch.h"
|
||||
#include "fonts/FreeMonoBold9pt7b.h"
|
||||
|
||||
#define WIDGET_NAME_NAME 0
|
||||
#define WIDGET_NAME_IPADDR 1
|
||||
@ -13,6 +12,7 @@
|
||||
|
||||
static uint8_t what = WIDGET_NAME_NAME;
|
||||
extern struct screen_t *screen;
|
||||
extern GFXfont FreeMonoBold9pt7b;
|
||||
|
||||
static void widget_name_render(struct widget_t *w, void *ev_data) {
|
||||
char namestring[21];
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include "mgos.h"
|
||||
#include "mongoose-touch.h"
|
||||
#include "fonts/FreeSerifBold9pt7b.h"
|
||||
|
||||
extern GFXfont FreeSerifBold9pt7b;
|
||||
|
||||
static void widget_time_render(struct widget_t *w, void *ev_data) {
|
||||
char tmp_buff[32];
|
||||
|
Reference in New Issue
Block a user