Skip to content

Commit

Permalink
Fixed|Client|UI|ConsoleCommandWidget: Completions popup height and po…
Browse files Browse the repository at this point in the history
…sition

The completions popup now moves with the command line, and has a
maximum height that does not exceed the top of the view.
  • Loading branch information
skyjake committed Aug 6, 2013
1 parent 037146e commit ff4142e
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions doomsday/client/src/ui/widgets/consolecommandwidget.cpp
Expand Up @@ -48,17 +48,23 @@ public IGameChangeObserver
// Popup for autocompletions.
completions = new DocumentWidget;
completions->setMaximumLineWidth(640);
completions->rule().setInput(Rule::Height,
OperatorRule::minimum(Const(400),
completions->contentRule().height() + 2 *
completions->margin()));

popup = new PopupWidget;
popup->set(Background(st.colors().colorf("editor.completion.background"),
Background::BorderGlow,
st.colors().colorf("editor.completion.glow"),
st.rules().rule("glow").valuei()));
popup->setContent(completions);

// Height for the content: depends on the document height (plus margins), but at
// most 400; never extend outside the view, though.
completions->rule().setInput(Rule::Height,
OperatorRule::minimum(
OperatorRule::minimum(Const(400),
completions->contentRule().height() +
2 * completions->margin()),
self.rule().top() - st.rules().rule("gap")));

self.add(popup);
}

Expand Down Expand Up @@ -182,7 +188,8 @@ void ConsoleCommandWidget::autoCompletionBegan(String const &)
d->completions->scrollToTop(0);

// Note: this is a fixed position, so it will not be updated if the view is resized.
d->popup->setAnchor(Vector2i(cursorRect().middle().x, rule().top().valuei()));
d->popup->setAnchorX(cursorRect().middle().x);
d->popup->setAnchorY(rule().top());
d->popup->open();
}
}
Expand Down

0 comments on commit ff4142e

Please sign in to comment.