Skip to content

Commit

Permalink
[FL-1461] Update progressbar UI (IR bruteforce) (flipperdevices#997)
Browse files Browse the repository at this point in the history
Co-authored-by: あく <[email protected]>
  • Loading branch information
albkharisov and skotopes authored Feb 16, 2022
1 parent b8b42d0 commit 97c9a22
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 25 deletions.
33 changes: 9 additions & 24 deletions applications/gui/elements.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,30 +37,15 @@ void elements_progress_bar(
furi_assert(canvas);
furi_assert(total > 0);
uint8_t height = 9;
uint8_t marker_width = 7;
furi_assert(width > marker_width);

uint8_t progress_length = ((float)progress / total) * (width - marker_width - 2);

// rframe doesnt work if (radius * 2) > any rect side, so write manually
uint8_t x_max = x + width - 1;
uint8_t y_max = y + height - 1;
canvas_draw_line(canvas, x + 3, y, x_max - 3, y);
canvas_draw_line(canvas, x_max - 3, y, x_max, y + 3);
canvas_draw_line(canvas, x_max, y + 3, x_max, y_max - 3);
canvas_draw_line(canvas, x_max, y_max - 3, x_max - 3, y_max);
canvas_draw_line(canvas, x_max - 3, y_max, x + 3, y_max);
canvas_draw_line(canvas, x + 3, y_max, x, y_max - 3);
canvas_draw_line(canvas, x, y_max - 3, x, y + 3);
canvas_draw_line(canvas, x, y + 3, x + 3, y);

canvas_draw_rbox(canvas, x + 1, y + 1, marker_width + progress_length, height - 2, 3);
canvas_invert_color(canvas);
canvas_draw_dot(canvas, x + progress_length + 3, y + 2);
canvas_draw_dot(canvas, x + progress_length + 4, y + 2);
canvas_draw_dot(canvas, x + progress_length + 5, y + 3);
canvas_draw_dot(canvas, x + progress_length + 6, y + 4);
canvas_invert_color(canvas);

uint8_t progress_length = roundf(((float)progress / total) * (width - 2));

canvas_set_color(canvas, ColorWhite);
canvas_draw_box(canvas, x + 1, y + 1, width - 2, height - 2);
canvas_set_color(canvas, ColorBlack);
canvas_draw_rframe(canvas, x, y, width, height, 3);

canvas_draw_box(canvas, x + 1, y + 1, progress_length, height - 2);
}

void elements_scrollbar_pos(
Expand Down
2 changes: 1 addition & 1 deletion applications/irda/view/irda_app_brut_view.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void popup_brut_draw_callback(Canvas* canvas, void* context) {
canvas_draw_line(canvas, x_max - 1, y_max - 2, x_max - 3, y_max - 2);

elements_progress_bar(
canvas, x + 4, y + 19, x_max - 8, popup_brut->progress, popup_brut->progress_max);
canvas, x + 4, y + 19, x_max - 7, popup_brut->progress, popup_brut->progress_max);

canvas_set_font(canvas, FontSecondary);
canvas_draw_str(canvas, x + 15, y + 12, "Sending ...");
Expand Down

0 comments on commit 97c9a22

Please sign in to comment.