mirror of
https://github.com/clangen/musikcube.git
synced 2025-03-29 19:20:28 +00:00
- Localize wrefresh() call to the input window that has focus when drawing cursor
- Moved Blur/Focus update functionality from ListWindow into ScrollableWindow
This commit is contained in:
parent
ceb629accd
commit
273b67076f
@ -8,12 +8,6 @@ typedef IScrollAdapter::ScrollPosition ScrollPos;
|
||||
|
||||
size_t ListWindow::NO_SELECTION = (size_t) -1;
|
||||
|
||||
#define REDRAW_VISIBLE_PAGE() \
|
||||
GetScrollAdapter().DrawPage( \
|
||||
this->GetContent(), \
|
||||
this->scrollPosition.firstVisibleEntryIndex, \
|
||||
&this->scrollPosition); \
|
||||
|
||||
ListWindow::ListWindow(IWindow *parent)
|
||||
: ScrollableWindow(parent) {
|
||||
this->selectedIndex = (size_t) -1;
|
||||
@ -36,16 +30,6 @@ void ListWindow::ScrollToBottom() {
|
||||
this->Repaint();
|
||||
}
|
||||
|
||||
void ListWindow::Blur() {
|
||||
ScrollableWindow::Blur();
|
||||
REDRAW_VISIBLE_PAGE();
|
||||
}
|
||||
|
||||
void ListWindow::Focus() {
|
||||
ScrollableWindow::Focus();
|
||||
REDRAW_VISIBLE_PAGE();
|
||||
}
|
||||
|
||||
void ListWindow::ScrollUp(int delta) {
|
||||
ScrollPos spos = this->GetScrollPosition();
|
||||
IScrollAdapter& adapter = this->GetScrollAdapter();
|
||||
|
@ -23,9 +23,6 @@ namespace cursespp {
|
||||
virtual void PageUp();
|
||||
virtual void PageDown();
|
||||
|
||||
virtual void Focus();
|
||||
virtual void Blur();
|
||||
|
||||
virtual size_t GetSelectedIndex();
|
||||
|
||||
protected:
|
||||
|
@ -11,6 +11,15 @@ using namespace cursespp;
|
||||
|
||||
typedef IScrollAdapter::ScrollPosition ScrollPos;
|
||||
|
||||
#define REDRAW_VISIBLE_PAGE() \
|
||||
{ \
|
||||
ScrollPos& pos = GetScrollPosition(); \
|
||||
GetScrollAdapter().DrawPage( \
|
||||
this->GetContent(), \
|
||||
pos.firstVisibleEntryIndex, \
|
||||
&pos); \
|
||||
} \
|
||||
|
||||
ScrollableWindow::ScrollableWindow(IWindow *parent)
|
||||
: Window(parent) {
|
||||
}
|
||||
@ -142,3 +151,13 @@ bool ScrollableWindow::IsLastItemVisible() {
|
||||
size_t lastVisible = firstVisible + pos.visibleEntryCount;
|
||||
return lastIndex >= firstVisible && lastIndex <= lastVisible;
|
||||
}
|
||||
|
||||
void ScrollableWindow::Blur() {
|
||||
Window::Blur();
|
||||
REDRAW_VISIBLE_PAGE();
|
||||
}
|
||||
|
||||
void ScrollableWindow::Focus() {
|
||||
Window::Focus();
|
||||
REDRAW_VISIBLE_PAGE();
|
||||
}
|
||||
|
@ -24,6 +24,9 @@ namespace cursespp {
|
||||
virtual void PageUp();
|
||||
virtual void PageDown();
|
||||
|
||||
virtual void Focus();
|
||||
virtual void Blur();
|
||||
|
||||
protected:
|
||||
virtual IScrollAdapter& GetScrollAdapter() = 0;
|
||||
virtual IScrollAdapter::ScrollPosition& GetScrollPosition();
|
||||
|
@ -13,6 +13,7 @@ static bool drawPending = false;
|
||||
void Window::WriteToScreen(IInput* input) {
|
||||
if (drawPending) {
|
||||
drawPending = false;
|
||||
|
||||
update_panels();
|
||||
doupdate();
|
||||
|
||||
@ -25,7 +26,7 @@ void Window::WriteToScreen(IInput* input) {
|
||||
Window* inputWindow = dynamic_cast<Window*>(input);
|
||||
if (inputWindow) {
|
||||
wmove(inputWindow->GetContent(), 0, input->Length());
|
||||
refresh();
|
||||
wrefresh(inputWindow->GetContent());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user