iPlug2 - C++ Audio Plug-in Framework
Loading...
Searching...
No Matches
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
23{
24public:
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
52private:
53 WDL_String mWidthStr;
54 WDL_String mHeightStr;
55 WDL_String mScaleStr;
56};
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
IGraphics * GetUI()
Definition: IControl.h:467
The lowest level base class of an IGraphics context.
Definition: IGraphics.h:86
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
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:2416
Control to display the size of a region.
void OnResize() override
Called when IControl is constructed or resized using SetRect().
void Draw(IGraphics &g) override
Draw the control to the graphics context.
void OnRescale() override
Implement to do something when graphics is scaled globally (e.g.
Used to manage a rectangular area, independent of draw class/platform.
float W() const
float H() const
IText is used to manage font and text/text entry style for a piece of text on the UI,...