NotificationDisplay: now able to build the expand functionality

...by delegating to an Expander placed into the ErrorLogDisplay widget
This commit is contained in:
Fischlurch 2018-08-31 22:55:23 +02:00
parent 3f327b335a
commit 41e0496576
5 changed files with 47 additions and 36 deletions

View file

@ -117,15 +117,6 @@ namespace ctrl {
return true;
}
virtual bool
doExpand (bool yes) override
{
if (widget_ or yes)
if (getWidget().expand (yes))
uiBus_.note (GenNode("expand", yes));
return false; // state persisted if necessary
}
virtual void
doRevealYourself() override
{
@ -180,7 +171,15 @@ namespace ctrl {
: model::Controller{identity, nexus}
, allocateWidget_{wa}
, widget_{}
{ }
{
installExpander([&](){ return widget_ and widget_->expand; }
,[&](bool yes)
{
if (widget_ or yes)
getWidget().expand (yes);
}
);
}
~NotificationHub() { };

View file

@ -262,7 +262,10 @@ namespace model {
Tangible::doMark (GenNode const& stateMark)
{
if (stateMark.idi.getSym() == "expand")
this->doExpand (stateMark.data.get<bool>());
{
if (this->doExpand (stateMark.data.get<bool>()))
uiBus_.note (GenNode("expand", true)); // possibly reentrant (yet harmless)
}
else
if (stateMark.idi.getSym() == "reset")
this->reset();

View file

@ -81,7 +81,11 @@ namespace panel{
/** on demand allocate display of information / error log
* @note we assume it stays alive forever, once allocated
* @todo add possibility to collapse it
* @remark the ErrorLogDisplay widget exposes a \ref Expander functor,
* which is wired here with the Gtk::Expander container holding the Log.
* This setup allows to trigger the expand/collapse functionality and
* query the expansion state directly on the widget. Especially
* \ref NotificationHub relies on this configuration.
*/
ErrorLogDisplay&
InfoBoxPanel::getLog()
@ -91,6 +95,9 @@ namespace panel{
theLog_.reset (new ErrorLogDisplay{});
logExpander_.set_expanded (false);
logExpander_.add (*theLog_);
theLog_->expand = model::Expander{[&]() { return logExpander_.get_expanded(); }
,[&](bool yes) { logExpander_.set_expanded (yes); }
};
frame_.set_border_width (5);
frame_.add (logExpander_);
frame_.show_all();

View file

@ -57,6 +57,7 @@
#define GUI_WIDGET_ERROR_LOG_DISPLAY_H
#include "gui/gtk-base.hpp"
#include "gui/model/expander-revealer.hpp"
#include "include/gui-notification-facade.h"
//#include "lib/util.hpp"
@ -96,6 +97,8 @@ namespace widget {
textLog_.set_editable (false);
}
model::Expander expand;
void
showMsg (NotifyLevel severity, string const& text)
@ -114,13 +117,6 @@ namespace widget {
}
}
bool
expand (bool yes)
{
UNIMPLEMENTED ("Maintain expansion state, build a collapsed representation.");
return false; //////TODO true if state change happened; this makes the state persistent
}
void
clearAll()
{

View file

@ -1741,10 +1741,10 @@
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1504203754175" ID="ID_580465154" MODIFIED="1533402997076" TEXT="Fehler-Level erkennen">
<icon BUILTIN="flag-yellow"/>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1534725200588" ID="ID_871562482" MODIFIED="1534725208028" TEXT="Operationen">
<icon BUILTIN="flag-yellow"/>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1534725109137" ID="ID_694776463" MODIFIED="1534725415160" TEXT="expand">
<icon BUILTIN="flag-yellow"/>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1534725200588" ID="ID_871562482" MODIFIED="1535752292770" TEXT="Operationen">
<icon BUILTIN="pencil"/>
<node COLOR="#338800" CREATED="1534725109137" ID="ID_694776463" MODIFIED="1535752255561" TEXT="expand">
<icon BUILTIN="button_ok"/>
<node COLOR="#338800" CREATED="1534725397553" ID="ID_1072347956" MODIFIED="1535631557024" TEXT="collapsed-Repr&#xe4;sentation schaffen">
<icon BUILTIN="button_ok"/>
<node CREATED="1535554610295" ID="ID_1050608842" MODIFIED="1535554619117" TEXT="nur vorl&#xe4;ufige L&#xf6;sung">
@ -1779,7 +1779,7 @@
<icon BUILTIN="info"/>
</node>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1535554640586" ID="ID_1376241476" MODIFIED="1535737885653" TEXT="essentiell: passiert im Parent-Widget">
<node COLOR="#435e98" CREATED="1535554640586" ID="ID_1376241476" MODIFIED="1535752092225" TEXT="essentiell: passiert im Parent-Widget">
<richcontent TYPE="NOTE"><html>
<head>
@ -1789,7 +1789,7 @@
<p>der Parent-Container ist f&#252;r das expand/collapse zust&#228;ndig</p>
</body>
</html></richcontent>
<icon BUILTIN="pencil"/>
<icon BUILTIN="button_ok"/>
<node COLOR="#338800" CREATED="1535634032601" ID="ID_964641889" MODIFIED="1535731317069" TEXT="Design-Problem: sich expandieren">
<icon BUILTIN="button_ok"/>
<node CREATED="1535634116925" ID="ID_1129948550" MODIFIED="1535634126600" TEXT="Voraussetzung: unser Widget-Protokoll">
@ -1941,8 +1941,8 @@
<icon BUILTIN="button_ok"/>
</node>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1535725923421" ID="ID_298871659" MODIFIED="1535725936028" TEXT="Expander geeignet verdrahten">
<icon BUILTIN="flag-yellow"/>
<node COLOR="#338800" CREATED="1535725923421" ID="ID_298871659" MODIFIED="1535752076020" TEXT="Expander geeignet verdrahten">
<icon BUILTIN="button_ok"/>
<node COLOR="#435e98" CREATED="1535725940226" ID="ID_162482468" MODIFIED="1535750016792" TEXT="validiert das Design">
<icon BUILTIN="yes"/>
</node>
@ -2441,19 +2441,19 @@
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1534119979555" ID="ID_1159164748" MODIFIED="1534725765116" TEXT="Controller-Interface">
<icon BUILTIN="pencil"/>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1534120150457" ID="ID_1499287865" MODIFIED="1534725759893" TEXT="doReset()">
<icon BUILTIN="pencil"/>
<node CREATED="1534120150458" ID="ID_1390376483" MODIFIED="1534120202934" TEXT="&quot;Clear log contents, collapse widget, clear error state&quot;&quot;">
<icon BUILTIN="info"/>
</node>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1534120150458" ID="ID_1083026482" MODIFIED="1534725759894" TEXT="doExpand(yes)">
<icon BUILTIN="pencil"/>
<node COLOR="#338800" CREATED="1534120150458" ID="ID_1083026482" MODIFIED="1535752367109" TEXT="Expander">
<icon BUILTIN="button_ok"/>
<node CREATED="1534120150459" ID="ID_1182032725" MODIFIED="1534120202934" TEXT="&quot;Allocate Widget if necessary, expand widget&quot;">
<icon BUILTIN="info"/>
</node>
<node COLOR="#338800" CREATED="1535752333217" ID="ID_332486075" MODIFIED="1535752360062" TEXT="geeignet verdrahten f&#xfc;r Delegation">
<icon BUILTIN="button_ok"/>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1534120150459" ID="ID_1466610963" MODIFIED="1534725759894" TEXT="doRevealYourself()">
<node COLOR="#338800" CREATED="1535752347574" ID="ID_883461261" MODIFIED="1535752358566" TEXT="Expander im ErrorLog widget verwenden">
<icon BUILTIN="button_ok"/>
</node>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1534120150459" ID="ID_1466610963" MODIFIED="1535752377006" TEXT="doRevealYourself()">
<icon BUILTIN="pencil"/>
<node CREATED="1534120150460" ID="ID_1726008784" MODIFIED="1534120253931">
<richcontent TYPE="NODE"><html>
@ -2471,6 +2471,12 @@
</html></richcontent>
</node>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1534120150457" ID="ID_1499287865" MODIFIED="1534725759893" TEXT="doReset()">
<icon BUILTIN="pencil"/>
<node CREATED="1534120150458" ID="ID_1390376483" MODIFIED="1534120202934" TEXT="&quot;Clear log contents, collapse widget, clear error state&quot;&quot;">
<icon BUILTIN="info"/>
</node>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1534120150462" ID="ID_1528884346" MODIFIED="1534725759894" TEXT="doMsg(text)">
<icon BUILTIN="pencil"/>
<node CREATED="1534120150462" ID="ID_1226643824" MODIFIED="1534120202934" TEXT="&quot;Possibly allocate Widget, place text into its buffer. No need to expand&quot;">