Skip to content

Commit

Permalink
MSVC|Refactor: Workaround for compiler limitation
Browse files Browse the repository at this point in the history
Even VS2015 doesn't know how to determine that a CallbackAction *
cannot be used as std::function...
  • Loading branch information
skyjake committed Feb 27, 2016
1 parent 1c68ff5 commit 85318a6
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 9 deletions.
4 changes: 2 additions & 2 deletions doomsday/apps/client/src/ui/home/gamepanelbuttonwidget.cpp
Expand Up @@ -55,7 +55,7 @@ DENG_GUI_PIMPL(GamePanelButtonWidget)
playButton->setImage(new StyleProceduralImage("play", self));
playButton->setImageColor(style().colors().colorf("inverted.text"));
playButton->setOverrideImageSize(style().fonts().font("default").height().value());
playButton->setAction([this] () { playButtonPressed(); });
playButton->setActionFn([this] () { playButtonPressed(); });
self.addButton(playButton);

// List of saved games.
Expand All @@ -71,7 +71,7 @@ DENG_GUI_PIMPL(GamePanelButtonWidget)
deleteSaveButton->setSizePolicy(ui::Expand, ui::Expand);
deleteSaveButton->set(Background());
deleteSaveButton->hide();
deleteSaveButton->setAction([this] () { deleteButtonPressed(); });
deleteSaveButton->setActionFn([this] () { deleteButtonPressed(); });
self.panel().add(deleteSaveButton);

self.panel().setContent(saves);
Expand Down
Expand Up @@ -50,7 +50,7 @@ DENG_GUI_PIMPL(MultiplayerPanelButtonWidget)
joinButton->setText(tr("Join"));
joinButton->useInfoStyle();
joinButton->setSizePolicy(ui::Expand, ui::Expand);
joinButton->setAction([this] () { joinButtonPressed(); });
joinButton->setActionFn([this] () { joinButtonPressed(); });
self.addButton(joinButton);

info = new LabelWidget;
Expand Down
6 changes: 3 additions & 3 deletions doomsday/apps/client/src/ui/home/packageswidget.cpp
Expand Up @@ -89,7 +89,7 @@ DENG_GUI_PIMPL(PackagesWidget)
_loadButton = new ButtonWidget;
//_loadButton->setFont("small");
//_loadButton->margins().setTopBottom("unit");
_loadButton->setAction([this] ()
_loadButton->setActionFn([this] ()
{
auto &loader = App::packageLoader();
if(loader.isLoaded(packageId()))
Expand Down Expand Up @@ -177,7 +177,7 @@ DENG_GUI_PIMPL(PackagesWidget)
{
auto *btn = new ButtonWidget;
btn->setText(_E(l) + tag.toLower());
btn->setAction([this, tag] ()
btn->setActionFn([this, tag] ()
{
String terms = _owner.d->search->text();
if(!terms.isEmpty() && !terms.last().isSpace()) terms += " ";
Expand Down Expand Up @@ -305,7 +305,7 @@ DENG_GUI_PIMPL(PackagesWidget)
clearSearch->rule()
.setInput(Rule::Right, search->rule().left())
.setMidAnchorY(search->rule().midY());
clearSearch->setAction([this] () {
clearSearch->setActionFn([this] () {
search->setText("");
root().setFocus(search);
});
Expand Down
2 changes: 1 addition & 1 deletion doomsday/apps/client/src/ui/home/savelistwidget.cpp
Expand Up @@ -73,7 +73,7 @@ DENG_GUI_PIMPL(SaveListWidget)
button.margins().set("dialog.gap");
button.set(Background(Vector4f()));

button.setAction([this, &button] () {
button.setActionFn([this, &button] () {
toggleSelectedItem(button);
emit owner.mouseActivity();
});
Expand Down
5 changes: 4 additions & 1 deletion doomsday/sdk/libappfw/include/de/widgets/buttonwidget.h
Expand Up @@ -101,8 +101,11 @@ class LIBAPPFW_PUBLIC ButtonWidget : public LabelWidget
* when the button is pressed.
*
* @param callback Callback function.
*
* @todo Rename back to setAction() when MSVC can understand that Action *
* cannot be used to initialize a std::function<void ()>.
*/
void setAction(std::function<void ()> callback);
void setActionFn(std::function<void ()> callback);

Action const *action() const;

Expand Down
2 changes: 1 addition & 1 deletion doomsday/sdk/libappfw/src/widgets/buttonwidget.cpp
Expand Up @@ -265,7 +265,7 @@ void ButtonWidget::setAction(RefArg<Action> action)
}
}

void ButtonWidget::setAction(std::function<void ()> callback)
void ButtonWidget::setActionFn(std::function<void ()> callback)
{
setAction(new CallbackAction(callback));
}
Expand Down

0 comments on commit 85318a6

Please sign in to comment.