mirror of
https://github.com/clangen/musikcube.git
synced 2025-03-14 13:21:13 +00:00
Fixed a bug in SimpleScrollAdapter "selectable" mode.
This commit is contained in:
parent
c8d3bd1692
commit
174e0dfbce
@ -1,3 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
#define VERSION "0.3.0"
|
||||
#define VERSION "0.3.1"
|
||||
|
@ -60,12 +60,12 @@ namespace cursespp {
|
||||
};
|
||||
|
||||
class IEntry {
|
||||
public:
|
||||
virtual ~IEntry() { }
|
||||
virtual size_t GetLineCount() = 0;
|
||||
virtual std::string GetLine(size_t line) = 0;
|
||||
virtual void SetWidth(size_t width) = 0;
|
||||
virtual int64 GetAttrs(size_t line) = 0;
|
||||
public:
|
||||
virtual ~IEntry() { }
|
||||
virtual size_t GetLineCount() = 0;
|
||||
virtual std::string GetLine(size_t line) = 0;
|
||||
virtual void SetWidth(size_t width) = 0;
|
||||
virtual int64 GetAttrs(size_t line) = 0;
|
||||
};
|
||||
|
||||
typedef std::shared_ptr<IEntry> EntryPtr;
|
||||
|
@ -58,7 +58,7 @@ int64 MultiLineEntry::GetAttrs(size_t line) {
|
||||
}
|
||||
|
||||
void MultiLineEntry::SetWidth(size_t width) {
|
||||
if (this->width != width) {
|
||||
if (this->width != width && width > 0) {
|
||||
this->width = width;
|
||||
this->lines = text::BreakLines(this->value, this->width);
|
||||
}
|
||||
|
@ -76,12 +76,15 @@ void SimpleScrollAdapter::SetMaxEntries(size_t maxEntries) {
|
||||
EntryPtr SimpleScrollAdapter::GetEntry(cursespp::ScrollableWindow* window, size_t index) {
|
||||
auto entry = this->entries.at(index);
|
||||
|
||||
SingleLineEntry* styleable = static_cast<SingleLineEntry*>(entry.get());
|
||||
styleable->SetAttrs(-1LL);
|
||||
/* this is pretty damned gross, but super convenient. */
|
||||
if (window && selectable) {
|
||||
SingleLineEntry* single = dynamic_cast<SingleLineEntry*>(entry.get());
|
||||
if (single) {
|
||||
single->SetAttrs(-1LL);
|
||||
|
||||
if (window && this->selectable) {
|
||||
if (index == window->GetScrollPosition().logicalIndex) {
|
||||
styleable->SetAttrs(COLOR_PAIR(CURSESPP_HIGHLIGHTED_LIST_ITEM));
|
||||
if (index == window->GetScrollPosition().logicalIndex) {
|
||||
single->SetAttrs(COLOR_PAIR(CURSESPP_HIGHLIGHTED_LIST_ITEM));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user