iPlug2 - C++ Audio Plug-in Framework
Loading...
Searching...
No Matches
TestMaskControl.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 TestMaskControl(const IRECT& bounds, const IBitmap& bitmap)
26 : IBitmapControl(bounds, bitmap)
27 {
28 }
29
30 void Draw(IGraphics& g) override
31 {
32 g.FillRect(COLOR_INDIGO, mRECT);
33 IRECT r = mRECT.GetCentredInside(100);
34
35 g.StartLayer(this, r);
36 g.DrawFittedBitmap(mBitmap, r);
37 const IPattern pattern = IPattern::CreateRadialGradient(r.MW(), r.MH(), r.W()/2.f, { {COLOR_BLACK, 0.f}, {COLOR_BLACK, 0.95f}, {COLOR_TRANSPARENT, 1.f} });
38 g.PathRect(r);
39 g.PathFill(pattern, IFillOptions(), &BLEND_DST_IN);
40// g.FillRect(COLOR_ORANGE, r, &BLEND_DST_OVER); // fill the outside, comment for transparency
41 mLayer = g.EndLayer();
42 g.DrawLayer(mLayer);
43 }
44
45private:
46 ILayerPtr mLayer;
47};
This file contains the base IControl implementation, along with some base classes for specific types ...
A basic control to draw a bitmap, or one frame of a stacked bitmap depending on the current value.
Definition: IControl.h:2081
User-facing bitmap abstraction that you use to manage bitmap data, independant of draw class/platform...
The lowest level base class of an IGraphics context.
Definition: IGraphics.h:86
virtual void DrawFittedBitmap(const IBitmap &bitmap, const IRECT &bounds, const IBlend *pBlend=0)
Draw a bitmap (raster) image to the graphics context, scaling the image to fit the bounds.
Definition: IGraphics.cpp:2774
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 StartLayer(IControl *pOwner, const IRECT &r, bool cacheable=false)
Create an IGraphics layer.
Definition: IGraphics.cpp:1977
Control to display the size of a region.
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 fill behaviour.
Used to store pattern information for gradients.
static IPattern CreateRadialGradient(float x1, float y1, float r, const std::initializer_list< IColorStop > &stops={})
Create a radial gradient IPattern.
Used to manage a rectangular area, independent of draw class/platform.
IRECT GetCentredInside(const IRECT &sr) const
Get a rectangle the size of sr but with the same center point as this rectangle.
float MH() const
float W() const
float MW() const