Action.hpp File Reference

Detailed Description

  • Conditions
  • Integration with menus, toolbars, etc.
  • TODO solve the problem of a "single" action used in multiple contexts e.g. copy-paste.
  • Steps :
    • declaring the conditions
    • declaring the action types
    • instantiating the conditions
    • instantiating the action types

Go to the source code of this file.

Classes

class  score::ActionGroup
 The ActionGroup class A semantic group of actions : for instance, all the actions related to audio recording, etc. This is to be used for documentation purposes, for instance on a potential keyboard shortcut widget. More...
 
class  score::Action
 The Action class. More...
 
struct  score::MetaAction< Action_T >
 
struct  score::ActionContainer
 The ActionContainer struct. More...
 
struct  score::ActionCondition
 The ActionCondition struct. More...
 
struct  score::DocumentActionCondition
 The DocumentActionCondition struct. More...
 
struct  score::EnableActionIfDocument
 The EnableActionIfDocument struct. More...
 
struct  score::FocusActionCondition
 The FocusActionCondition struct. More...
 
struct  score::SelectionActionCondition
 The SelectionActionCondition struct. More...
 
struct  score::CustomActionCondition
 The CustomActionCondition struct. More...
 

Namespaces

 score
 Base toolkit upon which the software is built.
 

Macros

#define SCORE_DECLARE_SELECTED_OBJECT_CONDITION(Type)
 
#define SCORE_DECLARE_FOCUSED_OBJECT_CONDITION(Type)
 
#define SCORE_DECLARE_DOCUMENT_CONDITION(Type)
 
#define SCORE_DECLARE_ACTION(ActionName, Text, Group, Shortcut)
 
#define SCORE_DECLARE_ACTION_2S(ActionName, Text, Group, Shortcut1, Shortcut2)
 

Typedefs

using score::ActionGroupKey = StringKey< ActionGroup >
 
using score::ActionKey = StringKey< Action >
 
using score::ActionConditionKey = StringKey< score::ActionCondition >
 

Macro Definition Documentation

◆ SCORE_DECLARE_ACTION

#define SCORE_DECLARE_ACTION (   ActionName,
  Text,
  Group,
  Shortcut 
)
Value:
namespace Actions \
{ \
struct ActionName; \
} \
namespace score \
{ \
template <> \
struct MetaAction<Actions::ActionName> \
{ \
static score::Action make(QAction* ptr) \
{ \
return score::Action{ \
ptr, QObject::tr(Text), key(), score::ActionGroupKey{#Group}, Shortcut}; \
} \
\
static score::ActionKey key() \
{ \
return score::ActionKey{#ActionName}; \
} \
}; \
}
The Action class.
Definition: Action.hpp:79
Base toolkit upon which the software is built.
Definition: Application.cpp:90

◆ SCORE_DECLARE_ACTION_2S

#define SCORE_DECLARE_ACTION_2S (   ActionName,
  Text,
  Group,
  Shortcut1,
  Shortcut2 
)
Value:
namespace Actions \
{ \
struct ActionName; \
} \
namespace score \
{ \
template <> \
struct MetaAction<Actions::ActionName> \
{ \
static score::Action make(QAction* ptr) \
{ \
return score::Action{ptr, QObject::tr(Text), \
key(), score::ActionGroupKey{#Group}, \
Shortcut1, Shortcut2}; \
} \
\
static score::ActionKey key() \
{ \
return score::ActionKey{#ActionName}; \
} \
}; \
}

◆ SCORE_DECLARE_DOCUMENT_CONDITION

#define SCORE_DECLARE_DOCUMENT_CONDITION (   Type)
Value:
namespace score \
{ \
template <> \
class EnableWhenDocumentIs<Type> final : public score::DocumentActionCondition \
{ \
public: \
static score::ActionConditionKey static_key() \
{ \
return score::ActionConditionKey{"DocumentIs" #Type}; \
} \
EnableWhenDocumentIs() \
{ \
} \
\
private: \
void action(score::ActionManager& mgr, score::MaybeDocument doc) override \
{ \
if(!doc) \
{ \
setEnabled(mgr, false); \
return; \
} \
auto model = score::IDocument::try_get<Type>(doc->document); \
setEnabled(mgr, bool(model)); \
} \
}; \
}
The ActionManager class.
Definition: ActionManager.hpp:19
The DocumentActionCondition struct.
Definition: Action.hpp:221
Definition: DocumentContext.hpp:18

\macro SCORE_DECLARE_DOCUMENT_CONDITION

Use this macro to declare a new condition that will be enabled whenever a document of the given type is brought forward, or open.

e.g. SCORE_DECLARE_DOCUMENT_CONDITION(Foo) will declare a condition that will enable its actions whenever a document of type Foo is opened (by clicking in its name on the document tab for instance).

Warning
This macro must be used outside of any namespace.

◆ SCORE_DECLARE_FOCUSED_OBJECT_CONDITION

#define SCORE_DECLARE_FOCUSED_OBJECT_CONDITION (   Type)

\macro SCORE_DECLARE_FOCUSED_OBJECT_CONDITION

Use this macro to declare a new condition that will be enabled whenever an object of the given type is focused.

e.g. SCORE_DECLARE_FOCUSED_OBJECT_CONDITION(Foo) will declare a condition that will enable its actions whenever an object of type Foo is focused.

Warning
This macro must be used outside of any namespace.

◆ SCORE_DECLARE_SELECTED_OBJECT_CONDITION

#define SCORE_DECLARE_SELECTED_OBJECT_CONDITION (   Type)

\macro SCORE_DECLARE_SELECTED_OBJECT_CONDITION

Use this macro to declare a new condition that will be enabled whenever an object of the given type is selected.

e.g. SCORE_DECLARE_SELECTED_OBJECT_CONDITION(Foo) will declare a condition that will enable its actions whenever an object of type Foo is selected.

Warning
This macro must be used outside of any namespace.