From 65f16d54fad82f3aadfdfc1736fbfb5422067136 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Sat, 27 Mar 2021 16:47:22 +0100 Subject: [PATCH] Clip-Drag: setup access-front-end via dependency injection Decision to use a dedicated holder service (GestureState), maintained as sub-service within InteractionDirector --- src/stage/ctrl/ui-manager.hpp | 3 +- src/stage/id-scheme.hpp | 16 +++- src/stage/interact/cmd-context.cpp | 5 +- src/stage/interact/gesture-state.cpp | 62 ++++++++++++++ src/stage/interact/gesture-state.hpp | 93 +++++++++++++++++++++ src/stage/interact/interaction-director.cpp | 6 +- src/stage/interact/interaction-director.hpp | 6 +- src/stage/interact/ui-location-solver.hpp | 2 + wiki/thinkPad.ichthyo.mm | 45 +++++++--- 9 files changed, 222 insertions(+), 16 deletions(-) create mode 100644 src/stage/interact/gesture-state.cpp create mode 100644 src/stage/interact/gesture-state.hpp diff --git a/src/stage/ctrl/ui-manager.hpp b/src/stage/ctrl/ui-manager.hpp index 524962c4e..edf6e6ab2 100644 --- a/src/stage/ctrl/ui-manager.hpp +++ b/src/stage/ctrl/ui-manager.hpp @@ -29,7 +29,8 @@ ** of the UI-Layer and thus, indirectly offers services to provide Icons and other resources, to ** open and manage workspace windows, to form and issue (global) actions and to delve into the ** UI representation of top-level parts of the session model. And, last but not least, it - ** exposes the functions to start and stop the GTK event loop. + ** exposes the functions to start and stop the GTK event loop. However -- most of these + ** activities are in fact performed and maintained by delegates and sub components. ** ** The initialisation and shutdown of the framework is handled by the ApplicationBase parent, ** while the constituents of the Lumiera UI backbone are allocated as member fields: diff --git a/src/stage/id-scheme.hpp b/src/stage/id-scheme.hpp index afcdaf4a3..fe24d3adb 100644 --- a/src/stage/id-scheme.hpp +++ b/src/stage/id-scheme.hpp @@ -40,7 +40,21 @@ ** Thus, starting from a given model element, it is always possible to "cast" some message towards ** the corresponding UI view element, without actually knowing much about that element's implementation. ** - ** @note This header provides the basic definitions for easily accessing relevant UI elements. + ** @note This header provides the basic definitions for easily accessing relevant UI elements. + ** + ** ## The View-Spec DSL + ** + ** The goal for the Lumiera UI is not to totally hard-wire the overall structure. Rather, it shall be + ** possible to "allocate" a view based of rules where to place it within the existing UI structure. + ** This is especially important, since we expect much editing work to be done in a multi-monitor setup, + ** where the UI has to span several top-level windows, and allow for location of views in accordance + ** to the individual editor's habits. + ** + ** In the current state (2017/2021) the foundation for such a rule based view allocation was worked out, + ** but all the possibly quite elaborated details of hooking into the actual widget tree was postponed, + ** until we have a more mature implementation of actual presentation widgets in place. + ** + ** @todo as of 2017 .. 2021, this is a half-finished draft and postponed in favour of building the actually visible timeline display first ** ** @see interaction-director.hpp ** @see ui-bus.hpp diff --git a/src/stage/interact/cmd-context.cpp b/src/stage/interact/cmd-context.cpp index 1ba938252..9f254331d 100644 --- a/src/stage/interact/cmd-context.cpp +++ b/src/stage/interact/cmd-context.cpp @@ -31,8 +31,10 @@ //#include "lib/util.hpp" //#include "lib/symbol.hpp" +#include "lib/depend.hpp" //#include "include/logging.h" #include "stage/interact/cmd-context.hpp" +#include "stage/interact/gesture-state.hpp" //#include //#include @@ -47,7 +49,7 @@ namespace stage { namespace interact { namespace { // internal details - + lib::Depend gestures; } // internal details @@ -62,6 +64,7 @@ namespace interact { CmdContext& CmdContext::of (Symbol cmdID, string ctxID) { + InteractionState& state = gestures().getStateFor (ctxID); UNIMPLEMENTED ("context-bound commands: tap into the InteractionDirector to access the interaction state"); } diff --git a/src/stage/interact/gesture-state.cpp b/src/stage/interact/gesture-state.cpp new file mode 100644 index 000000000..d8a144531 --- /dev/null +++ b/src/stage/interact/gesture-state.cpp @@ -0,0 +1,62 @@ +/* + GestureState - holder for interaction-state dedicated to specific gestures + + Copyright (C) Lumiera.org + 2021, 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 gesture-state.cpp + ** Implementation of a holder and manager for interaction state. + ** + ** @todo do we really need a separate implementation unit for this?? + ** + */ + + +//#include "lib/util.hpp" +//#include "lib/symbol.hpp" +//#include "include/logging.h" +#include "stage/interact/gesture-state.hpp" + +//#include +//#include + +//using std::map; +//using std::string; + +//using util::contains; +//using util::isnil; + +namespace stage { +namespace interact { + + namespace { // internal details + + } // internal details + + + + GestureState::~GestureState() { } // TODO really needed? + + + + + /** nonsense */ + +}} // namespace stage::interact diff --git a/src/stage/interact/gesture-state.hpp b/src/stage/interact/gesture-state.hpp new file mode 100644 index 000000000..10c13ff45 --- /dev/null +++ b/src/stage/interact/gesture-state.hpp @@ -0,0 +1,93 @@ +/* + GESTURE-STATE.hpp - holder for interaction-state dedicated to specific gestures + + Copyright (C) Lumiera.org + 2015, 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 gesture-state.hpp + ** Sub-Service of the InteractionDirector: Hold and maintain InteractionState. + ** Typically, each distinct gesture or elaborate interaction pattern has a dedicated + ** InteractionState subclass to maintain the state of ongoing gestures within the UI. + ** Client code attaches and accesses this state through the CmdContext front-end. + ** The InteractionDirector exposes a singleton instance of the GestureState manager + ** through the lib::Depend access framework (Dependency-Injection). + ** + ** @todo WIP-WIP as of 3/2021 about to create a prototype implementation for dragging clips... + ** + ** @see ////TODO_test usage example + ** + */ + + +#ifndef STAGE_INTERACT_GESTURE_STATE_H +#define STAGE_INTERACT_GESTURE_STATE_H + + +#include "lib/error.hpp" +#include "lib/nocopy.hpp" +//#include "stage/ctrl/bus-term.hpp" +#include "stage/interact/interaction-state.hpp" +//#include "lib/idi/entry-id.hpp" +#include "lib/symbol.hpp" +//#include "lib/util.hpp" + +//#include + + +namespace stage { +namespace interact { + +// using lib::HashVal; + using lib::Symbol; +// using util::isnil; +// using std::string; + +//class Subject; + + + /** + * Holder for InteractionState dedicated to UI gestures and complex interactions. + * + * @todo write type comment... + * @todo WIP-WIP as of /3/2021 + * ///////////////////////////////////TODO do we need a translation unit interaction-state.cpp (otherwise delete it!) + */ + class GestureState + : util::NonCopyable + { + public: + ~GestureState(); ///////////TODO required?? + + public: + /** + */ + InteractionState& + getStateFor (std::string ctxID) + { + UNIMPLEMENTED ("how to designate and access state for specific gestures"); + } + + private: + }; + + + +}} // namespace stage::interact +#endif /*STAGE_INTERACT_GESTURE_STATE_H*/ diff --git a/src/stage/interact/interaction-director.cpp b/src/stage/interact/interaction-director.cpp index 5dd03dde8..aa03ac593 100644 --- a/src/stage/interact/interaction-director.cpp +++ b/src/stage/interact/interaction-director.cpp @@ -36,6 +36,7 @@ #include "stage/interact/navigator.hpp" #include "stage/interact/focus-tracker.hpp" #include "stage/interact/ui-coord-resolver.hpp" +#include "stage/interact/gesture-state.hpp" #include "stage/dialog/preferences-dialog.hpp" #include "stage/dialog/render.hpp" #include "stage/workspace/workspace-window.hpp" @@ -100,6 +101,7 @@ namespace interact { InteractionDirector::InteractionDirector (GlobalCtx& globals) : model::Controller(session::Root::getID(), globals.uiBus_.getAccessPoint()) , globalCtx_(globals) + , gestureState_{} , viewLocator_{new ViewLocator} , spotLocator_{new SpotLocator} , navigator_{*spotLocator_, *viewLocator_} // Service exposed as Depend @@ -246,7 +248,7 @@ namespace interact { void InteractionDirector::render() { - dialog::Render dialog(getWorkspaceWindow()); //////global -> InteractionDirector + dialog::Render dialog{getWorkspaceWindow()}; //////global -> InteractionDirector dialog.run(); unimplemented ("start render"); @@ -305,7 +307,7 @@ namespace interact { namespace { /** - * The timeline is actually a front-end to a binding to a root track. + * The timeline is actually a front-end for a binding to some root track. * For that reason, we always create the root-track representation alongside * the timeline, and thus we need a very special INS message to create a timeline: * - it must be a record (an "object") diff --git a/src/stage/interact/interaction-director.hpp b/src/stage/interact/interaction-director.hpp index 22e8897e8..577ae40e3 100644 --- a/src/stage/interact/interaction-director.hpp +++ b/src/stage/interact/interaction-director.hpp @@ -93,6 +93,8 @@ namespace interact { class FocusTracker; class ViewLocator; + class GestureState; + using timeline::TimelineGui; @@ -106,11 +108,13 @@ namespace interact { { ctrl::GlobalCtx& globalCtx_; - // == exposed to Depend on == + // == exposed for Dependency-Incection == using Service_LocationQuery = lib::DependInject::ServiceInstance; + using Service_GestureState = lib::DependInject::ServiceInstance<>; // == global Services == + Service_GestureState gestureState_; unique_ptr viewLocator_; unique_ptr spotLocator_; Service_LocationQuery navigator_; diff --git a/src/stage/interact/ui-location-solver.hpp b/src/stage/interact/ui-location-solver.hpp index 64c32c378..d62cec9bc 100644 --- a/src/stage/interact/ui-location-solver.hpp +++ b/src/stage/interact/ui-location-solver.hpp @@ -58,6 +58,8 @@ ** As a minimum requirement, each LocationRule should be concluded with such a "catch-all" explicit ** create clause, which describes the standard location of the element in question. ** + ** @todo as of 2017 .. 2021, this is a half-finished draft and postponed in favour of building the actually visible timeline display first + ** ** @see UILocationSolver_test ** @see ViewSpecDSL_test ** @see UICoordResolver diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index 3d971c3bf..0e383c47f 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -31601,7 +31601,7 @@ - + @@ -31629,7 +31629,7 @@ - + @@ -31690,8 +31690,8 @@ - - + + @@ -31835,8 +31835,8 @@ - - + + @@ -32128,7 +32128,7 @@ - + @@ -32327,11 +32327,32 @@ - - - + + + + + + + + + + + + + + + + + + + + + + + + @@ -37142,6 +37163,10 @@ + + + +