Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GUI: NumberInput small improvements #3840

Draft
wants to merge 4 commits into
base: dev
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions applications/services/gui/modules/number_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ static void number_input_draw_input(Canvas* canvas, NumberInputModel* model) {
const size_t text_x = 8;
const size_t text_y = 25;

elements_slightly_rounded_frame(canvas, 6, 14, 116, 15);
elements_slightly_rounded_frame(canvas, 4, 14, 120, 15);

canvas_draw_str(canvas, text_x, text_y, furi_string_get_cstr(model->text_buffer));
}
Expand Down Expand Up @@ -215,7 +215,7 @@ static void number_input_add_digit(NumberInputModel* model, char* newChar) {
}
model->current_number = strtol(furi_string_get_cstr(model->text_buffer), NULL, 10);
if(model->current_number == 0) {
furi_string_reset(model->text_buffer);
furi_string_set(model->text_buffer, "0");
}
}

Expand Down Expand Up @@ -426,7 +426,9 @@ void number_input_set_result_callback(
int32_t max_value) {
furi_check(number_input);

current_number = CLAMP(current_number, max_value, min_value);
if(current_number != 0) {
current_number = CLAMP(current_number, max_value, min_value);
}

with_view_model(
number_input->view,
Expand All @@ -435,7 +437,11 @@ void number_input_set_result_callback(
model->callback = callback;
model->callback_context = callback_context;
model->current_number = current_number;
furi_string_printf(model->text_buffer, "%ld", current_number);
if(current_number != 0) {
furi_string_printf(model->text_buffer, "%ld", current_number);
} else {
furi_string_set(model->text_buffer, "");
}
model->min_value = min_value;
model->max_value = max_value;
},
Expand Down