iPlug2 - C++ Audio Plug-in Framework
Loading...
Searching...
No Matches
TestGFXLabel.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 GFXLabelControl(const IRECT& rect)
26 : IControl(rect)
27 {
28 mIgnoreMouse = true;
29 }
30
31 void Draw(IGraphics& g) override
32 {
33 if (!g.CheckLayer(mLayer))
34 {
35 g.StartLayer(this, mRECT);
36//#ifdef IGRAPHICS_NANOVG
37// static IText text {14, COLOR_WHITE, "Roboto-Regular", EAlign::Center, EVAlign::Middle, 0};
38//#else
39 static IText text {34, COLOR_WHITE, "Roboto-Regular", EAlign::Center, EVAlign::Top, 0};
40//#endif
41 IRECT r = mRECT;
42 g.MeasureText(text, g.GetDrawingAPIStr(), r);
43 r.Pad(20, 0, 20, 0);
44
45 g.FillRect(COLOR_BLACK, r);
46
47 g.DrawText(text, g.GetDrawingAPIStr(), mRECT);
48 mLayer = g.EndLayer();
49 IShadow shadow(COLOR_BLACK_DROP_SHADOW, 10.0, 3.0, 6.0, 0.7f, true);
50 g.ApplyLayerDropShadow(mLayer, shadow);
51 }
52
53 g.DrawLayer(mLayer);
54// g.DrawRotatedLayer(mLayer, 45);
55 }
56
57private:
58 ILayerPtr mLayer;
59};
This file contains the base IControl implementation, along with some base classes for specific types ...
Control to display the graphics backend.
Definition: TestGFXLabel.h:23
void Draw(IGraphics &g) override
Draw the control to the graphics context.
Definition: TestGFXLabel.h:31
The lowest level base class of an IGraphics control.
Definition: IControl.h:49
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 const char * GetDrawingAPIStr()=0
bool CheckLayer(const ILayerPtr &layer)
Test to see if a layer needs drawing, for instance if the control's bounds were changed.
Definition: IGraphics.cpp:2032
void DrawLayer(const ILayerPtr &layer, const IBlend *pBlend=nullptr)
Draw a layer to the main IGraphics context.
Definition: IGraphics.cpp:2045
virtual void FillRect(const IColor &color, const IRECT &bounds, const IBlend *pBlend=0)
Fill a rectangular region of the graphics context with a color.
Definition: IGraphics.cpp:2569
void ApplyLayerDropShadow(ILayerPtr &layer, const IShadow &shadow)
Applies a drop shadow directly onto a layer.
Definition: IGraphics.cpp:2075
void StartLayer(IControl *pOwner, const IRECT &r, bool cacheable=false)
Create an IGraphics layer.
Definition: IGraphics.cpp:1977
ILayerPtr EndLayer()
End an IGraphics layer.
Definition: IGraphics.cpp:2000
virtual float MeasureText(const IText &text, const char *str, IRECT &bounds) const
Measure the rectangular region that some text will occupy.
Definition: IGraphics.cpp:678
std::unique_ptr< ILayer > ILayerPtr
ILayerPtr is a managed pointer for transferring the ownership of layers.
Used to manage a rectangular area, independent of draw class/platform.
void Pad(float padding)
Pad this IRECT N.B.
Used to specify properties of a drop-shadow to a layer.
IText is used to manage font and text/text entry style for a piece of text on the UI,...