-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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: Submenu and VarItemList API additions and improvements #3621
Draft
Willy-JL
wants to merge
12
commits into
flipperdevices:dev
Choose a base branch
from
Willy-JL:submenu-varitemlist-api
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+541
−41
Draft
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
6fe017a
Gui: Submenu and VarItemList API additions and improvements
Willy-JL 3a1a539
Fix ellipsis
Willy-JL 20cb434
Gui: Elements centered scrollable text and horizontal scrollbar
Willy-JL ba8b8e3
Gui: Fix varitemlist value text position
Willy-JL add64ef
Update symbols
Willy-JL 3237c24
Fix typo
Willy-JL 942f78a
Gui: Fix scrolling text when only 1 char over limit
Willy-JL d0c4d0c
Merge branch 'dev' of https://github.com/flipperdevices/flipperzero-f…
Willy-JL fadef34
Merge branch 'dev' into submenu-varitemlist-api
skotopes 5624c5f
Merge branch 'dev' into submenu-varitemlist-api
skotopes 974cd38
Bump API symbols version
skotopes 1b88828
Merge remote-tracking branch 'origin/dev' into submenu-varitemlist-api
skotopes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -92,6 +92,32 @@ void elements_scrollbar_pos( | |
} | ||
} | ||
|
||
void elements_scrollbar_horizontal( | ||
Canvas* canvas, | ||
int32_t x, | ||
int32_t y, | ||
size_t width, | ||
size_t pos, | ||
size_t total) { | ||
furi_check(canvas); | ||
|
||
// prevent overflows | ||
canvas_set_color(canvas, ColorWhite); | ||
canvas_draw_box(canvas, x, y - 3, width, 3); | ||
|
||
// dot line | ||
canvas_set_color(canvas, ColorBlack); | ||
for(size_t i = x; i < width + x; i += 2) { | ||
canvas_draw_dot(canvas, i, y - 2); | ||
} | ||
|
||
// Position block | ||
if(total) { | ||
float block_w = ((float)width) / total; | ||
canvas_draw_box(canvas, x + (block_w * pos), y - 3, MAX(block_w, 1), 3); | ||
} | ||
} | ||
|
||
void elements_scrollbar(Canvas* canvas, size_t pos, size_t total) { | ||
furi_check(canvas); | ||
|
||
|
@@ -590,21 +616,38 @@ void elements_scrollable_text_line( | |
FuriString* string, | ||
size_t scroll, | ||
bool ellipsis) { | ||
elements_scrollable_text_line_centered(canvas, x, y, width, string, scroll, ellipsis, false); | ||
} | ||
|
||
void elements_scrollable_text_line_centered( | ||
Canvas* canvas, | ||
int32_t x, | ||
int32_t y, | ||
size_t width, | ||
FuriString* string, | ||
size_t scroll, | ||
bool ellipsis, | ||
bool centered) { | ||
furi_check(canvas); | ||
furi_check(string); | ||
|
||
FuriString* line = furi_string_alloc_set(string); | ||
|
||
size_t len_px = canvas_string_width(canvas, furi_string_get_cstr(line)); | ||
if(len_px > width) { | ||
if(centered) { | ||
centered = false; | ||
x -= width / 2; | ||
} | ||
|
||
if(ellipsis) { | ||
width -= canvas_string_width(canvas, "..."); | ||
} | ||
|
||
// Calculate scroll size | ||
size_t scroll_size = furi_string_size(line); | ||
size_t right_width = 0; | ||
for(size_t i = scroll_size; i > 0; i--) { | ||
for(size_t i = scroll_size - 1; i > 0; i--) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and if line is empty? |
||
right_width += canvas_glyph_width(canvas, furi_string_get_char(line, i)); | ||
if(right_width > width) break; | ||
scroll_size--; | ||
|
@@ -628,7 +671,12 @@ void elements_scrollable_text_line( | |
} | ||
} | ||
|
||
canvas_draw_str(canvas, x, y, furi_string_get_cstr(line)); | ||
if(centered) { | ||
canvas_draw_str_aligned( | ||
canvas, x, y, AlignCenter, AlignBottom, furi_string_get_cstr(line)); | ||
} else { | ||
canvas_draw_str(canvas, x, y, furi_string_get_cstr(line)); | ||
} | ||
furi_string_free(line); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about calling it
elements_scrollable_text_line_centered
and instead ofbool centered
accept Align?