iPlug 2: TestLayerControl.h Source File

1

2

3

4

5

6

7

8

9

10

11#pragma once

12

19

23{

24public:

27 {

29 }

30

32 {

34

35 if (mDrawBackground)

36 {

38 {

40 text.mVAlign = EVAlign::Top;

41 text.mSize = 15;

46 }

47

49 }

50

51 g.FillCircle(COLOR_BLUE, mRECT.MW(), mRECT.MH(), mRECT.H() / 4.f);

52 g.DrawRadialLine(COLOR_BLACK, mRECT.MW(), mRECT.MH(), -120.f + static_cast<float>(GetValue()) * 240.f, 0.f, mRECT.H() / 4.f, nullptr, 3.f);

53 }

54

56 {

57 mLayer->Invalidate();

58 mDrawBackground = !mDrawBackground;

60 }

61

62private:

64 bool mDrawBackground = true;

65};

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.

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.

void DrawRadialLine(const IColor &color, float cx, float cy, float angle, float rMin, float rMax, const IBlend *pBlend=0, float thickness=1.f)

Draw a radial line to the graphics context, useful for pointers on dials.

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.

bool CheckLayer(const ILayerPtr &layer)

Test to see if a layer needs drawing, for instance if the control's bounds were changed.

void DrawLayer(const ILayerPtr &layer, const IBlend *pBlend=nullptr)

Draw a layer to the main IGraphics 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.

void StartLayer(IControl *pOwner, const IRECT &r, bool cacheable=false)

Create an IGraphics layer.

virtual void FillCircle(const IColor &color, float cx, float cy, float r, const IBlend *pBlend=0)

Fill a circle with a color.

ILayerPtr EndLayer()

End an IGraphics layer.

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

Control to test IGraphics layers.

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.

std::unique_ptr< ILayer > ILayerPtr

ILayerPtr is a managed pointer for transferring the ownership of layers.

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.

IText is used to manage font and text/text entry style for a piece of text on the UI,...