Lumiera 0.pre.04~rc.1
»edit your freedom«
Loading...
Searching...
No Matches
tangible.hpp
Go to the documentation of this file.
1/*
2 TANGIBLE.hpp - a tangible element of the user interface
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
120#ifndef STAGE_MODEL_TANGIBLE_H
121#define STAGE_MODEL_TANGIBLE_H
122
123
124#include "lib/error.hpp"
125#include "lib/nocopy.hpp"
129#include "lib/idi/entry-id.hpp"
130#include "lib/symbol.hpp"
131
132#include <sigc++/trackable.h>
133#include <utility>
134#include <string>
135
136
137namespace stage {
138namespace model {
139
140 using std::string;
141 using lib::Symbol;
142
143
157 : public sigc::trackable
160 {
161 public:
164 protected:
167
169
172
173
174 Tangible(ID identity, ctrl::BusTerm& nexus)
175 : uiBus_{nexus.attach(identity, *this)}
176 , expand_{}
177 , reveal_{}
178 { }
179
180 public:
181 virtual ~Tangible();
182
183 operator string() const;
184 operator LuidH() const { return uiBus_.getID().getHash(); }
185
186 ID getID() const { return uiBus_.getID();}
187
188 void reset();
189 void clearMsg();
190 void clearErr();
191
192 template<typename...ARGS>
193 void invoke (Symbol cmdID, ARGS&&...);
194 void invoke (Symbol cmdID, Rec&& arguments);
195
196 void slotExpand();
197 void slotCollapse();
198 void slotReveal();
199
200 void markFlash();
201 void markMsg (string message);
202 void markErr (string error);
203 void mark(GenNode const&);
204
207
208 protected:
209 virtual bool doReset() =0;
210 virtual bool doClearMsg() =0;
211 virtual bool doClearErr() =0;
212 virtual bool doExpand (bool yes);
213 virtual void doReveal ();
214
215 virtual bool doMsg (string) =0;
216 virtual bool doErr (string) =0;
217 virtual void doFlash() =0;
218 virtual void doMark(GenNode const&) =0;
219
220 public:
222
223
228 friend constexpr size_t
230 {
231 return 512;
232 }
233 };
234
235
236
240 template<typename...ARGS>
241 inline lib::diff::GenNode
242 commandMessage (Symbol cmdID, ARGS&&... args)
243 {
244 using lib::diff::Rec;
245 using lib::diff::GenNode;
246 using GenNodeIL = std::initializer_list<GenNode>;
247
248
249 return GenNode (string{cmdID},
250 Rec(Rec::TYPE_NIL_SYM
251 ,GenNodeIL{}
252 ,GenNodeIL {std::forward<ARGS> (args)...}));
253 } // not typed, no attributes, all arguments as children
254
255
257 template<typename...ARGS>
258 inline void
259 Tangible::invoke (Symbol cmdID, ARGS&&... args)
260 {
261 uiBus_.act (commandMessage (cmdID, std::forward<ARGS> (args)...));
262 }
263
264
272 inline void
274 Expander::ChangeFun howto_expand_collapse)
275 {
276 expand_ = Expander{move (detectCurrExpansionState), move (howto_expand_collapse)};
277 }
278
279
287 inline void
289 {
290 reveal_ = Revealer{move (how_to_uncover_the_element)};
291 }
292
293
294
295
296}} // namespace stage::model
297#endif /*STAGE_MODEL_TANGIBLE_H*/
Attachment point to the UI-Bus.
A handle to allow for safe »remote implantation« of an unknown subclass into a given opaque InPlaceBu...
Token or Atom with distinct identity.
Definition symbol.hpp:120
Marker or capability interface: an otherwise not further disclosed data structure,...
object-like record of data.
Definition record.hpp:142
Hash implementation based on a lumiera unique object id (LUID) When invoking the default ctor,...
connection point at the UI-Bus.
Definition bus-term.hpp:98
virtual void act(GenNode const &command)
prepare or trigger invocation of a command.
Definition ui-bus.cpp:113
EntryID const & ID
Definition bus-term.hpp:107
Functor component to support the default implementation of expanding/collapsing.
std::function< bool(void)> ProbeFun
std::function< void(bool)> ChangeFun
Functor component to support the default implementation of revealing an UI-Element.
std::function< void()> RevealeItFun
Interface common to all UI elements of relevance for the Lumiera application.
Definition tangible.hpp:160
friend constexpr size_t treeMutatorSize(const Tangible *)
override default size traits for diff application.
Definition tangible.hpp:229
virtual bool doClearErr()=0
void clearErr()
invoke the hook to clear error markers
Definition tangible.cpp:87
virtual void doFlash()=0
Tangible(ID identity, ctrl::BusTerm &nexus)
Definition tangible.hpp:174
virtual void doMark(GenNode const &)=0
default implementation and catch-all handler for receiving »state mark« messages.
Definition tangible.cpp:286
void installExpander(Expander::ProbeFun, Expander::ChangeFun)
Configure the (optional) functionality to expand or collapse the UI-Element.
Definition tangible.hpp:273
virtual bool doMsg(string)=0
virtual bool doErr(string)=0
void markFlash()
highlight the element visually to catch the user's attention
Definition tangible.cpp:110
virtual bool doReset()=0
void slotReveal()
Cause the element to be brought into sight.
Definition tangible.cpp:213
void clearMsg()
invoke the hook to clear notification messages
Definition tangible.cpp:98
void invoke(Symbol cmdID, ARGS &&...)
void slotCollapse()
Collapse or minimise this element and remember the collapsed state.
Definition tangible.cpp:173
void markErr(string error)
push an error state tag to the element
Definition tangible.cpp:141
void installRevealer(Revealer::RevealeItFun)
Configure the (optional) functionality to bring the UI-Element into sight.
Definition tangible.hpp:288
lib::hash::LuidH LuidH
Definition tangible.hpp:163
void markMsg(string message)
push a notification (or warning) message to the element.
Definition tangible.cpp:130
ctrl::BusTerm::ID ID
Definition tangible.hpp:162
virtual bool doClearMsg()=0
virtual void buildMutator(lib::diff::TreeMutator::Handle)=0
build a custom implementation of the TreeMutator interface, suitably wired to cause appropriate chang...
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
virtual void doReveal()
generic default implementation of the "reveal" functionality.
Definition tangible.cpp:225
ctrl::BusTerm uiBus_
Definition tangible.hpp:168
void reset()
invoke the generic reset hook
Definition tangible.cpp:65
void slotExpand()
Expand this element and remember the expanded state.
Definition tangible.cpp:161
virtual ~Tangible()
this is an interface
Definition tangible.cpp:37
Any copy and copy construction prohibited.
Definition nocopy.hpp:38
Abstraction or descriptor interface for a data structure exposing the ability for mutation by receivi...
Bare symbolic and hash ID used for accounting of asset like entries.
Lumiera error handling (C++ interface).
Helper components to implement some standard UI-element actions by installing a functor.
Record< GenNode > Rec
Definition gen-node.hpp:133
lib::diff::GenNode commandMessage(Symbol cmdID, ARGS &&... args)
convenience shortcut to build a message suitable for command invocation
Definition tangible.hpp:242
Lumiera GTK UI implementation root.
Definition guifacade.cpp:37
Mix-Ins to allow or prohibit various degrees of copying and cloning.
generic data element node within a tree
Definition gen-node.hpp:224
Marker types to indicate a literal string and a Symbol.