[FL-1235] Cut long names (#494)
* fix typo, elements_string_fit_width added * add string_fit_witdt to fileselect module Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#include "archive_views.h"
|
||||
|
||||
static const char* ArchiveTabNames[] =
|
||||
{"Favorites", "iButton", "NFC", "SubOne", "Rfid", "Infared", "Browser"};
|
||||
{"Favourites", "iButton", "NFC", "SubOne", "Rfid", "Infared", "Browser"};
|
||||
|
||||
static const IconName ArchiveItemIcons[] = {
|
||||
[ArchiveFileTypeIButton] = I_ibutt_10px,
|
||||
@@ -59,20 +59,6 @@ static void trim_file_ext(string_t name) {
|
||||
}
|
||||
}
|
||||
|
||||
static void format_filename_buffer(Canvas* canvas, string_t name, ArchiveFileTypeEnum type) {
|
||||
furi_assert(name);
|
||||
|
||||
size_t s_len = strlen(string_get_cstr(name));
|
||||
uint16_t len_px = canvas_string_width(canvas, string_get_cstr(name));
|
||||
|
||||
if(is_known_app(type)) trim_file_ext(name);
|
||||
|
||||
if(len_px > MAX_LEN_PX) {
|
||||
string_mid(name, 0, s_len - (size_t)((len_px - MAX_LEN_PX) / ((len_px / s_len) + 2) + 2));
|
||||
string_cat(name, "...");
|
||||
}
|
||||
}
|
||||
|
||||
static void archive_draw_frame(Canvas* canvas, uint16_t idx, bool scrollbar) {
|
||||
canvas_set_color(canvas, ColorBlack);
|
||||
canvas_draw_box(canvas, 0, 15 + idx * FRAME_HEIGHT, scrollbar ? 122 : 127, FRAME_HEIGHT);
|
||||
@@ -101,7 +87,9 @@ static void draw_list(Canvas* canvas, ArchiveViewModel* model) {
|
||||
ArchiveFile_t* file = files_array_get(model->files, CLAMP(idx, array_size - 1, 0));
|
||||
|
||||
string_set(str_buff, file->name);
|
||||
format_filename_buffer(canvas, str_buff, file->type);
|
||||
|
||||
if(is_known_app(file->type)) trim_file_ext(str_buff);
|
||||
elements_string_fit_width(canvas, str_buff, MAX_LEN_PX);
|
||||
|
||||
if(model->idx == idx) {
|
||||
archive_draw_frame(canvas, i, scrollbar);
|
||||
|
||||
Reference in New Issue
Block a user