Clip-Drag: wire access to the actual InteractionState for dragging

This commit is contained in:
Fischlurch 2021-04-02 16:57:18 +02:00
parent 91273e5931
commit 6578b3cf1c
4 changed files with 58 additions and 13 deletions

View file

@ -129,6 +129,7 @@ namespace interact {
/**
* Helper for dynamic command argument resolution.
* @todo 4/2021 this was part of a design draft in 2017, not clear yet if we need it
*/
struct CmdContext::Resolver
{

View file

@ -25,7 +25,7 @@
** Concrete implementation of a dragging gesture to relocate an UI entity.
** This gesture controller is maintained as an InteractionState holder within
** the InteractionDirector and serves as target to receive signals, in order to
** observe a draggable widget and possibly activate the formation of a dragging
** observe a draggable widget and possibly activate on formation of a dragging
** gesture. When this happens, the DragRelocateController is responsible for
** observing the mouse movements, to integrate a movement delta, and finally
** to recognise the end of the dragging gesture and invoke the associated
@ -34,7 +34,7 @@
**
** @note this implementation level header is meant to be included
** solely for the purpose of creating an instance from within
** facility responsible for actually managing InvocationState
** GestureState, the facility managing InvocationState instances.
**
** @todo WIP and prototypical implementation as of 3/2021
**

View file

@ -24,18 +24,30 @@
/** @file gesture-state.cpp
** Implementation of a holder and manager for interaction state.
**
** @todo do we really need a separate implementation unit for this??
**
** @todo do we really need a segregated translation unit for the
** InteractionState implementations? The alternative would be
** to emit all the related code from interaction-director.cpp;
** and in this alternative solution, we'd also allocate all the
** interaction state right within GestureState, without PImpl.
** The benefit would to avoid yet another indirection, while
** the downside would be to include all those implementations
** unnecessarily also into cmd-context.cpp, with the danger that
** someone later on starts to "short circuit" directly into some
** implementation, by switching on type.
*/
#include "lib/error.hpp"
//#include "lib/util.hpp"
//#include "lib/symbol.hpp"
//#include "include/logging.h"
#include "lib/format-string.hpp"
#include "stage/interact/gesture-state.hpp"
#include "stage/interact/drag-relocate-controller.hpp"
//#include <string>
//#include <map>
using util::_Fmt;
//using std::map;
//using std::string;
@ -46,17 +58,41 @@
namespace stage {
namespace interact {
namespace error = lumiera::error;
namespace { // internal details
} // internal details
GestureState::~GestureState() { } // TODO really needed?
GestureState::~GestureState() { } // emit dtors of managed objects here....
GestureState::GestureState()
: dragRelocate_{new DragRelocateController{}}
{ }
/** nonsense */
/**
* @todo as of 4/2021, interactions and UI state handling can be considered an early draft;
* since the UI needs to be fleshed out in more detail in order to decide on a proper
* organisation and possibly flexible configuration. In the meantime, we use some
* hard wired mappings to actual InteractionState implementations
*/
InteractionState&
GestureState::getStateFor (Action action, Scope qualifier)
{
if (DRAG==action and ON_TIMELINE==qualifier)
return *dragRelocate_;
else
throw error::State (_Fmt{"Unforeseen interaction state in Lumiera UI requested. "
"GestureState::getStateFor... Action=%d Scope=%d"}
% action
% qualifier);
}
}} // namespace stage::interact

View file

@ -49,6 +49,7 @@
//#include "lib/util.hpp"
//#include <string>
#include <memory>
namespace stage {
@ -58,8 +59,10 @@ namespace interact {
using lib::Symbol;
// using util::isnil;
// using std::string;
using std::unique_ptr;
//class Subject;
class DragRelocateController;
/**
@ -73,8 +76,11 @@ namespace interact {
class GestureState
: util::NonCopyable
{
unique_ptr<DragRelocateController> dragRelocate_;
public:
~GestureState(); ///////////TODO required??
GestureState();
~GestureState();
public:
enum Action {
@ -87,12 +93,14 @@ namespace interact {
};
/**
* Decode the classification of the kind of interaction and gesture,
* and thus translate to a concrete InteractionState implementation.
* @return reference to the actual UI state with respect to the
* specific gesture requested, which can then e.g. be used
* to wire a specific UI widget to become responsive to
* this kind of gesture.
*/
InteractionState&
getStateFor (Action action, Scope qualifier)
{
UNIMPLEMENTED ("how to designate and access state for specific gestures");
}
InteractionState& getStateFor (Action action, Scope qualifier);
private:
};