refactor(table): convert lv_table_add_cell_ctrl to a setter
This commit is contained in:
@@ -71,7 +71,7 @@ Merge cells
|
|||||||
-----------
|
-----------
|
||||||
|
|
||||||
Cells can be merged horizontally with
|
Cells can be merged horizontally with
|
||||||
:cpp:expr:`lv_table_add_cell_ctrl(table, row, col, LV_TABLE_CELL_CTRL_MERGE_RIGHT)`.
|
:cpp:expr:`lv_table_set_cell_ctrl(table, row, col, LV_TABLE_CELL_CTRL_MERGE_RIGHT)`.
|
||||||
To merge more adjacent cells, call this function for each cell.
|
To merge more adjacent cells, call this function for each cell.
|
||||||
|
|
||||||
Scrolling
|
Scrolling
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ static void change_event_cb(lv_event_t * e)
|
|||||||
lv_table_get_selected_cell(obj, &row, &col);
|
lv_table_get_selected_cell(obj, &row, &col);
|
||||||
bool chk = lv_table_has_cell_ctrl(obj, row, 0, LV_TABLE_CELL_CTRL_CUSTOM_1);
|
bool chk = lv_table_has_cell_ctrl(obj, row, 0, LV_TABLE_CELL_CTRL_CUSTOM_1);
|
||||||
if(chk) lv_table_clear_cell_ctrl(obj, row, 0, LV_TABLE_CELL_CTRL_CUSTOM_1);
|
if(chk) lv_table_clear_cell_ctrl(obj, row, 0, LV_TABLE_CELL_CTRL_CUSTOM_1);
|
||||||
else lv_table_add_cell_ctrl(obj, row, 0, LV_TABLE_CELL_CTRL_CUSTOM_1);
|
else lv_table_set_cell_ctrl(obj, row, 0, LV_TABLE_CELL_CTRL_CUSTOM_1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ void lv_xml_table_cell_apply(lv_xml_parser_state_t * state, const char ** attrs)
|
|||||||
ctrl |= table_ctrl_to_enum(str);
|
ctrl |= table_ctrl_to_enum(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
lv_table_add_cell_ctrl(table, row, column, ctrl);
|
lv_table_set_cell_ctrl(table, row, column, ctrl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -315,7 +315,7 @@ void lv_table_set_column_width(lv_obj_t * obj, uint32_t col_id, int32_t w)
|
|||||||
refr_size_form_row(obj, 0);
|
refr_size_form_row(obj, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void lv_table_add_cell_ctrl(lv_obj_t * obj, uint32_t row, uint32_t col, lv_table_cell_ctrl_t ctrl)
|
void lv_table_set_cell_ctrl(lv_obj_t * obj, uint32_t row, uint32_t col, lv_table_cell_ctrl_t ctrl)
|
||||||
{
|
{
|
||||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||||
|
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ void lv_table_set_column_width(lv_obj_t * obj, uint32_t col_id, int32_t w);
|
|||||||
* @param col id of the column [0 .. col_cnt -1]
|
* @param col id of the column [0 .. col_cnt -1]
|
||||||
* @param ctrl OR-ed values from ::lv_table_cell_ctrl_t
|
* @param ctrl OR-ed values from ::lv_table_cell_ctrl_t
|
||||||
*/
|
*/
|
||||||
void lv_table_add_cell_ctrl(lv_obj_t * obj, uint32_t row, uint32_t col, lv_table_cell_ctrl_t ctrl);
|
void lv_table_set_cell_ctrl(lv_obj_t * obj, uint32_t row, uint32_t col, lv_table_cell_ctrl_t ctrl);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear control bits of the cell.
|
* Clear control bits of the cell.
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ void test_table_should_identify_cell_with_ctrl(void)
|
|||||||
|
|
||||||
TEST_ASSERT_FALSE(has_ctrl);
|
TEST_ASSERT_FALSE(has_ctrl);
|
||||||
|
|
||||||
lv_table_add_cell_ctrl(table, 0, 0, LV_TABLE_CELL_CTRL_MERGE_RIGHT);
|
lv_table_set_cell_ctrl(table, 0, 0, LV_TABLE_CELL_CTRL_MERGE_RIGHT);
|
||||||
has_ctrl = lv_table_has_cell_ctrl(table, 0, 0, LV_TABLE_CELL_CTRL_MERGE_RIGHT);
|
has_ctrl = lv_table_has_cell_ctrl(table, 0, 0, LV_TABLE_CELL_CTRL_MERGE_RIGHT);
|
||||||
TEST_ASSERT_TRUE(has_ctrl);
|
TEST_ASSERT_TRUE(has_ctrl);
|
||||||
}
|
}
|
||||||
@@ -67,7 +67,7 @@ void test_table_should_clear_selected_cell_ctrl(void)
|
|||||||
{
|
{
|
||||||
bool has_ctrl = false;
|
bool has_ctrl = false;
|
||||||
|
|
||||||
lv_table_add_cell_ctrl(table, 0, 0, LV_TABLE_CELL_CTRL_MERGE_RIGHT);
|
lv_table_set_cell_ctrl(table, 0, 0, LV_TABLE_CELL_CTRL_MERGE_RIGHT);
|
||||||
has_ctrl = lv_table_has_cell_ctrl(table, 0, 0, LV_TABLE_CELL_CTRL_MERGE_RIGHT);
|
has_ctrl = lv_table_has_cell_ctrl(table, 0, 0, LV_TABLE_CELL_CTRL_MERGE_RIGHT);
|
||||||
TEST_ASSERT_TRUE(has_ctrl);
|
TEST_ASSERT_TRUE(has_ctrl);
|
||||||
|
|
||||||
@@ -80,7 +80,7 @@ void test_table_should_keep_not_selected_cell_ctrl(void)
|
|||||||
{
|
{
|
||||||
bool has_ctrl = false;
|
bool has_ctrl = false;
|
||||||
|
|
||||||
lv_table_add_cell_ctrl(table, 0, 0, LV_TABLE_CELL_CTRL_MERGE_RIGHT | LV_TABLE_CELL_CTRL_TEXT_CROP);
|
lv_table_set_cell_ctrl(table, 0, 0, LV_TABLE_CELL_CTRL_MERGE_RIGHT | LV_TABLE_CELL_CTRL_TEXT_CROP);
|
||||||
|
|
||||||
lv_table_clear_cell_ctrl(table, 0, 0, LV_TABLE_CELL_CTRL_MERGE_RIGHT);
|
lv_table_clear_cell_ctrl(table, 0, 0, LV_TABLE_CELL_CTRL_MERGE_RIGHT);
|
||||||
has_ctrl = lv_table_has_cell_ctrl(table, 0, 0, LV_TABLE_CELL_CTRL_MERGE_RIGHT);
|
has_ctrl = lv_table_has_cell_ctrl(table, 0, 0, LV_TABLE_CELL_CTRL_MERGE_RIGHT);
|
||||||
@@ -182,13 +182,13 @@ void test_table_rendering(void)
|
|||||||
lv_table_set_column_width(table, 1, 60);
|
lv_table_set_column_width(table, 1, 60);
|
||||||
lv_table_set_column_width(table, 2, 100);
|
lv_table_set_column_width(table, 2, 100);
|
||||||
|
|
||||||
lv_table_add_cell_ctrl(table, 0, 1, LV_TABLE_CELL_CTRL_MERGE_RIGHT);
|
lv_table_set_cell_ctrl(table, 0, 1, LV_TABLE_CELL_CTRL_MERGE_RIGHT);
|
||||||
lv_table_set_cell_value(table, 0, 1, "2 cells are merged");
|
lv_table_set_cell_value(table, 0, 1, "2 cells are merged");
|
||||||
|
|
||||||
lv_table_add_cell_ctrl(table, 1, 0, LV_TABLE_CELL_CTRL_MERGE_RIGHT);
|
lv_table_set_cell_ctrl(table, 1, 0, LV_TABLE_CELL_CTRL_MERGE_RIGHT);
|
||||||
lv_table_add_cell_ctrl(table, 1, 1, LV_TABLE_CELL_CTRL_MERGE_RIGHT);
|
lv_table_set_cell_ctrl(table, 1, 1, LV_TABLE_CELL_CTRL_MERGE_RIGHT);
|
||||||
lv_table_add_cell_ctrl(table, 1, 2, LV_TABLE_CELL_CTRL_MERGE_RIGHT);
|
lv_table_set_cell_ctrl(table, 1, 2, LV_TABLE_CELL_CTRL_MERGE_RIGHT);
|
||||||
lv_table_add_cell_ctrl(table, 1, 3, LV_TABLE_CELL_CTRL_MERGE_RIGHT);
|
lv_table_set_cell_ctrl(table, 1, 3, LV_TABLE_CELL_CTRL_MERGE_RIGHT);
|
||||||
lv_table_set_cell_value(table, 1, 0, "5 cells are merged");
|
lv_table_set_cell_value(table, 1, 0, "5 cells are merged");
|
||||||
|
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
@@ -199,7 +199,7 @@ void test_table_rendering(void)
|
|||||||
lv_table_set_cell_value_fmt(table, 2, 3, "Multi\nline text");
|
lv_table_set_cell_value_fmt(table, 2, 3, "Multi\nline text");
|
||||||
lv_table_set_cell_value_fmt(table, 2, 4, "Very long text wrapped automatically");
|
lv_table_set_cell_value_fmt(table, 2, 4, "Very long text wrapped automatically");
|
||||||
|
|
||||||
lv_table_add_cell_ctrl(table, 4, 3, LV_TABLE_CELL_CTRL_TEXT_CROP);
|
lv_table_set_cell_ctrl(table, 4, 3, LV_TABLE_CELL_CTRL_TEXT_CROP);
|
||||||
lv_table_set_cell_value_fmt(table, 4, 3, "crop crop crop crop crop crop crop crop ");
|
lv_table_set_cell_value_fmt(table, 4, 3, "crop crop crop crop crop crop crop crop ");
|
||||||
|
|
||||||
TEST_ASSERT_EQUAL_SCREENSHOT("widgets/table_1.png");
|
TEST_ASSERT_EQUAL_SCREENSHOT("widgets/table_1.png");
|
||||||
|
|||||||
@@ -17,12 +17,8 @@
|
|||||||
<enum name="custom_4"/>
|
<enum name="custom_4"/>
|
||||||
</enumdef>
|
</enumdef>
|
||||||
|
|
||||||
<prop name="row_conunt" help="">
|
<prop name="row_conunt" type="int" help=""/>
|
||||||
<param name="cnt" type="int" help=""/>
|
<prop name="column_conunt" type="int" help=""/>
|
||||||
</prop>
|
|
||||||
<prop name="column_conunt" help="">
|
|
||||||
<param name="cnt" type="int" help=""/>
|
|
||||||
</prop>
|
|
||||||
<prop name="selected cell" help="">
|
<prop name="selected cell" help="">
|
||||||
<param name="row" type="int" help=""/>
|
<param name="row" type="int" help=""/>
|
||||||
<param name="column" type="int" help=""/>
|
<param name="column" type="int" help=""/>
|
||||||
@@ -30,9 +26,7 @@
|
|||||||
|
|
||||||
<element name="column" access="set">
|
<element name="column" access="set">
|
||||||
<arg name="column" type="int" help=""/>
|
<arg name="column" type="int" help=""/>
|
||||||
<prop name="values" help="set values from an array">
|
<prop name="width" type="px" help="width of the column"/>
|
||||||
<param name="width" type="px" help="width of the column"/>
|
|
||||||
</prop>
|
|
||||||
</element>
|
</element>
|
||||||
|
|
||||||
<element name="cell" access="set">
|
<element name="cell" access="set">
|
||||||
|
|||||||
Reference in New Issue
Block a user