mirror of
https://github.com/clangen/musikcube.git
synced 2025-03-14 13:21:13 +00:00
Added new Redraw() base class method, and renamed Repaint() to
Invalidate(). Also renamed Window::Invalidate to Window::InvalidateScreen
This commit is contained in:
parent
68f574235b
commit
f56ffb0bcf
@ -344,6 +344,10 @@ void TransportWindow::OnPlaybackShuffled(bool shuffled) {
|
||||
DEBOUNCE_REFRESH(TimeSync, 0);
|
||||
}
|
||||
|
||||
void TransportWindow::Redraw() {
|
||||
this->Update();
|
||||
}
|
||||
|
||||
void TransportWindow::Update(TimeMode timeMode) {
|
||||
this->Clear();
|
||||
|
||||
@ -545,5 +549,5 @@ void TransportWindow::Update(TimeMode timeMode) {
|
||||
wprintw(c, repeatModeLabel.c_str());
|
||||
OFF(c, repeatAttrs);
|
||||
|
||||
this->Repaint();
|
||||
this->Invalidate();
|
||||
}
|
||||
|
@ -65,6 +65,7 @@ namespace musik {
|
||||
virtual void Show();
|
||||
virtual void OnFocusChanged(bool focused);
|
||||
virtual bool KeyPress(const std::string& key);
|
||||
virtual void Redraw();
|
||||
|
||||
void SetFocus(FocusTarget target);
|
||||
FocusTarget GetFocus() const;
|
||||
|
@ -180,7 +180,7 @@ void App::Run(ILayoutPtr layout) {
|
||||
quit = true;
|
||||
}
|
||||
else if (kn == "M-r") {
|
||||
Window::Invalidate();
|
||||
Window::InvalidateScreen();
|
||||
}
|
||||
else if (kn == "KEY_RESIZE") {
|
||||
resizeAt = App::Now() + REDRAW_DEBOUNCE_MS;
|
||||
@ -202,7 +202,7 @@ void App::Run(ILayoutPtr layout) {
|
||||
actual resize until its settled. */
|
||||
if (resizeAt && App::Now() > resizeAt) {
|
||||
resize_term(0, 0);
|
||||
Window::Invalidate();
|
||||
Window::InvalidateScreen();
|
||||
|
||||
if (this->resizeHandler) {
|
||||
this->resizeHandler();
|
||||
|
@ -111,7 +111,7 @@ void Checkbox::Redraw() {
|
||||
wattroff(c, COLOR_PAIR(attrs));
|
||||
}
|
||||
|
||||
this->Repaint();
|
||||
this->Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,7 @@ DialogOverlay& DialogOverlay::SetTitle(const std::string& title) {
|
||||
this->title = title;
|
||||
this->RecalculateSize();
|
||||
this->Layout();
|
||||
this->Repaint();
|
||||
this->Invalidate();
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -92,7 +92,7 @@ DialogOverlay& DialogOverlay::SetMessage(const std::string& message) {
|
||||
this->width = 0; /* implicitly triggers a new BreakLines() */
|
||||
this->RecalculateSize();
|
||||
this->Layout();
|
||||
this->Repaint();
|
||||
this->Invalidate();
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -110,7 +110,7 @@ DialogOverlay& DialogOverlay::AddButton(
|
||||
this->shortcuts->AddShortcut(key, caption);
|
||||
this->buttons[rawKey] = callback;
|
||||
this->Layout();
|
||||
this->Repaint();
|
||||
this->Invalidate();
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,8 @@ namespace cursespp {
|
||||
class IWindow : public IOrderable, public IDisplayable, public IMessageTarget {
|
||||
public:
|
||||
virtual ~IWindow() { }
|
||||
virtual void Repaint() = 0;
|
||||
virtual void Invalidate() = 0;
|
||||
virtual void Redraw() = 0;
|
||||
virtual void SetParent(IWindow* parent) = 0;
|
||||
virtual void Show() = 0;
|
||||
virtual void Hide() = 0;
|
||||
|
@ -116,7 +116,7 @@ void LayoutBase::BringToTop() {
|
||||
this->children.at(i)->BringToTop();
|
||||
}
|
||||
|
||||
this->Repaint();
|
||||
this->Invalidate();
|
||||
}
|
||||
|
||||
void LayoutBase::SendToBottom() {
|
||||
@ -127,14 +127,20 @@ void LayoutBase::SendToBottom() {
|
||||
Window::SendToBottom();
|
||||
}
|
||||
|
||||
void LayoutBase::Repaint() {
|
||||
void LayoutBase::Invalidate() {
|
||||
/* repaint bottom up. start with ourselves, then our children,
|
||||
recursively. */
|
||||
|
||||
Window::Repaint();
|
||||
Window::Invalidate();
|
||||
|
||||
for (size_t i = 0; i < this->children.size(); i++) {
|
||||
this->children.at(i)->Repaint();
|
||||
this->children.at(i)->Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
void LayoutBase::Redraw() {
|
||||
for (size_t i = 0; i < this->children.size(); i++) {
|
||||
this->children.at(i)->Redraw();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,8 @@ namespace cursespp {
|
||||
/* IWindow */
|
||||
virtual void Show();
|
||||
virtual void Hide();
|
||||
virtual void Repaint();
|
||||
virtual void Invalidate();
|
||||
virtual void Redraw();
|
||||
|
||||
/* IOrderable */
|
||||
virtual void BringToTop();
|
||||
|
@ -94,7 +94,7 @@ ListOverlay& ListOverlay::SetTitle(const std::string& title) {
|
||||
this->title = title;
|
||||
this->RecalculateSize();
|
||||
this->Layout();
|
||||
this->Repaint();
|
||||
this->Invalidate();
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -172,7 +172,7 @@ void ListWindow::ScrollTo(size_t index) {
|
||||
this->GetScrollAdapter().DrawPage(
|
||||
this, index, &this->GetMutableScrollPosition());
|
||||
|
||||
this->Repaint();
|
||||
this->Invalidate();
|
||||
}
|
||||
|
||||
void ListWindow::OnSelectionChanged(size_t newIndex, size_t oldIndex) {
|
||||
@ -189,7 +189,7 @@ void ListWindow::SetSelectedIndex(size_t index) {
|
||||
this->scrollPosition.firstVisibleEntryIndex,
|
||||
&this->GetMutableScrollPosition());
|
||||
|
||||
this->Repaint();
|
||||
this->Invalidate();
|
||||
|
||||
this->OnSelectionChanged(index, prev); /* internal */
|
||||
this->SelectionChanged(this, index, prev); /* external */
|
||||
|
@ -42,12 +42,6 @@ using namespace cursespp;
|
||||
|
||||
typedef IScrollAdapter::EntryPtr EntryPtr;
|
||||
|
||||
/* used for some calculations. it's ok to let this leak. if it's
|
||||
a static instance var we will have non-deterministic behavior when
|
||||
the instance is destructed, because the global message queue may
|
||||
be torn down as well */
|
||||
static ListWindow* DUMMY_SCROLLABLE_WINDOW = new ListWindow();
|
||||
|
||||
ScrollAdapterBase::ScrollAdapterBase() {
|
||||
this->height = 0;
|
||||
this->width = 0;
|
||||
|
@ -111,6 +111,13 @@ bool ScrollableWindow::KeyPress(const std::string& key) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void ScrollableWindow::Redraw() {
|
||||
IScrollAdapter *adapter = &GetScrollAdapter();
|
||||
ScrollPos &pos = this->GetMutableScrollPosition();
|
||||
adapter->DrawPage(this, pos.firstVisibleEntryIndex, &pos);
|
||||
this->Invalidate();
|
||||
}
|
||||
|
||||
void ScrollableWindow::OnAdapterChanged() {
|
||||
IScrollAdapter *adapter = &GetScrollAdapter();
|
||||
|
||||
@ -122,7 +129,7 @@ void ScrollableWindow::OnAdapterChanged() {
|
||||
else {
|
||||
ScrollPos &pos = this->GetMutableScrollPosition();
|
||||
adapter->DrawPage(this, pos.firstVisibleEntryIndex, &pos);
|
||||
this->Repaint();
|
||||
this->Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
@ -133,7 +140,7 @@ void ScrollableWindow::Show() {
|
||||
|
||||
void ScrollableWindow::ScrollToTop() {
|
||||
GetScrollAdapter().DrawPage(this, 0, &this->GetMutableScrollPosition());
|
||||
this->Repaint();
|
||||
this->Invalidate();
|
||||
}
|
||||
|
||||
void ScrollableWindow::ScrollToBottom() {
|
||||
@ -142,7 +149,7 @@ void ScrollableWindow::ScrollToBottom() {
|
||||
GetScrollAdapter().GetEntryCount(),
|
||||
&this->GetMutableScrollPosition());
|
||||
|
||||
this->Repaint();
|
||||
this->Invalidate();
|
||||
}
|
||||
|
||||
void ScrollableWindow::ScrollUp(int delta) {
|
||||
@ -152,7 +159,7 @@ void ScrollableWindow::ScrollUp(int delta) {
|
||||
GetScrollAdapter().DrawPage(
|
||||
this, pos.firstVisibleEntryIndex - delta, &pos);
|
||||
|
||||
this->Repaint();
|
||||
this->Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
@ -162,7 +169,7 @@ void ScrollableWindow::ScrollDown(int delta) {
|
||||
GetScrollAdapter().DrawPage(
|
||||
this, pos.firstVisibleEntryIndex + delta, &pos);
|
||||
|
||||
this->Repaint();
|
||||
this->Invalidate();
|
||||
}
|
||||
|
||||
size_t ScrollableWindow::GetPreviousPageEntryIndex() {
|
||||
|
@ -62,6 +62,7 @@ namespace cursespp {
|
||||
virtual void Blur();
|
||||
|
||||
virtual void OnAdapterChanged();
|
||||
virtual void Redraw();
|
||||
|
||||
void SetAllowArrowKeyPropagation(bool allow = true);
|
||||
|
||||
|
@ -52,7 +52,7 @@ ShortcutsWindow::~ShortcutsWindow() {
|
||||
|
||||
void ShortcutsWindow::SetAlignment(text::TextAlign align) {
|
||||
this->alignment = align;
|
||||
this->Repaint();
|
||||
this->Redraw();
|
||||
}
|
||||
|
||||
void ShortcutsWindow::AddShortcut(
|
||||
@ -63,22 +63,22 @@ void ShortcutsWindow::AddShortcut(
|
||||
this->entries.push_back(
|
||||
std::shared_ptr<Entry>(new Entry(key, description, attrs)));
|
||||
|
||||
this->Repaint();
|
||||
this->Redraw();
|
||||
}
|
||||
|
||||
void ShortcutsWindow::RemoveAll() {
|
||||
this->entries.clear();
|
||||
this->Repaint();
|
||||
this->Redraw();
|
||||
}
|
||||
|
||||
void ShortcutsWindow::SetActive(const std::string& key) {
|
||||
this->activeKey = key;
|
||||
this->Repaint();
|
||||
this->Redraw();
|
||||
}
|
||||
|
||||
void ShortcutsWindow::OnFocusChanged(bool focused) {
|
||||
this->UpdateContentColor();
|
||||
this->Repaint();
|
||||
this->Redraw();
|
||||
}
|
||||
|
||||
void ShortcutsWindow::UpdateContentColor() {
|
||||
@ -110,9 +110,7 @@ size_t ShortcutsWindow::CalculateLeftPadding() {
|
||||
return (padding / 2); /* text::AlignCenter */
|
||||
}
|
||||
|
||||
void ShortcutsWindow::Repaint() {
|
||||
Window::Repaint();
|
||||
|
||||
void ShortcutsWindow::Redraw() {
|
||||
this->Clear();
|
||||
|
||||
int64 normalAttrs = COLOR_PAIR(CURSESPP_BUTTON_NORMAL);
|
||||
@ -166,4 +164,6 @@ void ShortcutsWindow::Repaint() {
|
||||
|
||||
remaining -= len;
|
||||
}
|
||||
|
||||
this->Invalidate();
|
||||
}
|
||||
|
@ -56,10 +56,8 @@ namespace cursespp {
|
||||
int64 attrs = -1);
|
||||
|
||||
void RemoveAll();
|
||||
|
||||
void SetActive(const std::string& key);
|
||||
|
||||
virtual void Repaint();
|
||||
virtual void Redraw();
|
||||
|
||||
protected:
|
||||
virtual void OnFocusChanged(bool focused);
|
||||
|
@ -42,13 +42,6 @@
|
||||
|
||||
using namespace cursespp;
|
||||
|
||||
inline static void redrawContents(IWindow &window, const std::string& text) {
|
||||
WINDOW* c = window.GetContent();
|
||||
werase(c);
|
||||
wprintw(c, text.c_str());
|
||||
window.Repaint();
|
||||
}
|
||||
|
||||
inline static bool removeUtf8Char(std::string& value, size_t position) {
|
||||
/* optimize the normal case, at the end... */
|
||||
if (position >= value.size()) {
|
||||
@ -84,7 +77,14 @@ TextInput::~TextInput() {
|
||||
|
||||
void TextInput::Show() {
|
||||
Window::Show();
|
||||
redrawContents(*this, buffer);
|
||||
this->Redraw();
|
||||
}
|
||||
|
||||
void TextInput::Redraw() {
|
||||
WINDOW* c = this->GetContent();
|
||||
werase(c);
|
||||
wprintw(c, buffer.c_str());
|
||||
this->Invalidate();
|
||||
}
|
||||
|
||||
size_t TextInput::Length() {
|
||||
@ -117,7 +117,7 @@ bool TextInput::Write(const std::string& key) {
|
||||
}
|
||||
|
||||
this->TextChanged(this, this->buffer);
|
||||
redrawContents(*this, buffer);
|
||||
this->Redraw();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -133,7 +133,7 @@ bool TextInput::KeyPress(const std::string& key) {
|
||||
if (this->position > 0) {
|
||||
if (removeUtf8Char(this->buffer, this->position)) {
|
||||
--this->bufferLength;
|
||||
redrawContents(*this, buffer);
|
||||
this->Redraw();
|
||||
this->position = std::max(0, this->position - 1);
|
||||
this->TextChanged(this, this->buffer);
|
||||
}
|
||||
@ -152,19 +152,20 @@ bool TextInput::KeyPress(const std::string& key) {
|
||||
}
|
||||
else if (key == "KEY_HOME") {
|
||||
this->position = 0;
|
||||
redrawContents(*this, buffer);
|
||||
this->Redraw();
|
||||
return true;
|
||||
}
|
||||
else if (key == "KEY_END") {
|
||||
this->position = this->bufferLength;
|
||||
redrawContents(*this, buffer);
|
||||
this->Redraw();
|
||||
return true;
|
||||
}
|
||||
else if (key == "KEY_DC") {
|
||||
if ((int) this->bufferLength > this->position) {
|
||||
removeUtf8Char(this->buffer, this->position + 1);
|
||||
this->bufferLength = u8len(buffer);
|
||||
redrawContents(*this, buffer);
|
||||
this->Redraw();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -178,7 +179,7 @@ bool TextInput::OffsetPosition(int delta) {
|
||||
|
||||
if (this->position != actual) {
|
||||
this->position = actual;
|
||||
redrawContents(*this, buffer);
|
||||
this->Redraw();
|
||||
return true; /* moved */
|
||||
}
|
||||
|
||||
@ -191,6 +192,6 @@ void TextInput::SetText(const std::string& value) {
|
||||
this->bufferLength = u8len(buffer);
|
||||
this->position = 0;
|
||||
this->TextChanged(this, this->buffer);
|
||||
redrawContents(*this, buffer);
|
||||
this->Redraw();
|
||||
}
|
||||
}
|
||||
|
@ -56,12 +56,13 @@ namespace cursespp {
|
||||
virtual ~TextInput();
|
||||
|
||||
virtual void Show();
|
||||
virtual void Redraw();
|
||||
|
||||
virtual bool Write(const std::string& key);
|
||||
virtual size_t Length();
|
||||
virtual size_t Position();
|
||||
|
||||
virtual void SetInputMode(InputMode inputMode) {
|
||||
virtual void SetInputMode(InputMode inputMode) {
|
||||
this->inputMode = inputMode;
|
||||
};
|
||||
|
||||
|
@ -73,7 +73,7 @@ void TextLabel::Redraw() {
|
||||
wattroff(c, COLOR_PAIR(attrs));
|
||||
}
|
||||
|
||||
this->Repaint();
|
||||
this->Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -65,6 +65,7 @@ namespace cursespp {
|
||||
virtual size_t Length() { return u8cols(this->buffer); }
|
||||
|
||||
virtual void Show();
|
||||
virtual void Redraw();
|
||||
|
||||
virtual bool KeyPress(const std::string& key);
|
||||
|
||||
@ -72,7 +73,6 @@ namespace cursespp {
|
||||
virtual void OnFocusChanged(bool focused);
|
||||
|
||||
private:
|
||||
void Redraw();
|
||||
|
||||
std::string buffer;
|
||||
text::TextAlign alignment;
|
||||
|
@ -73,7 +73,7 @@ void Window::WriteToScreen(IInput* input) {
|
||||
}
|
||||
}
|
||||
|
||||
void Window::Invalidate() {
|
||||
void Window::InvalidateScreen() {
|
||||
wclear(stdscr);
|
||||
drawPending = true;
|
||||
}
|
||||
@ -81,14 +81,14 @@ void Window::Invalidate() {
|
||||
void Window::Freeze() {
|
||||
if (!freeze) {
|
||||
freeze = true;
|
||||
Window::Invalidate();
|
||||
Window::InvalidateScreen();
|
||||
}
|
||||
}
|
||||
|
||||
void Window::Unfreeze() {
|
||||
if (freeze) {
|
||||
freeze = false;
|
||||
Window::Invalidate();
|
||||
Window::InvalidateScreen();
|
||||
}
|
||||
}
|
||||
|
||||
@ -238,7 +238,7 @@ void Window::SetPosition(int x, int y) {
|
||||
}
|
||||
|
||||
void Window::OnDimensionsChanged() {
|
||||
this->Repaint();
|
||||
this->Invalidate();
|
||||
}
|
||||
|
||||
void Window::OnVisibilityChanged(bool visible) {
|
||||
@ -291,7 +291,7 @@ void Window::SetContentColor(int64 color) {
|
||||
wbkgd(this->content, COLOR_PAIR(this->contentColor));
|
||||
}
|
||||
|
||||
this->Repaint();
|
||||
this->Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
@ -305,7 +305,7 @@ void Window::SetFrameColor(int64 color) {
|
||||
wbkgd(this->content, COLOR_PAIR(this->contentColor));
|
||||
}
|
||||
|
||||
this->Repaint();
|
||||
this->Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
@ -523,7 +523,7 @@ void Window::Clear() {
|
||||
}
|
||||
}
|
||||
|
||||
void Window::Repaint() {
|
||||
void Window::Invalidate() {
|
||||
if (this->isVisible) {
|
||||
if (this->frame) {
|
||||
drawPending = true;
|
||||
|
@ -58,7 +58,7 @@ namespace cursespp {
|
||||
virtual void Show();
|
||||
virtual void Hide();
|
||||
|
||||
virtual void Repaint();
|
||||
virtual void Invalidate();
|
||||
|
||||
void SetFrameVisible(bool enabled);
|
||||
bool IsFrameVisible();
|
||||
@ -97,7 +97,7 @@ namespace cursespp {
|
||||
bool HasBadBounds() { return this->badBounds; }
|
||||
|
||||
static void WriteToScreen(IInput* input);
|
||||
static void Invalidate();
|
||||
static void InvalidateScreen();
|
||||
static void Freeze();
|
||||
static void Unfreeze();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user