Lumiera 0.pre.04
»edit your freedom«
Loading...
Searching...
No Matches
notification-hub.hpp
Go to the documentation of this file.
1/*
2 NOTIFICATION-HUB.hpp - receive and reroute notification messages
3
4 Copyright (C)
5 2018, 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
53#ifndef STAGE_CTRL_NOTIFICATION_HUB_H
54#define STAGE_CTRL_NOTIFICATION_HUB_H
55
60
61#include <functional>
62
63
64namespace stage {
65namespace ctrl {
66
68 using model::WLink;
69
70
71
72
80 : public model::Controller
81 {
82
83
85 void
87 {
88 buffer.emplace(
90 );
91 UNIMPLEMENTED ("define and implement what need to be reflected from asset::ErrorLog");
92 }
93
94
95 /* ==== Tangible interface ==== */
96
97 virtual bool
98 doReset() override
99 {
100 if (not widget_) return false;
101
102 widget_->clearAll();
103 widget_->expand (false);
104 return true;
105 }
106
107 virtual bool
108 doMsg (string text) override
109 {
110 getWidget().addInfo (text);
111 return false; // logging is no persistent state
112 }
113
114 virtual bool
115 doClearMsg () override
116 {
117 if (widget_)
118 widget_->clearInfoMsg();
119 return false; // not persistent (sticky)
120 }
121
122 virtual bool
123 doErr (string text) override
124 {
125 getWidget().addError (text);
126 return false;
127 }
128
129 virtual bool
130 doClearErr () override
131 {
132 if (widget_)
133 widget_->turnError_into_InfoMsg();
134 return false; // not persistent (sticky)
135 }
136
138 virtual void
139 doMark (GenNode const& stateMark) override
140 {
141 if (stateMark.idi.getSym() == MARK_Warning)
142 getWidget().addWarn (stateMark.data.get<string>());
143 else
144 // forward to default handler
145 Controller::doMark (stateMark);
146 }
147
148 virtual void
149 doFlash() override
150 {
151 if (not widget_) return;
152 widget_->reveal();
153 widget_->triggerFlash();
154 }
155
156
157 public:
158 using WidgetAllocator = std::function<widget::ErrorLogDisplay&(void)>;
159
160
162 : model::Controller{identity, nexus}
163 , allocateWidget_{wa}
164 , widget_{}
165 {
166 installExpander([&](){ return widget_ and widget_->expand; }
167 ,[&](bool yes)
168 {
169 if (widget_ or yes)
170 getWidget().expand (yes);
171 }
172 );
173 installRevealer([&](){ getWidget().reveal(); }); // implementation implies also expand
174 }
175
177
178
179 private:
182
185
186
189 {
190 if (not widget_)
191 widget_.connect (allocateWidget_());
192 return *widget_;
193 }
194 };
195
196
197
198}}// namespace stage::ctrl
199#endif /*STAGE_CTRL_NOTIFICATION_HUB_H*/
A handle to allow for safe »remote implantation« of an unknown subclass into a given opaque InPlaceBu...
SUB & emplace(SUB &&implementation)
move-construct an instance of a subclass into the opaque buffer
Customisable intermediary to abstract mutating operations on arbitrary, hierarchical object-like data...
static Builder< TreeMutator > build()
DSL: start building a custom adapted tree mutator, where the operations are tied by closures or wrapp...
string const & getSym() const
Definition entry-id.hpp:169
connection point at the UI-Bus.
Definition bus-term.hpp:98
Service to receive and display error, warning and notification messages.
virtual bool doClearErr() override
WidgetAllocator allocateWidget_
external operation to find or allocate an log display widget
virtual bool doReset() override
virtual bool doMsg(string text) override
widget::ErrorLogDisplay & getWidget()
virtual void doMark(GenNode const &stateMark) override
adds special treatment for a state mark tagged as "Warning"
virtual void doFlash() override
void buildMutator(lib::diff::TreeMutator::Handle buffer) override
population and manipulation of persistent content via UI-Bus
std::function< widget::ErrorLogDisplay &(void)> WidgetAllocator
WLink< widget::ErrorLogDisplay > widget_
collaboration with a log display allocated elsewhere
virtual bool doClearMsg() override
NotificationHub(ID identity, ctrl::BusTerm &nexus, WidgetAllocator wa)
virtual bool doErr(string text) override
void installExpander(Expander::ProbeFun, Expander::ChangeFun)
Configure the (optional) functionality to expand or collapse the UI-Element.
Definition tangible.hpp:273
void installRevealer(Revealer::RevealeItFun)
Configure the (optional) functionality to bring the UI-Element into sight.
Definition tangible.hpp:288
ctrl::BusTerm::ID ID
Definition tangible.hpp:162
Widget to display log and error messages.
void addError(string text)
present an error notification prominently.
void addWarn(string text)
add an information message, formatted more prominent as warning
void addInfo(string text)
just add normal information message to buffer, without special markup and without expanding the widge...
Common Abstraction of all sub-controller, coordinated by the UI-Bus.
Widget to display error messages to be accessible in non-modal way.
Lumiera GTK UI implementation root.
Definition guifacade.cpp:37
const Symbol MARK_Warning
generic data element node within a tree
Definition gen-node.hpp:224
Customisable intermediary to abstract generic tree mutation operations.