File: context.dox

package info (click to toggle)
lomiri-action-api 1.2.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,104 kB
  • sloc: cpp: 3,784; ansic: 1,052; xml: 64; makefile: 54
file content (61 lines) | stat: -rw-r--r-- 2,501 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*!
\page page_contexts Action Contexts

\section sec_overview Overview
Application which has different views needs to manage it actions based on the currently active view;
not all of the actions supported by the application might be relevant or applicable on all of the views.

Therefore Lomiri Action API provides action contexts; a context groups actions together and by providing multiple contexts
the developer is able to control the visibility of the actions. The ActionManager then exposes the actions from
these different contexts.

\image html context_overview.png

Each application has one global context; the actions in this context are always available. The application may have one or more
additional local context of which only one can be active at a time. The ActionManager merges the global context and the active local
context together; the actions available at any given time is the union of the global context and the active local context.

\image html multiple_contexts.png


\section sec_single_context Applications with Single Context
For applications that do not require multiple contexts using the API is straight forward as the
ActionManager provides the global context automatically.

First, create the Action:
\snippet action-context/action-context.cpp create global action

And add it to the ActionManager:
\snippet action-context/action-context.cpp add global to manager

myAction is now added to the global context.


\section sec_multiple_contexts Applications with Multiple Contexts
When multiple contexts are needed the developer creates suitable number of ActionContext objects,
adds the actions to the contexts, adds the contexts to the manager and sets the active one.

Setting the active context must be managed by the developer. The can only be one active
local context at a time.

Create the local actions:
\snippet action-context/action-context.cpp create local actions

Create the local contexts:
\snippet action-context/action-context.cpp create contexts

Add the local actions to the contexts:
\snippet action-context/action-context.cpp add context actions

Add the local contexts to the manager:
\snippet action-context/action-context.cpp add local ctx to manager

Manage the active context by setting the active property on any of them:
\snippet action-context/action-context.cpp set context active
Setting an another context active later will inactivate the previously active one.

---
The complete example:
\include action-context/action-context.cpp

*/