mirror of
https://github.com/clangen/musikcube.git
synced 2024-11-19 11:10:52 +00:00
Added support for IWindow/Window frame titles; use them in BrowseLayout
and NowPlayingLayout. Removed special view title complexity in BrowseLayout.
This commit is contained in:
parent
b3b210cb22
commit
151611fe64
@ -114,23 +114,6 @@ void BrowseLayout::OnLayout() {
|
||||
|
||||
size_t categoryWidth = std::min(MAX_CATEGORY_WIDTH, cx / 4);
|
||||
|
||||
if (Screen::GetHeight() > MIN_LIST_TITLE_HEIGHT) {
|
||||
++y;
|
||||
|
||||
this->categoryTitle->MoveAndResize(x, y, categoryWidth, 1);
|
||||
this->categoryTitle->Show();
|
||||
|
||||
this->tracksTitle->MoveAndResize(x + categoryWidth, y, cx - categoryWidth, 1);
|
||||
this->tracksTitle->Show();
|
||||
|
||||
++y;
|
||||
cy -= 2;
|
||||
}
|
||||
else {
|
||||
this->categoryTitle->Hide();
|
||||
this->tracksTitle->Hide();
|
||||
}
|
||||
|
||||
this->categoryList->MoveAndResize(x, y, categoryWidth, cy);
|
||||
|
||||
if (this->playlistModified) {
|
||||
@ -150,22 +133,17 @@ void BrowseLayout::OnLayout() {
|
||||
}
|
||||
|
||||
void BrowseLayout::InitializeWindows() {
|
||||
this->categoryTitle.reset(new TextLabel());
|
||||
this->categoryTitle->SetText(_TSTR(DEFAULT_CATEGORY_NAME), text::AlignCenter);
|
||||
this->categoryTitle->Hide();
|
||||
this->categoryList.reset(new CategoryListView(this->playback, this->library, DEFAULT_CATEGORY));
|
||||
this->categoryList->SetFrameTitle(_TSTR(DEFAULT_CATEGORY_NAME));
|
||||
|
||||
this->tracksTitle.reset(new TextLabel());
|
||||
this->tracksTitle->SetText(_TSTR("browse_title_tracks"), text::AlignCenter);
|
||||
this->trackList.reset(new TrackListView(this->playback, this->library));
|
||||
this->trackList->SetFrameTitle(_TSTR("browse_title_tracks"));
|
||||
|
||||
this->modifiedLabel.reset(new TextLabel());
|
||||
this->modifiedLabel->SetText(getModifiedText(), text::AlignCenter);
|
||||
this->modifiedLabel->SetContentColor(CURSESPP_BANNER);
|
||||
this->modifiedLabel->Hide();
|
||||
|
||||
this->AddWindow(this->categoryTitle);
|
||||
this->AddWindow(this->tracksTitle);
|
||||
this->AddWindow(this->categoryList);
|
||||
this->AddWindow(this->trackList);
|
||||
this->AddWindow(this->modifiedLabel);
|
||||
@ -188,9 +166,7 @@ void BrowseLayout::ProcessMessage(musik::core::runtime::IMessage &message) {
|
||||
void BrowseLayout::ScrollTo(const std::string& fieldType, int64_t fieldId) {
|
||||
this->SetFocus(this->trackList);
|
||||
this->categoryList->RequeryWithField(fieldType, "", fieldId);
|
||||
|
||||
std::string title = getTitleForCategory(fieldType);
|
||||
this->categoryTitle->SetText(title, text::AlignCenter);
|
||||
this->categoryList->SetFrameTitle(getTitleForCategory(fieldType));
|
||||
}
|
||||
|
||||
void BrowseLayout::OnVisibilityChanged(bool visible) {
|
||||
@ -243,9 +219,7 @@ void BrowseLayout::OnCategoryViewInvalidated(
|
||||
|
||||
void BrowseLayout::SwitchCategory(const std::string& fieldName) {
|
||||
this->categoryList->SetFieldName(fieldName);
|
||||
|
||||
std::string title = getTitleForCategory(fieldName);
|
||||
this->categoryTitle->SetText(title, text::AlignCenter);
|
||||
this->categoryList->SetFrameTitle(getTitleForCategory(fieldName));
|
||||
}
|
||||
|
||||
bool BrowseLayout::KeyPress(const std::string& key) {
|
||||
|
@ -94,8 +94,6 @@ namespace musik {
|
||||
musik::core::ILibraryPtr library;
|
||||
std::shared_ptr<CategoryListView> categoryList;
|
||||
std::shared_ptr<TrackListView> trackList;
|
||||
std::shared_ptr<cursespp::TextLabel> categoryTitle;
|
||||
std::shared_ptr<cursespp::TextLabel> tracksTitle;
|
||||
std::shared_ptr<cursespp::TextLabel> modifiedLabel;
|
||||
};
|
||||
}
|
||||
|
@ -130,6 +130,7 @@ void NowPlayingLayout::InitializeWindows() {
|
||||
std::bind(formatWithAlbum, std::placeholders::_1, std::placeholders::_2),
|
||||
std::bind(&NowPlayingLayout::RowDecorator, this, std::placeholders::_1, std::placeholders::_2)));
|
||||
|
||||
this->trackListView->SetFrameTitle(_TSTR("playqueue_title"));
|
||||
this->trackListView->Requeried.connect(this, &NowPlayingLayout::OnTrackListRequeried);
|
||||
this->AddWindow(this->trackListView);
|
||||
}
|
||||
|
@ -84,6 +84,8 @@ namespace cursespp {
|
||||
virtual bool IsFocused() = 0;
|
||||
virtual void OnParentVisibilityChanged(bool visible) = 0;
|
||||
virtual bool IsTop() = 0;
|
||||
virtual void SetFrameTitle(const std::string& title) = 0;
|
||||
virtual std::string GetFrameTitle() const = 0;
|
||||
};
|
||||
|
||||
typedef std::shared_ptr<IWindow> IWindowPtr;
|
||||
|
@ -141,7 +141,7 @@ bool ScrollableWindow::KeyPress(const std::string& key) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void ScrollableWindow::Redraw() {
|
||||
void ScrollableWindow::OnRedraw() {
|
||||
IScrollAdapter *adapter = &GetScrollAdapter();
|
||||
ScrollPos &pos = this->GetMutableScrollPosition();
|
||||
adapter->DrawPage(this, pos.firstVisibleEntryIndex, pos);
|
||||
|
@ -76,7 +76,6 @@ namespace cursespp {
|
||||
virtual void Blur();
|
||||
|
||||
virtual void OnAdapterChanged();
|
||||
virtual void Redraw();
|
||||
|
||||
void SetAllowArrowKeyPropagation(bool allow = true);
|
||||
|
||||
@ -85,6 +84,7 @@ namespace cursespp {
|
||||
protected:
|
||||
virtual IScrollAdapter& GetScrollAdapter();
|
||||
virtual IScrollAdapter::ScrollPosition& GetMutableScrollPosition();
|
||||
virtual void OnRedraw();
|
||||
|
||||
size_t GetPreviousPageEntryIndex();
|
||||
bool IsLastItemVisible();
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include "IInput.h"
|
||||
#include "Colors.h"
|
||||
#include "Screen.h"
|
||||
#include "Text.h"
|
||||
|
||||
#include <core/runtime/Message.h>
|
||||
#include <core/runtime/MessageQueue.h>
|
||||
@ -481,8 +482,6 @@ void Window::OnParentVisibilityChanged(bool visible) {
|
||||
if (this->framePanel) {
|
||||
this->Destroy();
|
||||
}
|
||||
|
||||
//this->OnVisibilityChanged(false);
|
||||
}
|
||||
else if (visible && this->isVisible) {
|
||||
if (this->framePanel) {
|
||||
@ -491,8 +490,6 @@ void Window::OnParentVisibilityChanged(bool visible) {
|
||||
else {
|
||||
this->Recreate();
|
||||
}
|
||||
|
||||
//this->OnVisibilityChanged(true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -551,6 +548,16 @@ int Window::GetAbsoluteY() const {
|
||||
return this->parent ? (this->y + parent->GetAbsoluteY()) : this->y;
|
||||
}
|
||||
|
||||
void Window::SetFrameTitle(const std::string& title) {
|
||||
this->title = title;
|
||||
this->Destroy();
|
||||
this->Redraw();
|
||||
}
|
||||
|
||||
std::string Window::GetFrameTitle() const {
|
||||
return this->title;
|
||||
}
|
||||
|
||||
void Window::Create() {
|
||||
assert(this->frame == nullptr);
|
||||
assert(this->content == nullptr);
|
||||
@ -641,6 +648,17 @@ void Window::Create() {
|
||||
if (currentContentColor != CURSESPP_DEFAULT_COLOR) {
|
||||
wbkgd(this->content, COLOR_PAIR(currentContentColor));
|
||||
}
|
||||
|
||||
/* draw the title, if one is specified */
|
||||
size_t titleLen = u8len(this->title);
|
||||
if (titleLen > 0) {
|
||||
int max = this->width - 4; /* 4 = corner + space + space + corner */
|
||||
if (max > 3) { /* 3 = first character plus ellipse (e.g. 'F..')*/
|
||||
std::string adjusted = " " + text::Ellipsize(this->title, (size_t) max - 2) + " ";
|
||||
wmove(this->frame, 0, 2);
|
||||
waddstr(this->frame, adjusted.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this->Show();
|
||||
|
@ -92,6 +92,9 @@ namespace cursespp {
|
||||
virtual int GetAbsoluteY() const;
|
||||
virtual int GetId() const;
|
||||
|
||||
virtual void SetFrameTitle(const std::string& title);
|
||||
virtual std::string GetFrameTitle() const;
|
||||
|
||||
virtual void BringToTop();
|
||||
virtual void SendToBottom();
|
||||
|
||||
@ -155,6 +158,7 @@ namespace cursespp {
|
||||
int id;
|
||||
int64_t contentColor, frameColor;
|
||||
int64_t focusedContentColor, focusedFrameColor;
|
||||
std::string title;
|
||||
int width, height, x, y;
|
||||
int lastAbsoluteX, lastAbsoluteY;
|
||||
};
|
||||
|
@ -61,6 +61,8 @@
|
||||
"playback_overlay_invalid_transport": "the selected output device (%s) doesn't support crossfading.",
|
||||
"playback_overlay_no_output_plugins_mesage": "no output plugins found!",
|
||||
|
||||
"playqueue_title": "play queue",
|
||||
|
||||
"playqueue_overlay_add_to_start": "add to beginning",
|
||||
"playqueue_overlay_add_to_end": "add to end",
|
||||
"playqueue_overlay_add_as_next": "add as next",
|
||||
|
Loading…
Reference in New Issue
Block a user