From 65bbc45e025f6ee42d969cf17367260683f2822a Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Mon, 20 Aug 2018 03:55:06 +0200 Subject: [PATCH] NotificationDisplay: care for lifecycle issues and expansion state persistence --- src/gui/ctrl/nexus.hpp | 2 +- src/gui/ctrl/notification-hub.hpp | 5 +++-- src/gui/ctrl/state-recorder.hpp | 8 +++++++ src/gui/widget/error-log-display.hpp | 23 ++++++++++++++++++- wiki/thinkPad.ichthyo.mm | 33 +++++++++++++++++++++------- 5 files changed, 59 insertions(+), 12 deletions(-) diff --git a/src/gui/ctrl/nexus.hpp b/src/gui/ctrl/nexus.hpp index 3d6a93a9f..eab41a8ea 100644 --- a/src/gui/ctrl/nexus.hpp +++ b/src/gui/ctrl/nexus.hpp @@ -69,7 +69,7 @@ namespace ctrl{ * * Thus, the "uplink", which is in fact the CoreService, is left to handle * - the *`act`* messages (command invocation) - * - the *`mark`* messages (upstream state change notification) + * - the *`note`* messages (upstream state change notification) * * @todo write type comment */ diff --git a/src/gui/ctrl/notification-hub.hpp b/src/gui/ctrl/notification-hub.hpp index 5b3a5b685..7726bbe18 100644 --- a/src/gui/ctrl/notification-hub.hpp +++ b/src/gui/ctrl/notification-hub.hpp @@ -121,8 +121,9 @@ namespace ctrl { doExpand (bool yes) override { if (widget_ or yes) - getWidget().expand (yes); - return false; // expand state not sticky + if (getWidget().expand (yes)) + uiBus_.note (GenNode("expand", yes)); + return false; // state persisted if necessary } virtual void diff --git a/src/gui/ctrl/state-recorder.hpp b/src/gui/ctrl/state-recorder.hpp index 47d15ee1e..edf89dd44 100644 --- a/src/gui/ctrl/state-recorder.hpp +++ b/src/gui/ctrl/state-recorder.hpp @@ -187,6 +187,14 @@ namespace ctrl { } private: + /** @remark depending on the response of the notified element, + * this might lead to a reentrant record() call, because the + * element might chose to send a _note_ message immediately, + * to record a state change, since it can not know this _is_ + * already the replay of a stored state note. However, this + * reentrant call is harmless, it just updates the existing + * entry with identical content. + */ void replayPropertiesOf (Record entry) { diff --git a/src/gui/widget/error-log-display.hpp b/src/gui/widget/error-log-display.hpp index 0e16dab30..383677e44 100644 --- a/src/gui/widget/error-log-display.hpp +++ b/src/gui/widget/error-log-display.hpp @@ -27,6 +27,26 @@ ** entries can be added with a severity level, causing the widget to scroll ** down to the last line of the content buffer. ** + ** ## Lifecycle considerations + ** + ** The ErrorLogDisplay is typically managed as child of a container widget. + ** However, the ctrl::NotificationHub as controller does a lookup and attaches + ** to an ErrorLogDisplay found within the InfoBoxPanel, using it as holder for + ** information and error messages pushed into the GUI. For that reason, it is + ** important really _to destroy_ the ErrorLogDisplay, when it is taken out of + ** service. Since ErrorLogDisplay inherits from `sigc::tangible`, it is + ** automatically detached from the WLink implementing this cross-attachment, + ** when actually the dtor is called. + ** @note this is a special convention; usually it is sufficient just to hide() + ** a GTK widget, because it is then left alone by the event handling and + ** automatically cleaned up at shutdown. Moreover, if you ` remove()` a + ** widget from a container, the container no longer manages the widget, + ** so you are responsible to take ownership in such situations. And, + ** as said, in case of the ErrorLogDisplay, you should `delete` it. + ** @remark the standard use case is to have the ErrorLogDisplay sitting + ** within the InfoBoxPanel. If the latter is destroyed, it destroys + ** its children and all works as expected without much ado. + ** ** @todo WIP-WIP-WIP as of 9/2017 this is a first draft of a widget to be ** used as receiver by the GuiNotificationService. ** @@ -94,10 +114,11 @@ namespace widget { } } - void + 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 diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index 7aa9681dc..c06db4fa3 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -1888,8 +1888,8 @@ - - + + @@ -1906,7 +1906,7 @@ - + @@ -1946,7 +1946,7 @@ - + @@ -2101,11 +2101,28 @@ - - + + + + + + + + +

+ entweder sie laufen über den Getter, +

+

+ oder sie prüfen den Zustand und machen nichts, wenn das Widget nicht da ist +

+ + +
+ +
@@ -2122,8 +2139,8 @@ - - + +