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.
This commit is contained in:
parent
c7d157e295
commit
f763e90d2d
2 changed files with 26 additions and 20 deletions
|
|
@ -1636,6 +1636,16 @@ namespace lib {
|
|||
return TreeExplorer<Base> (std::forward<IT> (srcSeq));
|
||||
}
|
||||
|
||||
/** synonym for #treeExplore.
|
||||
* @remark this might become an extension to C++20 pipelines
|
||||
*/
|
||||
template<class IT>
|
||||
inline auto
|
||||
explore (IT&& srcSeq)
|
||||
{
|
||||
return treeExplore (std::forward<IT> (srcSeq));
|
||||
}
|
||||
|
||||
|
||||
} // namespace lib
|
||||
#endif /* LIB_ITER_TREE_EXPLORER_H */
|
||||
|
|
|
|||
|
|
@ -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<TrackPresenter>;
|
||||
using PClip = unique_ptr<ClipPresenter>;
|
||||
using PMark = unique_ptr<MarkerWidget>;
|
||||
using PRuler = unique_ptr<RulerTrack>;
|
||||
|
||||
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<class CLPS, class MRKS>
|
||||
void establishExtension (CLPS, MRKS);
|
||||
void establishExtension (vector<PClip>&, vector<PMark>&);
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -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<class CLPS, class MRKS>
|
||||
/** find out about the vertical extension of a single track display. */
|
||||
inline void
|
||||
DisplayFrame::establishExtension (CLPS clips, MRKS markers)
|
||||
DisplayFrame::establishExtension (vector<PClip>& clips, vector<PMark>&)
|
||||
{
|
||||
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();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue