Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
design_fit_view.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <pulp/view/view.hpp>
4
5#include <memory>
6
7namespace pulp::view {
8
46class DesignFitView : public View {
47public:
49 ~DesignFitView() override;
50
52 std::unique_ptr<View> set_content(std::unique_ptr<View> content);
53 View* content() const { return content_; }
55 std::unique_ptr<View> take_content();
56
61 void set_design_size(float w, float h);
62 float design_width() const { return design_w_; }
63 float design_height() const { return design_h_; }
64
69 void set_allow_upscale(bool allow);
70 bool allow_upscale() const { return allow_upscale_; }
71
76 bool top_align() const { return top_align_; }
77
81 float fit_scale() const { return fit_scale_; }
82 float content_offset_x() const { return offset_x_; }
83 float content_offset_y() const { return offset_y_; }
84
85 bool owns_child_layout() const override { return true; }
86 void layout_children() override;
87 View* hit_test(Point local_point) override;
88
89private:
94 bool resolve_design_size(float& w, float& h) const;
95
96 View* content_ = nullptr;
97 float design_w_ = 0.0f;
98 float design_h_ = 0.0f;
99 bool allow_upscale_ = false;
100 bool top_align_ = false;
101
102 float fit_scale_ = 1.0f;
103 float offset_x_ = 0.0f;
104 float offset_y_ = 0.0f;
105};
106
107} // namespace pulp::view
void set_design_size(float w, float h)
Authored size of the content, in design points.
bool owns_child_layout() const override
Definition design_fit_view.hpp:85
bool top_align() const
Definition design_fit_view.hpp:76
float content_offset_y() const
Definition design_fit_view.hpp:83
void set_top_align(bool top_align)
Anchor the fitted design to the TOP of the container instead of centering it vertically.
void layout_children() override
float design_width() const
Definition design_fit_view.hpp:62
std::unique_ptr< View > take_content()
Detach the content without destroying it.
View * content() const
Definition design_fit_view.hpp:53
bool allow_upscale() const
Definition design_fit_view.hpp:70
std::unique_ptr< View > set_content(std::unique_ptr< View > content)
Install the subtree to fit. Replaces (and returns) any previous content.
float design_height() const
Definition design_fit_view.hpp:63
View * hit_test(Point local_point) override
float fit_scale() const
The applied fit, valid after layout.
Definition design_fit_view.hpp:81
float content_offset_x() const
Definition design_fit_view.hpp:82
void set_allow_upscale(bool allow)
Whether a design SMALLER than the container may be scaled UP to fill it.
Hover-cursor tracking for platform window hosts.
Definition fwd.hpp:27
@ h
Definition input_events.hpp:39
@ w
Definition input_events.hpp:41
Definition geometry.hpp:20