mirror of
https://github.com/lvgl/lvgl.git
synced 2026-09-22 19:26:06 +08:00
feat(chart): add lv_chart_set_cursor_pos_x/pos_y()
This commit is contained in:
committed by
Felipe Neves
parent
352327007b
commit
8d0a5197bc
@@ -91,6 +91,8 @@ lv_dir_t lv_xml_dir_to_enum(const char * txt)
|
||||
if(lv_streq("bottom", txt)) return LV_DIR_BOTTOM;
|
||||
if(lv_streq("left", txt)) return LV_DIR_LEFT;
|
||||
if(lv_streq("right", txt)) return LV_DIR_RIGHT;
|
||||
if(lv_streq("hor", txt)) return LV_DIR_HOR;
|
||||
if(lv_streq("ver", txt)) return LV_DIR_VER;
|
||||
if(lv_streq("all", txt)) return LV_DIR_ALL;
|
||||
|
||||
LV_LOG_WARN("%s is an unknown value for dir", txt);
|
||||
|
||||
@@ -114,6 +114,9 @@ void * lv_xml_chart_cursor_create(lv_xml_parser_state_t * state, const char ** a
|
||||
{
|
||||
const char * color = lv_xml_get_value_of(attrs, "color");
|
||||
const char * dir = lv_xml_get_value_of(attrs, "dir");
|
||||
if(color == NULL) color = "0x0000ff";
|
||||
if(dir == NULL) dir = "all";
|
||||
|
||||
void * item = lv_chart_add_cursor(lv_xml_state_get_parent(state), lv_color_hex(lv_xml_strtol(color, NULL, 16)),
|
||||
lv_xml_dir_to_enum(dir));
|
||||
|
||||
@@ -132,13 +135,8 @@ void lv_xml_chart_cursor_apply(lv_xml_parser_state_t * state, const char ** attr
|
||||
const char * name = attrs[i];
|
||||
const char * value = attrs[i + 1];
|
||||
|
||||
|
||||
if(lv_streq("pos", name)) {
|
||||
int32_t x = lv_xml_atoi_split(&value, ' ');
|
||||
int32_t y = lv_xml_atoi_split(&value, ' ');
|
||||
lv_point_t p = {x, y};
|
||||
lv_chart_set_cursor_pos(chart, cursor, &p);
|
||||
}
|
||||
if(lv_streq("pos_x", name)) lv_chart_set_cursor_pos_x(chart, cursor, lv_xml_atoi(value));
|
||||
if(lv_streq("pos_y", name)) lv_chart_set_cursor_pos_y(chart, cursor, lv_xml_atoi(value));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,7 +145,7 @@ void * lv_xml_chart_axis_create(lv_xml_parser_state_t * state, const char ** att
|
||||
LV_UNUSED(attrs);
|
||||
|
||||
/*Nothing to create*/
|
||||
return lv_xml_state_get_parent(state);;
|
||||
return lv_xml_state_get_parent(state);
|
||||
}
|
||||
|
||||
void lv_xml_chart_axis_apply(lv_xml_parser_state_t * state, const char ** attrs)
|
||||
|
||||
@@ -455,6 +455,26 @@ void lv_chart_set_cursor_pos(lv_obj_t * chart, lv_chart_cursor_t * cursor, lv_po
|
||||
lv_chart_refresh(chart);
|
||||
}
|
||||
|
||||
void lv_chart_set_cursor_pos_x(lv_obj_t * chart, lv_chart_cursor_t * cursor, int32_t x)
|
||||
{
|
||||
LV_ASSERT_NULL(cursor);
|
||||
LV_UNUSED(chart);
|
||||
|
||||
cursor->pos.x = x;
|
||||
cursor->pos_set = 1;
|
||||
lv_chart_refresh(chart);
|
||||
}
|
||||
|
||||
void lv_chart_set_cursor_pos_y(lv_obj_t * chart, lv_chart_cursor_t * cursor, int32_t y)
|
||||
{
|
||||
LV_ASSERT_NULL(cursor);
|
||||
LV_UNUSED(chart);
|
||||
|
||||
cursor->pos.y = y;
|
||||
cursor->pos_set = 1;
|
||||
lv_chart_refresh(chart);
|
||||
}
|
||||
|
||||
void lv_chart_set_cursor_point(lv_obj_t * chart, lv_chart_cursor_t * cursor, lv_chart_series_t * ser, uint32_t point_id)
|
||||
{
|
||||
LV_ASSERT_NULL(cursor);
|
||||
|
||||
@@ -228,6 +228,22 @@ lv_chart_cursor_t * lv_chart_add_cursor(lv_obj_t * obj, lv_color_t color, lv_di
|
||||
*/
|
||||
void lv_chart_set_cursor_pos(lv_obj_t * chart, lv_chart_cursor_t * cursor, lv_point_t * pos);
|
||||
|
||||
/**
|
||||
* Set the X coordinate of the cursor with respect to the paddings
|
||||
* @param chart pointer to a chart object
|
||||
* @param cursor pointer to the cursor
|
||||
* @param x the new X coordinate of cursor relative to the chart
|
||||
*/
|
||||
void lv_chart_set_cursor_pos_x(lv_obj_t * chart, lv_chart_cursor_t * cursor, int32_t x);
|
||||
|
||||
/**
|
||||
* Set the coordinate of the cursor with respect to the paddings
|
||||
* @param chart pointer to a chart object
|
||||
* @param cursor pointer to the cursor
|
||||
* @param y the new Y coordinate of cursor relative to the chart
|
||||
*/
|
||||
void lv_chart_set_cursor_pos_y(lv_obj_t * chart, lv_chart_cursor_t * cursor, int32_t y);
|
||||
|
||||
/**
|
||||
* Stick the cursor to a point
|
||||
* @param chart pointer to a chart object
|
||||
|
||||
@@ -43,6 +43,9 @@
|
||||
<enum name="bottom" help="Some help"/>
|
||||
<enum name="left" help="Some help"/>
|
||||
<enum name="right" help="Some help"/>
|
||||
<enum name="hor" help="Some help"/>
|
||||
<enum name="ver" help="Some help"/>
|
||||
<enum name="all" help="Some help"/>
|
||||
</enumdef>
|
||||
<enumdef name="lv_layout">
|
||||
<enum name="none" help="Some help"/>
|
||||
|
||||
+2
-3
@@ -50,9 +50,8 @@
|
||||
<element name="cursor" type="lv_chart_cursor" access="add">
|
||||
<arg name="color" type="color" arg="true"/>
|
||||
<arg name="dir" type="enum:lv_dir" arg="true"/>
|
||||
<prop name="pos" help="position of the cursor">
|
||||
<param name="point" type="point" help="the point"/>
|
||||
</prop>
|
||||
<prop name="pos_x" type="int" help="x position of the cursor"/>
|
||||
<prop name="pos_y" type="int" help="y position of the cursor"/>
|
||||
</element>
|
||||
|
||||
<element name="axis" access="set">
|
||||
|
||||
Reference in New Issue
Block a user