Lumiera  0.pre.03
»edit your freedom«
cmd-context.hpp
Go to the documentation of this file.
1 /*
2  CMD-CONTEXT.hpp - interface to access command context binding services within the UI
3 
4  Copyright (C)
5  2017, Hermann Vosseler <Ichthyostega@web.de>
6 
7   **Lumiera** is free software; you can redistribute it and/or modify it
8   under the terms of the GNU General Public License as published by the
9   Free Software Foundation; either version 2 of the License, or (at your
10   option) any later version. See the file COPYING for further details.
11 
12 */
13 
14 
44 #ifndef STAGE_INTERACT_CMD_CONTEXT_H
45 #define STAGE_INTERACT_CMD_CONTEXT_H
46 
47 
48 #include "lib/error.hpp"
49 #include "lib/nocopy.hpp"
50 //#include "stage/ctrl/bus-term.hpp"
51 //#include "lib/idi/entry-id.hpp"
52 #include "lib/hash-indexed.hpp"
53 #include "lib/opaque-holder.hpp"
54 #include "lib/symbol.hpp"
55 #include "lib/nocopy.hpp"
56 //#include "lib/util.hpp"
57 
58 //#include <string>
59 #include <utility>
60 
61 namespace Gtk {
62  class Widget;
63 }
64 namespace stage {
65 namespace interact {
66 
67 // using lib::HashVal;
68  using lib::hash::LuidH;
69  using lib::Symbol;
70 // using util::isnil;
71 // using std::string;
72 
73  class InteractionState;
74 
75 
76 
89  : public util::MoveAssign
90  {
91  Symbol cmdID_;
92 
93  public:
94  virtual ~GestureObserver();
95 
96  GestureObserver (Symbol cmdID) : cmdID_(cmdID) { }
97 
98  GestureObserver (GestureObserver&&) = default;
99  GestureObserver& operator= (GestureObserver&&) = default;
100 
101 
102  Symbol getCmdID() const { return cmdID_; }
103 
104  virtual void updateOffset (double deltaX, double deltaY) =0;
105  virtual void markGestureCompleted() =0;
106  };
107 
108 
111  : public GestureObserver
112  {
113  void updateOffset (double, double) override { /*NOOP*/ }
114  void markGestureCompleted() override { /*NOOP*/ }
115  public:
116  InactiveObserver() : GestureObserver(Symbol::BOTTOM) { }
117  };
118 
119 
120 
127  class Subject
129  {
130  protected:
131  virtual ~Subject();
132 
133  public:
135  virtual void buildGestureObserver (Symbol cmdID, Buffer) =0;
136  virtual Gtk::Widget& exposeWidget() =0;
137  };
138 
139 
140 
148  {
149  InteractionState& iState_;
150  Symbol cmdID_;
151 
152  /* ===== Builder State ===== */
153  Subject* subject_{nullptr};
154 
155  CmdContext (InteractionState& iState, Symbol cmdID)
156  : iState_{iState}
157  , cmdID_{cmdID}
158  { }
159  public:
160  // using the default move-ctor
161 
162  /* === access front-end === */
163  static CmdContext of (Symbol cmdID, Symbol ctxID);
164 
165  struct Resolver;
166 
168  CmdContext&& linkSubject (Subject& subj) { this->subject_ = &subj; return std::move (*this); }
169 
178  void setupRelocateDrag();
179 
180  protected:
181  private:
182  };
183 
184 
190  {
191 
195  operator LuidH ();
196 
197 
198  enum Spec {
199  HERE,
200  RECENT
201  };
202 
203 
204  friend Resolver
205  scope (Spec scopeSpec)
206  {
207  return Resolver{scopeSpec};
208  }
209 
210 
211  friend Resolver
212  element (Spec elementSpec)
213  {
214  return Resolver{elementSpec};
215  }
216 
217  private:
218  const Spec spec = HERE;
219 
220  Resolver(Spec s)
221  : spec(s)
222  { }
223  };
224 
225 
226 }} // namespace stage::interact
227 #endif /*STAGE_INTERACT_CMD_CONTEXT_H*/
Types marked with this mix-in may be moved and move-assigned.
Definition: nocopy.hpp:63
CmdContext && linkSubject(Subject &subj)
Builder operation: define the subject to use for the following interaction bindings.
Any copy and copy construction prohibited.
Definition: nocopy.hpp:37
Types marked with this mix-in may be moved but not copied.
Definition: nocopy.hpp:49
Abstract foundation for context dependent UI interactions.
Token or Atom with distinct identity.
Definition: symbol.hpp:117
Mix-Ins to allow or prohibit various degrees of copying and cloning.
A handle to allow for safe »remote implantation« of an unknown subclass into a given opaque InPlaceBu...
Definition: record.hpp:104
Marker types to indicate a literal string and a Symbol.
Lumiera GTK UI implementation root.
Definition: guifacade.cpp:37
Helper allowing type erasure while holding the actual object inline.
»Null Object« when no gesture is being tracked currently.
A template for generating hash based ID tags carrying compile-time type info.
Lumiera error handling (C++ interface).
Hash implementation based on a lumiera unique object id (LUID) When invoking the default ctor...
Helper for dynamic command argument resolution.
Collaboration interface for tracking the formation of a gesture.
Definition: cmd-context.hpp:88
Builder to define a binding to relate some entity or place within the UI with a specific from of inte...
Role-Interface: the Subject of Interaction.