mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-10 05:59:08 -07:00
Add var item list set item label api
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
#include <stdint.h>
|
||||
|
||||
struct VariableItem {
|
||||
const char* label;
|
||||
FuriString* label;
|
||||
uint8_t current_value_index;
|
||||
FuriString* current_value_text;
|
||||
uint8_t values_count;
|
||||
@@ -81,9 +81,9 @@ static void variable_item_list_draw_callback(Canvas* canvas, void* _model) {
|
||||
|
||||
if(item->current_value_index == 0 && furi_string_empty(item->current_value_text)) {
|
||||
// Only left text, no right text
|
||||
canvas_draw_str(canvas, 6, item_text_y, item->label);
|
||||
canvas_draw_str(canvas, 6, item_text_y, furi_string_get_cstr(item->label));
|
||||
} else {
|
||||
elements_scrollable_text_line_str(
|
||||
elements_scrollable_text_line_centered(
|
||||
canvas, 6, item_text_y, 66, item->label, scroll_counter, false, false);
|
||||
}
|
||||
|
||||
@@ -420,6 +420,7 @@ void variable_item_list_free(VariableItemList* variable_item_list) {
|
||||
VariableItemArray_it_t it;
|
||||
for(VariableItemArray_it(it, model->items); !VariableItemArray_end_p(it);
|
||||
VariableItemArray_next(it)) {
|
||||
furi_string_free(VariableItemArray_ref(it)->label);
|
||||
furi_string_free(VariableItemArray_ref(it)->current_value_text);
|
||||
furi_string_free(VariableItemArray_ref(it)->locked_message);
|
||||
}
|
||||
@@ -444,6 +445,7 @@ void variable_item_list_reset(VariableItemList* variable_item_list) {
|
||||
VariableItemArray_it_t it;
|
||||
for(VariableItemArray_it(it, model->items); !VariableItemArray_end_p(it);
|
||||
VariableItemArray_next(it)) {
|
||||
furi_string_free(VariableItemArray_ref(it)->label);
|
||||
furi_string_free(VariableItemArray_ref(it)->current_value_text);
|
||||
furi_string_free(VariableItemArray_ref(it)->locked_message);
|
||||
}
|
||||
@@ -472,7 +474,7 @@ VariableItem* variable_item_list_add(
|
||||
VariableItemListModel * model,
|
||||
{
|
||||
item = VariableItemArray_push_new(model->items);
|
||||
item->label = label;
|
||||
item->label = furi_string_alloc_set(label);
|
||||
item->values_count = values_count;
|
||||
item->change_callback = change_callback;
|
||||
item->context = context;
|
||||
@@ -510,6 +512,10 @@ void variable_item_set_values_count(VariableItem* item, uint8_t values_count) {
|
||||
item->values_count = values_count;
|
||||
}
|
||||
|
||||
void variable_item_set_item_label(VariableItem* item, const char* label) {
|
||||
furi_string_set(item->label, label);
|
||||
}
|
||||
|
||||
void variable_item_set_current_value_text(VariableItem* item, const char* current_value_text) {
|
||||
furi_string_set(item->current_value_text, current_value_text);
|
||||
}
|
||||
|
||||
@@ -88,6 +88,13 @@ void variable_item_set_current_value_index(VariableItem* item, uint8_t current_v
|
||||
*/
|
||||
void variable_item_set_values_count(VariableItem* item, uint8_t values_count);
|
||||
|
||||
/** Set number of values for item
|
||||
*
|
||||
* @param item VariableItem* instance
|
||||
* @param label The new label text
|
||||
*/
|
||||
void variable_item_set_item_label(VariableItem* item, const char* label);
|
||||
|
||||
/** Set item current selected text
|
||||
*
|
||||
* @param item VariableItem* instance
|
||||
|
||||
Reference in New Issue
Block a user