iPlug 2: TestMultiPathControl.h Source File

1

2

3

4

5

6

7

8

9

10

11#pragma once

12

19

23{

24public:

27 , mShape(0)

28 {

30 }

31

33 {

35

36 const float value = static_cast<float>(GetValue());

37

38 float r0 = value * (mRECT.H() / 2.f);

39 float l = mRECT.L + mRECT.W() * 0.1f;

40 float r = mRECT.L + mRECT.W() * 0.9f;

41 float t = mRECT.T + mRECT.H() * 0.1f;

42 float b = mRECT.T + mRECT.H() * 0.9f;

43 float l0 = mRECT.L + mRECT.W() * 0.2f;

44 float t0 = mRECT.T + mRECT.H() * 0.3f;

45 float b0 = mRECT.T + mRECT.H() * 0.7f;

46 float mx = mRECT.L + mRECT.W() * 0.43f;

47 float my = mRECT.MH();

48

49 if (mShape == 0)

50 {

53 }

54 else if (mShape == 1)

55 {

56 float pad1 = (mRECT.W() / 2.f) * (1.f - value);

57 float pad2 = (mRECT.H() / 2.f) * (1.f - value);

58 IRECT size1 = mRECT.GetPadded(-pad1, -pad2, -pad1, -pad2);

59 pad1 = (size1.W() / 2.f) * (1.f - value);

60 pad2 = (size1.H() / 2.f) * (1.f - value);

61 IRECT size2 = size1.GetPadded(-pad1, -pad2, -pad1, -pad2);

64 }

65 else if (mShape == 2)

66 {

67 float pad1 = (mRECT.W() / 2.f) * (1.f - value);

68 float pad2 = (mRECT.H() / 2.f) * (1.f - value);

69 IRECT size1 = mRECT.GetPadded(-pad1, -pad2, -pad1, -pad2);

70 pad1 = (size1.W() / 2.f) * (1.f - value);

71 pad2 = (size1.H() / 2.f) * (1.f - value);

72 IRECT size2 = size1.GetPadded(-pad1, -pad2, -pad1, -pad2);

75 }

76 else if (mShape == 3)

77 {

79 g.PathCubicBezierTo(mRECT.L + mRECT.W() * 0.125f, mRECT.T + mRECT.H() * 0.725f, mRECT.L + mRECT.W() * 0.25f, mRECT.T + mRECT.H() * 0.35f, mRECT.MW(), mRECT.MH());

82 }

83 else if (mShape == 4)

84 {

92 }

93 else if (mShape == 5)

94 {

104 }

105 else if (mShape == 6)

106 {

117 }

118 else if (mShape == 7)

119 {

130 }

131 else if (mShape == 8)

132 {

133 float centerX = mRECT.MW();

134 float centerY = mRECT.MH();

135 float radius = mRECT.W() * 0.25f;

136 float width = radius * 0.75f;

137 float startAngle = -90.0f;

138 float endAngle = +90.0f;

139

140 g.PathArc(centerX, centerY, radius - width * 0.5f, startAngle, endAngle);

141 g.PathArc(centerX, centerY, radius + width * 0.5f, endAngle, startAngle, EWinding::CCW);

143 }

144 else

145 {

146 float centerX = mRECT.MW();

147 float centerY = mRECT.MH();

148 float radius = mRECT.W() * 0.25f;

149 float width = radius * 0.75f;

150 float startAngle = -90.0f;

151 float endAngle = +90.0f;

152

153 g.PathArc(centerX, centerY, radius - width * 0.5f, startAngle, endAngle);

154 g.PathArc(centerX, centerY, radius + width * 0.5f, endAngle, startAngle, EWinding::CW);

156 }

157

159 fillOptions.mFillRule = value > 0.5 ? EFillRule::EvenOdd : EFillRule::Winding;

160 fillOptions.mPreserve = true;

162 float dashes[] = { 11, 4, 7 };

163 strokeOptions.mDash.SetDash(dashes, 0.0, 2);

164 g.PathFill(COLOR_BLACK, fillOptions);

165 g.PathStroke(COLOR_WHITE, 1, strokeOptions);

166 }

167

169 {

170 if (++mShape > 9)

171 mShape = 0;

172

174 }

175

176private:

177 int mShape;

178};

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.

virtual void SetDirty(bool triggerAction=true, int valIdx=kNoValIdx)

Mark the control as dirty, i.e.

The lowest level base class of an IGraphics context.

virtual void PathFill(const IPattern &pattern, const IFillOptions &options=IFillOptions(), const IBlend *pBlend=0)=0

Fill the current current path.

void PathRoundRect(const IRECT &bounds, float ctl, float ctr, float cbl, float cbr)

Add a rounded rectangle to the current path, with independent corner roundness.

virtual void PathClose()=0

Close the path that is being specified.

void PathRect(const IRECT &bounds)

Add a rectangle to the current path.

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.

virtual void PathStroke(const IPattern &pattern, float thickness, const IStrokeOptions &options=IStrokeOptions(), const IBlend *pBlend=0)=0

Stroke the current current path.

void PathCircle(float cx, float cy, float r)

Add a circle to the current path.

virtual void PathMoveTo(float x, float y)=0

Move the current point in the current path.

virtual void PathArc(float cx, float cy, float r, float a1, float a2, EWinding winding=EWinding::CW)=0

Add an arc to the current path.

virtual void PathLineTo(float x, float y)=0

Add a line to the current path from the current point to the specified location.

virtual void PathCubicBezierTo(float c1x, float c1y, float c2x, float c2y, float x2, float y2)=0

Add a cubic bezier to the current path from the current point to the specified location.

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

Control to test drawing paths in path-based drawing backends.

void Draw(IGraphics &g) override

Draw the control to the graphics context.

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

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

Used to manage stroke behaviour for path based drawing back ends.

Used to manage fill behaviour.

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.