- 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:
Casey Langen 2016-05-28 12:08:15 -07:00
parent ceb629accd
commit 273b67076f
5 changed files with 24 additions and 20 deletions

View File

@ -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();

View File

@ -23,9 +23,6 @@ namespace cursespp {
virtual void PageUp();
virtual void PageDown();
virtual void Focus();
virtual void Blur();
virtual size_t GetSelectedIndex();
protected:

View File

@ -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();
}

View File

@ -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();

View File

@ -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());
}
}
}