Fixed focus problems in top-level layout management, and also fixed a bug in CommandWindow where it wasn't re-shown properly.

This commit is contained in:
casey 2016-05-14 22:10:24 -07:00
parent 4eabea9f20
commit 45e8cf956e
4 changed files with 15 additions and 6 deletions

View File

@ -51,6 +51,14 @@ CommandWindow::~CommandWindow() {
delete[] buffer; delete[] buffer;
} }
void CommandWindow::Show() {
Window::Show();
wmove(this->GetContent(), 0, 0);
std::string buf(buffer, bufferPosition);
wprintw(this->GetContent(), "%s", buf.c_str());
}
void CommandWindow::Focus() { void CommandWindow::Focus() {
wmove(this->GetContent(), 0, bufferPosition); wmove(this->GetContent(), 0, bufferPosition);
} }

View File

@ -23,6 +23,7 @@ class CommandWindow : public Window, public IInput, public sigslot::has_slots<>
virtual void WriteChar(int64 ch); virtual void WriteChar(int64 ch);
virtual void Focus(); virtual void Focus();
virtual void Show();
private: private:
void ListPlugins() const; void ListPlugins() const;

View File

@ -113,6 +113,10 @@ void LayoutBase::IndexFocusables() {
for (size_t i = 0; i < this->children.size(); i++) { for (size_t i = 0; i < this->children.size(); i++) {
AddFocusable(this->children.at(i)); AddFocusable(this->children.at(i));
} }
if (focusedWindow) {
this->focused = find(this->focusable, focusedWindow);
}
} }
void LayoutBase::SortFocusables() { void LayoutBase::SortFocusables() {

View File

@ -81,13 +81,14 @@ void changeLayout(WindowState& current, ILayout* newLayout) {
current.layout = newLayout; current.layout = newLayout;
current.layout->Layout(); current.layout->Layout();
current.layout->Show(); current.layout->Show();
current.focused = newLayout->GetFocus(); current.focused = current.layout->GetFocus();
current.input = dynamic_cast<IInput*>(current.focused); current.input = dynamic_cast<IInput*>(current.focused);
current.scrollable = dynamic_cast<IScrollable*>(current.focused); current.scrollable = dynamic_cast<IScrollable*>(current.focused);
} }
if (current.input) { if (current.input) {
curs_set(1); curs_set(1);
current.input->Focus();
wtimeout(current.focused->GetContent(), IDLE_TIMEOUT_MS); wtimeout(current.focused->GetContent(), IDLE_TIMEOUT_MS);
} }
else { else {
@ -176,11 +177,6 @@ int main(int argc, char* argv[])
WindowState state = { 0 }; WindowState state = { 0 };
changeLayout(state, &mainLayout); changeLayout(state, &mainLayout);
if (state.input != NULL) {
curs_set(1);
wtimeout(state.focused->GetContent(), IDLE_TIMEOUT_MS);
}
while (!quit) { while (!quit) {
/* if the focused item is an IInput, then get characters from it, /* if the focused item is an IInput, then get characters from it,
so it can draw a pretty cursor if it wants */ so it can draw a pretty cursor if it wants */