From 28d43f2111551b1f7b37c8296ba458039f6899e3 Mon Sep 17 00:00:00 2001 From: casey langen Date: Sat, 15 Jul 2017 19:53:32 -0700 Subject: [PATCH] - Added circular item focus in ShortcutsWindow. - Version bump for 0.20.1 --- CHANGELOG.txt | 6 +++ CMakeLists.txt | 2 +- src/musikbox/app/util/Version.h | 4 +- src/musikbox/cursespp/ShortcutsWindow.cpp | 45 ++++++++++++++--------- 4 files changed, 36 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index bb0caadca..6e9473916 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,3 +1,9 @@ +0.21.1 + +* arrow keys can now select items in the shortcuts window while focused. + +-------------------------------------------------------------------------------- + 0.20.0 * added play queue "hot-swap". you can now swap a different list of tracks diff --git a/CMakeLists.txt b/CMakeLists.txt index 365f920c4..53c14e8a6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,7 +8,7 @@ cmake_minimum_required(VERSION 3.0) project(musikbox) set (musikbox_VERSION_MAJOR 0) set (musikbox_VERSION_MINOR 20) -set (musikbox_VERSION_PATCH 0) +set (musikbox_VERSION_PATCH 1) set (musikbox_VERSION "${musikbox_VERSION_MAJOR}.${musikbox_VERSION_MINOR}.${musikbox_VERSION_PATCH}") include(CMakeToolsHelpers OPTIONAL) diff --git a/src/musikbox/app/util/Version.h b/src/musikbox/app/util/Version.h index 590844002..ffa4a15f5 100644 --- a/src/musikbox/app/util/Version.h +++ b/src/musikbox/app/util/Version.h @@ -2,5 +2,5 @@ #define VERSION_MAJOR 0 #define VERSION_MINOR 20 -#define VERSION_PATCH 0 -#define VERSION "0.20.0" +#define VERSION_PATCH 1 +#define VERSION "0.20.1" diff --git a/src/musikbox/cursespp/ShortcutsWindow.cpp b/src/musikbox/cursespp/ShortcutsWindow.cpp index 71eea5252..c4df2f8b8 100755 --- a/src/musikbox/cursespp/ShortcutsWindow.cpp +++ b/src/musikbox/cursespp/ShortcutsWindow.cpp @@ -107,29 +107,38 @@ void ShortcutsWindow::SetChangedCallback(ChangedCallback callback) { bool ShortcutsWindow::KeyPress(const std::string& key) { if (this->changedCallback && this->IsFocused()) { - if (key == "KEY_RIGHT") { - int active = getActiveIndex(); - if (active >= 0 && active + 1 < (int) this->entries.size()) { - this->activeKey = this->entries[active + 1]->key; + int count = (int) this->entries.size(); + if (count > 0) { + if (key == "KEY_RIGHT") { + int active = getActiveIndex(); + if (active >= 0 && active + 1 < count) { + this->activeKey = this->entries[active + 1]->key; + } + else { + this->activeKey = this->entries[0]->key; + } this->Redraw(); + return true; } - return true; - } - else if (key == "KEY_LEFT") { - int active = getActiveIndex(); - if (active > 0) { - this->activeKey = this->entries[active - 1]->key; + else if (key == "KEY_LEFT") { + int active = getActiveIndex(); + if (active > 0) { + this->activeKey = this->entries[active - 1]->key; + } + else { + this->activeKey = this->entries[count - 1]->key; + } this->Redraw(); + return true; } - return true; - } - else if (key == "KEY_ENTER") { - /* replace the original key we cached when we were forcused originally - to "commit" the operation, as it'll be swapped back when we lose focus */ - this->originalKey = this->activeKey; + else if (key == "KEY_ENTER") { + /* replace the original key we cached when we were forcused originally + to "commit" the operation, as it'll be swapped back when we lose focus */ + this->originalKey = this->activeKey; - if (this->changedCallback) { - this->changedCallback(this->activeKey); + if (this->changedCallback) { + this->changedCallback(this->activeKey); + } } } }