From c5656906aef790c0879b2aa4089f12d40c935fbe Mon Sep 17 00:00:00 2001 From: casey Date: Fri, 1 Jul 2016 15:10:47 -0700 Subject: [PATCH] Cleaned up Colors.h and made them more symbol and reusable. --- src/musikbox/app/layout/BrowseLayout.cpp | 4 ++ src/musikbox/app/layout/ConsoleLayout.cpp | 1 - src/musikbox/app/layout/IndexerLayout.cpp | 6 +-- src/musikbox/app/layout/SearchLayout.cpp | 6 ++- src/musikbox/app/layout/TrackSearchLayout.cpp | 6 ++- src/musikbox/app/window/CategoryListView.cpp | 23 +++++++++-- src/musikbox/app/window/CategoryListView.h | 1 + src/musikbox/app/window/LogWindow.cpp | 8 ++-- src/musikbox/app/window/OutputWindow.cpp | 1 - src/musikbox/app/window/TrackListView.cpp | 7 ++-- src/musikbox/app/window/TransportWindow.cpp | 14 +++---- src/musikbox/cursespp/Checkbox.cpp | 2 +- src/musikbox/cursespp/Colors.cpp | 39 ++++++++++++------- src/musikbox/cursespp/Colors.h | 32 ++++++++------- src/musikbox/cursespp/LayoutBase.cpp | 4 +- src/musikbox/cursespp/Window.cpp | 9 +++-- 16 files changed, 98 insertions(+), 65 deletions(-) diff --git a/src/musikbox/app/layout/BrowseLayout.cpp b/src/musikbox/app/layout/BrowseLayout.cpp index 3f8b556dd..663b6a97b 100755 --- a/src/musikbox/app/layout/BrowseLayout.cpp +++ b/src/musikbox/app/layout/BrowseLayout.cpp @@ -171,6 +171,10 @@ bool BrowseLayout::KeyPress(const std::string& key) { this->categoryList->SetFieldName(constants::Track::GENRE); return true; } + else if (key == "M-m") { + this->categoryList->ScrollToPlaying(); + return true; + } return LayoutBase::KeyPress(key); } diff --git a/src/musikbox/app/layout/ConsoleLayout.cpp b/src/musikbox/app/layout/ConsoleLayout.cpp index 933aa1784..97d05dd63 100755 --- a/src/musikbox/app/layout/ConsoleLayout.cpp +++ b/src/musikbox/app/layout/ConsoleLayout.cpp @@ -72,7 +72,6 @@ ConsoleLayout::ConsoleLayout(ITransport& transport, LibraryPtr library) this->AddWindow(this->output); this->AddWindow(this->resources); - this->commands->SetContentColor(CURSESPP_WHITE_ON_TRANSPARENT); this->commands->EnterPressed.connect(this, &ConsoleLayout::OnEnterPressed); this->Help(); diff --git a/src/musikbox/app/layout/IndexerLayout.cpp b/src/musikbox/app/layout/IndexerLayout.cpp index f100439ea..f8f79fc78 100755 --- a/src/musikbox/app/layout/IndexerLayout.cpp +++ b/src/musikbox/app/layout/IndexerLayout.cpp @@ -136,15 +136,13 @@ int64 IndexerLayout::ListItemDecorator( { ListWindow* lw = static_cast(scrollable); if (lw->GetSelectedIndex() == index) { - return COLOR_PAIR(CURSESPP_BLACK_ON_GREEN); + return COLOR_PAIR(CURSESPP_HIGHLIGHTED_LIST_ITEM); } } return -1; } void IndexerLayout::InitializeWindows() { - this->SetContentColor(CURSESPP_WHITE_ON_TRANSPARENT); - this->title.reset(new TextLabel()); this->title->SetText("settings", TextLabel::AlignCenter); @@ -155,9 +153,7 @@ void IndexerLayout::InitializeWindows() { this->addedPathsLabel->SetText("indexed paths (BACKSPACE to remove)", TextLabel::AlignLeft); this->addedPathsList.reset(new cursespp::ListWindow(&this->addedPathsAdapter)); - this->addedPathsList->SetContentColor(CURSESPP_WHITE_ON_TRANSPARENT); this->browseList.reset(new cursespp::ListWindow(&this->browseAdapter)); - this->browseList->SetContentColor(CURSESPP_WHITE_ON_TRANSPARENT); ScrollAdapterBase::ItemDecorator decorator = std::bind( diff --git a/src/musikbox/app/layout/SearchLayout.cpp b/src/musikbox/app/layout/SearchLayout.cpp index 2a14fc6ef..1c58a6e35 100755 --- a/src/musikbox/app/layout/SearchLayout.cpp +++ b/src/musikbox/app/layout/SearchLayout.cpp @@ -105,7 +105,6 @@ void SearchLayout::Layout() { void SearchLayout::InitializeWindows(PlaybackService& playback) { this->input.reset(new cursespp::TextInput()); this->input->TextChanged.connect(this, &SearchLayout::OnInputChanged); - this->input->SetContentColor(CURSESPP_WHITE_ON_TRANSPARENT); this->input->SetFocusOrder(0); this->AddWindow(this->input); @@ -128,7 +127,9 @@ void SearchLayout::Requery() { } void SearchLayout::OnInputChanged(cursespp::TextInput* sender, std::string value) { - this->Requery(); + if (this->IsVisible()) { + this->Requery(); + } } void SearchLayout::OnVisibilityChanged(bool visible) { @@ -139,6 +140,7 @@ void SearchLayout::OnVisibilityChanged(bool visible) { this->Requery(); } else { + this->input->SetText(""); this->albums->Reset(); this->artists->Reset(); this->genres->Reset(); diff --git a/src/musikbox/app/layout/TrackSearchLayout.cpp b/src/musikbox/app/layout/TrackSearchLayout.cpp index dff21a740..d140c591a 100755 --- a/src/musikbox/app/layout/TrackSearchLayout.cpp +++ b/src/musikbox/app/layout/TrackSearchLayout.cpp @@ -93,7 +93,6 @@ void TrackSearchLayout::Layout() { void TrackSearchLayout::InitializeWindows() { this->input.reset(new cursespp::TextInput()); this->input->TextChanged.connect(this, &TrackSearchLayout::OnInputChanged); - this->input->SetContentColor(CURSESPP_WHITE_ON_TRANSPARENT); this->input->SetFocusOrder(0); this->AddWindow(this->input); @@ -112,6 +111,7 @@ void TrackSearchLayout::OnVisibilityChanged(bool visible) { this->Requery(); } else { + this->input->SetText(""); this->trackList->Clear(); } } @@ -131,7 +131,9 @@ void TrackSearchLayout::ProcessMessage(IMessage &message) { } void TrackSearchLayout::OnInputChanged(cursespp::TextInput* sender, std::string value) { - DEBOUNCE_REQUERY(REQUERY_INTERVAL_MS); + if (this->IsVisible()) { + DEBOUNCE_REQUERY(REQUERY_INTERVAL_MS); + } } bool TrackSearchLayout::KeyPress(const std::string& key) { diff --git a/src/musikbox/app/window/CategoryListView.cpp b/src/musikbox/app/window/CategoryListView.cpp index 444a14cf7..d57683167 100755 --- a/src/musikbox/app/window/CategoryListView.cpp +++ b/src/musikbox/app/window/CategoryListView.cpp @@ -62,7 +62,6 @@ CategoryListView::CategoryListView( const std::string& fieldName) : ListWindow(NULL) , playback(playback) { - this->SetContentColor(CURSESPP_WHITE_ON_TRANSPARENT); this->selectAfterQuery = 0; this->library = library; this->library->QueryCompleted.connect(this, &CategoryListView::OnQueryCompleted); @@ -129,12 +128,30 @@ void CategoryListView::SetFieldName(const std::string& fieldName) { if (this->metadata) { this->metadata.reset(); + this->ScrollToTop(); } this->Requery(); } } +void CategoryListView::ScrollToPlaying() { + if (this->playing) { + std::string value = this->playing->GetValue(this->fieldName.c_str()); + if (value.size()) { + /* binary search would be better, but need to research if sqlite + properly sorts utf8 strings. */ + for (size_t i = 0; i < this->metadata->size(); i++) { + if (this->metadata->at(i)->displayValue == value) { + this->SetSelectedIndex(i); + this->ScrollTo(i); + break; + } + } + } + } +} + void CategoryListView::OnQueryCompleted(IQueryPtr query) { boost::mutex::scoped_lock lock(this->queryMutex); @@ -207,11 +224,11 @@ IScrollAdapter::EntryPtr CategoryListView::Adapter::GetEntry(size_t index) { bool selected = index == parent.GetSelectedIndex(); - int64 attrs = selected ? COLOR_PAIR(CURSESPP_BLACK_ON_GREEN) : -1LL; + int64 attrs = selected ? COLOR_PAIR(CURSESPP_HIGHLIGHTED_LIST_ITEM) : -1LL; if (playing) { if (selected) { - attrs = COLOR_PAIR(CURSESPP_BLACK_ON_YELLOW); + attrs = COLOR_PAIR(CURSESPP_HIGHLIGHTED_SELECTED_LIST_ITEM); } else { attrs = COLOR_PAIR(CURSESPP_SELECTED_LIST_ITEM) | A_BOLD; diff --git a/src/musikbox/app/window/CategoryListView.h b/src/musikbox/app/window/CategoryListView.h index 162e45def..73053295c 100755 --- a/src/musikbox/app/window/CategoryListView.h +++ b/src/musikbox/app/window/CategoryListView.h @@ -86,6 +86,7 @@ namespace musik { DBID GetSelectedId(); std::string GetFieldName(); void SetFieldName(const std::string& fieldName); + void ScrollToPlaying(); protected: virtual IScrollAdapter& GetScrollAdapter(); diff --git a/src/musikbox/app/window/LogWindow.cpp b/src/musikbox/app/window/LogWindow.cpp index c5abd1371..fefe0943e 100755 --- a/src/musikbox/app/window/LogWindow.cpp +++ b/src/musikbox/app/window/LogWindow.cpp @@ -47,8 +47,6 @@ typedef IScrollAdapter::IEntry IEntry; LogWindow::LogWindow(IWindow *parent) : ScrollableWindow(parent) { - this->SetContentColor(CURSESPP_WHITE_ON_TRANSPARENT); - this->adapter = new SimpleScrollAdapter(); this->adapter->SetMaxEntries(500); @@ -78,18 +76,18 @@ void LogWindow::Update() { WINDOW* contents = this->GetContent(); for (size_t i = 0; i < pending.size(); i++) { - int64 attrs = COLOR_PAIR(CURSESPP_WHITE_ON_TRANSPARENT); + int64 attrs = COLOR_PAIR(CURSESPP_TEXT_DEFAULT); LogEntry* entry = pending[i]; switch (entry->level) { case musik::debug::level_error: { - attrs = COLOR_PAIR(CURSESPP_RED_ON_TRANSPARENT) | A_BOLD; + attrs = COLOR_PAIR(CURSESPP_TEXT_ERROR) | A_BOLD; break; } case musik::debug::level_warning: { - attrs = COLOR_PAIR(CURSESPP_YELLOW_ON_TRANSPARENT) | A_BOLD; + attrs = COLOR_PAIR(CURSESPP_TEXT_WARNING) | A_BOLD; break; } } diff --git a/src/musikbox/app/window/OutputWindow.cpp b/src/musikbox/app/window/OutputWindow.cpp index 3c5d17315..735bb7e23 100755 --- a/src/musikbox/app/window/OutputWindow.cpp +++ b/src/musikbox/app/window/OutputWindow.cpp @@ -47,7 +47,6 @@ typedef IScrollAdapter::EntryPtr EntryPtr; OutputWindow::OutputWindow(IWindow *parent) : ScrollableWindow(parent) { - this->SetContentColor(CURSESPP_BLACK_ON_GREY); this->adapter = new SimpleScrollAdapter(); this->adapter->SetDisplaySize(this->GetContentWidth(), this->GetContentHeight()); this->adapter->SetMaxEntries(500); diff --git a/src/musikbox/app/window/TrackListView.cpp b/src/musikbox/app/window/TrackListView.cpp index 739c6a692..c74ee5fc8 100755 --- a/src/musikbox/app/window/TrackListView.cpp +++ b/src/musikbox/app/window/TrackListView.cpp @@ -70,7 +70,6 @@ TrackListView::TrackListView( RowFormatter formatter) : ListWindow(NULL) , playback(playback) { - this->SetContentColor(CURSESPP_WHITE_ON_TRANSPARENT); this->library = library; this->library->QueryCompleted.connect(this, &TrackListView::OnQueryCompleted); this->playback.TrackChanged.connect(this, &TrackListView::OnTrackChanged); @@ -188,7 +187,7 @@ static std::string formatWithoutAlbum(TrackPtr track, size_t width) { IScrollAdapter::EntryPtr TrackListView::Adapter::GetEntry(size_t index) { bool selected = index == parent.GetSelectedIndex(); - int64 attrs = selected ? COLOR_PAIR(CURSESPP_BLACK_ON_GREEN) : -1LL; + int64 attrs = selected ? COLOR_PAIR(CURSESPP_HIGHLIGHTED_LIST_ITEM) : -1LL; TrackPtr track = parent.metadata->Get(index); @@ -198,7 +197,7 @@ IScrollAdapter::EntryPtr TrackListView::Adapter::GetEntry(size_t index) { playing->LibraryId() == track->LibraryId()) { if (selected) { - attrs = COLOR_PAIR(CURSESPP_BLACK_ON_YELLOW); + attrs = COLOR_PAIR(CURSESPP_HIGHLIGHTED_SELECTED_LIST_ITEM); } else { attrs = COLOR_PAIR(CURSESPP_SELECTED_LIST_ITEM) | A_BOLD; @@ -212,7 +211,7 @@ IScrollAdapter::EntryPtr TrackListView::Adapter::GetEntry(size_t index) { if (this->parent.headers->find(index) != this->parent.headers->end()) { std::string album = track->GetValue(constants::Track::ALBUM); std::shared_ptr entry(new EntryWithHeader(album, text)); - entry->SetAttrs(COLOR_PAIR(CURSESPP_GREEN_ON_TRANSPARENT), attrs); + entry->SetAttrs(COLOR_PAIR(CURSESPP_LIST_ITEM_HEADER), attrs); return entry; } else { diff --git a/src/musikbox/app/window/TransportWindow.cpp b/src/musikbox/app/window/TransportWindow.cpp index 374b72da5..ba86116de 100755 --- a/src/musikbox/app/window/TransportWindow.cpp +++ b/src/musikbox/app/window/TransportWindow.cpp @@ -136,7 +136,7 @@ size_t writePlayingFormat( TokenList tokens; tokenize(playingFormat, tokens); - int64 gb = COLOR_PAIR(CURSESPP_GREEN_ON_TRANSPARENT); + int64 gb = COLOR_PAIR(CURSESPP_TEXT_ACTIVE); size_t remaining = width; auto it = tokens.begin(); @@ -188,7 +188,6 @@ TransportWindow::TransportWindow(musik::box::PlaybackService& playback) , playback(playback) , transport(playback.GetTransport()) { - this->SetContentColor(CURSESPP_WHITE_ON_TRANSPARENT); this->SetFrameVisible(false); this->playback.TrackChanged.connect(this, &TransportWindow::OnPlaybackServiceTrackChanged); this->playback.ModeChanged.connect(this, &TransportWindow::OnPlaybackModeChanged); @@ -249,7 +248,8 @@ void TransportWindow::Update() { bool paused = (transport.GetPlaybackState() == ITransport::PlaybackPaused); bool stopped = (transport.GetPlaybackState() == ITransport::PlaybackStopped); - int64 gb = COLOR_PAIR(CURSESPP_GREEN_ON_TRANSPARENT); + int64 gb = COLOR_PAIR(CURSESPP_TEXT_ACTIVE); + int64 disabled = COLOR_PAIR(CURSESPP_TEXT_DISABLED); /* prepare the "shuffle" label */ @@ -261,9 +261,9 @@ void TransportWindow::Update() { std::string duration = "0"; if (stopped) { - wattron(c, A_DIM); + ON(c, disabled); wprintw(c, "playback is stopped"); - wattroff(c, A_DIM); + OFF(c, disabled); } else { std::string title, album; @@ -286,7 +286,7 @@ void TransportWindow::Update() { } wmove(c, 0, cx - shuffleLabelLen); - int64 shuffleAttrs = this->playback.IsShuffled() ? gb : A_DIM; + int64 shuffleAttrs = this->playback.IsShuffled() ? gb : disabled; ON(c, shuffleAttrs); wprintw(c, shuffleLabel.c_str()); OFF(c, shuffleAttrs); @@ -325,7 +325,7 @@ void TransportWindow::Update() { break; default: repeatModeLabel = "off"; - repeatAttrs = A_DIM; + repeatAttrs = disabled; break; } diff --git a/src/musikbox/cursespp/Checkbox.cpp b/src/musikbox/cursespp/Checkbox.cpp index ce6f0e741..6a6fa3789 100755 --- a/src/musikbox/cursespp/Checkbox.cpp +++ b/src/musikbox/cursespp/Checkbox.cpp @@ -98,7 +98,7 @@ void Checkbox::Redraw() { std::string ellipsized = symbol + " " + this->buffer; text::Ellipsize(ellipsized, cx); - int64 attrs = this->focused ? CURSESPP_RED_ON_TRANSPARENT : -1LL; + int64 attrs = this->focused ? CURSESPP_TEXT_FOCUSED : -1LL; if (attrs != -1) { wattron(c, COLOR_PAIR(attrs)); diff --git a/src/musikbox/cursespp/Colors.cpp b/src/musikbox/cursespp/Colors.cpp index 1da97a08f..4137f7da1 100755 --- a/src/musikbox/cursespp/Colors.cpp +++ b/src/musikbox/cursespp/Colors.cpp @@ -44,17 +44,19 @@ static int yellow = COLOR_YELLOW; static int green = COLOR_GREEN; static int black = COLOR_BLACK; - #define COLOR_CUSTOM_WHITE 16 #define COLOR_CUSTOM_BLUE 17 #define COLOR_CUSTOM_RED 18 #define COLOR_CUSTOM_YELLOW 19 #define COLOR_CUSTOM_GREEN 20 #define COLOR_CUSTOM_BLACK 21 -#define COLOR_SELECTED_LIST_ITEM_BG 22 +#define COLOR_CUSTOM_GREY 22 +#define COLOR_CUSTOM_SELECTED_LIST_ITEM_BG 23 +static int foreground = COLOR_WHITE; static int background = -1; static int selected = -1; +static int grey = COLOR_WHITE; #define SCALE(x) ((x * 1000) / 255) @@ -77,21 +79,28 @@ void Colors::Init() { red = initColor(COLOR_CUSTOM_RED, 220, 82, 86); green = initColor(COLOR_CUSTOM_GREEN, 166, 226, 46); yellow = initColor(COLOR_CUSTOM_YELLOW, 230, 220, 116); - selected = initColor(COLOR_SELECTED_LIST_ITEM_BG, 66, 66, 56); + selected = initColor(COLOR_CUSTOM_SELECTED_LIST_ITEM_BG, 66, 66, 56); + grey = initColor(COLOR_CUSTOM_GREY, 128, 128, 128); } - init_pair(CURSESPP_WHITE_ON_BLUE, white, blue); - init_pair(CURSESPP_RED_ON_BLUE, red, blue); - init_pair(CURSESPP_YELLOW_ON_BLUE, yellow, blue); - init_pair(CURSESPP_BLACK_ON_GREY, black, white); - init_pair(CURSESPP_BLACK_ON_GREEN, black, green); - init_pair(CURSESPP_YELLOW_ON_TRANSPARENT, yellow, background); - init_pair(CURSESPP_WHITE_ON_TRANSPARENT, white, background); - init_pair(CURSESPP_RED_ON_TRANSPARENT, red, background); - init_pair(CURSESPP_RED_ON_GREY, red, white); - init_pair(CURSESPP_GREEN_ON_TRANSPARENT, green, background); init_pair(CURSESPP_BLACK_ON_TRANSPARENT, black, background); - init_pair(CURSESPP_RED_ON_GREEN, red, green); - init_pair(CURSESPP_BLACK_ON_YELLOW, black, yellow); + init_pair(CURSESPP_RED_ON_BLUE, red, blue); + init_pair(CURSESPP_BLACK_ON_GREY, black, white); + init_pair(CURSESPP_RED_ON_GREY, red, white); + init_pair(CURSESPP_SELECTED_LIST_ITEM, yellow, selected); + init_pair(CURSESPP_HIGHLIGHTED_LIST_ITEM, black, green); + init_pair(CURSESPP_HIGHLIGHTED_SELECTED_LIST_ITEM, black, yellow); + init_pair(CURSESPP_LIST_ITEM_HEADER, green, background); + + init_pair(CURSESPP_DEFAULT_CONTENT_COLOR, foreground, background); + init_pair(CURSESPP_DEFAULT_FRAME_COLOR, foreground, background); + init_pair(CURSESPP_FOCUSED_FRAME_COLOR, red, background); + + init_pair(CURSESPP_TEXT_DEFAULT, white, background); + init_pair(CURSESPP_TEXT_DISABLED, grey, background); + init_pair(CURSESPP_TEXT_FOCUSED, red, background); + init_pair(CURSESPP_TEXT_ACTIVE, green, background); + init_pair(CURSESPP_TEXT_WARNING, yellow, background); + init_pair(CURSESPP_TEXT_ERROR, red, background); } diff --git a/src/musikbox/cursespp/Colors.h b/src/musikbox/cursespp/Colors.h index 75b60b5aa..ec1d8186e 100755 --- a/src/musikbox/cursespp/Colors.h +++ b/src/musikbox/cursespp/Colors.h @@ -36,20 +36,26 @@ #include "curses_config.h" -#define CURSESPP_WHITE_ON_BLUE 1 +#define CURSESPP_BLACK_ON_TRANSPARENT 1 #define CURSESPP_RED_ON_BLUE 2 -#define CURSESPP_YELLOW_ON_BLUE 3 -#define CURSESPP_BLACK_ON_GREY 4 -#define CURSESPP_BLACK_ON_GREEN 5 -#define CURSESPP_YELLOW_ON_TRANSPARENT 6 -#define CURSESPP_WHITE_ON_TRANSPARENT 7 -#define CURSESPP_RED_ON_TRANSPARENT 8 -#define CURSESPP_RED_ON_GREY 9 -#define CURSESPP_GREEN_ON_TRANSPARENT 10 -#define CURSESPP_BLACK_ON_TRANSPARENT 11 -#define CURSESPP_RED_ON_GREEN 12 -#define CURSESPP_BLACK_ON_YELLOW 13 -#define CURSESPP_SELECTED_LIST_ITEM 14 +#define CURSESPP_BLACK_ON_GREY 3 +#define CURSESPP_RED_ON_GREY 4 + +#define CURSESPP_SELECTED_LIST_ITEM 5 +#define CURSESPP_HIGHLIGHTED_LIST_ITEM 6 +#define CURSESPP_HIGHLIGHTED_SELECTED_LIST_ITEM 7 +#define CURSESPP_LIST_ITEM_HEADER 8 + +#define CURSESPP_DEFAULT_CONTENT_COLOR 9 +#define CURSESPP_DEFAULT_FRAME_COLOR 10 +#define CURSESPP_FOCUSED_FRAME_COLOR 11 + +#define CURSESPP_TEXT_DEFAULT 12 +#define CURSESPP_TEXT_DISABLED 13 +#define CURSESPP_TEXT_FOCUSED 14 +#define CURSESPP_TEXT_ACTIVE 15 +#define CURSESPP_TEXT_WARNING 16 +#define CURSESPP_TEXT_ERROR 17 namespace cursespp { class Colors { diff --git a/src/musikbox/cursespp/LayoutBase.cpp b/src/musikbox/cursespp/LayoutBase.cpp index 625fe403f..5a27eed10 100755 --- a/src/musikbox/cursespp/LayoutBase.cpp +++ b/src/musikbox/cursespp/LayoutBase.cpp @@ -64,12 +64,12 @@ bool sortByFocusOrder(IWindowPtr a, IWindowPtr b) { static inline IWindowPtr adjustFocus(IWindowPtr oldFocus, IWindowPtr newFocus) { if (oldFocus) { - oldFocus->SetFrameColor(CURSESPP_WHITE_ON_TRANSPARENT); + oldFocus->SetFrameColor(CURSESPP_DEFAULT_FRAME_COLOR); oldFocus->Blur(); } if (newFocus) { - newFocus->SetFrameColor(CURSESPP_RED_ON_TRANSPARENT); + newFocus->SetFrameColor(CURSESPP_FOCUSED_FRAME_COLOR); newFocus->Focus(); } diff --git a/src/musikbox/cursespp/Window.cpp b/src/musikbox/cursespp/Window.cpp index 4c372c8a2..eb8c10309 100755 --- a/src/musikbox/cursespp/Window.cpp +++ b/src/musikbox/cursespp/Window.cpp @@ -38,6 +38,7 @@ #include "IInput.h" #include "Message.h" #include "MessageQueue.h" +#include "Colors.h" using namespace cursespp; @@ -79,8 +80,8 @@ Window::Window(IWindow *parent) { this->width = 0; this->x = 0; this->y = 0; - this->contentColor = -1; - this->frameColor = -1; + this->contentColor = CURSESPP_DEFAULT_CONTENT_COLOR; + this->frameColor = CURSESPP_DEFAULT_FRAME_COLOR; this->drawFrame = true; this->isVisible = false; this->focusOrder = -1; @@ -254,7 +255,7 @@ int Window::GetY() const { } void Window::SetContentColor(int64 color) { - this->contentColor = color; + this->contentColor = (color == -1 ? CURSESPP_DEFAULT_CONTENT_COLOR : color); if (this->contentColor != -1 && this->content) { wbkgd(this->frame, COLOR_PAIR(this->frameColor)); @@ -268,7 +269,7 @@ void Window::SetContentColor(int64 color) { } void Window::SetFrameColor(int64 color) { - this->frameColor = color; + this->frameColor = (color == -1 ? CURSESPP_DEFAULT_FRAME_COLOR : color); if (this->drawFrame && this->frameColor != -1 && this->frame) { wbkgd(this->frame, COLOR_PAIR(this->frameColor));