Skip to content

Commit

Permalink
Refactor|libappfw: Use DocumentPopupWidget
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Jan 28, 2014
1 parent 9dcb32d commit 52d20df
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
3 changes: 3 additions & 0 deletions doomsday/libappfw/libappfw.pro
Expand Up @@ -46,6 +46,7 @@ HEADERS += \
include/de/DialogContentStylist \
include/de/DialogWidget \
include/de/DocumentWidget \
include/de/DocumentPopupWidget \
include/de/FoldPanelWidget \
include/de/FontLineWrapping \
include/de/framework \
Expand Down Expand Up @@ -120,6 +121,7 @@ HEADERS += \
include/de/widgets/compositorwidget.h \
include/de/widgets/dialogwidget.h \
include/de/widgets/documentwidget.h \
include/de/widgets/documentpopupwidget.h \
include/de/widgets/foldpanelwidget.h \
include/de/widgets/gridpopupwidget.h \
include/de/widgets/labelwidget.h \
Expand Down Expand Up @@ -166,6 +168,7 @@ SOURCES += \
src/widgets/compositorwidget.cpp \
src/widgets/dialogwidget.cpp \
src/widgets/documentwidget.cpp \
src/widgets/documentpopupwidget.cpp \
src/widgets/foldpanelwidget.cpp \
src/widgets/gridpopupwidget.cpp \
src/widgets/labelwidget.cpp \
Expand Down
26 changes: 10 additions & 16 deletions doomsday/libappfw/src/widgets/commandwidget.cpp
Expand Up @@ -17,8 +17,7 @@
*/

#include "de/CommandWidget"
#include "de/DocumentWidget"
#include "de/PopupWidget"
#include "de/DocumentPopupWidget"
#include "de/Style"

#include <de/shell/EditorHistory>
Expand All @@ -29,28 +28,23 @@ namespace de {
DENG_GUI_PIMPL(CommandWidget)
{
shell::EditorHistory history;
DocumentWidget *completions;
PopupWidget *popup; ///< Popup for autocompletions.
DocumentPopupWidget *popup; ///< Popup for autocompletions.
bool allowReshow; ///< Contents must still be valid.

Instance(Public *i) : Base(i), history(i), allowReshow(false)
{
// Popup for autocompletions.
completions = new DocumentWidget;
completions->setMaximumLineWidth(640);
completions->setScrollBarColor("inverted.accent");

popup = new PopupWidget;
popup->useInfoStyle();
popup->setContent(completions);
popup = new DocumentPopupWidget;
popup->document().setMaximumLineWidth(640);
popup->document().setScrollBarColor("inverted.accent");

// 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,
popup->document().rule().setInput(Rule::Height,
OperatorRule::minimum(
OperatorRule::minimum(style().rules().rule("editor.completion.height"),
completions->contentRule().height() +
completions->margins().height()),
popup->document().contentRule().height() +
popup->document().margins().height()),
self.rule().top() - style().rules().rule("gap")));

self.add(popup);
Expand Down Expand Up @@ -159,8 +153,8 @@ void CommandWidget::closeAutocompletionPopup()

void CommandWidget::showAutocompletionPopup(String const &completionsText)
{
d->completions->setText(completionsText);
d->completions->scrollToTop(0);
d->popup->document().setText(completionsText);
d->popup->document().scrollToTop(0);

d->popup->setAnchorX(cursorRect().middle().x);
d->popup->setAnchorY(rule().top());
Expand Down

0 comments on commit 52d20df

Please sign in to comment.