minor fixes
This commit is contained in:
@@ -273,6 +273,8 @@ static int32_t find_track_end(lv_obj_t * cont, int32_t item_start_id, lv_coord_t
|
||||
|
||||
lv_obj_t * item = lv_obj_get_child(cont, item_id);
|
||||
while(item) {
|
||||
if(item_id != item_start_id && lv_obj_has_flag(item, LV_OBJ_FLAG_LAYOUT_1)) break;
|
||||
|
||||
if(!lv_obj_has_flag_any(item, LV_OBJ_FLAG_IGNORE_LAYOUT | LV_OBJ_FLAG_HIDDEN | LV_OBJ_FLAG_FLOATING)) {
|
||||
lv_coord_t main_size = (row ? item->w_set : item->h_set);
|
||||
if(_LV_FLEX_GET_GROW(main_size)) {
|
||||
@@ -324,7 +326,6 @@ static int32_t find_track_end(lv_obj_t * cont, int32_t item_start_id, lv_coord_t
|
||||
*/
|
||||
static void children_repos(lv_obj_t * cont, int32_t item_first_id, int32_t item_last_id, lv_coord_t abs_x, lv_coord_t abs_y, lv_coord_t max_main_size, lv_coord_t item_gap, track_t * t)
|
||||
{
|
||||
|
||||
const lv_flex_t * f = (const lv_flex_t *)cont->spec_attr->layout_dsc;
|
||||
bool row = f->dir == LV_FLEX_FLOW_ROW ? true : false;
|
||||
|
||||
@@ -334,7 +335,6 @@ static void children_repos(lv_obj_t * cont, int32_t item_first_id, int32_t item_
|
||||
|
||||
bool rtl = lv_obj_get_base_dir(cont) == LV_BIDI_DIR_RTL ? true : false;
|
||||
|
||||
|
||||
lv_coord_t main_pos = 0;
|
||||
|
||||
lv_coord_t place_gap = 0;
|
||||
|
||||
@@ -392,6 +392,7 @@ static void style_init(void)
|
||||
style_init_reset(&styles->chart_bg);
|
||||
lv_style_set_line_dash_width(&styles->chart_bg, LV_DPX(10));
|
||||
lv_style_set_line_dash_gap(&styles->chart_bg, LV_DPX(10));
|
||||
lv_style_set_border_post(&styles->chart_bg, false);
|
||||
|
||||
style_init_reset(&styles->chart_series);
|
||||
lv_style_set_line_width(&styles->chart_series, LV_DPX(3));
|
||||
|
||||
@@ -609,8 +609,6 @@ static void lv_obj_constructor(lv_obj_t * obj, const lv_obj_t * copy)
|
||||
parent->spec_attr->children[parent->spec_attr->child_cnt - 1] = obj;
|
||||
}
|
||||
|
||||
obj->parent = parent;
|
||||
|
||||
lv_coord_t sl = lv_obj_get_scroll_left(parent);
|
||||
lv_coord_t st = lv_obj_get_scroll_top(parent);
|
||||
|
||||
|
||||
@@ -47,10 +47,9 @@ typedef struct
|
||||
const lv_point_t * p2;
|
||||
const lv_coord_t * radius;
|
||||
char text[16];
|
||||
int32_t value;
|
||||
uint32_t id;
|
||||
uint32_t part :8;
|
||||
uint32_t sub_part_id :12;
|
||||
uint32_t size :12;
|
||||
const void * sub_part_ptr;
|
||||
}lv_obj_draw_hook_dsc_t;
|
||||
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
#include "lv_btn.h"
|
||||
#if LV_USE_BTN != 0
|
||||
|
||||
#include "../extra/layouts/flex/lv_flex.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
@@ -59,6 +61,10 @@ static void lv_btn_constructor(lv_obj_t * obj, const lv_obj_t * copy)
|
||||
lv_obj_set_size(obj, LV_DPI_DEF, LV_DPI_DEF / 3);
|
||||
lv_obj_clear_flag(obj, LV_OBJ_FLAG_SCROLLABLE);
|
||||
lv_obj_add_flag(obj, LV_OBJ_FLAG_SCROLL_ON_FOCUS);
|
||||
|
||||
#if LV_USE_FLEX
|
||||
lv_obj_set_layout(obj, &lv_flex_row_center);
|
||||
#endif
|
||||
}
|
||||
|
||||
LV_TRACE_OBJ_CREATE("finished");
|
||||
|
||||
@@ -631,8 +631,8 @@ static void draw_div_lines(lv_obj_t * obj, const lv_area_t * clip_area)
|
||||
lv_coord_t y_ofs = obj->coords.y1 + pad_top - scroll_top;
|
||||
p1.x = obj->coords.x1;
|
||||
p2.x = obj->coords.x2;
|
||||
for(i = 0; i <= chart->hdiv_cnt + 1; i++) {
|
||||
p1.y = (int32_t)((int32_t)(h - line_dsc.width) * i) / (chart->hdiv_cnt + 1);
|
||||
for(i = 0; i < chart->hdiv_cnt; i++) {
|
||||
p1.y = (int32_t)((int32_t)(h - line_dsc.width) * i) / (chart->hdiv_cnt - 1);
|
||||
p1.y += y_ofs;
|
||||
p2.y = p1.y;
|
||||
lv_draw_line(&p1, &p2, &series_mask, &line_dsc);
|
||||
@@ -643,8 +643,8 @@ static void draw_div_lines(lv_obj_t * obj, const lv_area_t * clip_area)
|
||||
lv_coord_t x_ofs = obj->coords.x1 + pad_left - scroll_left;
|
||||
p1.y = obj->coords.y1;
|
||||
p2.y = obj->coords.y2;
|
||||
for(i = 0; i <= chart->vdiv_cnt + 1; i++) {
|
||||
p1.x = (int32_t)((int32_t)(w - line_dsc.width) * i) / (chart->vdiv_cnt + 1);
|
||||
for(i = 0; i < chart->vdiv_cnt; i++) {
|
||||
p1.x = (int32_t)((int32_t)(w - line_dsc.width) * i) / (chart->vdiv_cnt - 1);
|
||||
p1.x += x_ofs;
|
||||
p2.x = p1.x;
|
||||
lv_draw_line(&p1, &p2, &series_mask, &line_dsc);
|
||||
@@ -737,50 +737,59 @@ static void draw_series_line(lv_obj_t * obj, const lv_area_t * clip_area)
|
||||
|
||||
if(p2.x < clip_area->x1 - point_size_act) continue;
|
||||
|
||||
hook_dsc.id = p_act;
|
||||
hook_dsc.p1 = ser->points[p_prev] != LV_CHART_POINT_DEF ? &p1 : NULL;
|
||||
hook_dsc.p2 = ser->points[p_act] != LV_CHART_POINT_DEF ? &p2 : NULL;
|
||||
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &hook_dsc);
|
||||
|
||||
/*Don't draw the first point. A second point is also required to draw the line*/
|
||||
if(i != 0 && ser->points[p_prev] != LV_CHART_POINT_DEF && ser->points[p_act] != LV_CHART_POINT_DEF) {
|
||||
lv_draw_line(&p1, &p2, &series_mask, &line_dsc_default);
|
||||
}
|
||||
if(i != 0) {
|
||||
|
||||
if(point_size_act && ser->points[p_prev] != LV_CHART_POINT_DEF) {
|
||||
lv_area_t point_area;
|
||||
point_area.x1 = p1.x - point_size_act;
|
||||
point_area.x2 = p1.x + point_size_act;
|
||||
point_area.y1 = p1.y - point_size_act;
|
||||
point_area.y2 = p1.y + point_size_act;
|
||||
|
||||
point_area.x1 = p1.x;
|
||||
point_area.x2 = point_area.x1 + point_size_act;
|
||||
point_area.x1 -= point_size_act;
|
||||
hook_dsc.id = i - 1;
|
||||
hook_dsc.p1 = ser->points[p_prev] != LV_CHART_POINT_DEF ? &p1 : NULL;
|
||||
hook_dsc.p2 = ser->points[p_act] != LV_CHART_POINT_DEF ? &p2 : NULL;
|
||||
hook_dsc.draw_area = &point_area;
|
||||
hook_dsc.value = ser->points[p_prev];
|
||||
|
||||
point_area.y1 = p1.y;
|
||||
point_area.y2 = point_area.y1 + point_size_act;
|
||||
point_area.y1 -= point_size_act;
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &hook_dsc);
|
||||
|
||||
lv_draw_rect(&point_area, &series_mask, &point_dsc_default);
|
||||
if(ser->points[p_prev] != LV_CHART_POINT_DEF && ser->points[p_act] != LV_CHART_POINT_DEF) {
|
||||
lv_draw_line(&p1, &p2, &series_mask, &line_dsc_default);
|
||||
}
|
||||
|
||||
if(point_size_act && ser->points[p_act] != LV_CHART_POINT_DEF) {
|
||||
lv_draw_rect(&point_area, &series_mask, &point_dsc_default);
|
||||
}
|
||||
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_END, &hook_dsc);
|
||||
}
|
||||
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_END, &hook_dsc);
|
||||
|
||||
p_prev = p_act;
|
||||
}
|
||||
|
||||
/*Draw the last point*/
|
||||
if(point_size) {
|
||||
point_size_act = p_act == chart->pressed_point_id ? point_size_pr : point_size;
|
||||
|
||||
lv_area_t point_area;
|
||||
point_area.x1 = p2.x;
|
||||
point_area.x2 = point_area.x1 + point_size_act;
|
||||
point_area.x1 -= point_size_act;
|
||||
|
||||
point_area.y1 = p2.y;
|
||||
point_area.y2 = point_area.y1 + point_size_act;
|
||||
point_area.y1 -= point_size_act;
|
||||
point_size_act = p_act == chart->pressed_point_id ? point_size_pr : point_size;
|
||||
if(point_size_act && i == chart->point_cnt) {
|
||||
|
||||
if(ser->points[p_act] != LV_CHART_POINT_DEF) {
|
||||
lv_area_t point_area;
|
||||
point_area.x1 = p2.x - point_size_act;
|
||||
point_area.x2 = p2.x + point_size_act;
|
||||
point_area.y1 = p2.y - point_size_act;
|
||||
point_area.y2 = p2.y + point_size_act;
|
||||
|
||||
hook_dsc.id = i - 1;
|
||||
hook_dsc.p1 = NULL;
|
||||
hook_dsc.p2 = NULL;
|
||||
hook_dsc.draw_area = &point_area;
|
||||
hook_dsc.value = ser->points[p_act];
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &hook_dsc);
|
||||
lv_draw_rect(&point_area, &series_mask, &point_dsc_default);
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_END, &hook_dsc);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -901,7 +910,7 @@ static void draw_y_ticks(lv_obj_t * obj, const lv_area_t * clip_area, lv_chart_a
|
||||
|
||||
lv_obj_draw_hook_dsc_t hook_dsc;
|
||||
lv_obj_draw_hook_dsc_init(&hook_dsc, clip_area);
|
||||
hook_dsc.sub_part_id = axis;
|
||||
hook_dsc.id = axis;
|
||||
hook_dsc.part = LV_PART_MARKER;
|
||||
|
||||
lv_draw_line_dsc_t line_dsc;
|
||||
@@ -941,7 +950,7 @@ static void draw_y_ticks(lv_obj_t * obj, const lv_area_t * clip_area, lv_chart_a
|
||||
if(major && t->label_en) {
|
||||
int32_t tick_value = chart->ymax[axis] - lv_map(i, 0, total_tick_num, chart->ymin[axis], chart->ymax[axis]);
|
||||
lv_snprintf(hook_dsc.text, sizeof(hook_dsc.text), "%d", tick_value);
|
||||
hook_dsc.id = tick_value;
|
||||
hook_dsc.value = tick_value;
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &hook_dsc);
|
||||
|
||||
/* reserve appropriate area */
|
||||
@@ -985,12 +994,10 @@ static void draw_x_ticks(lv_obj_t * obj, const lv_area_t * clip_area)
|
||||
lv_point_t p2;
|
||||
|
||||
lv_coord_t pad_left = lv_obj_get_style_pad_left(obj, LV_PART_MAIN);
|
||||
lv_coord_t pad_top = lv_obj_get_style_pad_top(obj, LV_PART_MAIN);
|
||||
lv_coord_t w = (lv_obj_get_width_fit(obj) * chart->zoom_x) >> 8;
|
||||
lv_coord_t h = (lv_obj_get_height_fit(obj) * chart->zoom_y) >> 8;
|
||||
|
||||
lv_coord_t x_ofs = obj->coords.x1 + pad_left - lv_obj_get_scroll_left(obj);
|
||||
lv_coord_t y_ofs = obj->coords.y1 + pad_top;
|
||||
lv_coord_t y_ofs = obj->coords.y2;
|
||||
|
||||
lv_draw_label_dsc_t label_dsc;
|
||||
lv_draw_label_dsc_init(&label_dsc);
|
||||
@@ -998,8 +1005,8 @@ static void draw_x_ticks(lv_obj_t * obj, const lv_area_t * clip_area)
|
||||
|
||||
lv_coord_t label_gap = t->label_en ? lv_obj_get_style_pad_bottom(obj, LV_PART_MARKER) : 0;
|
||||
|
||||
if(h + y_ofs > clip_area->y2) return;
|
||||
if(h + y_ofs + label_gap + label_dsc.font->line_height + t->major_len < clip_area->y1) return;
|
||||
if(y_ofs > clip_area->y2) return;
|
||||
if(y_ofs + label_gap + label_dsc.font->line_height + t->major_len < clip_area->y1) return;
|
||||
|
||||
lv_draw_line_dsc_t line_dsc;
|
||||
lv_draw_line_dsc_init(&line_dsc);
|
||||
@@ -1009,7 +1016,7 @@ static void draw_x_ticks(lv_obj_t * obj, const lv_area_t * clip_area)
|
||||
|
||||
lv_obj_draw_hook_dsc_t hook_dsc;
|
||||
lv_obj_draw_hook_dsc_init(&hook_dsc, clip_area);
|
||||
hook_dsc.sub_part_id = LV_CHART_AXIS_X;
|
||||
hook_dsc.id = LV_CHART_AXIS_X;
|
||||
hook_dsc.part = LV_PART_MARKER;
|
||||
|
||||
/* The columns ticks should be aligned to the center of blocks */
|
||||
@@ -1020,7 +1027,7 @@ static void draw_x_ticks(lv_obj_t * obj, const lv_area_t * clip_area)
|
||||
w -= block_w;
|
||||
}
|
||||
|
||||
p1.y = h + y_ofs;
|
||||
p1.y = y_ofs;
|
||||
uint32_t total_tick_num = (t->major_cnt - 1) * t->minor_cnt;
|
||||
for(i = 0; i <= total_tick_num; i++) { /* one extra loop - it may not exist in the list, empty label */
|
||||
bool major = false;
|
||||
@@ -1042,7 +1049,7 @@ static void draw_x_ticks(lv_obj_t * obj, const lv_area_t * clip_area)
|
||||
|
||||
int32_t tick_value = i / t->minor_cnt;
|
||||
lv_snprintf(hook_dsc.text, sizeof(hook_dsc.text), "%d", i / t->minor_cnt);
|
||||
hook_dsc.id = tick_value;
|
||||
hook_dsc.value = tick_value;
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &hook_dsc);
|
||||
|
||||
/* reserve appropriate area */
|
||||
|
||||
@@ -396,7 +396,7 @@ static void draw_knob(lv_obj_t * obj, const lv_area_t * clip_area)
|
||||
lv_obj_draw_hook_dsc_t hook_dsc;
|
||||
lv_obj_draw_hook_dsc_init(&hook_dsc, clip_area);
|
||||
hook_dsc.part = LV_PART_KNOB;
|
||||
hook_dsc.sub_part_id = 0;
|
||||
hook_dsc.id = 0;
|
||||
hook_dsc.draw_area = &slider->right_knob_area;
|
||||
hook_dsc.rect_dsc = &knob_rect_dsc;
|
||||
|
||||
@@ -426,7 +426,7 @@ static void draw_knob(lv_obj_t * obj, const lv_area_t * clip_area)
|
||||
lv_memcpy(&knob_rect_dsc, &knob_rect_dsc_tmp, sizeof(lv_draw_rect_dsc_t));
|
||||
hook_dsc.draw_area = &slider->left_knob_area;
|
||||
hook_dsc.rect_dsc = &knob_rect_dsc;
|
||||
hook_dsc.sub_part_id = 1;
|
||||
hook_dsc.id = 1;
|
||||
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &hook_dsc);
|
||||
lv_draw_rect(&slider->left_knob_area, clip_area, &knob_rect_dsc);
|
||||
|
||||
Reference in New Issue
Block a user