iPlug 2: TestPolyControl.h Source File

1

2

3

4

5

6

7

8

9

10

11#pragma once

12

19

23{

24public:

27 {

29 }

30

32 {

33 const float value = (float) GetValue();

34 float xarray[32];

35 float yarray[32];

36 int npoints = 3 + (int) roundf((float) value * 29.f);

37 float angle = (-0.75f * (float) PI) + (float) value * (1.5f * (float) PI);

38 float incr = (2.f * (float) PI) / npoints;

39 float cr = (float) value * (mRECT.W() / 2.f);

40

43

44 for (int i = 0; i < npoints; i++)

45 {

46 xarray[i] = mRECT.MW() + sinf(angle + (float) i * incr) * mRECT.W() * 0.45f;

47 yarray[i] = mRECT.MH() + cosf(angle + (float) i * incr) * mRECT.W() * 0.45f;

48 }

49

50

53 }

54

56 {

59 }

60

62 {

65 }

66};

This file contains the base IControl implementation, along with some base classes for specific types ...

IControl * SetTooltip(const char *str)

Set a tooltip for the control.

double GetValue(int valIdx=0) const

Get the control's value.

The lowest level base class of an IGraphics context.

virtual void DrawConvexPolygon(const IColor &color, float *x, float *y, int nPoints, const IBlend *pBlend=0, float thickness=1.f)

Draw a convex polygon to the graphics context.

virtual void DrawRoundRect(const IColor &color, const IRECT &bounds, float cornerRadius=5.f, const IBlend *pBlend=0, float thickness=1.f)

Draw a rounded rectangle to the graphics context.

virtual void FillRoundRect(const IColor &color, const IRECT &bounds, float cornerRadius=5.f, const IBlend *pBlend=0)

Fill a rounded rectangle with a color.

virtual void FillConvexPolygon(const IColor &color, float *x, float *y, int nPoints, const IBlend *pBlend=0)

Fill a convex polygon with a color.

virtual void HideMouseCursor(bool hide=true, bool lock=true)=0

Call to hide/show the mouse cursor.

A base class for knob/dial controls, to handle mouse action and Sender.

void OnMouseDown(float x, float y, const IMouseMod &mod) override

Implement this method to respond to a mouse down event on this control.

void OnMouseUp(float x, float y, const IMouseMod &mod) override

Implement this method to respond to a mouse up event on this control.

Control to test drawing polygons.

void OnMouseDown(float x, float y, const IMouseMod &mod) override

Implement this method to respond to a mouse down event on this control.

void Draw(IGraphics &g) override

Draw the control to the graphics context.

void OnMouseUp(float x, float y, const IMouseMod &mod) override

Implement this method to respond to a mouse up event on this control.

Used to manage color data, independent of draw class/platform.

Used to manage mouse modifiers i.e.

Used to manage a rectangular area, independent of draw class/platform.

IRECT GetPadded(float padding) const

Get a copy of this IRECT with each value padded by padding N.B.