fix: kernel and desktop bug fixes
This commit is contained in:
@@ -58,10 +58,21 @@ inline int menu_row_height(const MenuRow& row) {
|
||||
}
|
||||
|
||||
inline int menu_total_height() {
|
||||
// Single-pass walk to avoid O(N^2) from menu_row_visible repeatedly
|
||||
// counting categories from the start.
|
||||
int h = 10; // top + bottom padding
|
||||
for (int i = 0; i < menu_row_count; i++)
|
||||
if (menu_row_visible(i))
|
||||
h += menu_row_height(menu_rows[i]);
|
||||
int cur_cat = -1;
|
||||
for (int i = 0; i < menu_row_count; i++) {
|
||||
const MenuRow& row = menu_rows[i];
|
||||
if (row.is_category) cur_cat++;
|
||||
bool visible = true;
|
||||
if (!row.is_category) {
|
||||
if (cur_cat >= 0 && cur_cat < MENU_NUM_CATS) {
|
||||
visible = menu_cat_expanded[cur_cat];
|
||||
}
|
||||
}
|
||||
if (visible) h += menu_row_height(row);
|
||||
}
|
||||
return h;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user