mirror of
https://github.com/jhbruhn/eurorack.git
synced 2025-03-15 02:55:49 +00:00
Fix bug when items are not visible on boot
This commit is contained in:
parent
2f6d9b6d03
commit
9ddd099604
3 changed files with 12 additions and 6 deletions
|
@ -5,6 +5,11 @@ const int kMenuItemHeight = 12;
|
|||
|
||||
void Menu::render(U8G2* u8g2_, uint8_t xStart, uint8_t yStart, uint8_t width, uint8_t height)
|
||||
{
|
||||
if (this->visibility_dirty) {
|
||||
this->update_visible_items();
|
||||
this->visibility_dirty = false;
|
||||
}
|
||||
|
||||
this->width = width;
|
||||
this->height = height;
|
||||
|
||||
|
@ -61,7 +66,6 @@ void Menu::update_visible_items()
|
|||
}
|
||||
this->visibleItems[this->visibleItemCount++] = this->items[i];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// if our visibleitem changed, chances are that the index of the selected item has changed:
|
||||
|
@ -94,7 +98,7 @@ void Menu::up()
|
|||
this->currentVisibleScrollStart = 0;
|
||||
}
|
||||
}
|
||||
this->update_visible_items();
|
||||
this->visibility_dirty = true;
|
||||
}
|
||||
|
||||
void Menu::down()
|
||||
|
@ -113,7 +117,7 @@ void Menu::down()
|
|||
this->selectedVisibleItem++;
|
||||
}
|
||||
}
|
||||
this->update_visible_items();
|
||||
this->visibility_dirty = true;
|
||||
}
|
||||
|
||||
bool Menu::enter()
|
||||
|
|
|
@ -15,6 +15,7 @@ class Menu {
|
|||
uint8_t selectedVisibleItem;
|
||||
uint8_t currentVisibleScrollStart; // index we start rendering the menu from (for scrolling)
|
||||
int8_t currentEditingVisibleItem;
|
||||
bool visibility_dirty;
|
||||
|
||||
uint8_t width, height;
|
||||
|
||||
|
@ -25,6 +26,7 @@ class Menu {
|
|||
: selectedVisibleItem(0)
|
||||
, currentVisibleScrollStart(0)
|
||||
, currentEditingVisibleItem(-1)
|
||||
, visibility_dirty(true)
|
||||
, width(10)
|
||||
, height(10) {};
|
||||
|
||||
|
@ -37,7 +39,7 @@ class Menu {
|
|||
if (itemCount < MAXIMUM_MENU_ITEM_COUNT) {
|
||||
items[itemCount++] = item;
|
||||
}
|
||||
this->update_visible_items();
|
||||
this->visibility_dirty = true;
|
||||
}
|
||||
|
||||
void render(U8G2* u8g2_, uint8_t x, uint8_t y, uint8_t width, uint8_t height);
|
||||
|
|
|
@ -31,12 +31,12 @@ PartMenu::PartMenu(Part* _part)
|
|||
{
|
||||
this->menu.add_item(&this->item_voice_count);
|
||||
this->menu.add_item(&this->item_voice_detail);
|
||||
this->menu.add_item(&this->item_midi_filter_enabled);
|
||||
this->menu.add_item(&this->item_midi_channel);
|
||||
this->menu.add_item(&this->item_midi_input);
|
||||
this->menu.add_item(&this->item_midi_lowest_note);
|
||||
this->menu.add_item(&this->item_midi_highest_note);
|
||||
this->menu.add_item(&this->item_midi_thru_mode);
|
||||
this->menu.add_item(&this->item_midi_filter_enabled);
|
||||
}
|
||||
|
||||
void PartMenu::up()
|
||||
|
|
Loading…
Reference in a new issue