LV_FONT_ANTIALIAS added
This commit is contained in:
@@ -21,7 +21,6 @@
|
||||
#include "../lv_appx/lv_app_sysmon.h"
|
||||
#include "../lv_appx/lv_app_terminal.h"
|
||||
#include "../lv_appx/lv_app_files.h"
|
||||
#include "../lv_appx/lv_app_visual.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
|
||||
@@ -311,7 +311,7 @@ void lv_draw_label(const area_t * cords_p,const area_t * mask_p,
|
||||
|
||||
if(cmd_state == CMD_STATE_IN) letter_fp(&pos, mask_p, font_p, txt[i], recolor, opa);
|
||||
else letter_fp(&pos, mask_p, font_p, txt[i], style->objs.color, opa);
|
||||
pos.x += font_get_width(font_p, txt[i]) + style->letter_space;
|
||||
pos.x += (font_get_width(font_p, txt[i]) >> LV_FONT_ANTIALIAS) + style->letter_space;
|
||||
}
|
||||
/*Go to next line*/
|
||||
line_start = line_end;
|
||||
@@ -325,7 +325,7 @@ void lv_draw_label(const area_t * cords_p,const area_t * mask_p,
|
||||
pos.x += (w - line_length) / 2;
|
||||
}
|
||||
/*Go the next line position*/
|
||||
pos.y += font_get_height(font_p);
|
||||
pos.y += font_get_height(font_p) >> LV_FONT_ANTIALIAS;
|
||||
pos.y += style->line_space;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,15 @@
|
||||
* @file lv_vdraw.c
|
||||
*
|
||||
*/
|
||||
#include "lv_conf.h"
|
||||
|
||||
#include <lv_conf.h>
|
||||
#include <lvgl/lv_misc/area.h>
|
||||
#include <lvgl/lv_misc/font.h>
|
||||
#include <misc/others/color.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#if LV_VDB_SIZE != 0
|
||||
|
||||
#include <stddef.h>
|
||||
@@ -140,10 +148,12 @@ void lv_vletter(const point_t * pos_p, const area_t * mask_p,
|
||||
uint8_t col_bit;
|
||||
uint8_t col_byte_cnt;
|
||||
|
||||
/* Calculate the col/row start/end on the map
|
||||
* If font anti alaiassing is enabled use the reduced letter sizes*/
|
||||
cord_t col_start = pos_p->x > mask_p->x1 ? 0 : mask_p->x1 - pos_p->x;
|
||||
cord_t col_end = pos_p->x + letter_w < mask_p->x2 ? letter_w : mask_p->x2 - pos_p->x + 1;
|
||||
cord_t col_end = pos_p->x + (letter_w >> LV_FONT_ANTIALIAS) < mask_p->x2 ? (letter_w >> LV_FONT_ANTIALIAS) : mask_p->x2 - pos_p->x + 1;
|
||||
cord_t row_start = pos_p->y > mask_p->y1 ? 0 : mask_p->y1 - pos_p->y;
|
||||
cord_t row_end = pos_p->y + letter_h < mask_p->y2 ? letter_h : mask_p->y2 - pos_p->y + 1;
|
||||
cord_t row_end = pos_p->y + (letter_h >> LV_FONT_ANTIALIAS) < mask_p->y2 ? (letter_h >> LV_FONT_ANTIALIAS) : mask_p->y2 - pos_p->y + 1;
|
||||
|
||||
/*Set a pointer on VDB to the first pixel of the letter*/
|
||||
vdb_buf_tmp += ((pos_p->y - vdb_p->vdb_area.y1) * vdb_width)
|
||||
@@ -153,8 +163,53 @@ void lv_vletter(const point_t * pos_p, const area_t * mask_p,
|
||||
vdb_buf_tmp += (row_start * vdb_width) + col_start;
|
||||
|
||||
/*Move on the map too*/
|
||||
map_p += (row_start * font_p->width_byte) + (col_start>>3);
|
||||
map_p += ((row_start << LV_FONT_ANTIALIAS) * font_p->width_byte) + ((col_start << LV_FONT_ANTIALIAS) >> 3);
|
||||
|
||||
#if LV_FONT_ANTIALIAS != 0
|
||||
const uint8_t * map1_p = map_p;
|
||||
const uint8_t * map2_p = map_p + font_p->width_byte;
|
||||
uint8_t px_cnt;
|
||||
for(row = row_start; row < row_end; row ++) {
|
||||
col_byte_cnt = 0;
|
||||
col_bit = 7 - ((col_start << LV_FONT_ANTIALIAS) % 8);
|
||||
for(col = col_start; col < col_end; col ++) {
|
||||
|
||||
px_cnt = 0;
|
||||
if((*map1_p & (1 << col_bit)) != 0) px_cnt++;
|
||||
if((*map2_p & (1 << col_bit)) != 0) px_cnt++;
|
||||
if(col_bit != 0) col_bit --;
|
||||
else {
|
||||
col_bit = 7;
|
||||
col_byte_cnt ++;
|
||||
map1_p ++;
|
||||
map2_p ++;
|
||||
}
|
||||
if((*map1_p & (1 << col_bit)) != 0) px_cnt++;
|
||||
if((*map2_p & (1 << col_bit)) != 0) px_cnt++;
|
||||
if(col_bit != 0) col_bit --;
|
||||
else {
|
||||
col_bit = 7;
|
||||
col_byte_cnt ++;
|
||||
map1_p ++;
|
||||
map2_p ++;
|
||||
}
|
||||
|
||||
|
||||
if(px_cnt != 0) {
|
||||
if(opa == OPA_COVER) *vdb_buf_tmp = color_mix(color, *vdb_buf_tmp, 63*px_cnt);
|
||||
else *vdb_buf_tmp = color_mix(color, *vdb_buf_tmp, opa);
|
||||
}
|
||||
|
||||
vdb_buf_tmp++;
|
||||
}
|
||||
|
||||
map1_p += font_p->width_byte;
|
||||
map2_p += font_p->width_byte;
|
||||
map1_p += font_p->width_byte - col_byte_cnt;
|
||||
map2_p += font_p->width_byte - col_byte_cnt;
|
||||
vdb_buf_tmp += vdb_width - ((col_end) - (col_start)); /*Next row in VDB*/
|
||||
}
|
||||
#else
|
||||
for(row = row_start; row < row_end; row ++) {
|
||||
col_byte_cnt = 0;
|
||||
col_bit = 7 - (col_start % 8);
|
||||
@@ -164,9 +219,9 @@ void lv_vletter(const point_t * pos_p, const area_t * mask_p,
|
||||
if(opa == OPA_COVER) *vdb_buf_tmp = color;
|
||||
else *vdb_buf_tmp = color_mix(color, *vdb_buf_tmp, opa);
|
||||
}
|
||||
vdb_buf_tmp++;
|
||||
|
||||
/*Use a col. more times depending on LV_UPSCALE_FONT*/
|
||||
vdb_buf_tmp++;
|
||||
|
||||
if(col_bit != 0) col_bit --;
|
||||
else {
|
||||
col_bit = 7;
|
||||
@@ -178,6 +233,7 @@ void lv_vletter(const point_t * pos_p, const area_t * mask_p,
|
||||
map_p += font_p->width_byte - col_byte_cnt;
|
||||
vdb_buf_tmp += vdb_width - (col_end - col_start); /*Next row in VDB*/
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -57,13 +57,13 @@ void txt_get_size(point_t * size_res, const char * text, const font_t * font,
|
||||
uint32_t line_start = 0;
|
||||
uint32_t new_line_start = 0;
|
||||
cord_t act_line_length;
|
||||
uint8_t letter_height = font_get_height(font);
|
||||
uint8_t letter_height = font_get_height(font) >> LV_FONT_ANTIALIAS;
|
||||
|
||||
/*Calc. the height and longest line*/
|
||||
while (text[line_start] != '\0')
|
||||
{
|
||||
new_line_start += txt_get_next_line(&text[line_start], font, letter_space, max_width, flag);
|
||||
size_res->y += letter_height;
|
||||
size_res->y += letter_height ;
|
||||
size_res->y += line_space;
|
||||
|
||||
/*Calculate the the longest line*/
|
||||
@@ -125,7 +125,7 @@ uint16_t txt_get_next_line(const char * txt, const font_t * font,
|
||||
return i+1; /*Return with the first letter of the next line*/
|
||||
|
||||
} else { /*Check the actual length*/
|
||||
act_l += font_get_width(font, txt[i]);
|
||||
act_l += font_get_width(font, txt[i]) >> LV_FONT_ANTIALIAS;
|
||||
|
||||
/*If the txt is too long then finish, this is the line end*/
|
||||
if(act_l > max_l) {
|
||||
@@ -183,14 +183,14 @@ cord_t txt_get_width(const char * txt, uint16_t char_num,
|
||||
continue;
|
||||
}
|
||||
}
|
||||
len += font_get_width(font, txt[i]);
|
||||
len += font_get_width(font, txt[i]) >> LV_FONT_ANTIALIAS;
|
||||
len += letter_space;
|
||||
}
|
||||
|
||||
/*Trim closing spaces */
|
||||
for(i = char_num - 1; i > 0; i--) {
|
||||
if(txt[i] == ' ') {
|
||||
len -= font_get_width(font, txt[i]);
|
||||
len -= font_get_width(font, txt[i]) >> LV_FONT_ANTIALIAS;
|
||||
len -= letter_space;
|
||||
} else {
|
||||
break;
|
||||
|
||||
@@ -311,12 +311,13 @@ static bool lv_ddlist_design(lv_obj_t * ddlist, const area_t * mask, lv_design_m
|
||||
if(ext->opened != 0) {
|
||||
lv_ddlists_t * style = lv_obj_get_style(ddlist);
|
||||
const font_t * font = font_get(style->list_labels.font);
|
||||
cord_t font_h = font_get_height(font) >> LV_FONT_ANTIALIAS;
|
||||
area_t rect_area;
|
||||
rect_area.y1 = ext->opt_label->cords.y1;
|
||||
rect_area.y1 += ext->sel_opt * (font_get_height(font) + style->list_labels.line_space);
|
||||
rect_area.y1 += ext->sel_opt * font_h + style->list_labels.line_space;
|
||||
rect_area.y1 -= style->sel_rects.vpad;
|
||||
|
||||
rect_area.y2 = rect_area.y1 + font_get_height(font) + 2 * style->sel_rects.vpad;
|
||||
rect_area.y2 = rect_area.y1 + font_h + 2 * style->sel_rects.vpad;
|
||||
rect_area.x1 = ext->opt_label->cords.x1 - style->pages.scrl_rects.hpad;
|
||||
rect_area.x2 = rect_area.x1 + lv_obj_get_width(lv_page_get_scrl(ddlist));
|
||||
|
||||
@@ -393,14 +394,14 @@ static void lv_ddlist_refr_size(lv_obj_t * ddlist, bool anim_en)
|
||||
if(ext->opened != 0) { /*Open the list*/
|
||||
new_height = lv_obj_get_height(lv_page_get_scrl(ddlist)) + 2 * style->pages.bg_rects.vpad;
|
||||
lv_obj_t * parent = lv_obj_get_parent(ddlist);
|
||||
/*Reduce the height is enabler and required*/
|
||||
/*Reduce the height if enabled and required*/
|
||||
if(ext->auto_size != 0 && new_height + ddlist->cords.y1 > parent->cords.y2) {
|
||||
new_height = parent->cords.y2 - ddlist->cords.y1;
|
||||
|
||||
}
|
||||
} else { /*Close the list*/
|
||||
const font_t * font = font_get(style->list_labels.font);
|
||||
new_height = font_get_height(font) + 2 * style->sel_rects.vpad;
|
||||
cord_t font_h = font_get_height(font) >> LV_FONT_ANTIALIAS;
|
||||
new_height = font_h + 2 * style->sel_rects.vpad;
|
||||
}
|
||||
if(anim_en == false) {
|
||||
lv_obj_set_height(ddlist, new_height);
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
*********************/
|
||||
#include "lv_conf.h"
|
||||
#if USE_LV_DDLIST != 0
|
||||
|
||||
#include "../lv_obj/lv_obj.h"
|
||||
#include "../lv_objx/lv_page.h"
|
||||
#include "../lv_objx/lv_label.h"
|
||||
|
||||
@@ -358,7 +358,7 @@ void lv_label_get_letter_pos(lv_obj_t * label, uint16_t index, point_t * pos)
|
||||
cord_t max_w = lv_obj_get_width(label);
|
||||
lv_labels_t * labels = lv_obj_get_style(label);
|
||||
const font_t * font = font_get(labels->font);
|
||||
uint8_t letter_height = font_get_height(font);
|
||||
uint8_t letter_height = font_get_height(font) >> LV_FONT_ANTIALIAS;
|
||||
cord_t y = 0;
|
||||
txt_flag_t flag = TXT_FLAG_NONE;
|
||||
|
||||
@@ -395,7 +395,7 @@ void lv_label_get_letter_pos(lv_obj_t * label, uint16_t index, point_t * pos)
|
||||
}
|
||||
}
|
||||
|
||||
x += font_get_width(font, text[i]) + labels->letter_space;
|
||||
x += (font_get_width(font, text[i]) >> LV_FONT_ANTIALIAS) + labels->letter_space;
|
||||
}
|
||||
|
||||
if(labels->mid != 0) {
|
||||
@@ -425,7 +425,7 @@ uint16_t lv_label_get_letter_on(lv_obj_t * label, point_t * pos)
|
||||
cord_t max_w = lv_obj_get_width(label);
|
||||
lv_labels_t * style = lv_obj_get_style(label);
|
||||
const font_t * font = font_get(style->font);
|
||||
uint8_t letter_height = font_get_height(font);
|
||||
uint8_t letter_height = font_get_height(font) >> LV_FONT_ANTIALIAS;
|
||||
cord_t y = 0;
|
||||
txt_flag_t flag = TXT_FLAG_NONE;
|
||||
|
||||
@@ -463,7 +463,7 @@ uint16_t lv_label_get_letter_on(lv_obj_t * label, point_t * pos)
|
||||
}
|
||||
}
|
||||
|
||||
x += font_get_width(font, text[i]) + style->letter_space;
|
||||
x += (font_get_width(font, text[i]) >> LV_FONT_ANTIALIAS) + style->letter_space;
|
||||
if(pos->x < x) break;
|
||||
}
|
||||
|
||||
@@ -595,7 +595,7 @@ static void lv_label_refr_text(lv_obj_t * label)
|
||||
anim.var = label;
|
||||
anim.repeat = 1;
|
||||
anim.playback = 1;
|
||||
anim.start = font_get_width(font, ' ');
|
||||
anim.start = font_get_width(font, ' ') >> LV_FONT_ANTIALIAS;
|
||||
anim.act_time = 0;
|
||||
anim.end_cb = NULL;
|
||||
anim.path = anim_get_path(ANIM_PATH_LIN);
|
||||
@@ -605,7 +605,8 @@ static void lv_label_refr_text(lv_obj_t * label)
|
||||
|
||||
bool hor_anim = false;
|
||||
if(lv_obj_get_width(label) > lv_obj_get_width(parent)) {
|
||||
anim.end = lv_obj_get_width(parent) - lv_obj_get_width(label) - font_get_width(font, ' ');
|
||||
anim.end = lv_obj_get_width(parent) - lv_obj_get_width(label) -
|
||||
(font_get_width(font, ' ') >> LV_FONT_ANTIALIAS);
|
||||
anim.fp = (anim_fp_t) lv_obj_set_x;
|
||||
anim.time = anim_speed_to_time(LV_LABEL_SCROLL_SPEED, anim.start, anim.end);
|
||||
anim_create(&anim);
|
||||
@@ -613,7 +614,8 @@ static void lv_label_refr_text(lv_obj_t * label)
|
||||
}
|
||||
|
||||
if(lv_obj_get_height(label) > lv_obj_get_height(parent)) {
|
||||
anim.end = lv_obj_get_height(parent) - lv_obj_get_height(label) - font_get_height(font);
|
||||
anim.end = lv_obj_get_height(parent) - lv_obj_get_height(label) -
|
||||
(font_get_height(font) - LV_FONT_ANTIALIAS);
|
||||
anim.fp = (anim_fp_t)lv_obj_set_y;
|
||||
|
||||
/*Different animation speed if horizontal animation is created too*/
|
||||
|
||||
@@ -326,9 +326,10 @@ void lv_ta_set_cursor_pos(lv_obj_t * ta, int16_t pos)
|
||||
}
|
||||
|
||||
/*Check the bottom*/
|
||||
if(label_cords.y1 + cur_pos.y + font_get_height(font_p) + style->pages.scrl_rects.vpad > ta_cords.y2) {
|
||||
cord_t font_h = font_get_height(font_p) >> LV_FONT_ANTIALIAS;
|
||||
if(label_cords.y1 + cur_pos.y + font_h + style->pages.scrl_rects.vpad > ta_cords.y2) {
|
||||
lv_obj_set_y(label_par, -(cur_pos.y - lv_obj_get_height(ta) +
|
||||
font_get_height(font_p) + 2 * style->pages.scrl_rects.vpad));
|
||||
font_h + 2 * style->pages.scrl_rects.vpad));
|
||||
}
|
||||
|
||||
lv_obj_inv(ta);
|
||||
@@ -380,7 +381,8 @@ void lv_ta_cursor_down(lv_obj_t * ta)
|
||||
/*Increment the y with one line and keep the valid x*/
|
||||
lv_labels_t * label_style = lv_obj_get_style(ext->label);
|
||||
const font_t * font_p = font_get(label_style->font);
|
||||
pos.y += font_get_height(font_p) + label_style->line_space + 1;
|
||||
cord_t font_h = font_get_height(font_p) >> LV_FONT_ANTIALIAS;
|
||||
pos.y += font_h + label_style->line_space + 1;
|
||||
pos.x = ext->cursor_valid_x;
|
||||
|
||||
/*Do not go below he last line*/
|
||||
@@ -406,7 +408,8 @@ void lv_ta_cursor_up(lv_obj_t * ta)
|
||||
/*Decrement the y with one line and keep the valid x*/
|
||||
lv_labels_t * label_style = lv_obj_get_style(ext->label);
|
||||
const font_t * font = font_get(label_style->font);
|
||||
pos.y -= font_get_height(font) + label_style->line_space - 1;
|
||||
cord_t font_h = font_get_height(font) >> LV_FONT_ANTIALIAS;
|
||||
pos.y -= font_h + label_style->line_space - 1;
|
||||
pos.x = ext->cursor_valid_x;
|
||||
|
||||
/*Get the letter index on the new cursor position and set it*/
|
||||
@@ -543,7 +546,7 @@ static bool lv_ta_scrling_design(lv_obj_t * scrling, const area_t * mask, lv_des
|
||||
cur_area.x1 = letter_pos.x + ta_ext->label->cords.x1 - (ta_style->cursor_width >> 1);
|
||||
cur_area.y1 = letter_pos.y + ta_ext->label->cords.y1;
|
||||
cur_area.x2 = letter_pos.x + ta_ext->label->cords.x1 + (ta_style->cursor_width >> 1);
|
||||
cur_area.y2 = letter_pos.y + ta_ext->label->cords.y1 + font_get_height(font_get(labels_p->font));
|
||||
cur_area.y2 = letter_pos.y + ta_ext->label->cords.y1 + (font_get_height(font_get(labels_p->font)) >> LV_FONT_ANTIALIAS);
|
||||
|
||||
lv_rects_t cur_rects;
|
||||
lv_rects_get(LV_RECTS_DEF, &cur_rects);
|
||||
|
||||
Reference in New Issue
Block a user