Skip to content
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

664 Hard crash with shift+scroll in small menus #698

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/deluge/gui/context_menu/launch_style.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,10 @@ bool LaunchStyle::setupAndCheckAvailability() {

currentOption = static_cast<int32_t>(valueOption);

#if HAVE_OLED
scrollPos = currentOption;
#endif
if (display->haveOLED()) {
scrollPos = currentOption;
}

return true;
}

Expand Down
38 changes: 20 additions & 18 deletions src/deluge/gui/menu_item/enumeration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,34 @@
namespace deluge::gui::menu_item {
void Enumeration::beginSession(MenuItem* navigatedBackwardFrom) {
Value::beginSession(navigatedBackwardFrom);
#if HAVE_OLED
soundEditor.menuCurrentScroll = 0;
#else
drawValue();
#endif
if (display->haveOLED()) {
soundEditor.menuCurrentScroll = 0;
}
else {
drawValue();
}
}

void Enumeration::selectEncoderAction(int32_t offset) {
this->setValue(this->getValue() + offset);
int32_t numOptions = size();

#if HAVE_OLED
if (this->getValue() >= numOptions) {
this->setValue(numOptions - 1);
}
else if (this->getValue() < 0) {
this->setValue(0);
}
#else
if (this->getValue() >= numOptions) {
this->setValue(this->getValue() - numOptions);
if (display->haveOLED()) {
if (this->getValue() >= numOptions) {
this->setValue(numOptions - 1);
}
else if (this->getValue() < 0) {
this->setValue(0);
}
}
else if (this->getValue() < 0) {
this->setValue(this->getValue() + numOptions);
else {
if (this->getValue() >= numOptions) {
this->setValue(this->getValue() - numOptions);
}
else if (this->getValue() < 0) {
this->setValue(this->getValue() + numOptions);
}
}
#endif

Value::selectEncoderAction(offset);
}
Expand Down
2 changes: 1 addition & 1 deletion src/deluge/gui/menu_item/selection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ void Selection::drawPixelsForOled() {
if (soundEditor.menuCurrentScroll > value) {
soundEditor.menuCurrentScroll = value;
}
else if (soundEditor.menuCurrentScroll < this->getValue() - kOLEDMenuNumOptionsVisible + 1) {
else if (soundEditor.menuCurrentScroll < value - kOLEDMenuNumOptionsVisible + 1) {
soundEditor.menuCurrentScroll = value - kOLEDMenuNumOptionsVisible + 1;
}

Expand Down
58 changes: 30 additions & 28 deletions src/deluge/gui/menu_item/submenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,45 +66,47 @@ void Submenu::drawPixelsForOled() {
}

void Submenu::selectEncoderAction(int32_t offset) {

int32_t sign = (offset > 0) ? 1 : ((offset < 0) ? -1 : 0);
auto thisSubmenuItem = current_item_;

do {
if (offset >= 0) {
thisSubmenuItem++;
if (thisSubmenuItem == items.end()) {
if (display->haveOLED()) {
return;
}
else {
for (size_t i = 0; i < std::abs(offset); ++i) {
do {
if (offset >= 0) {
thisSubmenuItem++;
if (thisSubmenuItem >= items.end()) {
if (display->haveOLED()) {
updateDisplay();
return;
}
// 7SEG wraps
thisSubmenuItem = items.begin();
}
}
}
else {
if (thisSubmenuItem == items.begin()) {
if (display->haveOLED()) {
return;
else {
if (thisSubmenuItem <= items.begin()) {
if (display->haveOLED()) {
updateDisplay();
return;
}
// 7SEG wraps
thisSubmenuItem = (items.end() - 1);
}
else {
thisSubmenuItem = (items.end() - 1);
thisSubmenuItem--;
}
}
else {
thisSubmenuItem--;
}
}
} while (!(*thisSubmenuItem)->isRelevant(soundEditor.currentSound, soundEditor.currentSourceIndex));
} while (!(*thisSubmenuItem)->isRelevant(soundEditor.currentSound, soundEditor.currentSourceIndex));

current_item_ = thisSubmenuItem;
current_item_ = thisSubmenuItem;

if (display->haveOLED()) {
soundEditor.menuCurrentScroll += offset;
if (soundEditor.menuCurrentScroll < 0) {
soundEditor.menuCurrentScroll = 0;
}
else if (soundEditor.menuCurrentScroll > kOLEDMenuNumOptionsVisible - 1) {
soundEditor.menuCurrentScroll = kOLEDMenuNumOptionsVisible - 1;
if (display->haveOLED()) {
soundEditor.menuCurrentScroll += sign;
if (soundEditor.menuCurrentScroll < 0) {
soundEditor.menuCurrentScroll = 0;
}
else if (soundEditor.menuCurrentScroll > kOLEDMenuNumOptionsVisible - 1) {
soundEditor.menuCurrentScroll = kOLEDMenuNumOptionsVisible - 1;
}
}
}

Expand Down