From f58b2af22876bdf7af4f29b185d514086f6a3cdb Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Sat, 13 Feb 2016 01:01:45 +0100 Subject: [PATCH] stub new parts --- .../interact/presentation-state-manager.cpp | 62 ++++++++++ .../interact/presentation-state-manager.hpp | 106 ++++++++++++++++++ tests/gui/bus-term-test.cpp | 18 +-- tests/gui/test/test-nexus.cpp | 15 +++ tests/gui/test/test-nexus.hpp | 5 + 5 files changed, 199 insertions(+), 7 deletions(-) create mode 100644 src/gui/interact/presentation-state-manager.cpp create mode 100644 src/gui/interact/presentation-state-manager.hpp diff --git a/src/gui/interact/presentation-state-manager.cpp b/src/gui/interact/presentation-state-manager.cpp new file mode 100644 index 000000000..eb3efcb30 --- /dev/null +++ b/src/gui/interact/presentation-state-manager.cpp @@ -0,0 +1,62 @@ +/* + PresentationStateManager - maintaining persistent interface state + + Copyright (C) Lumiera.org + 2016, 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 presentation-state-manager.cpp + ** Implementation details of persistent presentation state organisation. + ** + ** @see BusTerm_test + ** + */ + + +//#include "lib/util.hpp" +//#include "lib/symbol.hpp" +//#include "include/logging.h" +#include "gui/interact/presentation-state-manager.hpp" + +//#include +//#include +//#include + +//using std::map; +//using std::string; + +//using util::contains; +//using util::isnil; + +namespace gui { +namespace interact { + + namespace { // internal details + + } // internal details + + + PresentationStateManager::~PresentationStateManager() { } // Emit VTables here... + + + + + /** nonsense */ + +}} // namespace gui::interact diff --git a/src/gui/interact/presentation-state-manager.hpp b/src/gui/interact/presentation-state-manager.hpp new file mode 100644 index 000000000..d7160025a --- /dev/null +++ b/src/gui/interact/presentation-state-manager.hpp @@ -0,0 +1,106 @@ +/* + PRESENTATION-STATE-MANAGER.hpp - maintaining persistent interface state + + Copyright (C) Lumiera.org + 2016, 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 presentation-state-manager.hpp + ** Interface: a component to maintain persistent interface state. + ** Here, "presentation state" is understood as state not rooted within the + ** model and without effect on the final rendered result. Most of this state + ** is transitory and arises from the normal working from the UI (and toolkit set). + ** Yet part of this state is relevant to the _way to work with the tooling_, so we + ** typically expect these choices and traces of usage to remain sticky, persistent + ** across editing sessions. + ** + ** ## Implementation technique + ** In Lumiera, handling of persistent presentation state relies on the UI backbone + ** structure known as [UI-Bus](\ref ui-bus.hpp). Any element of more than local relevance, + ** as attached to this backbone, will emit *state mark notification* messages, whenever + ** some transition of presentation state is deemed relevant. The PresentationStateManager + ** operates as one of the [core services](\ref core-service.hpp) and receives, groups and + ** remembers those messages, always retaining the latest state information observed for any + ** property of any [tangible interface element](\ref tangible.hpp) encountered thus far. + ** + ** @todo as of 2/2016 this is complete WIP-WIP-WIP + ** + ** @see ////TODO_test usage example + ** + */ + + +#ifndef GUI_INTERACT_PRESENTATION_STATE_MANAGER_H +#define GUI_INTERACT_PRESENTATION_STATE_MANAGER_H + + +#include "lib/error.hpp" +//#include "gui/ctrl/bus-term.hpp" +//#include "lib/idi/entry-id.hpp" +#include "lib/diff/gen-node.hpp" +//#include "lib/symbol.hpp" +//#include "lib/util.hpp" + +#include +#include + + +namespace gui { +namespace interact { + +// using lib::HashVal; +// using util::isnil; + using std::string; + + + /** + * Interface: handling of persistent interface state. + * @todo write type comment... + */ + class PresentationStateManager + : boost::noncopyable + { + protected: + + public: + virtual ~PresentationStateManager(); ///< this is an interface + + + virtual lib::diff::GenNode const& + currentState (string elementSymbol, string propertyID) =0; + + virtual void + replayState (string elementSymbol, string propertyID) =0; + + virtual void + replayAllState () =0; + + virtual void + replayAllState (string propertyID) =0; + + virtual void + replayAllProperties (string elementSymbol) =0; + + private: + }; + + + +}} // namespace gui::interact +#endif /*GUI_INTERACT_PRESENTATION_STATE_MANAGER_H*/ diff --git a/tests/gui/bus-term-test.cpp b/tests/gui/bus-term-test.cpp index e481b48e0..8c3c2fd3f 100644 --- a/tests/gui/bus-term-test.cpp +++ b/tests/gui/bus-term-test.cpp @@ -23,6 +23,8 @@ #include "lib/test/run.hpp" #include "lib/test/test-helper.hpp" +#include "gui/ctrl/bus-term.hpp" +#include "gui/interact/presentation-state-manager.hpp" #include "test/test-nexus.hpp" #include "test/mock-elm.hpp" #include "lib/idi/entry-id.hpp" @@ -36,6 +38,8 @@ using lib::idi::EntryID; using lib::idi::BareEntryID; +using gui::interact::PresentationStateManager; +using gui::ctrl::BusTerm; using gui::test::MockElm; using lib::diff::GenNode; using lib::diff::Rec; @@ -238,7 +242,7 @@ namespace test { { MARK_TEST_FUN gui::test::Nexus::startNewLog(); - PresentationStateManager stateManager = gui::test::Nexus::useMockStateManager(); + PresentationStateManager& stateManager = gui::test::Nexus::useMockStateManager(); MockElm mockA("alpha"); MockElm mockB("bravo"); @@ -275,7 +279,7 @@ namespace test { replayStateMark () { MARK_TEST_FUN - PresentationStateManager stateManager = gui::test::Nexus::getMockStateManager(); + PresentationStateManager& stateManager = gui::test::Nexus::getMockStateManager(); MockElm mockA("alpha"); // no "bravo" this time @@ -284,8 +288,8 @@ namespace test { CHECK (not mockA.isExpanded()); CHECK (not mockC.isTouched()); - stateManager.replay("alpha", "expand"); - CHECK (mockA.isExpanded); + stateManager.replayState ("alpha", "expand"); + CHECK (mockA.isExpanded()); auto& uiBus = gui::test::Nexus::testUI(); uiBus.mark (mockA.getID(), GenNode{"expand", false}); @@ -293,10 +297,10 @@ namespace test { CHECK (not mockA.isExpanded()); CHECK (mockA.isTouched()); - stateManager.replayAllState("expand"); + stateManager.replayAllState ("expand"); - CHECK (mockA.isExpanded); - CHECK (not mockC.isExpanded); + CHECK (mockA.isExpanded()); + CHECK (not mockC.isExpanded()); CHECK (not mockC.isTouched()); ////////////////////////////////////////////////////////////////////////////////////////////////////TODO WIP diff --git a/tests/gui/test/test-nexus.cpp b/tests/gui/test/test-nexus.cpp index 54a0ba3ef..b9455a498 100644 --- a/tests/gui/test/test-nexus.cpp +++ b/tests/gui/test/test-nexus.cpp @@ -546,6 +546,21 @@ namespace test{ + + interact::PresentationStateManager& + Nexus::useMockStateManager() + { + UNIMPLEMENTED("install a presentation manager mock and state mark handler"); + } + + interact::PresentationStateManager& + Nexus::getMockStateManager() + { + UNIMPLEMENTED("access installed Mock presentation manager"); + } + + + /** * @return a defunct BusTerm with up-link to [ZombieNexus] * @remarks useful to create zombie mock UI-Elements for testing. diff --git a/tests/gui/test/test-nexus.hpp b/tests/gui/test/test-nexus.hpp index 27ce44cae..b18d98be1 100644 --- a/tests/gui/test/test-nexus.hpp +++ b/tests/gui/test/test-nexus.hpp @@ -48,6 +48,7 @@ #include "lib/error.hpp" #include "gui/ctrl/bus-term.hpp" #include "gui/model/tangible.hpp" +#include "gui/interact/presentation-state-manager.hpp" #include "test/placeholder-command.hpp" #include "lib/test/event-log.hpp" #include "lib/diff/gen-node.hpp" @@ -96,6 +97,10 @@ namespace test{ static void setStateMarkHandler (StateMarkHandler =StateMarkHandler()); + static interact::PresentationStateManager& useMockStateManager(); + static interact::PresentationStateManager& getMockStateManager(); + + using Cmd = interact::InvocationTrail; template