Krotos Modules 3
Loading...
Searching...
No Matches
ZoomableComponent.h
Go to the documentation of this file.
1namespace krotos
2{
6 class ZoomableComponent : public Component
7 {
8 public:
9 ZoomableComponent() = default;
10 ~ZoomableComponent() override = default;
11
12 void setHorizontalZoomFactor(float factor)
13 {
14 m_hZoom = factor;
16 }
17 void setHorizontalZoomCenter(float center)
18 {
19 m_hCenter = center;
21 }
22 void setVerticalZoomFactor(float factor)
23 {
24 m_vZoom = factor;
26 }
27 void setVerticalZoomCenter(float center)
28 {
29 m_vCenter = center;
31 }
32
33 void setHorizontalZoomFromRange(const Range<float> xr);
34 void SetTransformToFit(int width, int height);
35
36 float getHorizontalZoomFactor() const { return m_hZoom; }
37 float getHorizontalZoomCenter() const { return m_hCenter; }
38 float getVerticalZoomFactor() const { return m_vZoom; }
39 float getVerticalZoomCenter() const { return m_vCenter; }
40
41 Range<float> getHorizontalRange() const;
42 Range<float> getVerticalRange() const;
43
44 protected:
45 void drawNormalisedZoomedRect(Graphics& g, const Rectangle<float>& rect) const;
46 void drawNormalisedZoomedRectLine(Graphics& g, const Rectangle<float>& rect) const;
47 void drawZoomedRect(Graphics& g, const Rectangle<float>& rect) const;
48
49 void drawNormalisedZoomedLine(Graphics& g, Line<float> line, float thickness) const;
50 void drawZoomedLine(Graphics& g, const Line<float>& line, float thickness) const;
51
52 void drawNormalisedZoomedText(Graphics& g, String text, Rectangle<float> bounds) const;
53
54 void drawNormalisedZoomedPath(Graphics& g, const Path& path, float thickness);
55 void drawZoomedPath(Graphics& g, Path path, float thickness);
56
57 void drawNormalisedZoomedImage(Graphics& g, Image& image, const Rectangle<float>& bounds,
58 bool fillAlphaChannelWithCurrentBrush = false);
59
60 void fillNormalisedZoomedEllipse(Graphics& g, const Rectangle<float>& bounds);
61 void drawNormalisedZoomedEllipse(Graphics& g, const Rectangle<float>& bounds);
62 void drawZoomedEllipse(Graphics& g, const Rectangle<float>& bounds);
63
64 private:
65 void updateTransform();
66
67 float m_hZoom{1.0f};
68 float m_hCenter{0.5f};
69
70 float m_vZoom{1.0f};
71 float m_vCenter{0.5f};
72
73 AffineTransform m_transform;
74
75 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ZoomableComponent)
76 };
77} // namespace krotos
Enables zooming of a painted component using special drawing methods.
Definition ZoomableComponent.h:7
void drawZoomedEllipse(Graphics &g, const Rectangle< float > &bounds)
Definition ZoomableComponent.cpp:90
void setHorizontalZoomCenter(float center)
Definition ZoomableComponent.h:17
AffineTransform m_transform
Definition ZoomableComponent.h:73
void setHorizontalZoomFactor(float factor)
Definition ZoomableComponent.h:12
void drawZoomedLine(Graphics &g, const Line< float > &line, float thickness) const
Definition ZoomableComponent.cpp:46
void drawZoomedRect(Graphics &g, const Rectangle< float > &rect) const
Definition ZoomableComponent.cpp:24
void setVerticalZoomCenter(float center)
Definition ZoomableComponent.h:27
void SetTransformToFit(int width, int height)
Definition ZoomableComponent.cpp:123
float getHorizontalZoomFactor() const
Definition ZoomableComponent.h:36
void drawNormalisedZoomedRect(Graphics &g, const Rectangle< float > &rect) const
Definition ZoomableComponent.cpp:14
float getVerticalZoomFactor() const
Definition ZoomableComponent.h:38
void drawNormalisedZoomedRectLine(Graphics &g, const Rectangle< float > &rect) const
Definition ZoomableComponent.cpp:19
float m_hCenter
Definition ZoomableComponent.h:68
void drawNormalisedZoomedImage(Graphics &g, Image &image, const Rectangle< float > &bounds, bool fillAlphaChannelWithCurrentBrush=false)
Definition ZoomableComponent.cpp:73
float m_hZoom
Definition ZoomableComponent.h:67
void drawNormalisedZoomedPath(Graphics &g, const Path &path, float thickness)
Definition ZoomableComponent.cpp:57
~ZoomableComponent() override=default
float getVerticalZoomCenter() const
Definition ZoomableComponent.h:39
void drawNormalisedZoomedText(Graphics &g, String text, Rectangle< float > bounds) const
Definition ZoomableComponent.cpp:41
void drawNormalisedZoomedLine(Graphics &g, Line< float > line, float thickness) const
Definition ZoomableComponent.cpp:35
void setVerticalZoomFactor(float factor)
Definition ZoomableComponent.h:22
void setHorizontalZoomFromRange(const Range< float > xr)
Definition ZoomableComponent.cpp:116
void drawZoomedPath(Graphics &g, Path path, float thickness)
Definition ZoomableComponent.cpp:62
Range< float > getVerticalRange() const
Definition ZoomableComponent.cpp:9
void updateTransform()
Definition ZoomableComponent.cpp:101
Range< float > getHorizontalRange() const
Definition ZoomableComponent.cpp:3
void fillNormalisedZoomedEllipse(Graphics &g, const Rectangle< float > &bounds)
Definition ZoomableComponent.cpp:80
void drawNormalisedZoomedEllipse(Graphics &g, const Rectangle< float > &bounds)
Definition ZoomableComponent.cpp:85
float m_vCenter
Definition ZoomableComponent.h:71
float m_vZoom
Definition ZoomableComponent.h:70
float getHorizontalZoomCenter() const
Definition ZoomableComponent.h:37
Definition AirAbsorptionFilter.cpp:2