define the diff bindings for TimelineController

- set the name field
- manage a nested collection of markers

All based on boilerplate code copied from my diff binding tests
This commit is contained in:
Fischlurch 2016-12-03 22:59:03 +01:00
parent c5eff7f4c5
commit 81febc27e1
5 changed files with 33 additions and 49 deletions

View file

@ -93,11 +93,11 @@ namespace timeline {
~ClipPresenter();
private:/* ===== Internals ===== */
/** set up a binding to respond to mutation messages via UiBus */
virtual void buildMutator (lib::diff::TreeMutator::Handle) override;
private:/* ===== Internals ===== */
};

View file

@ -69,11 +69,10 @@ namespace timeline {
~MarkerWidget();
private:/* ===== Internals ===== */
/** set up a binding to respond to mutation messages via UiBus */
virtual void buildMutator (lib::diff::TreeMutator::Handle) override;
private:/* ===== Internals ===== */
};

View file

@ -56,6 +56,8 @@
//using util::_Fmt;
using lib::diff::TreeMutator;
using lib::diff::collection;
using std::make_unique;
//using std::shared_ptr;
//using std::weak_ptr;
//using util::contains;
@ -80,6 +82,7 @@ namespace timeline {
: Controller{identity, nexus}
, markers_{}
, fork_{new TrackPresenter{trackID, nexus}}
, name_{identity.getSym()} // fallback initialise name from human-readable ID symbol
{
UNIMPLEMENTED ("how to make the controller operative...");
}
@ -93,57 +96,38 @@ namespace timeline {
void
TimelineController::buildMutator (TreeMutator::Handle buffer)
{
#if false /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #1039
using Attrib = std::pair<const string,string>;
using lib::diff::collection;
using PMarker = unique_ptr<MarkerWidget>;
buffer.create (
TreeMutator::build()
.attach (collection(scope)
.attach (collection(markers_)
.isApplicableIf ([&](GenNode const& spec) -> bool
{
return spec.data.isNested(); // »Selector« : require object-like sub scope
})
.matchElement ([&](GenNode const& spec, PMockElm const& elm) -> bool
.matchElement ([&](GenNode const& spec, PMarker const& elm) -> bool
{
return spec.idi == elm->getID();
return spec.idi == ID(elm);
})
.constructFrom ([&](GenNode const& spec) -> PMockElm
.constructFrom ([&](GenNode const& spec) -> PMarker
{
PMockElm child = std::make_unique<MockElm>(spec.idi, this->uiBus_);
return child;
return make_unique<MarkerWidget>(spec.idi, this->uiBus_);
})
.buildChildMutator ([&](PMockElm& target, GenNode::ID const& subID, TreeMutator::Handle buff) -> bool
.buildChildMutator ([&](PMarker& target, GenNode::ID const& subID, TreeMutator::Handle buff) -> bool
{
if (target->getID() != subID) return false; //require match on already existing child object
if (ID(target) != subID) return false; //require match on already existing child object
target->buildMutator (buff); // delegate to child to build nested TreeMutator
return true;
}))
.attach (collection(attrib)
.isApplicableIf ([&](GenNode const& spec) -> bool
{
return spec.isNamed() // »Selector« : accept attribute-like values
and not spec.data.isNested(); // but no nested objects
})
.matchElement ([&](GenNode const& spec, Attrib const& elm) -> bool
{
return elm.first == spec.idi.getSym();
})
.constructFrom ([&](GenNode const& spec) -> Attrib
{
string key{spec.idi.getSym()},
val{render(spec.data)};
return {key, val};
})
.assignElement ([&](Attrib& target, GenNode const& spec) -> bool
{
string key{spec.idi.getSym()},
newVal{render (spec.data)};
target.second = newVal;
return true;
})));
#endif /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #1039
UNIMPLEMENTED ("diff mutation binding for the TimelineController");
.change("name", [&](string val)
{
name_ = val;
})
.mutateAttrib("fork", [&](TreeMutator::Handle buff)
{
REQUIRE (fork_);
fork_->buildMutator(buff);
}));
}

View file

@ -87,6 +87,8 @@ namespace timeline {
vector<unique_ptr<MarkerWidget>> markers_;
std::unique_ptr<TrackPresenter> fork_;
string name_;
public:
/**
* @param identity used to refer to a corresponding timeline element in the Session
@ -98,6 +100,9 @@ namespace timeline {
~TimelineController();
/** set up a binding to respond to mutation messages via UiBus */
virtual void buildMutator (lib::diff::TreeMutator::Handle) override;
public: /* ===== Control interface ===== */
@ -106,10 +111,6 @@ namespace timeline {
private:/* ===== Events ===== */
private:/* ===== Internals ===== */
/** set up a binding to respond to mutation messages via UiBus */
virtual void buildMutator (lib::diff::TreeMutator::Handle) override;
};

View file

@ -91,11 +91,11 @@ namespace timeline {
~TrackPresenter();
private:/* ===== Internals ===== */
/** set up a binding to respond to mutation messages via UiBus */
virtual void buildMutator (lib::diff::TreeMutator::Handle) override;
private:/* ===== Internals ===== */
};