Lumiera  0.pre.03
»edit your freedom«
tangible.cpp
Go to the documentation of this file.
1 /*
2  Tangible - common implementation base of all relevant interface elements
3 
4  Copyright (C)
5  2015, 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 
24 #include "stage/model/tangible.hpp"
25 #include "stage/model/widget.hpp"
27 #include "include/ui-protocol.hpp"
28 #include "lib/diff/gen-node.hpp"
29 #include "lib/meta/util.hpp"
30 
31 
32 namespace stage {
33 namespace model {
34 
35 
36 
37  Tangible::~Tangible() { } // Emit VTables here...
38 
39 
40 
44  Tangible::operator string() const
45  {
46  return lib::meta::typeStr (this)
47  + "("
48  + string{this->getID()}
49  + ")";
50  }
51 
52 
64  void
66  {
67  if (this->doReset())
68  uiBus_.note (GenNode{string{MARK_reset}, true});
69  }
70 
71 
86  void
88  {
89  if (this->doClearErr())
90  uiBus_.note (GenNode{string{MARK_clearErr}, true});
91  }
92 
93 
97  void
99  {
100  if (this->doClearMsg())
101  uiBus_.note (GenNode{string{MARK_clearMsg}, true});
102  }
103 
104 
109  void
111  {
112  this->doFlash();
113  }
114 
115 
129  void
130  Tangible::markMsg (string message)
131  {
132  if (this->doMsg (message))
133  uiBus_.note (GenNode{string{MARK_Message}, message});
134  }
135 
136 
140  void
142  {
143  if (this->doErr (error))
144  uiBus_.note (GenNode{string{MARK_Error}, error});
145  }
146 
147 
160  void
162  {
163  if (this->doExpand (true))
164  uiBus_.note (GenNode{string{MARK_expand}, true});
165  }
166 
167 
172  void
174  {
175  if (this->doExpand (false))
176  uiBus_.note (GenNode{string{MARK_expand}, false});
177  }
178 
179 
186  bool
188  {
189  if (not expand_.canExpand())
190  return false;
191  bool oldState = expand_(yes);
192  return oldState != yes; // actually changed
193  }
194 
195 
212  void
214  {
215  this->doReveal();
216  }
217 
218 
224  void
226  {
227  if (reveal_.canReveal())
228  reveal_();
229  }
230 
231 
232 
241  void
242  Tangible::invoke (Symbol cmdID, Rec&& arguments)
243  {
244  uiBus_.act (GenNode{string{cmdID}, std::forward<Rec>(arguments)});
245  }
246 
247 
248 
250  void
251  Tangible::mark (GenNode const& stateMark)
252  {
253  if (stateMark.idi.getSym() == MARK_Flash)
254  this->doFlash();
255  else
256  if (stateMark.idi.getSym() == MARK_Error)
257  this->markErr (stateMark.data.get<string>());
258  else
259  if (stateMark.idi.getSym() == MARK_Message)
260  this->markMsg (stateMark.data.get<string>());
261  else
262  this->doMark(stateMark);
263  }
264 
265 
285  void
286  Tangible::doMark (GenNode const& stateMark)
287  {
288  if (stateMark.idi.getSym() == MARK_expand)
289  {
290  if (this->doExpand (stateMark.data.get<bool>()))
291  uiBus_.note (GenNode(string{MARK_expand}, true)); // possibly reentrant (yet harmless)
292  }
293  else
294  if (stateMark.idi.getSym() == MARK_reset)
295  this->reset();
296  else
297  if (stateMark.idi.getSym() == MARK_clearMsg)
298  this->clearMsg();
299  else
300  if (stateMark.idi.getSym() == MARK_clearErr)
301  this->clearErr();
302  else
303  if (stateMark.idi.getSym() == MARK_reveal)
304  this->doReveal();
305  }
306 
307 
308 
309 }} // namespace stage::model
virtual ~Tangible()
this is an interface
Definition: tangible.cpp:37
void slotExpand()
Expand this element and remember the expanded state.
Definition: tangible.cpp:161
Abstraction: a tangible element of the User Interface.
Hard wired key constants and basic definitions for communication with the GUI.
Common Abstraction of all UIBus connected widget elements.
void reset()
invoke the generic reset hook
Definition: tangible.cpp:65
Simple and lightweight helpers for metaprogramming and type detection.
virtual void note(ID subject, GenNode const &mark)
capture and record a "state mark" for later replay for restoring UI state.
Definition: ui-bus.cpp:149
void mark(GenNode const &)
generic handler for all incoming "state mark" messages
Definition: tangible.cpp:251
virtual bool doExpand(bool yes)
generic default implementation of the expand/collapse functionality.
Definition: tangible.cpp:187
void clearMsg()
invoke the hook to clear notification messages
Definition: tangible.cpp:98
Token or Atom with distinct identity.
Definition: symbol.hpp:117
void markMsg(string message)
push a notification (or warning) message to the element.
Definition: tangible.cpp:130
void markFlash()
highlight the element visually to catch the user&#39;s attention
Definition: tangible.cpp:110
void markErr(string error)
push an error state tag to the element
Definition: tangible.cpp:141
Lumiera GTK UI implementation root.
Definition: guifacade.cpp:37
Generic building block for tree shaped (meta)data structures.
virtual void doMark(GenNode const &)=0
default implementation and catch-all handler for receiving »state mark« messages. ...
Definition: tangible.cpp:286
virtual void doReveal()
generic default implementation of the "reveal" functionality.
Definition: tangible.cpp:225
void slotCollapse()
Collapse or minimise this element and remember the collapsed state.
Definition: tangible.cpp:173
void clearErr()
invoke the hook to clear error markers
Definition: tangible.cpp:87
object-like record of data.
Definition: record.hpp:141
Common Abstraction of all sub-controller, coordinated by the UI-Bus.
virtual void act(GenNode const &command)
prepare or trigger invocation of a command.
Definition: ui-bus.cpp:130
generic data element node within a tree
Definition: gen-node.hpp:222
void slotReveal()
Cause the element to be brought into sight.
Definition: tangible.cpp:213