refactor(table): convert lv_table_add_cell_ctrl to a setter

This commit is contained in:
Gabor Kiss-Vamosi
2025-01-13 22:10:32 +01:00
parent 5f2888d93a
commit 39c4011864
7 changed files with 17 additions and 23 deletions

View File

@@ -71,7 +71,7 @@ Merge cells
-----------
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.
Scrolling

View File

@@ -53,7 +53,7 @@ static void change_event_cb(lv_event_t * e)
lv_table_get_selected_cell(obj, &row, &col);
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);
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);
}
/**

View File

@@ -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);
}
lv_table_add_cell_ctrl(table, row, column, ctrl);
lv_table_set_cell_ctrl(table, row, column, ctrl);
}
}
}

View File

@@ -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);
}
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);

View File

@@ -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 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.

View File

@@ -58,7 +58,7 @@ void test_table_should_identify_cell_with_ctrl(void)
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);
TEST_ASSERT_TRUE(has_ctrl);
}
@@ -67,7 +67,7 @@ void test_table_should_clear_selected_cell_ctrl(void)
{
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);
TEST_ASSERT_TRUE(has_ctrl);
@@ -80,7 +80,7 @@ void test_table_should_keep_not_selected_cell_ctrl(void)
{
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);
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, 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_add_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_add_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, 0, LV_TABLE_CELL_CTRL_MERGE_RIGHT);
lv_table_set_cell_ctrl(table, 1, 1, LV_TABLE_CELL_CTRL_MERGE_RIGHT);
lv_table_set_cell_ctrl(table, 1, 2, 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");
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, 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 ");
TEST_ASSERT_EQUAL_SCREENSHOT("widgets/table_1.png");

View File

@@ -17,12 +17,8 @@
<enum name="custom_4"/>
</enumdef>
<prop name="row_conunt" help="">
<param name="cnt" type="int" help=""/>
</prop>
<prop name="column_conunt" help="">
<param name="cnt" type="int" help=""/>
</prop>
<prop name="row_conunt" type="int" help=""/>
<prop name="column_conunt" type="int" help=""/>
<prop name="selected cell" help="">
<param name="row" type="int" help=""/>
<param name="column" type="int" help=""/>
@@ -30,9 +26,7 @@
<element name="column" access="set">
<arg name="column" type="int" help=""/>
<prop name="values" help="set values from an array">
<param name="width" type="px" help="width of the column"/>
</prop>
<prop name="width" type="px" help="width of the column"/>
</element>
<element name="cell" access="set">