From f763e90d2dd4bf1ff95c872dbbea2038bdcddb49 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Sun, 8 Mar 2020 02:31:49 +0100 Subject: [PATCH] DisplayEvaluation: prefer simpler solution without templates ...while the first solution looked as a nice API, abstracting away the actual collections (and in fact helped me to sport and fix a problem with type substitution), in the end I prefer a simpler solution. Since we're now passing in a lambda for transform anyway, it is completely pointless to create an abstracted iterator type, just for the sole purpose of dereferencing an unique_ptr. As it stands now, this is all tightly interwoven implementation code, and the DisplayFrame is no longer intended to become an important interface on it's own (this role has been taken by the ViewHook / ViewHooked types). Note: as an asside, this solution also highlights, that our TreeExplorer framework has gradually turned into a generic pipeline building framework, rendering the "monadic use" just one usage scenario amongst others. And since C++20 will bring us a language based framework for building iteration pipelines, very similar to what we have here, we can expect to retrofit this framework eventually. For this reason, I now start using the simple name `lib::explore(IT)` as a synonym. --- src/lib/iter-tree-explorer.hpp | 10 +++++++ src/stage/timeline/track-presenter.hpp | 36 ++++++++++++-------------- 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/src/lib/iter-tree-explorer.hpp b/src/lib/iter-tree-explorer.hpp index a4b5de54a..44a761b80 100644 --- a/src/lib/iter-tree-explorer.hpp +++ b/src/lib/iter-tree-explorer.hpp @@ -1636,6 +1636,16 @@ namespace lib { return TreeExplorer (std::forward (srcSeq)); } + /** synonym for #treeExplore. + * @remark this might become an extension to C++20 pipelines + */ + template + inline auto + explore (IT&& srcSeq) + { + return treeExplore (std::forward (srcSeq)); + } + } // namespace lib #endif /* LIB_ITER_TREE_EXPLORER_H */ diff --git a/src/stage/timeline/track-presenter.hpp b/src/stage/timeline/track-presenter.hpp index ddbedae12..6d4806ec8 100644 --- a/src/stage/timeline/track-presenter.hpp +++ b/src/stage/timeline/track-presenter.hpp @@ -90,10 +90,8 @@ #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/iter-tree-explorer.hpp" #include "lib/util-coll.hpp" -#include "lib/itertools.hpp" /////////////////////////////////////////////////////////////////////////////////////////////////////////////TICKET #1201 : test/code... remove this #include "lib/format-cout.hpp" /////////////////////////////////////////////////////////////////////////////////////////////////////////////TICKET #1201 : test/code... remove this @@ -116,17 +114,14 @@ namespace timeline { using lib::diff::TreeMutator; using lib::diff::collection; using std::make_unique; + using lib::explore; + using util::max; 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. @@ -174,8 +169,7 @@ namespace timeline { return body_.bindRulers(); } - template - void establishExtension (CLPS, MRKS); + void establishExtension (vector&, vector&); }; @@ -351,25 +345,27 @@ namespace timeline { } - /** @todo 2/2020 */ + + /** handle the DisplayEvaluation pass for this track and its sub-tracks. + * @todo 2/2020 WIP-WIP initial draft; need to find out more about Clip display + */ inline void TrackPresenter::establishLayout (DisplayEvaluation& displayEvaluation) { - display_.establishExtension (elems(clips_), elems(markers_)); + display_.establishExtension (clips_, markers_); for (auto& subTrack: subFork_) subTrack->establishLayout (displayEvaluation); } - /** */ - template + /** find out about the vertical extension of a single track display. */ inline void - DisplayFrame::establishExtension (CLPS clips, MRKS markers) + DisplayFrame::establishExtension (vector& clips, vector&) { - int maxVSize = util::max (lib::transformIterator(clips, - [](ClipPresenter const& clip) - { - return clip.determineRequiredVerticalExtension(); - })); + int maxVSize = max (explore (clips) + .transform([](PClip const& clip) + { + return clip->determineRequiredVerticalExtension(); + })); int headSize = this->head_.get_height(); int bodySize = this->body_.calcHeight(); }