diff --git a/src/gui/model/w-link.hpp b/src/gui/model/w-link.hpp new file mode 100644 index 000000000..8273a3d67 --- /dev/null +++ b/src/gui/model/w-link.hpp @@ -0,0 +1,92 @@ +/* + W-LINK.hpp - smart-link to GTK widget + + Copyright (C) Lumiera.org + 2018, Hermann Vosseler + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + + +/** @file w-link.hpp + ** A smart link to an GTK widget with automatic disconnection. + ** Allows to hold a connection to a `sigc::trackable` without ownership. + ** The is statefull, can be reconnected, and automatically transitions into disconnected + ** state when the target dies. + ** + ** @see \ref WLink_test + ** @see \ref NotificationHub (usage example) + ** + */ + + +#ifndef GUI_MODEL_W_LINK_H +#define GUI_MODEL_W_LINK_H + + +#include "lib/error.hpp" +//#include "lib/symbol.hpp" + +#include +#include +//#include +//#include + + +namespace gui { +namespace model { + +// using std::string; +// using lib::Symbol; + + + /** + * Managed link to a `sigc::trackable` UI widget, without taking ownership. + */ + template + class WLink + { + static_assert (std::is_base_of() + ,"target type required to be sigc::trackable"); + + TAR* widget_; + + + public: + ~WLink() + { + + } + WLink() + { + + } + explicit + WLink(TAR& targetWidget) + : widget_{&targetWidget} + { } + + protected: + }; + + + + /** c */ + + + +}} // namespace gui::model +#endif /*GUI_MODEL_W_LINK_H*/ diff --git a/tests/gui/model/w-link-test.cpp b/tests/gui/model/w-link-test.cpp new file mode 100644 index 000000000..369f06610 --- /dev/null +++ b/tests/gui/model/w-link-test.cpp @@ -0,0 +1,106 @@ +/* + WLink(Test) - verify managed link to sigc::trackable widget + + Copyright (C) Lumiera.org + 2018, Hermann Vosseler + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +* *****************************************************/ + +/** @file w-link-test.cpp + ** unit test \ref WLink_test + */ + + +#include "lib/test/run.hpp" +#include "lib/test/test-helper.hpp" +#include "gui/model/w-link.hpp" +//#include "gen-node-location-query.hpp" +#include "lib/format-cout.hpp" +//#include "lib/idi/entry-id.hpp" +//#include "lib/diff/gen-node.hpp" +#include "lib/util.hpp" + +//#include +//#include + + +//using std::string; +//using lib::diff::MakeRec; +//using lib::diff::Rec; +//using lib::idi::EntryID; +//using lib::diff::GenNode; +using util::isSameObject; +using util::isnil; + + +namespace gui { +namespace model{ +namespace test { + +// using lumiera::error::LUMIERA_ERROR_WRONG_TYPE; +// using lib::test::showSizeof; + + + + + /******************************************************************************//** + * @test verify the usage pattern of low-level UI element access, based on a + * mock implementation of the accessor directory. + * @see w-link.hpp + */ + class WLink_test : public Test + { + + virtual void + run (Arg) + { + verify_standardUsage(); + verify_reconnect(); + verify_copy(); + } + + + /** @test the standard use case is to hold onto a widget + * owned by _someone else_, with automatic disconnection + */ + void + verify_standardUsage() + { + UNIMPLEMENTED ("demonstrate a simple usage scenario"); + } + + + void + verify_reconnect() + { + UNIMPLEMENTED ("change connection state"); + } + + + void + verify_copy() + { + UNIMPLEMENTED ("copy with magic"); + } + }; + + + /** Register this test class... */ + LAUNCHER (WLink_test, "unit gui"); + + +}}} // namespace gui::model::test diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index 64260aa10..2e9348cca 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -22,7 +22,7 @@ - + @@ -1573,8 +1573,7 @@ in proc::asset::meta::theErrorLog_ID

- - +
@@ -1768,6 +1767,10 @@ + + + + @@ -1810,8 +1813,7 @@ Possibly allocate Widget, expand it. But how to make it visible?

- - +
@@ -1849,8 +1851,7 @@ - - +
@@ -1875,12 +1876,14 @@ TODO also doRevealYourself."

- - +
+ + + @@ -3156,8 +3159,68 @@ - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+ Name: WLink +

+ + +
+ +
+ + +
@@ -32241,8 +32304,7 @@ Ganz prominent fehlt hier also z.B: MIDI

- - +
@@ -32262,8 +32324,7 @@ die Aufgrund von Klassifikationen automatisch bereits existieren

- - +
@@ -32313,8 +32374,7 @@ das ErrorLog

- - + @@ -32332,8 +32392,7 @@ über den UI-Bus schickt, an einen Empfänger mit bekannter ID.

- -
+
@@ -32349,8 +32408,7 @@ dort gibt es eine ErrorLogView

- - +
@@ -32362,8 +32420,7 @@ und den Controller: NotificationHub

- -
+
@@ -32391,8 +32448,7 @@ dadurch werden Meta-Operationen auf gleiche Ebene gestellt wie normale Struktur-Manipulationen

- - + @@ -32422,8 +32478,7 @@ und verlieren ihren magischen Charakter außerhalb der Event-Sourcing-Struktur

- - +
@@ -34112,7 +34167,7 @@ - + @@ -34129,7 +34184,7 @@

- +