Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
libdeng2: Added Action, a base class for UI actions
  • Loading branch information
skyjake committed Apr 13, 2013
1 parent f91f5e6 commit c490fde
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 0 deletions.
1 change: 1 addition & 0 deletions doomsday/libdeng2/include/de/Action
@@ -0,0 +1 @@
#include "widgets/action.h"
52 changes: 52 additions & 0 deletions doomsday/libdeng2/include/de/widgets/action.h
@@ -0,0 +1,52 @@
/** @file action.h Abstract base class for UI actions.
*
* @authors Copyright © 2013 Jaakko Keränen <jaakko.keranen@iki.fi>
*
* @par License
* GPL: http://www.gnu.org/licenses/gpl.html
*
* <small>This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. This program is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details. You should have received a copy of the GNU
* General Public License along with this program; if not, see:
* http://www.gnu.org/licenses</small>
*/

#ifndef LIBDENG2_ACTION_H
#define LIBDENG2_ACTION_H

#include <de/Observers>

namespace de {

/**
* Abstract base class for user interface actions.
*
* @ingroup widgets
*/
class DENG2_PUBLIC Action
{
public:
/**
* Audience to be notified when the action is triggerd.
*/
DENG2_DEFINE_AUDIENCE(Triggered, void actionTriggered(Action &))

public:
virtual ~Action();

/**
* Perform the action this instance represents. Derived classes must call
* this or manually notify the Triggered audience in their own
* implementation of the method.
*/
virtual void trigger();
};

} // namespace de

#endif // LIBDENG2_ACTION_H
31 changes: 31 additions & 0 deletions doomsday/libdeng2/src/widgets/action.cpp
@@ -0,0 +1,31 @@
/** @file action.cpp Abstract base class for UI actions.
*
* @authors Copyright © 2013 Jaakko Keränen <jaakko.keranen@iki.fi>
*
* @par License
* GPL: http://www.gnu.org/licenses/gpl.html
*
* <small>This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. This program is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details. You should have received a copy of the GNU
* General Public License along with this program; if not, see:
* http://www.gnu.org/licenses</small>
*/

#include "de/Action"

namespace de {

Action::~Action()
{}

void Action::trigger()
{
DENG2_FOR_AUDIENCE(Triggered, i) i->actionTriggered(*this);
}

} // namespace de
3 changes: 3 additions & 0 deletions doomsday/libdeng2/widgets.pri
@@ -1,4 +1,5 @@
HEADERS += \
include/de/Action \
include/de/Animation \
include/de/AnimationVector \
include/de/DelegateRule \
Expand All @@ -10,6 +11,7 @@ HEADERS += \
include/de/Widget

HEADERS += \
include/de/widgets/action.h \
include/de/widgets/animation.h \
include/de/widgets/animationvector.h \
include/de/widgets/constantrule.h \
Expand All @@ -23,6 +25,7 @@ HEADERS += \
include/de/widgets/widget.h

SOURCES += \
src/widgets/action.cpp \
src/widgets/animation.cpp \
src/widgets/constantrule.cpp \
src/widgets/delegaterule.cpp \
Expand Down

0 comments on commit c490fde

Please sign in to comment.