QmlMaterial 0.1.0
Loading...
Searching...
No Matches
carousel_keylines.hpp
1#pragma once
2
3#include "qml_material/carousel/carousel_strategy.hpp"
4
5namespace qml_material
6{
7
8struct Keyline
9{
10 qreal offset = 0; // center position in viewport (main axis)
11 qreal size = 0;
12 int size_class = 2;
13};
14
15struct KeylineList
16{
17 QVector<Keyline> keylines;
18 qreal scroll_step = 0;
19 qreal large_size = 0;
20 qreal medium_size = 0;
21 qreal small_size = 0;
22};
23
24class CarouselKeylines
25{
26public:
27 static auto buildList(const CarouselLayoutInput& input) -> KeylineList;
28 static auto layoutItems(const CarouselLayoutInput& input, const KeylineList& keylines)
29 -> CarouselLayoutOutput;
30};
31
33namespace CarouselHeroKeylines
34{
35
36enum class HeroPhase
37{
38 Leading,
39 Middle,
40 Trailing,
41};
42
43struct HeroMetrics
44{
45 qreal small_leading = 0;
46 qreal small_center = 0;
47 qreal large_leading = 0;
48 qreal large_center = 0;
49 qreal medium_leading = 0;
50 qreal medium_center = 0;
51 qreal scroll_step_leading = 0;
52 qreal scroll_step_center = 0;
53};
54
55auto computeMetrics(const CarouselLayoutInput& in) -> HeroMetrics;
56auto phaseKeylines(const CarouselLayoutInput& in, HeroPhase phase, bool keep_leading_peek) -> KeylineList;
57void computeHeroSnapOffsets(CarouselLayoutOutput& out, const CarouselLayoutInput& in,
58 bool keep_leading_peek);
59auto keepLeadingPeek(const CarouselLayoutInput& in) -> bool;
60
61} // namespace CarouselHeroKeylines
62
63} // namespace qml_material