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