iPlug2 - C++ Audio Plug-in Framework
Loading...
Searching...
No Matches
TestDropShadowControl.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#include "nanosvg.h"
20
24{
25public:
26 TestDropShadowControl(const IRECT& bounds, const ISVG& svg)
27 : IControl(bounds)
28 , mSVG(svg)
29 {
30 SetTooltip("TestDropShadowControl");
31 }
32
33 void Draw(IGraphics& g) override
34 {
35 g.DrawDottedRect(COLOR_BLACK, mRECT);
36
37 if (!g.CheckLayer(mLayer))
38 {
39 g.StartLayer(this, mRECT);
40
41 g.DrawSVG(mSVG, mRECT);
42
43 mLayer = g.EndLayer();
44 IShadow shadow(COLOR_BLACK, 10.0, 5.0, 10.0, 0.7f, true);
45 g.ApplyLayerDropShadow(mLayer, shadow);
46 }
47
48 g.DrawLayer(mLayer);
49 }
50
51 void OnDrop(const char* str) override
52 {
53 SetSVG(GetUI()->LoadSVG(str));
54 SetDirty(false);
55 }
56
57 void SetSVG(const ISVG& svg)
58 {
59 mSVG = svg;
60 mLayer->Invalidate();
61 }
62
63private:
64 ILayerPtr mLayer;
65 ISVG mSVG;
66};
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
IControl * SetTooltip(const char *str)
Set a tooltip for the control.
Definition: IControl.h:216
virtual void SetDirty(bool triggerAction=true, int valIdx=kNoValIdx)
Mark the control as dirty, i.e.
Definition: IControl.cpp:198
The lowest level base class of an IGraphics context.
Definition: IGraphics.h:86
virtual void DrawDottedRect(const IColor &color, const IRECT &bounds, const IBlend *pBlend=0, float thickness=1.f, float dashLen=2.f)
Draw a dotted rectangle to the graphics context.
Definition: IGraphics.cpp:2539
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
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
virtual void DrawSVG(const ISVG &svg, const IRECT &bounds, const IBlend *pBlend=0, const IColor *pStrokeColor=nullptr, const IColor *pFillColor=nullptr)
Draw an SVG image to the graphics context.
Definition: IGraphics.cpp:2784
ILayerPtr EndLayer()
End an IGraphics layer.
Definition: IGraphics.cpp:2000
Control to test layer drop shadows.
void Draw(IGraphics &g) override
Draw the control to the graphics context.
void OnDrop(const char *str) override
Implement to do something when something was drag 'n dropped onto this control.
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.
User-facing SVG abstraction that you use to manage SVG data ISVG doesn't actually own the image data.
Used to specify properties of a drop-shadow to a layer.