mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-12 11:18:35 -07:00
Fix + optimize compact and c64 menus --nobuild
This commit is contained in:
@@ -282,8 +282,6 @@ static void menu_draw_callback(Canvas* canvas, void* _model) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MenuStyleC64: {
|
case MenuStyleC64: {
|
||||||
FuriString* memstr = furi_string_alloc();
|
|
||||||
|
|
||||||
size_t index;
|
size_t index;
|
||||||
size_t y_off, x_off;
|
size_t y_off, x_off;
|
||||||
|
|
||||||
@@ -291,10 +289,9 @@ static void menu_draw_callback(Canvas* canvas, void* _model) {
|
|||||||
canvas_draw_str_aligned(
|
canvas_draw_str_aligned(
|
||||||
canvas, 64, 0, AlignCenter, AlignTop, "* FLIPPADORE 64 BASIC *");
|
canvas, 64, 0, AlignCenter, AlignTop, "* FLIPPADORE 64 BASIC *");
|
||||||
|
|
||||||
furi_string_printf(memstr, "%d BASIC BYTES FREE", memmgr_get_free_heap());
|
char memstr[29];
|
||||||
|
snprintf(memstr, sizeof(memstr), "%d BASIC BYTES FREE", memmgr_get_free_heap());
|
||||||
canvas_draw_str_aligned(
|
canvas_draw_str_aligned(canvas, 64, 9, AlignCenter, AlignTop, memstr);
|
||||||
canvas, 64, 9, AlignCenter, AlignTop, furi_string_get_cstr(memstr));
|
|
||||||
|
|
||||||
canvas_set_font(canvas, FontKeyboard);
|
canvas_set_font(canvas, FontKeyboard);
|
||||||
|
|
||||||
@@ -313,14 +310,12 @@ static void menu_draw_callback(Canvas* canvas, void* _model) {
|
|||||||
item = MenuItemArray_get(model->items, index);
|
item = MenuItemArray_get(model->items, index);
|
||||||
menu_short_name(item, name);
|
menu_short_name(item, name);
|
||||||
|
|
||||||
FuriString* item_str = furi_string_alloc();
|
char indexstr[5];
|
||||||
|
snprintf(indexstr, sizeof(indexstr), "%d.", index);
|
||||||
furi_string_printf(item_str, "%d.%s", index, furi_string_get_cstr(name));
|
furi_string_replace_at(name, 0, 0, indexstr);
|
||||||
|
|
||||||
elements_scrollable_text_line(
|
elements_scrollable_text_line(
|
||||||
canvas, x_off + 2, y_off + 12, 64, item_str, scroll_counter, false);
|
canvas, x_off + 2, y_off + 12, 64, name, scroll_counter, false);
|
||||||
|
|
||||||
furi_string_free(item_str);
|
|
||||||
|
|
||||||
if(selected) {
|
if(selected) {
|
||||||
canvas_set_color(canvas, ColorBlack);
|
canvas_set_color(canvas, ColorBlack);
|
||||||
@@ -328,8 +323,6 @@ static void menu_draw_callback(Canvas* canvas, void* _model) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
furi_string_free(memstr);
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MenuStyleEurocorp: {
|
case MenuStyleEurocorp: {
|
||||||
@@ -363,8 +356,6 @@ static void menu_draw_callback(Canvas* canvas, void* _model) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MenuStyleCompact: {
|
case MenuStyleCompact: {
|
||||||
FuriString* memstr = furi_string_alloc();
|
|
||||||
|
|
||||||
size_t index;
|
size_t index;
|
||||||
size_t y_off, x_off;
|
size_t y_off, x_off;
|
||||||
|
|
||||||
@@ -385,14 +376,8 @@ static void menu_draw_callback(Canvas* canvas, void* _model) {
|
|||||||
item = MenuItemArray_get(model->items, index);
|
item = MenuItemArray_get(model->items, index);
|
||||||
menu_short_name(item, name);
|
menu_short_name(item, name);
|
||||||
|
|
||||||
FuriString* item_str = furi_string_alloc();
|
|
||||||
|
|
||||||
furi_string_printf(item_str, "%s", furi_string_get_cstr(name));
|
|
||||||
|
|
||||||
elements_scrollable_text_line(
|
elements_scrollable_text_line(
|
||||||
canvas, x_off + 2, y_off + 12, 64, item_str, scroll_counter, false);
|
canvas, x_off + 2, y_off + 12, 64, name, scroll_counter, false);
|
||||||
|
|
||||||
furi_string_free(item_str);
|
|
||||||
|
|
||||||
if(selected) {
|
if(selected) {
|
||||||
canvas_set_color(canvas, ColorBlack);
|
canvas_set_color(canvas, ColorBlack);
|
||||||
@@ -400,8 +385,6 @@ static void menu_draw_callback(Canvas* canvas, void* _model) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
furi_string_free(memstr);
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@@ -648,18 +631,13 @@ static void menu_process_up(Menu* menu) {
|
|||||||
vertical_offset = CLAMP(MAX((int)position - 4, 0), MAX((int)count - 8, 0), 0);
|
vertical_offset = CLAMP(MAX((int)position - 4, 0), MAX((int)count - 8, 0), 0);
|
||||||
break;
|
break;
|
||||||
case MenuStyleC64:
|
case MenuStyleC64:
|
||||||
if(position > 0) {
|
|
||||||
position--;
|
|
||||||
} else {
|
|
||||||
position = count - 1;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case MenuStyleCompact:
|
case MenuStyleCompact:
|
||||||
if(position > 0) {
|
if(position > 0) {
|
||||||
position--;
|
position--;
|
||||||
} else {
|
} else {
|
||||||
position = count - 1;
|
position = count - 1;
|
||||||
}
|
}
|
||||||
|
vertical_offset = CLAMP(MAX((int)position - 4, 0), MAX((int)count - 8, 0), 0);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@@ -703,18 +681,13 @@ static void menu_process_down(Menu* menu) {
|
|||||||
vertical_offset = CLAMP(MAX((int)position - 4, 0), MAX((int)count - 8, 0), 0);
|
vertical_offset = CLAMP(MAX((int)position - 4, 0), MAX((int)count - 8, 0), 0);
|
||||||
break;
|
break;
|
||||||
case MenuStyleC64:
|
case MenuStyleC64:
|
||||||
if(position < count - 1) {
|
|
||||||
position++;
|
|
||||||
} else {
|
|
||||||
position = 0;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case MenuStyleCompact:
|
case MenuStyleCompact:
|
||||||
if(position < count - 1) {
|
if(position < count - 1) {
|
||||||
position++;
|
position++;
|
||||||
} else {
|
} else {
|
||||||
position = 0;
|
position = 0;
|
||||||
}
|
}
|
||||||
|
vertical_offset = CLAMP(MAX((int)position - 4, 0), MAX((int)count - 8, 0), 0);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@@ -765,16 +738,18 @@ static void menu_process_left(Menu* menu) {
|
|||||||
case MenuStyleC64:
|
case MenuStyleC64:
|
||||||
if((position % 10) < 5) {
|
if((position % 10) < 5) {
|
||||||
position = position + 5;
|
position = position + 5;
|
||||||
} else if((position % 10) >= 5) {
|
} else {
|
||||||
position = position - 5;
|
position = position - 5;
|
||||||
}
|
}
|
||||||
|
vertical_offset = CLAMP(MAX((int)position - 4, 0), MAX((int)count - 8, 0), 0);
|
||||||
break;
|
break;
|
||||||
case MenuStyleCompact:
|
case MenuStyleCompact:
|
||||||
if((position % 16) < 8) {
|
if((position % 14) < 7) {
|
||||||
position = position + 7;
|
position = position + 7;
|
||||||
} else if((position % 16) >= 8) {
|
} else {
|
||||||
position = position - 7;
|
position = position - 7;
|
||||||
}
|
}
|
||||||
|
vertical_offset = CLAMP(MAX((int)position - 4, 0), MAX((int)count - 8, 0), 0);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@@ -828,18 +803,20 @@ static void menu_process_right(Menu* menu) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MenuStyleC64:
|
case MenuStyleC64:
|
||||||
if(position >= (count - count) && (position % 10) < 5) {
|
if((position % 10) < 5) {
|
||||||
position = position + 5;
|
position = position + 5;
|
||||||
} else if((position % 10) >= 5 && position < count) {
|
} else {
|
||||||
position = position - 5;
|
position = position - 5;
|
||||||
}
|
}
|
||||||
|
vertical_offset = CLAMP(MAX((int)position - 4, 0), MAX((int)count - 8, 0), 0);
|
||||||
break;
|
break;
|
||||||
case MenuStyleCompact:
|
case MenuStyleCompact:
|
||||||
if(position >= (count - count) && (position % 16) < 8) {
|
if((position % 14) < 7) {
|
||||||
position = position + 7;
|
position = position + 7;
|
||||||
} else if((position % 16) >= 8 && position < count) {
|
} else {
|
||||||
position = position - 7;
|
position = position - 7;
|
||||||
}
|
}
|
||||||
|
vertical_offset = CLAMP(MAX((int)position - 4, 0), MAX((int)count - 8, 0), 0);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@@ -865,4 +842,4 @@ static void menu_process_ok(Menu* menu) {
|
|||||||
if(item && item->callback) {
|
if(item && item->callback) {
|
||||||
item->callback(item->callback_context, item->index);
|
item->callback(item->callback_context, item->index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user