mirror of
https://github.com/clangen/musikcube.git
synced 2025-03-14 04:18:36 +00:00
Use a stack to remember previously selected directories in the settings
layout. Updated CHANGELOG accordingly.
This commit is contained in:
parent
45f6795ccf
commit
54f1097789
@ -11,6 +11,8 @@ user-facing:
|
||||
places if the window or view is resized
|
||||
* added localization support for "dimensions". this allows for per-locale sizing
|
||||
of ui components
|
||||
* directory browser now remembers which directories were previously selected,
|
||||
making up navigation in the settings view smoother
|
||||
* added a "list_header_highlighted_background" and
|
||||
"list_header_highlighted_foreground" color theme variables
|
||||
* tweaked the win32 icon so it looks a bit better on the taskbar
|
||||
|
@ -459,9 +459,12 @@ void SettingsLayout::RemoveSelectedDirectory() {
|
||||
}
|
||||
|
||||
void SettingsLayout::DrillIntoSelectedDirectory() {
|
||||
this->browseAdapter->Select(this->browseList->GetSelectedIndex());
|
||||
this->browseList->SetSelectedIndex(0);
|
||||
size_t selectIndexAt = this->browseAdapter->Select(
|
||||
this->browseList.get(), this->browseList->GetSelectedIndex());
|
||||
|
||||
this->browseList->OnAdapterChanged();
|
||||
this->browseList->SetSelectedIndex(selectIndexAt);
|
||||
this->browseList->ScrollTo(selectIndexAt);
|
||||
}
|
||||
|
||||
bool SettingsLayout::KeyPress(const std::string& key) {
|
||||
|
@ -98,12 +98,20 @@ DirectoryAdapter::~DirectoryAdapter() {
|
||||
|
||||
}
|
||||
|
||||
void DirectoryAdapter::Select(size_t index) {
|
||||
size_t DirectoryAdapter::Select(cursespp::ListWindow* window, size_t index) {
|
||||
bool hasParent = dir.has_parent_path();
|
||||
size_t selectedIndex = 0;
|
||||
|
||||
if (hasParent && index == 0) {
|
||||
if (selectedIndexStack.size()) {
|
||||
selectedIndex = this->selectedIndexStack.top();
|
||||
this->selectedIndexStack.pop();
|
||||
}
|
||||
|
||||
this->dir = this->dir.parent_path();
|
||||
}
|
||||
else {
|
||||
selectedIndexStack.push(window->GetSelectedIndex());
|
||||
dir /= this->subdirs[hasParent ? index - 1 : index];
|
||||
}
|
||||
|
||||
@ -114,12 +122,14 @@ void DirectoryAdapter::Select(size_t index) {
|
||||
{
|
||||
dir = path();
|
||||
buildDriveList(subdirs);
|
||||
return;
|
||||
return selectedIndex;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
buildDirectoryList(dir, subdirs, showDotfiles);
|
||||
|
||||
return selectedIndex;
|
||||
}
|
||||
|
||||
std::string DirectoryAdapter::GetFullPathAt(size_t index) {
|
||||
|
@ -35,8 +35,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <cursespp/ScrollAdapterBase.h>
|
||||
#include <cursespp/ListWindow.h>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <vector>
|
||||
#include <stack>
|
||||
|
||||
namespace musik {
|
||||
namespace box {
|
||||
@ -48,7 +50,7 @@ namespace musik {
|
||||
virtual size_t GetEntryCount();
|
||||
virtual EntryPtr GetEntry(cursespp::ScrollableWindow* window, size_t index);
|
||||
|
||||
void Select(size_t index);
|
||||
size_t Select(cursespp::ListWindow* window, size_t index);
|
||||
std::string GetFullPathAt(size_t index);
|
||||
|
||||
void SetDotfilesVisible(bool visible);
|
||||
@ -56,6 +58,7 @@ namespace musik {
|
||||
private:
|
||||
boost::filesystem::path dir;
|
||||
std::vector<std::string> subdirs;
|
||||
std::stack<size_t> selectedIndexStack;
|
||||
bool showDotfiles;
|
||||
};
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user