AModule::getScrollDir: convert if-else chain into switch statement

This commit is contained in:
Patrick Hilhorst 2019-06-17 20:37:37 +02:00
parent 7c85aec8e0
commit 86d6668ed4
No known key found for this signature in database
GPG Key ID: 589BB0A8DAFEF2B2

View File

@ -53,15 +53,12 @@ bool AModule::handleToggle(GdkEventButton* const& e) {
} }
AModule::SCROLL_DIR AModule::getScrollDir(GdkEventScroll* e) { AModule::SCROLL_DIR AModule::getScrollDir(GdkEventScroll* e) {
if (e->direction == GDK_SCROLL_UP) { switch (e -> direction) {
return SCROLL_DIR::UP; case GDK_SCROLL_UP: return SCROLL_DIR::UP;
} else if (e->direction == GDK_SCROLL_DOWN) { case GDK_SCROLL_DOWN: return SCROLL_DIR::DOWN;
return SCROLL_DIR::DOWN; case GDK_SCROLL_LEFT: return SCROLL_DIR::LEFT;
} else if (e->direction == GDK_SCROLL_LEFT) { case GDK_SCROLL_RIGHT: return SCROLL_DIR::RIGHT;
return SCROLL_DIR::LEFT; case GDK_SCROLL_SMOOTH: {
} else if (e->direction == GDK_SCROLL_RIGHT) {
return SCROLL_DIR::RIGHT;
} else if (e->direction == GDK_SCROLL_SMOOTH) {
SCROLL_DIR dir{SCROLL_DIR::NONE}; SCROLL_DIR dir{SCROLL_DIR::NONE};
distance_scrolled_y_ += e->delta_y; distance_scrolled_y_ += e->delta_y;
@ -89,6 +86,9 @@ AModule::SCROLL_DIR AModule::getScrollDir(GdkEventScroll* e) {
} }
return dir; return dir;
} }
// Silence -Wreturn-type:
default: return SCROLL_DIR::NONE;
}
} }
bool AModule::handleScroll(GdkEventScroll* e) { bool AModule::handleScroll(GdkEventScroll* e) {