Krotos Modules 3
Loading...
Searching...
No Matches
StartStopButton.cpp
Go to the documentation of this file.
2
3namespace krotos
4{
5 //======================================= StartStopButton
6 //========================================================================
7 StartStopButton::StartStopButton() : DrawableButton("StartStopButton", DrawableButton::ButtonStyle::ImageFitted)
8 {
9 setComponentID("Start Stop");
10
11 addMouseListener(this, true);
12
13 setClickingTogglesState(true);
14
15 // Set up the images
16
17 m_startDefaultImage = Drawable::createFromImageData(KrotosBinaryData::StartDefault_svg,
18 KrotosBinaryData::StartDefault_svgSize);
19
21 Drawable::createFromImageData(KrotosBinaryData::StartHover_svg, KrotosBinaryData::StartHover_svgSize);
22
24 Drawable::createFromImageData(KrotosBinaryData::StopDefault_svg, KrotosBinaryData::StopDefault_svgSize);
25
27 Drawable::createFromImageData(KrotosBinaryData::StopHover_svg, KrotosBinaryData::StopHover_svgSize);
28
29 onStateChange = [this] {
30 if (getToggleState())
32 else
34 };
35 }
36
37 void StartStopButton::resized() { m_bounds = getLocalBounds().toFloat(); }
38
39 void StartStopButton::paint(Graphics& g)
40 {
41 switch (m_mode)
42 {
44 if (isMouseOver())
45 m_startHoverImage->drawWithin(g, m_bounds, RectanglePlacement::stretchToFit, 1.0f);
46 else
47 m_startDefaultImage->drawWithin(g, m_bounds, RectanglePlacement::stretchToFit, 1.0f);
48 break;
49 }
51 if (isMouseOver())
52 m_stopHoverImage->drawWithin(g, m_bounds, RectanglePlacement::stretchToFit, 1.0f);
53 else
54 m_stopDefaultImage->drawWithin(g, m_bounds, RectanglePlacement::stretchToFit, 1.0f);
55 break;
56 }
57 }
58 }
59
60} // namespace krotos
std::unique_ptr< Drawable > m_startDefaultImage
Definition StartStopButton.h:33
std::unique_ptr< Drawable > m_stopDefaultImage
Definition StartStopButton.h:33
std::unique_ptr< Drawable > m_startHoverImage
Definition StartStopButton.h:33
Rectangle< float > m_bounds
Definition StartStopButton.h:30
void paint(Graphics &g) override
Definition StartStopButton.cpp:39
StartStopButton()
Definition StartStopButton.cpp:7
StartStopModes m_mode
Definition StartStopButton.h:32
void resized() override
Definition StartStopButton.cpp:37
std::unique_ptr< Drawable > m_stopHoverImage
Definition StartStopButton.h:33
Definition AirAbsorptionFilter.cpp:2