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 qreal offset = 0; // center position in viewport (main axis)
10 qreal size = 0;
11 int size_class = 2;
12 qreal unadjusted_offset = 0;
13};
14
15struct KeylineList {
16 QVector<Keyline> keylines;
17 qreal scroll_step = 0;
18 qreal large_size = 0;
19 qreal medium_size = 0;
20 qreal small_size = 0;
21};
22
23class QML_MATERIAL_API CarouselKeylines {
24public:
25 static auto buildList(const CarouselLayoutInput& input) -> KeylineList;
26 static auto layoutItems(const CarouselLayoutInput& input, const KeylineList& keylines)
27 -> CarouselLayoutOutput;
28};
29
31namespace CarouselHeroKeylines
32{
33
34enum class HeroPhase
35{
36 Leading,
37 Middle,
38 Trailing,
39};
40
41struct HeroMetrics {
42 bool single_item = false;
43 qreal small_leading = 0;
44 qreal small_center = 0;
45 qreal large_leading = 0;
46 qreal large_center = 0;
47 qreal medium_leading = 0;
48 qreal medium_center = 0;
49 qreal scroll_step_leading = 0;
50 qreal scroll_step_center = 0;
51};
52
53auto computeMetrics(const CarouselLayoutInput& in) -> HeroMetrics;
54auto phaseKeylines(const CarouselLayoutInput& in, HeroPhase phase, bool keep_leading_peek)
55 -> KeylineList;
56auto keepLeadingPeek(const CarouselLayoutInput& in) -> bool;
57
58} // namespace CarouselHeroKeylines
59
60} // namespace qml_material