iPlug2 - C++ Audio Plug-in Framework
Loading...
Searching...
No Matches
TestGesturesControl.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 "IControl.h"
19
23{
24public:
26 : ITextControl(bounds, "Do a gesture...")
27 {
28 mIgnoreMouse = false;
29 #ifdef OS_IOS
30 mText = IText(60.f);
31 #endif
32 }
33
34 void Draw(IGraphics& g) override
35 {
36 #ifdef OS_IOS
37 g.DrawDottedRect(COLOR_BLACK, mRECT);
38
40 g.PathTransformTranslate(mRECT.MW(), mRECT.MH());
41 g.PathTransformRotate(mAngle);
42 g.PathTransformScale(mScale);
43 g.PathRect(IRECT(-100, -100, 100, 100));
44 g.PathFill(COLOR_RED);
46
47 if (mStr.GetLength())
48 g.DrawText(mText, mStr.Get(), mRECT);
49 #else
50 g.DrawText(mText, "UNSUPPORTED", mRECT);
51 #endif
52 }
53
54 void OnInit() override
55 {
56 int idx = 1; // 0 = unknown
57 for(auto& type : { EGestureType::DoubleTap,
58 EGestureType::TripleTap,
59 EGestureType::LongPress1,
60 EGestureType::LongPress2,
61 EGestureType::SwipeLeft,
62 EGestureType::SwipeRight,
63 EGestureType::SwipeUp,
64 EGestureType::SwipeDown,
65 EGestureType::Pinch,
66 EGestureType::Rotate,
67 EGestureType::Pan} )
68 {
69 AttachGestureRecognizer(type, [&, idx](IControl* pCaller, const IGestureInfo& info) {
70 SetStr(kGestureTypeStrs[idx]);
71
72 if(info.type == EGestureType::Rotate)
73 mAngle = info.angle;
74
75 if(info.type == EGestureType::Pinch)
76 mScale = info.scale;
77
78 if(info.type == EGestureType::DoubleTap)
79 {
80 mAngle = 0.;
81 mScale = 1.;
82 }
83
84 SetDirty();
85 });
86 idx++;
87 }
88 }
89
90private:
91 float mAngle = 0.f;
92 float mScale = 1.f;
93};
This file contains the base IControl implementation, along with some base classes for specific types ...
The lowest level base class of an IGraphics control.
Definition: IControl.h:49
IControl * AttachGestureRecognizer(EGestureType type, IGestureFunc func)
Add a IGestureFunc that should be triggered in response to a certain type of gesture.
Definition: IControl.cpp:311
virtual void SetDirty(bool triggerAction=true, int valIdx=kNoValIdx)
Mark the control as dirty, i.e.
Definition: IControl.cpp:198
The lowest level base class of an IGraphics context.
Definition: IGraphics.h:86
virtual void PathFill(const IPattern &pattern, const IFillOptions &options=IFillOptions(), const IBlend *pBlend=0)=0
Fill the current current path.
void DrawText(const IText &text, const char *str, const IRECT &bounds, const IBlend *pBlend=0)
Draw some text to the graphics context in a specific rectangle.
Definition: IGraphics.cpp:670
void PathTransformTranslate(float x, float y)
Apply a translation transform to the current path.
Definition: IGraphics.cpp:2730
void PathRect(const IRECT &bounds)
Add a rectangle to the current path.
Definition: IGraphics.cpp:2635
void PathTransformScale(float x, float y)
Apply a scale transform to the current path, with independant x, y scales.
Definition: IGraphics.cpp:2736
virtual void DrawDottedRect(const IColor &color, const IRECT &bounds, const IBlend *pBlend=0, float thickness=1.f, float dashLen=2.f)
Draw a dotted rectangle to the graphics context.
Definition: IGraphics.cpp:2539
void PathTransformRestore()
Restore the affine transform of the current path, to the previously saved state.
Definition: IGraphics.cpp:2708
void PathTransformRotate(float angle)
Apply a rotation transform to the current path.
Definition: IGraphics.cpp:2747
void PathTransformSave()
Save the current affine transform of the current path.
Definition: IGraphics.cpp:2703
A basic control to display some text.
Definition: IControl.h:2152
virtual void SetStr(const char *str)
Set the text to display.
Definition: IControl.cpp:456
Control to test multi gesture recognizers.
void Draw(IGraphics &g) override
Draw the control to the graphics context.
void OnInit() override
Called just prior to when the control is attached, after its delegate and graphics member variable se...
Used to describe a particular gesture.
Used to manage a rectangular area, independent of draw class/platform.
float MH() const
float MW() const
IText is used to manage font and text/text entry style for a piece of text on the UI,...