Cleaned up Colors.h and made them more symbol and reusable.

This commit is contained in:
casey 2016-07-01 15:10:47 -07:00
parent b7e6099483
commit c5656906ae
16 changed files with 98 additions and 65 deletions

View File

@ -171,6 +171,10 @@ bool BrowseLayout::KeyPress(const std::string& key) {
this->categoryList->SetFieldName(constants::Track::GENRE); this->categoryList->SetFieldName(constants::Track::GENRE);
return true; return true;
} }
else if (key == "M-m") {
this->categoryList->ScrollToPlaying();
return true;
}
return LayoutBase::KeyPress(key); return LayoutBase::KeyPress(key);
} }

View File

@ -72,7 +72,6 @@ ConsoleLayout::ConsoleLayout(ITransport& transport, LibraryPtr library)
this->AddWindow(this->output); this->AddWindow(this->output);
this->AddWindow(this->resources); this->AddWindow(this->resources);
this->commands->SetContentColor(CURSESPP_WHITE_ON_TRANSPARENT);
this->commands->EnterPressed.connect(this, &ConsoleLayout::OnEnterPressed); this->commands->EnterPressed.connect(this, &ConsoleLayout::OnEnterPressed);
this->Help(); this->Help();

View File

@ -136,15 +136,13 @@ int64 IndexerLayout::ListItemDecorator(
{ {
ListWindow* lw = static_cast<ListWindow*>(scrollable); ListWindow* lw = static_cast<ListWindow*>(scrollable);
if (lw->GetSelectedIndex() == index) { if (lw->GetSelectedIndex() == index) {
return COLOR_PAIR(CURSESPP_BLACK_ON_GREEN); return COLOR_PAIR(CURSESPP_HIGHLIGHTED_LIST_ITEM);
} }
} }
return -1; return -1;
} }
void IndexerLayout::InitializeWindows() { void IndexerLayout::InitializeWindows() {
this->SetContentColor(CURSESPP_WHITE_ON_TRANSPARENT);
this->title.reset(new TextLabel()); this->title.reset(new TextLabel());
this->title->SetText("settings", TextLabel::AlignCenter); this->title->SetText("settings", TextLabel::AlignCenter);
@ -155,9 +153,7 @@ void IndexerLayout::InitializeWindows() {
this->addedPathsLabel->SetText("indexed paths (BACKSPACE to remove)", TextLabel::AlignLeft); this->addedPathsLabel->SetText("indexed paths (BACKSPACE to remove)", TextLabel::AlignLeft);
this->addedPathsList.reset(new cursespp::ListWindow(&this->addedPathsAdapter)); 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.reset(new cursespp::ListWindow(&this->browseAdapter));
this->browseList->SetContentColor(CURSESPP_WHITE_ON_TRANSPARENT);
ScrollAdapterBase::ItemDecorator decorator = ScrollAdapterBase::ItemDecorator decorator =
std::bind( std::bind(

View File

@ -105,7 +105,6 @@ void SearchLayout::Layout() {
void SearchLayout::InitializeWindows(PlaybackService& playback) { void SearchLayout::InitializeWindows(PlaybackService& playback) {
this->input.reset(new cursespp::TextInput()); this->input.reset(new cursespp::TextInput());
this->input->TextChanged.connect(this, &SearchLayout::OnInputChanged); this->input->TextChanged.connect(this, &SearchLayout::OnInputChanged);
this->input->SetContentColor(CURSESPP_WHITE_ON_TRANSPARENT);
this->input->SetFocusOrder(0); this->input->SetFocusOrder(0);
this->AddWindow(this->input); this->AddWindow(this->input);
@ -128,7 +127,9 @@ void SearchLayout::Requery() {
} }
void SearchLayout::OnInputChanged(cursespp::TextInput* sender, std::string value) { void SearchLayout::OnInputChanged(cursespp::TextInput* sender, std::string value) {
if (this->IsVisible()) {
this->Requery(); this->Requery();
}
} }
void SearchLayout::OnVisibilityChanged(bool visible) { void SearchLayout::OnVisibilityChanged(bool visible) {
@ -139,6 +140,7 @@ void SearchLayout::OnVisibilityChanged(bool visible) {
this->Requery(); this->Requery();
} }
else { else {
this->input->SetText("");
this->albums->Reset(); this->albums->Reset();
this->artists->Reset(); this->artists->Reset();
this->genres->Reset(); this->genres->Reset();

View File

@ -93,7 +93,6 @@ void TrackSearchLayout::Layout() {
void TrackSearchLayout::InitializeWindows() { void TrackSearchLayout::InitializeWindows() {
this->input.reset(new cursespp::TextInput()); this->input.reset(new cursespp::TextInput());
this->input->TextChanged.connect(this, &TrackSearchLayout::OnInputChanged); this->input->TextChanged.connect(this, &TrackSearchLayout::OnInputChanged);
this->input->SetContentColor(CURSESPP_WHITE_ON_TRANSPARENT);
this->input->SetFocusOrder(0); this->input->SetFocusOrder(0);
this->AddWindow(this->input); this->AddWindow(this->input);
@ -112,6 +111,7 @@ void TrackSearchLayout::OnVisibilityChanged(bool visible) {
this->Requery(); this->Requery();
} }
else { else {
this->input->SetText("");
this->trackList->Clear(); this->trackList->Clear();
} }
} }
@ -131,7 +131,9 @@ void TrackSearchLayout::ProcessMessage(IMessage &message) {
} }
void TrackSearchLayout::OnInputChanged(cursespp::TextInput* sender, std::string value) { void TrackSearchLayout::OnInputChanged(cursespp::TextInput* sender, std::string value) {
if (this->IsVisible()) {
DEBOUNCE_REQUERY(REQUERY_INTERVAL_MS); DEBOUNCE_REQUERY(REQUERY_INTERVAL_MS);
}
} }
bool TrackSearchLayout::KeyPress(const std::string& key) { bool TrackSearchLayout::KeyPress(const std::string& key) {

View File

@ -62,7 +62,6 @@ CategoryListView::CategoryListView(
const std::string& fieldName) const std::string& fieldName)
: ListWindow(NULL) : ListWindow(NULL)
, playback(playback) { , playback(playback) {
this->SetContentColor(CURSESPP_WHITE_ON_TRANSPARENT);
this->selectAfterQuery = 0; this->selectAfterQuery = 0;
this->library = library; this->library = library;
this->library->QueryCompleted.connect(this, &CategoryListView::OnQueryCompleted); this->library->QueryCompleted.connect(this, &CategoryListView::OnQueryCompleted);
@ -129,12 +128,30 @@ void CategoryListView::SetFieldName(const std::string& fieldName) {
if (this->metadata) { if (this->metadata) {
this->metadata.reset(); this->metadata.reset();
this->ScrollToTop();
} }
this->Requery(); 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) { void CategoryListView::OnQueryCompleted(IQueryPtr query) {
boost::mutex::scoped_lock lock(this->queryMutex); boost::mutex::scoped_lock lock(this->queryMutex);
@ -207,11 +224,11 @@ IScrollAdapter::EntryPtr CategoryListView::Adapter::GetEntry(size_t index) {
bool selected = index == parent.GetSelectedIndex(); 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 (playing) {
if (selected) { if (selected) {
attrs = COLOR_PAIR(CURSESPP_BLACK_ON_YELLOW); attrs = COLOR_PAIR(CURSESPP_HIGHLIGHTED_SELECTED_LIST_ITEM);
} }
else { else {
attrs = COLOR_PAIR(CURSESPP_SELECTED_LIST_ITEM) | A_BOLD; attrs = COLOR_PAIR(CURSESPP_SELECTED_LIST_ITEM) | A_BOLD;

View File

@ -86,6 +86,7 @@ namespace musik {
DBID GetSelectedId(); DBID GetSelectedId();
std::string GetFieldName(); std::string GetFieldName();
void SetFieldName(const std::string& fieldName); void SetFieldName(const std::string& fieldName);
void ScrollToPlaying();
protected: protected:
virtual IScrollAdapter& GetScrollAdapter(); virtual IScrollAdapter& GetScrollAdapter();

View File

@ -47,8 +47,6 @@ typedef IScrollAdapter::IEntry IEntry;
LogWindow::LogWindow(IWindow *parent) LogWindow::LogWindow(IWindow *parent)
: ScrollableWindow(parent) { : ScrollableWindow(parent) {
this->SetContentColor(CURSESPP_WHITE_ON_TRANSPARENT);
this->adapter = new SimpleScrollAdapter(); this->adapter = new SimpleScrollAdapter();
this->adapter->SetMaxEntries(500); this->adapter->SetMaxEntries(500);
@ -78,18 +76,18 @@ void LogWindow::Update() {
WINDOW* contents = this->GetContent(); WINDOW* contents = this->GetContent();
for (size_t i = 0; i < pending.size(); i++) { 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]; LogEntry* entry = pending[i];
switch (entry->level) { switch (entry->level) {
case musik::debug::level_error: { case musik::debug::level_error: {
attrs = COLOR_PAIR(CURSESPP_RED_ON_TRANSPARENT) | A_BOLD; attrs = COLOR_PAIR(CURSESPP_TEXT_ERROR) | A_BOLD;
break; break;
} }
case musik::debug::level_warning: { case musik::debug::level_warning: {
attrs = COLOR_PAIR(CURSESPP_YELLOW_ON_TRANSPARENT) | A_BOLD; attrs = COLOR_PAIR(CURSESPP_TEXT_WARNING) | A_BOLD;
break; break;
} }
} }

View File

@ -47,7 +47,6 @@ typedef IScrollAdapter::EntryPtr EntryPtr;
OutputWindow::OutputWindow(IWindow *parent) OutputWindow::OutputWindow(IWindow *parent)
: ScrollableWindow(parent) { : ScrollableWindow(parent) {
this->SetContentColor(CURSESPP_BLACK_ON_GREY);
this->adapter = new SimpleScrollAdapter(); this->adapter = new SimpleScrollAdapter();
this->adapter->SetDisplaySize(this->GetContentWidth(), this->GetContentHeight()); this->adapter->SetDisplaySize(this->GetContentWidth(), this->GetContentHeight());
this->adapter->SetMaxEntries(500); this->adapter->SetMaxEntries(500);

View File

@ -70,7 +70,6 @@ TrackListView::TrackListView(
RowFormatter formatter) RowFormatter formatter)
: ListWindow(NULL) : ListWindow(NULL)
, playback(playback) { , playback(playback) {
this->SetContentColor(CURSESPP_WHITE_ON_TRANSPARENT);
this->library = library; this->library = library;
this->library->QueryCompleted.connect(this, &TrackListView::OnQueryCompleted); this->library->QueryCompleted.connect(this, &TrackListView::OnQueryCompleted);
this->playback.TrackChanged.connect(this, &TrackListView::OnTrackChanged); 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) { IScrollAdapter::EntryPtr TrackListView::Adapter::GetEntry(size_t index) {
bool selected = index == parent.GetSelectedIndex(); 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); TrackPtr track = parent.metadata->Get(index);
@ -198,7 +197,7 @@ IScrollAdapter::EntryPtr TrackListView::Adapter::GetEntry(size_t index) {
playing->LibraryId() == track->LibraryId()) playing->LibraryId() == track->LibraryId())
{ {
if (selected) { if (selected) {
attrs = COLOR_PAIR(CURSESPP_BLACK_ON_YELLOW); attrs = COLOR_PAIR(CURSESPP_HIGHLIGHTED_SELECTED_LIST_ITEM);
} }
else { else {
attrs = COLOR_PAIR(CURSESPP_SELECTED_LIST_ITEM) | A_BOLD; 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()) { if (this->parent.headers->find(index) != this->parent.headers->end()) {
std::string album = track->GetValue(constants::Track::ALBUM); std::string album = track->GetValue(constants::Track::ALBUM);
std::shared_ptr<EntryWithHeader> entry(new EntryWithHeader(album, text)); std::shared_ptr<EntryWithHeader> 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; return entry;
} }
else { else {

View File

@ -136,7 +136,7 @@ size_t writePlayingFormat(
TokenList tokens; TokenList tokens;
tokenize(playingFormat, tokens); tokenize(playingFormat, tokens);
int64 gb = COLOR_PAIR(CURSESPP_GREEN_ON_TRANSPARENT); int64 gb = COLOR_PAIR(CURSESPP_TEXT_ACTIVE);
size_t remaining = width; size_t remaining = width;
auto it = tokens.begin(); auto it = tokens.begin();
@ -188,7 +188,6 @@ TransportWindow::TransportWindow(musik::box::PlaybackService& playback)
, playback(playback) , playback(playback)
, transport(playback.GetTransport()) , transport(playback.GetTransport())
{ {
this->SetContentColor(CURSESPP_WHITE_ON_TRANSPARENT);
this->SetFrameVisible(false); this->SetFrameVisible(false);
this->playback.TrackChanged.connect(this, &TransportWindow::OnPlaybackServiceTrackChanged); this->playback.TrackChanged.connect(this, &TransportWindow::OnPlaybackServiceTrackChanged);
this->playback.ModeChanged.connect(this, &TransportWindow::OnPlaybackModeChanged); this->playback.ModeChanged.connect(this, &TransportWindow::OnPlaybackModeChanged);
@ -249,7 +248,8 @@ void TransportWindow::Update() {
bool paused = (transport.GetPlaybackState() == ITransport::PlaybackPaused); bool paused = (transport.GetPlaybackState() == ITransport::PlaybackPaused);
bool stopped = (transport.GetPlaybackState() == ITransport::PlaybackStopped); 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 */ /* prepare the "shuffle" label */
@ -261,9 +261,9 @@ void TransportWindow::Update() {
std::string duration = "0"; std::string duration = "0";
if (stopped) { if (stopped) {
wattron(c, A_DIM); ON(c, disabled);
wprintw(c, "playback is stopped"); wprintw(c, "playback is stopped");
wattroff(c, A_DIM); OFF(c, disabled);
} }
else { else {
std::string title, album; std::string title, album;
@ -286,7 +286,7 @@ void TransportWindow::Update() {
} }
wmove(c, 0, cx - shuffleLabelLen); wmove(c, 0, cx - shuffleLabelLen);
int64 shuffleAttrs = this->playback.IsShuffled() ? gb : A_DIM; int64 shuffleAttrs = this->playback.IsShuffled() ? gb : disabled;
ON(c, shuffleAttrs); ON(c, shuffleAttrs);
wprintw(c, shuffleLabel.c_str()); wprintw(c, shuffleLabel.c_str());
OFF(c, shuffleAttrs); OFF(c, shuffleAttrs);
@ -325,7 +325,7 @@ void TransportWindow::Update() {
break; break;
default: default:
repeatModeLabel = "off"; repeatModeLabel = "off";
repeatAttrs = A_DIM; repeatAttrs = disabled;
break; break;
} }

View File

@ -98,7 +98,7 @@ void Checkbox::Redraw() {
std::string ellipsized = symbol + " " + this->buffer; std::string ellipsized = symbol + " " + this->buffer;
text::Ellipsize(ellipsized, cx); text::Ellipsize(ellipsized, cx);
int64 attrs = this->focused ? CURSESPP_RED_ON_TRANSPARENT : -1LL; int64 attrs = this->focused ? CURSESPP_TEXT_FOCUSED : -1LL;
if (attrs != -1) { if (attrs != -1) {
wattron(c, COLOR_PAIR(attrs)); wattron(c, COLOR_PAIR(attrs));

View File

@ -44,17 +44,19 @@ static int yellow = COLOR_YELLOW;
static int green = COLOR_GREEN; static int green = COLOR_GREEN;
static int black = COLOR_BLACK; static int black = COLOR_BLACK;
#define COLOR_CUSTOM_WHITE 16 #define COLOR_CUSTOM_WHITE 16
#define COLOR_CUSTOM_BLUE 17 #define COLOR_CUSTOM_BLUE 17
#define COLOR_CUSTOM_RED 18 #define COLOR_CUSTOM_RED 18
#define COLOR_CUSTOM_YELLOW 19 #define COLOR_CUSTOM_YELLOW 19
#define COLOR_CUSTOM_GREEN 20 #define COLOR_CUSTOM_GREEN 20
#define COLOR_CUSTOM_BLACK 21 #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 background = -1;
static int selected = -1; static int selected = -1;
static int grey = COLOR_WHITE;
#define SCALE(x) ((x * 1000) / 255) #define SCALE(x) ((x * 1000) / 255)
@ -77,21 +79,28 @@ void Colors::Init() {
red = initColor(COLOR_CUSTOM_RED, 220, 82, 86); red = initColor(COLOR_CUSTOM_RED, 220, 82, 86);
green = initColor(COLOR_CUSTOM_GREEN, 166, 226, 46); green = initColor(COLOR_CUSTOM_GREEN, 166, 226, 46);
yellow = initColor(COLOR_CUSTOM_YELLOW, 230, 220, 116); 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_BLACK_ON_TRANSPARENT, black, background);
init_pair(CURSESPP_RED_ON_GREEN, red, green); init_pair(CURSESPP_RED_ON_BLUE, red, blue);
init_pair(CURSESPP_BLACK_ON_YELLOW, black, yellow); 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_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);
} }

View File

@ -36,20 +36,26 @@
#include "curses_config.h" #include "curses_config.h"
#define CURSESPP_WHITE_ON_BLUE 1 #define CURSESPP_BLACK_ON_TRANSPARENT 1
#define CURSESPP_RED_ON_BLUE 2 #define CURSESPP_RED_ON_BLUE 2
#define CURSESPP_YELLOW_ON_BLUE 3 #define CURSESPP_BLACK_ON_GREY 3
#define CURSESPP_BLACK_ON_GREY 4 #define CURSESPP_RED_ON_GREY 4
#define CURSESPP_BLACK_ON_GREEN 5
#define CURSESPP_YELLOW_ON_TRANSPARENT 6 #define CURSESPP_SELECTED_LIST_ITEM 5
#define CURSESPP_WHITE_ON_TRANSPARENT 7 #define CURSESPP_HIGHLIGHTED_LIST_ITEM 6
#define CURSESPP_RED_ON_TRANSPARENT 8 #define CURSESPP_HIGHLIGHTED_SELECTED_LIST_ITEM 7
#define CURSESPP_RED_ON_GREY 9 #define CURSESPP_LIST_ITEM_HEADER 8
#define CURSESPP_GREEN_ON_TRANSPARENT 10
#define CURSESPP_BLACK_ON_TRANSPARENT 11 #define CURSESPP_DEFAULT_CONTENT_COLOR 9
#define CURSESPP_RED_ON_GREEN 12 #define CURSESPP_DEFAULT_FRAME_COLOR 10
#define CURSESPP_BLACK_ON_YELLOW 13 #define CURSESPP_FOCUSED_FRAME_COLOR 11
#define CURSESPP_SELECTED_LIST_ITEM 14
#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 { namespace cursespp {
class Colors { class Colors {

View File

@ -64,12 +64,12 @@ bool sortByFocusOrder(IWindowPtr a, IWindowPtr b) {
static inline IWindowPtr adjustFocus(IWindowPtr oldFocus, IWindowPtr newFocus) { static inline IWindowPtr adjustFocus(IWindowPtr oldFocus, IWindowPtr newFocus) {
if (oldFocus) { if (oldFocus) {
oldFocus->SetFrameColor(CURSESPP_WHITE_ON_TRANSPARENT); oldFocus->SetFrameColor(CURSESPP_DEFAULT_FRAME_COLOR);
oldFocus->Blur(); oldFocus->Blur();
} }
if (newFocus) { if (newFocus) {
newFocus->SetFrameColor(CURSESPP_RED_ON_TRANSPARENT); newFocus->SetFrameColor(CURSESPP_FOCUSED_FRAME_COLOR);
newFocus->Focus(); newFocus->Focus();
} }

View File

@ -38,6 +38,7 @@
#include "IInput.h" #include "IInput.h"
#include "Message.h" #include "Message.h"
#include "MessageQueue.h" #include "MessageQueue.h"
#include "Colors.h"
using namespace cursespp; using namespace cursespp;
@ -79,8 +80,8 @@ Window::Window(IWindow *parent) {
this->width = 0; this->width = 0;
this->x = 0; this->x = 0;
this->y = 0; this->y = 0;
this->contentColor = -1; this->contentColor = CURSESPP_DEFAULT_CONTENT_COLOR;
this->frameColor = -1; this->frameColor = CURSESPP_DEFAULT_FRAME_COLOR;
this->drawFrame = true; this->drawFrame = true;
this->isVisible = false; this->isVisible = false;
this->focusOrder = -1; this->focusOrder = -1;
@ -254,7 +255,7 @@ int Window::GetY() const {
} }
void Window::SetContentColor(int64 color) { void Window::SetContentColor(int64 color) {
this->contentColor = color; this->contentColor = (color == -1 ? CURSESPP_DEFAULT_CONTENT_COLOR : color);
if (this->contentColor != -1 && this->content) { if (this->contentColor != -1 && this->content) {
wbkgd(this->frame, COLOR_PAIR(this->frameColor)); wbkgd(this->frame, COLOR_PAIR(this->frameColor));
@ -268,7 +269,7 @@ void Window::SetContentColor(int64 color) {
} }
void Window::SetFrameColor(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) { if (this->drawFrame && this->frameColor != -1 && this->frame) {
wbkgd(this->frame, COLOR_PAIR(this->frameColor)); wbkgd(this->frame, COLOR_PAIR(this->frameColor));