Line data Source code
1 : /*
2 : ==============================================================================
3 : OptionsPanelLayout — computes Y positions for the options panel given
4 : section fold states and scroll offset.
5 : Pure C++, no JUCE dependency, so it can be unit-tested independently.
6 : ==============================================================================
7 : */
8 :
9 : #pragma once
10 : #include "StyleTokens.h"
11 :
12 21 : class OptionsPanelLayout {
13 : public:
14 : enum Section { MidiRouting = 0, Video, Circles, Animation, SectionCount };
15 :
16 : // Fold state
17 : void setFolded(Section s, bool folded);
18 : bool isFolded(Section s) const;
19 : void toggleFolded(Section s);
20 :
21 : // Scroll state
22 : void setScrollOffset(int offset);
23 : int scrollOffset() const;
24 : void scrollBy(int delta);
25 :
26 : // Viewport
27 : void setViewportHeight(int h);
28 : int viewportHeight() const;
29 :
30 : // Computed values
31 : int contentHeight() const;
32 : int maxScrollOffset() const;
33 :
34 : // Y positions in content space (subtract scrollOffset() for screen Y).
35 : // Fixed header area (above foldable sections)
36 : static constexpr int kTitleY = 8;
37 : static constexpr int kFirstDividerY = 30;
38 : static constexpr int kMidiSettingsButtonY = 34;
39 :
40 : // Section header Y (accounts for fold state of preceding sections)
41 : int sectionHeaderY(Section s) const;
42 :
43 : // Section content start Y (header Y + header height)
44 : int sectionContentY(Section s) const;
45 :
46 : // Convenience accessors for specific widget Y offsets within each section.
47 : // These return absolute content-space Y values.
48 : int midiRoutingFirstRowY() const;
49 : int videoTransportY() const;
50 : int videoSeekBarY() const;
51 : int videoTimeLabelY() const;
52 : int videoCtrlY() const;
53 : int videoFilesY() const;
54 : int videoFileListTopY() const;
55 : int circlesSizeRangeY() const;
56 : int circlesSliderY() const;
57 : int circlesHandleLabelsY() const;
58 : int animFloatToggleY() const;
59 : int animCollisionToggleY() const;
60 : int animClockToggleY() const;
61 : int animClockDivY() const;
62 : int animClockKickSliderY() const;
63 : int animFloatIntensitySliderY() const;
64 : int animFloatSpeedSliderY() const;
65 : int buttonsY() const;
66 :
67 : // Hit-test: which section header contains this content-space Y?
68 : // Returns SectionCount if no header hit.
69 : Section hitTestHeader(int contentY) const;
70 :
71 : // Section content heights (when expanded)
72 : static constexpr int kHeaderH = 20;
73 : static constexpr int kSectionGap = 20;
74 : static constexpr int kMidiRoutingContentH = 7 * 26; // 182
75 : static constexpr int kVideoContentH = 288 + StyleTokens::kPadding;
76 : static constexpr int kCirclesContentH = 80;
77 : static constexpr int kAnimationContentH = 304;
78 : static constexpr int kButtonsH = 68;
79 :
80 : // Y where the first foldable section starts
81 : static constexpr int kFirstSectionY = 66;
82 :
83 : private:
84 21 : bool folded_[SectionCount] = {false, false, false, false};
85 21 : int scrollOffset_ = 0;
86 21 : int viewportHeight_ = 1080;
87 :
88 : void clampScroll();
89 : };
|