iPlug2 - C++ Audio Plug-in Framework
TestSizeControl.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 
22 class TestSizeControl : public IControl
23 {
24 public:
25  TestSizeControl(const IRECT& bounds)
26  : IControl(bounds)
27  {
28  mIgnoreMouse = true;
29  mText = IText(15, COLOR_BLACK, nullptr, EAlign::Near);
30  }
31 
32  void Draw(IGraphics& g) override
33  {
34  g.DrawLine(COLOR_BLACK, 10, 0, 10, mRECT.B);
35  g.DrawLine(COLOR_BLACK, 0, mRECT.B-10, mRECT.R, mRECT.B-10);
36  g.DrawText(mText, mWidthStr.Get(), mRECT.L + 15, mRECT.T + 5);
37  g.DrawText(mText, mHeightStr.Get(), mRECT.R - 40, mRECT.B - 20);
38  g.DrawText(mText, mScaleStr.Get(), mRECT.L + 15, mRECT.B - 20);
39  }
40 
41  void OnRescale() override
42  {
43  }
44 
45  void OnResize() override
46  {
47  mWidthStr.SetFormatted(32, "%i px", (int) mRECT.W());
48  mHeightStr.SetFormatted(32, "%i px", (int) mRECT.H());
49  mScaleStr.SetFormatted(64, "width %i, height %i, scale %0.2f", GetUI()->WindowWidth(), GetUI()->WindowHeight(), GetUI()->GetDrawScale());
50  }
51 
52 private:
53  WDL_String mWidthStr;
54  WDL_String mHeightStr;
55  WDL_String mScaleStr;
56 };
The lowest level base class of an IGraphics control.
Definition: IControl.h:42
Used to manage a rectangular area, independent of draw class/platform.
void Draw(IGraphics &g) override
Draw the control to the graphics context.
Control to display the size of a region.
void OnRescale() override
Implement to do something when graphics is scaled globally (e.g.
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:631
This file contains the base IControl implementation, along with some base classes for specific types ...
float R
Right side of the rectangle (X + W)
float H() const
float W() const
IText is used to manage font and text/text entry style for a piece of text on the UI...
IControl(const IRECT &bounds, int paramIdx=kNoParameter, IActionFunction actionFunc=nullptr)
Constructor.
Definition: IControl.cpp:81
The lowest level base class of an IGraphics context.
Definition: IGraphics.h:86
IGraphics * GetUI()
Definition: IControl.h:452
float L
Left side of the rectangle (X)
void OnResize() override
Called when IControl is constructed or resized using SetRect().
virtual void DrawLine(const IColor &color, float x1, float y1, float x2, float y2, const IBlend *pBlend=0, float thickness=1.f)
Draw a line to the graphics context.
Definition: IGraphics.cpp:2402
float T
Top of the rectangle (Y)
float B
Bottom of the rectangle (Y + H)