iPlug2 - C++ Audio Plug-in Framework
Loading...
Searching...
No Matches
TestShadowGradientControl.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
27 : IControl(rect)
28 {
29 }
30
31 void Draw(IGraphics& g) override
32 {
33 IPattern pattern = IPattern::CreateLinearGradient(mRECT.L + mRECT.W() / 2.f, mRECT.T + mRECT.H() / 2.f, mRECT.R, mRECT.B);
34 pattern.AddStop(COLOR_BLACK, 0.f);
35 pattern.AddStop(COLOR_WHITE, 1.f);
36
37 IShadow shadow(pattern, 0.f, mRECT.W() / 2.f, mRECT.H() / 2.f, 1.f, false);
38 IRECT bounds(mRECT.L, mRECT.T, mRECT.L + mRECT.W() / 2.f, mRECT.T + mRECT.H() / 2.f);
39
40 g.StartLayer(this, mRECT);
41 g.FillRect(COLOR_WHITE, bounds);
42 mLayer = g.EndLayer();
43 g.ApplyLayerDropShadow(mLayer, shadow);
44 g.DrawLayer(mLayer);
45 }
46
47private:
48 ILayerPtr mLayer;
49};
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
The lowest level base class of an IGraphics context.
Definition: IGraphics.h:86
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
Control to test drawing shadows with gradients.
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 store pattern information for gradients.
void AddStop(IColor color, float offset)
Add an IColorStop to the IPattern.
static IPattern CreateLinearGradient(float x1, float y1, float x2, float y2, const std::initializer_list< IColorStop > &stops={})
Create a linear gradient IPattern.
Used to manage a rectangular area, independent of draw class/platform.
float W() const
float H() const
Used to specify properties of a drop-shadow to a layer.