mirror of
https://github.com/clangen/musikcube.git
synced 2025-03-01 10:13:22 +00:00
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:
parent
4eabea9f20
commit
45e8cf956e
@ -51,6 +51,14 @@ CommandWindow::~CommandWindow() {
|
||||
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() {
|
||||
wmove(this->GetContent(), 0, bufferPosition);
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ class CommandWindow : public Window, public IInput, public sigslot::has_slots<>
|
||||
|
||||
virtual void WriteChar(int64 ch);
|
||||
virtual void Focus();
|
||||
virtual void Show();
|
||||
|
||||
private:
|
||||
void ListPlugins() const;
|
||||
|
@ -113,6 +113,10 @@ void LayoutBase::IndexFocusables() {
|
||||
for (size_t i = 0; i < this->children.size(); i++) {
|
||||
AddFocusable(this->children.at(i));
|
||||
}
|
||||
|
||||
if (focusedWindow) {
|
||||
this->focused = find(this->focusable, focusedWindow);
|
||||
}
|
||||
}
|
||||
|
||||
void LayoutBase::SortFocusables() {
|
||||
|
@ -81,13 +81,14 @@ void changeLayout(WindowState& current, ILayout* newLayout) {
|
||||
current.layout = newLayout;
|
||||
current.layout->Layout();
|
||||
current.layout->Show();
|
||||
current.focused = newLayout->GetFocus();
|
||||
current.focused = current.layout->GetFocus();
|
||||
current.input = dynamic_cast<IInput*>(current.focused);
|
||||
current.scrollable = dynamic_cast<IScrollable*>(current.focused);
|
||||
}
|
||||
|
||||
if (current.input) {
|
||||
curs_set(1);
|
||||
current.input->Focus();
|
||||
wtimeout(current.focused->GetContent(), IDLE_TIMEOUT_MS);
|
||||
}
|
||||
else {
|
||||
@ -176,11 +177,6 @@ int main(int argc, char* argv[])
|
||||
WindowState state = { 0 };
|
||||
changeLayout(state, &mainLayout);
|
||||
|
||||
if (state.input != NULL) {
|
||||
curs_set(1);
|
||||
wtimeout(state.focused->GetContent(), IDLE_TIMEOUT_MS);
|
||||
}
|
||||
|
||||
while (!quit) {
|
||||
/* if the focused item is an IInput, then get characters from it,
|
||||
so it can draw a pretty cursor if it wants */
|
||||
|
Loading…
x
Reference in New Issue
Block a user