From 4070cc0d83d5ba6016f46a9cf7ca01857219b107 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Sat, 7 Mar 2020 19:39:51 +0100 Subject: [PATCH] DisplayEvaluation: draft evaluation invocation per track ...however, running into some type deduction problems... --- research/try.cpp | 93 +++++++++++++++++--------- src/stage/timeline/clip-presenter.cpp | 6 ++ src/stage/timeline/clip-presenter.hpp | 5 ++ src/stage/timeline/track-presenter.hpp | 74 ++++++++++++++++---- wiki/thinkPad.ichthyo.mm | 26 +++++-- 5 files changed, 157 insertions(+), 47 deletions(-) diff --git a/research/try.cpp b/research/try.cpp index a99028e37..5a84633a0 100644 --- a/research/try.cpp +++ b/research/try.cpp @@ -43,28 +43,40 @@ // 12/18 - investigate the trinomial random number algorithm from the C standard lib // 04/19 - forwarding tuple element(s) to function invocation // 06/19 - use a statefull counting filter in a treeExplorer pipeline +// 03/20 - investigate type deduction bug with PtrDerefIter /** @file try.cpp - * How to pick a configurable prefix segment from an iterable sequence. - * Instead of using a classic indexed for loop, the same effect can be achieved - * through a statefull filter functor in a `treeExplore()`-pipeline; after full - * optimisation I'd expect even to get the same assembly as from an equivalent - * hand written for loop. (Caveat: debug builds will be bloated) + * Compiling a seemingly valid iterator pipeline failed, due to type deduction problems. + * As expected, they originate within PtrDerefIter, which I abused here to dereference + * an unique_ptr -- which might seem strange, yet is true to the spirit of generic programming. + * Since I consider this a valid usage, the fix is to add a further specialisation to my + * hand-written RemovePtr trait template in iter-adapter-ptr-deref.hpp (which also justifies + * in hindsight to use a hand-written trait right within this header, instead of some library). */ typedef unsigned int uint; +namespace std { +template + class unique_ptr; +} + #include "lib/format-cout.hpp" #include "lib/test/test-helper.hpp" #include "lib/util.hpp" -#include "lib/iter-tree-explorer.hpp" +#include "lib/iter-adapter-ptr-deref.hpp" +#include "lib/iter-adapter-stl.hpp" +#include "lib/itertools.hpp" #include #include #include +#include +#include using std::string; +using std::make_unique; @@ -73,37 +85,56 @@ using std::string; #define SHOW_EXPR(_XX_) \ cout << "Probe " << STRINGIFY(_XX_) << " ? = " << _XX_ < -auto -selectSeg(IT&& it, bool useFirst) -{ - struct CountingFilter - { - int cnt; - bool useFirst; - - bool - operator() (...) - { - bool isPrefixPart = 0 < cnt--; - return useFirst? isPrefixPart : not isPrefixPart; - } - }; - return lib::treeExplore(std::forward (it)) - .filter(CountingFilter{50, useFirst}); -} +using PStr = std::unique_ptr; +using Strs = std::vector; +constexpr auto elems = [](auto& coll) { return lib::ptrDeref (lib::iter_stl::eachElm (coll)); }; + +namespace lib { + + namespace { + + template + struct RemovePtr> { typedef T Type; }; + } +} + namespace { + template + inline auto + max (IT&& elms) + { + using Val = std::remove_reference_t; + Val res = std::numeric_limits::min(); + for (auto& elm : std::forward (elms)) + if (elm > res) + res = elm; + return res; + } + } int main (int, char**) { - using VecN = std::vector; - VecN numz{1,1,2,3,5,8,13,21}; + Strs ss; + ss.emplace_back(new string{"li"}); + ss.emplace_back(new string{"la"}); + ss.emplace_back(new string{"lutsch"}); + SHOW_EXPR (ss); + SHOW_EXPR (elems(ss)); + using ITS = decltype(elems(ss)); + SHOW_TYPE (ITS); - for (auto& elm : selectSeg(numz, false)) - cout << elm<<"::"; - for (auto& elm : selectSeg(numz, true)) - cout << elm<<"::"; +// using ITSR = typename ITS::reference; +// lib::test::TypeDebugger buggy; + + auto dings = elems(ss); + + int maxVSize = max (lib::transformIterator(dings, + [](string const& ding) + { + return ding.length(); + })); + SHOW_EXPR (maxVSize); cout << "\n.gulp.\n"; return 0; diff --git a/src/stage/timeline/clip-presenter.cpp b/src/stage/timeline/clip-presenter.cpp index 99ab600de..4a8c2ec64 100644 --- a/src/stage/timeline/clip-presenter.cpp +++ b/src/stage/timeline/clip-presenter.cpp @@ -152,6 +152,12 @@ namespace timeline { } + int + ClipPresenter::determineRequiredVerticalExtension() const + { + UNIMPLEMENTED ("any details regarding clip presentation"); + } + }}// namespace stage::timeline diff --git a/src/stage/timeline/clip-presenter.hpp b/src/stage/timeline/clip-presenter.hpp index e9eb083f9..ee950c47a 100644 --- a/src/stage/timeline/clip-presenter.hpp +++ b/src/stage/timeline/clip-presenter.hpp @@ -98,6 +98,11 @@ namespace timeline { virtual void buildMutator (lib::diff::TreeMutator::Handle) override; + /** find out the number of pixels necessary to render this clip properly, + * assuming its current presentation mode (abbreviated, full, expanded). + */ + int determineRequiredVerticalExtension() const; + private:/* ===== Internals ===== */ }; diff --git a/src/stage/timeline/track-presenter.hpp b/src/stage/timeline/track-presenter.hpp index 2f4657971..fec152bdc 100644 --- a/src/stage/timeline/track-presenter.hpp +++ b/src/stage/timeline/track-presenter.hpp @@ -90,6 +90,9 @@ #include "stage/timeline/clip-presenter.hpp" #include "stage/timeline/track-head-widget.hpp" #include "stage/timeline/track-body.hpp" +#include "lib/iter-adapter-ptr-deref.hpp" +#include "lib/iter-adapter-stl.hpp" +#include "lib/itertools.hpp" /////////////////////////////////////////////////////////////////////////////////////////////////////////////TICKET #1201 : test/code... remove this #include "lib/format-cout.hpp" /////////////////////////////////////////////////////////////////////////////////////////////////////////////TICKET #1201 : test/code... remove this @@ -113,6 +116,16 @@ namespace timeline { using lib::diff::collection; using std::make_unique; + using PFork = unique_ptr; + using PClip = unique_ptr; + using PMark = unique_ptr; + using PRuler = unique_ptr; + + namespace{ + /** Helper: iterator to yield direct reference to collection members managed by (unique)pointer. */ + constexpr auto elems = [](auto& coll) { return lib::ptrDeref (lib::iter_stl::eachElm (coll)); }; + } + /** * Reference frame to organise the presentation related to a specific Track in the Timeline-GUI. @@ -159,6 +172,9 @@ namespace timeline { { return body_.bindRulers(); } + + template + void establishExtension (CLPS, MRKS); }; @@ -171,9 +187,9 @@ namespace timeline { { DisplayFrame display_; - vector> subFork_; - vector> markers_; - vector> clips_; + vector subFork_; + vector markers_; + vector clips_; public: @@ -249,11 +265,6 @@ namespace timeline { inline void TrackPresenter::buildMutator (TreeMutator::Handle buffer) { - using PFork = unique_ptr; - using PClip = unique_ptr; - using PMarker = unique_ptr; - using PRuler = unique_ptr; - buffer.create ( TreeMutator::build() .attach (collection(display_.bindRulers()) @@ -280,15 +291,15 @@ namespace timeline { { // »Selector« : require object-like sub scope with type-field "Marker" return TYPE_Marker == spec.data.recordType(); }) - .matchElement ([&](GenNode const& spec, PMarker const& elm) -> bool + .matchElement ([&](GenNode const& spec, PMark const& elm) -> bool { return spec.idi == elm->getID(); }) - .constructFrom ([&](GenNode const& spec) -> PMarker + .constructFrom ([&](GenNode const& spec) -> PMark { return make_unique (spec.idi, this->uiBus_); }) - .buildChildMutator ([&](PMarker& target, GenNode::ID const& subID, TreeMutator::Handle buff) -> bool + .buildChildMutator ([&](PMark& target, GenNode::ID const& subID, TreeMutator::Handle buff) -> bool { if (subID != target->getID()) return false; target->buildMutator (buff); @@ -343,9 +354,48 @@ namespace timeline { inline void TrackPresenter::establishLayout (DisplayEvaluation& displayEvaluation) { - UNIMPLEMENTED ("respond to the DisplayEvaluation-Pass and pass on evaluation recursively"); + display_.establishExtension (elems(clips_), elems(markers_)); + for (auto& subTrack: subFork_) + subTrack->establishLayout (displayEvaluation); } + namespace { + template + inline auto + max (IT&& elms) + { + using Val = typename IT::value_type; + Val res = std::numeric_limits::min(); + for (auto& elm : std::forward (elms)) + if (elm > res) + res = elm; + return res; + } + } + + /** */ + template + inline void + DisplayFrame::establishExtension (CLPS clips, MRKS markers) + { +// int maxVSize = max (lib::transformIterator(clips, +// [](ClipPresenter const& clip) +// { +// return clip.determineRequiredVerticalExtension(); +// })); + int headSize = this->head_.get_height(); + int bodySize = this->body_.calcHeight(); + + + ////////////////////TODO: was ist? +// typedef typename IT::value_type pointer; +// typedef typename RemovePtr::Type value_type; + +/// wobei IT = lib::RangeIter<__gnu_cxx::__normal_iterator*, ... + } + + + }}// namespace stage::timeline #endif /*STAGE_TIMELINE_TRACK_PRESENTER_H*/ diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index 66c6d2035..19f59ea2a 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -21338,8 +21338,7 @@ - - + @@ -21585,10 +21584,29 @@ - + + + + + + + + + +

+ hängen garnicht direkt damit zusammen, sondern wurden getriggert durch den "unorthodoxen" Gebrauch des PtrDerefIter +

+ + +
+ +
+
+
- + +