-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImageBrowserDeferredActions.cpp
More file actions
45 lines (41 loc) · 1.35 KB
/
Copy pathImageBrowserDeferredActions.cpp
File metadata and controls
45 lines (41 loc) · 1.35 KB
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
#include "ImageBrowserDeferredActions.h"
namespace ImageBrowserDeferredActions
{
void Queue(DeferredState& state, int kind, const Floar::VirtualPath& path, const std::wstring& text)
{
state.kind = kind;
state.path = path;
state.text = text;
}
DeferredSnapshot TakeSnapshotAndClear(DeferredState& state, int noneKind)
{
DeferredSnapshot snapshot {};
snapshot.kind = state.kind;
snapshot.path = state.path;
snapshot.text = state.text;
state.kind = noneKind;
state.path = Floar::VirtualPath();
state.text.clear();
return snapshot;
}
bool Dispatch(
const DeferredSnapshot& snapshot,
const std::function<bool(int)>& noPayloadDispatcher,
const std::function<bool(int, const Floar::VirtualPath&)>& pathDispatcher,
const std::function<bool(int, const Floar::VirtualPath&, const std::wstring&)>& pathAndTextDispatcher)
{
if (noPayloadDispatcher && noPayloadDispatcher(snapshot.kind))
{
return true;
}
if (pathDispatcher && pathDispatcher(snapshot.kind, snapshot.path))
{
return true;
}
if (pathAndTextDispatcher && pathAndTextDispatcher(snapshot.kind, snapshot.path, snapshot.text))
{
return true;
}
return false;
}
}