iPlug2 - C++ Audio Plug-in Framework
Loading...
Searching...
No Matches
IAboutBoxControl.h
Go to the documentation of this file.
1/*
2 ==============================================================================
3
4 This file is part of the iPlug 2 library. Copyright (C) the iPlug 2 developers.
5
6 See LICENSE.txt for more info.
7
8 ==============================================================================
9*/
10
11#pragma once
12
18#include "IControls.h"
19
20BEGIN_IPLUG_NAMESPACE
21BEGIN_IGRAPHICS_NAMESPACE
22
58{
59public:
66 IAboutBoxControl(const IRECT& bounds, const IPattern& color,
67 AttachFunc attachFunc = nullptr, ResizeFunc resizeFunc = nullptr,
68 int animationTime = 200)
69 : IPanelControl(bounds, color, false, attachFunc, resizeFunc)
70 , mAnimationTime(animationTime)
71 {
72 mIgnoreMouse = false;
73 }
74
75 bool OnKeyDown(float x, float y, const IKeyPress& key) override
76 {
77 if (key.VK == kVK_ESCAPE)
78 {
79 Dismiss();
80 return true;
81 }
82
83 return false;
84 }
85
86 void OnMouseDown(float x, float y, const IMouseMod& mod) override
87 {
88 Dismiss();
89 }
90
91 void Dismiss()
92 {
93 Hide(true);
94 }
95
96 void Show()
97 {
99
100 SetAnimation([&](IControl* pCaller) {
101 auto progress = static_cast<float>(pCaller->GetAnimationProgress());
102
103 auto blend = IBlend(EBlend::Default, progress);
104
105 SetBlend(blend);
106
107 ForAllChildrenFunc([blend](int, IControl* pControl) {
108 pControl->SetBlend(blend);
109 });
110
111 if (progress > 1.0f)
112 {
113 pCaller->OnEndAnimation();
115 return;
116 }
117
118 }, mAnimationTime);
119
120 SetDirty(true);
121 }
122
123private:
124 int mAnimationTime = 200;
125};
126
127END_IGRAPHICS_NAMESPACE
128END_IPLUG_NAMESPACE
129
130
A collection of IControls for common UI widgets, such as knobs, sliders, switches.
A "meta control" which you can attach child controls to display an about box, or preferences panel Wh...
IAboutBoxControl(const IRECT &bounds, const IPattern &color, AttachFunc attachFunc=nullptr, ResizeFunc resizeFunc=nullptr, int animationTime=200)
Constructor.
void OnMouseDown(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouse down event on this control.
bool OnKeyDown(float x, float y, const IKeyPress &key) override
Implement this method to respond to a key down event on this control.
void Hide(bool hide) override
Shows or hides the IControl.
Definition: IControl.h:674
The lowest level base class of an IGraphics control.
Definition: IControl.h:49
IGraphics * GetUI()
Definition: IControl.h:467
virtual void Hide(bool hide)
Shows or hides the IControl.
Definition: IControl.cpp:239
double GetAnimationProgress() const
Get the progress in a control's animation, in the range 0-1.
Definition: IControl.cpp:431
void SetBlend(const IBlend &blend)
Set the Blend for this control.
Definition: IControl.h:296
virtual void SetDirty(bool triggerAction=true, int valIdx=kNoValIdx)
Mark the control as dirty, i.e.
Definition: IControl.cpp:198
void SetAnimation(IAnimationFunction func)
Set the animation function.
Definition: IControl.h:492
void SetAllControlsDirty()
Calls SetDirty() on every control.
Definition: IGraphics.cpp:582
A basic control to fill a rectangle with a color or gradient.
Definition: IControl.h:1969
Used to manage composite/blend operations, independent of draw class/platform.
Used for key press info, such as ASCII representation, virtual key (mapped to win32 codes) and modifi...
Definition: IPlugStructs.h:616
Used to manage mouse modifiers i.e.
Used to store pattern information for gradients.
Used to manage a rectangular area, independent of draw class/platform.