New style system introduced! Still not applied to apps
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
#include "lv_draw_rbasic.h"
|
||||
#include "lv_draw_vbasic.h"
|
||||
#include "misc/fs/ufs/ufs.h"
|
||||
#include "../lv_objx/lv_img.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
@@ -42,10 +43,10 @@ typedef enum
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
#if USE_LV_RECT != 0
|
||||
static void lv_draw_rect_main_mid(const area_t * cords_p, const area_t * mask_p, const lv_rects_t * rects_p);
|
||||
static void lv_draw_rect_main_corner(const area_t * cords_p, const area_t * mask_p, const lv_rects_t * rects_p);
|
||||
static void lv_draw_rect_border_straight(const area_t * cords_p, const area_t * mask_p, const lv_rects_t * rects_p);
|
||||
static void lv_draw_rect_border_corner(const area_t * cords_p, const area_t * mask_p, const lv_rects_t * rects_p);
|
||||
static void lv_draw_rect_main_mid(const area_t * cords_p, const area_t * mask_p, const lv_style_t * style);
|
||||
static void lv_draw_rect_main_corner(const area_t * cords_p, const area_t * mask_p, const lv_style_t * style_p);
|
||||
static void lv_draw_rect_border_straight(const area_t * cords_p, const area_t * mask_p, const lv_style_t * style_p);
|
||||
static void lv_draw_rect_border_corner(const area_t * cords_p, const area_t * mask_p, const lv_style_t * style);
|
||||
static uint16_t lv_draw_rect_radius_corr(uint16_t r, cord_t w, cord_t h);
|
||||
#endif /*USE_LV_RECT != 0*/
|
||||
|
||||
@@ -68,20 +69,6 @@ static void (*map_fp)(const area_t * cords_p, const area_t * mask_p, const color
|
||||
#endif
|
||||
|
||||
|
||||
#if USE_LV_IMG != 0 && USE_FSINT != 0 && USE_UFS != 0
|
||||
static lv_rects_t lv_img_no_pic_rects = {
|
||||
.base.color = COLOR_BLACK, .gcolor = COLOR_BLACK,
|
||||
.bcolor = COLOR_RED, .bwidth = 2 * LV_DOWNSCALE, .bopa = 100,
|
||||
.radius = 0, .empty = 0
|
||||
};
|
||||
|
||||
static lv_labels_t lv_img_no_pic_labels = {
|
||||
.base.color = COLOR_WHITE,
|
||||
.letter_space = 1 * LV_DOWNSCALE, .line_space = 1 * LV_DOWNSCALE,
|
||||
.mid = 1,
|
||||
};
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
@@ -95,25 +82,25 @@ static lv_labels_t lv_img_no_pic_labels = {
|
||||
* Draw a rectangle
|
||||
* @param cords_p the coordinates of the rectangle
|
||||
* @param mask_p the rectangle will be drawn only in this mask
|
||||
* @param rects_p pointer to a rectangle style
|
||||
* @param style_p pointer to a style
|
||||
*/
|
||||
void lv_draw_rect(const area_t * cords_p, const area_t * mask_p, const lv_rects_t * rects_p)
|
||||
void lv_draw_rect(const area_t * cords_p, const area_t * mask_p, const lv_style_t * style_p)
|
||||
{
|
||||
if(area_get_height(cords_p) < 1 || area_get_width(cords_p) < 1) return;
|
||||
|
||||
if(rects_p->empty == 0){
|
||||
lv_draw_rect_main_mid(cords_p, mask_p, rects_p);
|
||||
if(style_p->empty == 0){
|
||||
lv_draw_rect_main_mid(cords_p, mask_p, style_p);
|
||||
|
||||
if(rects_p->radius != 0) {
|
||||
lv_draw_rect_main_corner(cords_p, mask_p, rects_p);
|
||||
if(style_p->radius != 0) {
|
||||
lv_draw_rect_main_corner(cords_p, mask_p, style_p);
|
||||
}
|
||||
}
|
||||
|
||||
if(rects_p->bwidth != 0) {
|
||||
lv_draw_rect_border_straight(cords_p, mask_p, rects_p);
|
||||
if(style_p->bwidth != 0) {
|
||||
lv_draw_rect_border_straight(cords_p, mask_p, style_p);
|
||||
|
||||
if(rects_p->radius != 0) {
|
||||
lv_draw_rect_border_corner(cords_p, mask_p, rects_p);
|
||||
if(style_p->radius != 0) {
|
||||
lv_draw_rect_border_corner(cords_p, mask_p, style_p);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -233,11 +220,11 @@ void lv_draw_triangle(const point_t * points, const area_t * mask_p, color_t col
|
||||
* Write a text
|
||||
* @param cords_p coordinates of the label
|
||||
* @param mask_p the label will be drawn only in this area
|
||||
* @param labels_p pointer to a label style
|
||||
* @param style pointer to a style
|
||||
* @param txt 0 terminated text to write
|
||||
* @param flag settings for the text from 'txt_flag_t' enum
|
||||
*/
|
||||
void lv_draw_label(const area_t * cords_p,const area_t * mask_p, const lv_labels_t * style,
|
||||
void lv_draw_label(const area_t * cords_p,const area_t * mask_p, const lv_style_t * style,
|
||||
const char * txt, txt_flag_t flag)
|
||||
{
|
||||
const font_t * font = style->font;
|
||||
@@ -254,7 +241,7 @@ void lv_draw_label(const area_t * cords_p,const area_t * mask_p, const lv_labels
|
||||
pos.y = cords_p->y1;
|
||||
|
||||
/*Align the line to middle if enabled*/
|
||||
if(style->mid != 0) {
|
||||
if(style->txt_align != 0) {
|
||||
line_length = txt_get_width(&txt[line_start], line_end - line_start,
|
||||
font, style->letter_space, flag);
|
||||
pos.x += (w - line_length) / 2;
|
||||
@@ -298,7 +285,7 @@ void lv_draw_label(const area_t * cords_p,const area_t * mask_p, const lv_labels
|
||||
sscanf(buf, "%02x%02x%02x", &r, &g, &b);
|
||||
recolor = COLOR_MAKE(r, g, b);
|
||||
} else {
|
||||
recolor.full = style->base.color.full;
|
||||
recolor.full = style->ccolor.full;
|
||||
}
|
||||
cmd_state = CMD_STATE_IN; /*After the parameter the text is in the command*/
|
||||
}
|
||||
@@ -306,8 +293,8 @@ void lv_draw_label(const area_t * cords_p,const area_t * mask_p, const lv_labels
|
||||
}
|
||||
}
|
||||
|
||||
if(cmd_state == CMD_STATE_IN) letter_fp(&pos, mask_p, font, txt[i], recolor, style->base.opa);
|
||||
else letter_fp(&pos, mask_p, font, txt[i], style->base.color, style->base.opa);
|
||||
if(cmd_state == CMD_STATE_IN) letter_fp(&pos, mask_p, font, txt[i], recolor, style->opa);
|
||||
else letter_fp(&pos, mask_p, font, txt[i], style->ccolor, style->opa);
|
||||
pos.x += (font_get_width(font, txt[i]) >> LV_FONT_ANTIALIAS) + style->letter_space;
|
||||
}
|
||||
/*Go to next line*/
|
||||
@@ -316,7 +303,7 @@ void lv_draw_label(const area_t * cords_p,const area_t * mask_p, const lv_labels
|
||||
|
||||
pos.x = cords_p->x1;
|
||||
/*Align to middle*/
|
||||
if(style->mid != 0) {
|
||||
if(style->txt_align != 0) {
|
||||
line_length = txt_get_width(&txt[line_start], line_end - line_start,
|
||||
font, style->letter_space, flag);
|
||||
pos.x += (w - line_length) / 2;
|
||||
@@ -338,12 +325,11 @@ void lv_draw_label(const area_t * cords_p,const area_t * mask_p, const lv_labels
|
||||
* @param opa opacity of the image (0..255)
|
||||
*/
|
||||
void lv_draw_img(const area_t * cords_p, const area_t * mask_p,
|
||||
const lv_imgs_t * style, const char * fn)
|
||||
const lv_style_t * style, const char * fn)
|
||||
{
|
||||
if(fn == NULL) {
|
||||
lv_draw_rect(cords_p, mask_p, &lv_img_no_pic_rects);
|
||||
if(lv_img_no_pic_labels.font == NULL) lv_img_no_pic_labels.font = font_get(LV_FONT_DEFAULT);
|
||||
lv_draw_label(cords_p, mask_p,&lv_img_no_pic_labels, "No data", TXT_FLAG_NONE);
|
||||
lv_draw_rect(cords_p, mask_p, lv_style_get(LV_STYLE_PLAIN, NULL));
|
||||
lv_draw_label(cords_p, mask_p, lv_style_get(LV_STYLE_PLAIN, NULL), "No data", TXT_FLAG_NONE);
|
||||
} else {
|
||||
fs_file_t file;
|
||||
fs_res_t res = fs_open(&file, fn, FS_MODE_RD);
|
||||
@@ -412,15 +398,15 @@ void lv_draw_img(const area_t * cords_p, const area_t * mask_p,
|
||||
uint8_t * f_data = ((ufs_file_t*)file.file_d)->ent->data_d;
|
||||
f_data += ((ufs_file_t*)file.file_d)->rwp;
|
||||
((ufs_file_t*)file.file_d)->rwp += useful_data;
|
||||
map_fp(&act_area, &mask_sub, (void*)f_data , style->base.opa, header.transp, upscale,
|
||||
style->base.color, style->recolor_opa);
|
||||
map_fp(&act_area, &mask_sub, (void*)f_data , style->opa, header.transp, upscale,
|
||||
style->ccolor, style->img_recolor);
|
||||
}
|
||||
/*Or read the NOT const files normally*/
|
||||
else {
|
||||
color_t buf[LV_HOR_RES];
|
||||
res = fs_read(&file, buf, useful_data, &br);
|
||||
map_fp(&act_area, &mask_sub, buf, style->base.opa, header.transp, upscale,
|
||||
style->base.color, style->recolor_opa);
|
||||
map_fp(&act_area, &mask_sub, buf, style->opa, header.transp, upscale,
|
||||
style->ccolor, style->img_recolor);
|
||||
}
|
||||
|
||||
fs_tell(&file, &act_pos);
|
||||
@@ -433,9 +419,8 @@ void lv_draw_img(const area_t * cords_p, const area_t * mask_p,
|
||||
fs_close(&file);
|
||||
|
||||
if(res != FS_RES_OK) {
|
||||
lv_draw_rect(cords_p, mask_p, &lv_img_no_pic_rects);
|
||||
if(lv_img_no_pic_labels.font == NULL) lv_img_no_pic_labels.font = font_get(LV_FONT_DEFAULT);
|
||||
lv_draw_label(cords_p, mask_p,&lv_img_no_pic_labels, fn, TXT_FLAG_NONE);
|
||||
lv_draw_rect(cords_p, mask_p, lv_style_get(LV_STYLE_PLAIN, NULL));
|
||||
lv_draw_label(cords_p, mask_p, lv_style_get(LV_STYLE_PLAIN, NULL), "No data", TXT_FLAG_NONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -452,9 +437,9 @@ void lv_draw_img(const area_t * cords_p, const area_t * mask_p,
|
||||
* @param lines_p pointer to a line style
|
||||
*/
|
||||
void lv_draw_line(const point_t * p1, const point_t * p2, const area_t * mask_p,
|
||||
const lv_lines_t * style)
|
||||
const lv_style_t * style)
|
||||
{
|
||||
if(style->width == 0) return;
|
||||
if(style->line_width == 0) return;
|
||||
|
||||
if(p1->x == p2->x && p1->y == p2->y) return;
|
||||
|
||||
@@ -490,7 +475,7 @@ void lv_draw_line(const point_t * p1, const point_t * p2, const area_t * mask_p,
|
||||
}
|
||||
|
||||
/*Make the correction on lie width*/
|
||||
width = ((style->width - 1) * width_corr_array[wcor]) >> LINE_WIDTH_CORR_SHIFT;
|
||||
width = ((style->line_width - 1) * width_corr_array[wcor]) >> LINE_WIDTH_CORR_SHIFT;
|
||||
width_half = width >> 1;
|
||||
width_1 = width & 0x1 ? 1 : 0;
|
||||
|
||||
@@ -509,7 +494,7 @@ void lv_draw_line(const point_t * p1, const point_t * p2, const area_t * mask_p,
|
||||
draw_area.x2 = MATH_MAX(act_area.x1, act_area.x2);
|
||||
draw_area.y1 = MATH_MIN(act_area.y1, act_area.y2);
|
||||
draw_area.y2 = MATH_MAX(act_area.y1, act_area.y2);
|
||||
fill_fp(&draw_area, mask_p, style->base.color, style->base.opa);
|
||||
fill_fp(&draw_area, mask_p, style->ccolor, style->opa);
|
||||
}
|
||||
if (hor == false && last_x != act_point.x) {
|
||||
area_t act_area;
|
||||
@@ -525,7 +510,7 @@ void lv_draw_line(const point_t * p1, const point_t * p2, const area_t * mask_p,
|
||||
draw_area.x2 = MATH_MAX(act_area.x1, act_area.x2);
|
||||
draw_area.y1 = MATH_MIN(act_area.y1, act_area.y2);
|
||||
draw_area.y2 = MATH_MAX(act_area.y1, act_area.y2);
|
||||
fill_fp(&draw_area, mask_p, style->base.color, style->base.opa);
|
||||
fill_fp(&draw_area, mask_p, style->ccolor, style->opa);
|
||||
}
|
||||
|
||||
/*Calc. the next point of the line*/
|
||||
@@ -553,7 +538,7 @@ void lv_draw_line(const point_t * p1, const point_t * p2, const area_t * mask_p,
|
||||
draw_area.x2 = MATH_MAX(act_area.x1, act_area.x2);
|
||||
draw_area.y1 = MATH_MIN(act_area.y1, act_area.y2);
|
||||
draw_area.y2 = MATH_MAX(act_area.y1, act_area.y2);
|
||||
fill_fp(&draw_area, mask_p, style->base.color, style->base.opa);
|
||||
fill_fp(&draw_area, mask_p, style->ccolor, style->opa);
|
||||
}
|
||||
if (hor == false) {
|
||||
area_t act_area;
|
||||
@@ -567,7 +552,7 @@ void lv_draw_line(const point_t * p1, const point_t * p2, const area_t * mask_p,
|
||||
draw_area.x2 = MATH_MAX(act_area.x1, act_area.x2);
|
||||
draw_area.y1 = MATH_MIN(act_area.y1, act_area.y2);
|
||||
draw_area.y2 = MATH_MAX(act_area.y1, act_area.y2);
|
||||
fill_fp(&draw_area, mask_p, style->base.color, style->base.opa);
|
||||
fill_fp(&draw_area, mask_p, style->ccolor, style->opa);
|
||||
}
|
||||
}
|
||||
#endif /*USE_LV_LINE != 0*/
|
||||
@@ -583,14 +568,14 @@ void lv_draw_line(const point_t * p1, const point_t * p2, const area_t * mask_p,
|
||||
* @param mask_p the rectangle will be drawn only on this area
|
||||
* @param rects_p pointer to a rectangle style
|
||||
*/
|
||||
static void lv_draw_rect_main_mid(const area_t * cords_p, const area_t * mask_p, const lv_rects_t * rects_p)
|
||||
static void lv_draw_rect_main_mid(const area_t * cords_p, const area_t * mask_p, const lv_style_t * style)
|
||||
{
|
||||
uint16_t radius = rects_p->radius;
|
||||
uint16_t radius = style->radius;
|
||||
|
||||
color_t mcolor = rects_p->base.color;
|
||||
color_t gcolor = rects_p->gcolor;
|
||||
color_t mcolor = style->mcolor;
|
||||
color_t gcolor = style->gcolor;
|
||||
uint8_t mix;
|
||||
opa_t opa = rects_p->base.opa;
|
||||
opa_t opa = style->opa;
|
||||
cord_t height = area_get_height(cords_p);
|
||||
cord_t width = area_get_width(cords_p);
|
||||
|
||||
@@ -633,14 +618,14 @@ static void lv_draw_rect_main_mid(const area_t * cords_p, const area_t * mask_p,
|
||||
* @param mask_p the rectangle will be drawn only on this area
|
||||
* @param rects_p pointer to a rectangle style
|
||||
*/
|
||||
static void lv_draw_rect_main_corner(const area_t * cords_p, const area_t * mask_p, const lv_rects_t * rects_p)
|
||||
static void lv_draw_rect_main_corner(const area_t * cords_p, const area_t * mask_p, const lv_style_t * style_p)
|
||||
{
|
||||
uint16_t radius = rects_p->radius;
|
||||
uint16_t radius = style_p->radius;
|
||||
|
||||
color_t mcolor = rects_p->base.color;
|
||||
color_t gcolor = rects_p->gcolor;
|
||||
color_t mcolor = style_p->mcolor;
|
||||
color_t gcolor = style_p->gcolor;
|
||||
color_t act_color;
|
||||
opa_t opa = rects_p->base.opa;
|
||||
opa_t opa = style_p->opa;
|
||||
uint8_t mix;
|
||||
cord_t height = area_get_height(cords_p);
|
||||
cord_t width = area_get_width(cords_p);
|
||||
@@ -804,14 +789,14 @@ if(edge_top_area.y1 != mid_top_area.y1) {
|
||||
* @param mask_p the rectangle will be drawn only on this area
|
||||
* @param rects_p pointer to a rectangle style
|
||||
*/
|
||||
static void lv_draw_rect_border_straight(const area_t * cords_p, const area_t * mask_p, const lv_rects_t * rects_p)
|
||||
static void lv_draw_rect_border_straight(const area_t * cords_p, const area_t * mask_p, const lv_style_t * style_p)
|
||||
{
|
||||
uint16_t radius = rects_p->radius;
|
||||
uint16_t radius = style_p->radius;
|
||||
|
||||
cord_t width = area_get_width(cords_p);
|
||||
cord_t height = area_get_height(cords_p);
|
||||
uint16_t bwidth = rects_p->bwidth;
|
||||
opa_t bopa = (uint16_t)((uint16_t) rects_p->base.opa * rects_p->bopa) >> 8;
|
||||
uint16_t bwidth = style_p->bwidth;
|
||||
opa_t bopa = (uint16_t)((uint16_t) style_p->opa * style_p->bopa) >> 8;
|
||||
area_t work_area;
|
||||
cord_t length_corr = 0;
|
||||
cord_t corner_size = 0;
|
||||
@@ -831,7 +816,7 @@ static void lv_draw_rect_border_straight(const area_t * cords_p, const area_t *
|
||||
/* Modify the corner_size if corner is drawn */
|
||||
corner_size ++;
|
||||
|
||||
color_t b_color = rects_p->bcolor;
|
||||
color_t b_color = style_p->bcolor;
|
||||
|
||||
/*Left border*/
|
||||
work_area.x1 = cords_p->x1;
|
||||
@@ -920,12 +905,12 @@ static void lv_draw_rect_border_straight(const area_t * cords_p, const area_t *
|
||||
* @param rects_p pointer to a rectangle style
|
||||
* @param opa opacity of the rectangle (0..255)
|
||||
*/
|
||||
static void lv_draw_rect_border_corner(const area_t * cords_p, const area_t * mask_p, const lv_rects_t * rects_p)
|
||||
static void lv_draw_rect_border_corner(const area_t * cords_p, const area_t * mask_p, const lv_style_t * style)
|
||||
{
|
||||
uint16_t radius = rects_p->radius;
|
||||
uint16_t bwidth = rects_p->bwidth;
|
||||
color_t bcolor = rects_p->bcolor;
|
||||
opa_t bopa = (uint16_t)((uint16_t) rects_p->base.opa * rects_p->bopa ) >> 8;
|
||||
uint16_t radius = style->radius;
|
||||
uint16_t bwidth = style->bwidth;
|
||||
color_t bcolor = style->bcolor;
|
||||
opa_t bopa = (uint16_t)((uint16_t) style->opa * style->bopa ) >> 8;
|
||||
|
||||
/*0 px border width drawn as 1 px, so decrement the bwidth*/
|
||||
bwidth--;
|
||||
|
||||
@@ -9,14 +9,9 @@
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../lv_objx/lv_btn.h"
|
||||
#include "../lv_objx/lv_rect.h"
|
||||
#include "../lv_objx/lv_line.h"
|
||||
#include "../lv_objx/lv_img.h"
|
||||
#include "../lv_objx/lv_label.h"
|
||||
|
||||
#include "misc_conf.h"
|
||||
#include "../lv_misc/text.h"
|
||||
#include "../lv_obj/lv_style.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
@@ -34,10 +29,10 @@
|
||||
* Draw a rectangle
|
||||
* @param cords_p the coordinates of the rectangle
|
||||
* @param mask_p the rectangle will be drawn only in this mask
|
||||
* @param rects_p pointer to a rectangle style
|
||||
* @param style_p pointer to a style
|
||||
*/
|
||||
#if USE_LV_RECT != 0
|
||||
void lv_draw_rect(const area_t * cords_p, const area_t * mask_p, const lv_rects_t * rects_p);
|
||||
void lv_draw_rect(const area_t * cords_p, const area_t * mask_p, const lv_style_t * style_p);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -57,12 +52,12 @@ void lv_draw_triangle(const point_t * points, const area_t * mask_p, color_t col
|
||||
* Write a text
|
||||
* @param cords_p coordinates of the label
|
||||
* @param mask_p the label will be drawn only in this area
|
||||
* @param labels_p pointer to a label style
|
||||
* @param style_p pointer to a style
|
||||
* @param txt 0 terminated text to write
|
||||
* @param flags settings for the text from 'txt_flag_t' enum
|
||||
*/
|
||||
#if USE_LV_LABEL != 0
|
||||
void lv_draw_label(const area_t * cords_p,const area_t * mask_p, const lv_labels_t * style,
|
||||
void lv_draw_label(const area_t * cords_p,const area_t * mask_p, const lv_style_t * style_p,
|
||||
const char * txt, txt_flag_t flag);
|
||||
#endif
|
||||
|
||||
@@ -74,7 +69,7 @@ void lv_draw_label(const area_t * cords_p,const area_t * mask_p, const lv_labels
|
||||
*/
|
||||
#if USE_LV_IMG != 0 && USE_FSINT != 0 && USE_UFS != 0
|
||||
void lv_draw_img(const area_t * cords_p, const area_t * mask_p,
|
||||
const lv_imgs_t * imgs_p, const char * fn);
|
||||
const lv_style_t * style_p, const char * fn);
|
||||
#endif
|
||||
|
||||
/**
|
||||
@@ -82,11 +77,11 @@ void lv_draw_img(const area_t * cords_p, const area_t * mask_p,
|
||||
* @param p1 first point of the line
|
||||
* @param p2 second point of the line
|
||||
* @param mask_pthe line will be drawn only on this area
|
||||
* @param lines_p pointer to a line style
|
||||
* @param style_p pointer to a style
|
||||
*/
|
||||
#if USE_LV_LINE != 0
|
||||
void lv_draw_line(const point_t * p1, const point_t * p2, const area_t * mask_p,
|
||||
const lv_lines_t * lines_p);
|
||||
const lv_style_t * style_p);
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
|
||||
Reference in New Issue
Block a user