From 41e04965769f3b38d779fa7f3661b649d093cdd6 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Fri, 31 Aug 2018 22:55:23 +0200 Subject: [PATCH] NotificationDisplay: now able to build the expand functionality ...by delegating to an Expander placed into the ErrorLogDisplay widget --- src/gui/ctrl/notification-hub.hpp | 19 +++++++------ src/gui/model/tangible.cpp | 5 +++- src/gui/panel/infobox-panel.cpp | 9 ++++++- src/gui/widget/error-log-display.hpp | 10 +++---- wiki/thinkPad.ichthyo.mm | 40 ++++++++++++++++------------ 5 files changed, 47 insertions(+), 36 deletions(-) diff --git a/src/gui/ctrl/notification-hub.hpp b/src/gui/ctrl/notification-hub.hpp index 7726bbe18..3c75f17f9 100644 --- a/src/gui/ctrl/notification-hub.hpp +++ b/src/gui/ctrl/notification-hub.hpp @@ -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() { }; diff --git a/src/gui/model/tangible.cpp b/src/gui/model/tangible.cpp index f435174b0..581912e7a 100644 --- a/src/gui/model/tangible.cpp +++ b/src/gui/model/tangible.cpp @@ -262,7 +262,10 @@ namespace model { Tangible::doMark (GenNode const& stateMark) { if (stateMark.idi.getSym() == "expand") - this->doExpand (stateMark.data.get()); + { + if (this->doExpand (stateMark.data.get())) + uiBus_.note (GenNode("expand", true)); // possibly reentrant (yet harmless) + } else if (stateMark.idi.getSym() == "reset") this->reset(); diff --git a/src/gui/panel/infobox-panel.cpp b/src/gui/panel/infobox-panel.cpp index a0980b279..2c8d86996 100644 --- a/src/gui/panel/infobox-panel.cpp +++ b/src/gui/panel/infobox-panel.cpp @@ -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(); diff --git a/src/gui/widget/error-log-display.hpp b/src/gui/widget/error-log-display.hpp index 66c431d0a..376ceea2f 100644 --- a/src/gui/widget/error-log-display.hpp +++ b/src/gui/widget/error-log-display.hpp @@ -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() { diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index 7a744cd16..8ae6c0337 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -1741,10 +1741,10 @@ - - - - + + + + @@ -1779,7 +1779,7 @@ - + @@ -1789,7 +1789,7 @@

der Parent-Container ist für das expand/collapse zuständig

- + @@ -1941,8 +1941,8 @@ - - + + @@ -2441,19 +2441,19 @@ - - - - - - - - + + + + - + + + + + @@ -2471,6 +2471,12 @@ + + + + + +