LMMS
Loading...
Searching...
No Matches
juce_FillType.cpp
Go to the documentation of this file.
1/*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 By using JUCE, you agree to the terms of both the JUCE 7 End-User License
11 Agreement and JUCE Privacy Policy.
12
13 End User License Agreement: www.juce.com/juce-7-licence
14 Privacy Policy: www.juce.com/juce-privacy-policy
15
16 Or: You may also use this code under the terms of the GPL v3 (see
17 www.gnu.org/licenses).
18
19 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
20 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
21 DISCLAIMED.
22
23 ==============================================================================
24*/
25
26namespace juce
27{
28
30 : colour (0xff000000)
31{
32}
33
38
40 : colour (0xff000000), gradient (new ColourGradient (g))
41{
42}
43
45 : colour (0xff000000), gradient (new ColourGradient (std::move (g)))
46{
47}
48
50 : colour (0xff000000), image (im), transform (t)
51{
52}
53
55 : colour (other.colour),
57 image (other.image),
58 transform (other.transform)
59{
60}
61
62FillType& FillType::operator= (const FillType& other)
63{
64 if (this != &other)
65 {
66 colour = other.colour;
67 gradient.reset (createCopyIfNotNull (other.gradient.get()));
68 image = other.image;
69 transform = other.transform;
70 }
71
72 return *this;
73}
74
76 : colour (other.colour),
77 gradient (std::move (other.gradient)),
78 image (std::move (other.image)),
79 transform (other.transform)
80{
81}
82
83FillType& FillType::operator= (FillType&& other) noexcept
84{
85 jassert (this != &other); // hopefully the compiler should make this situation impossible!
86
87 colour = other.colour;
88 gradient = std::move (other.gradient);
89 image = std::move (other.image);
90 transform = other.transform;
91 return *this;
92}
93
97
98bool FillType::operator== (const FillType& other) const
99{
100 return colour == other.colour && image == other.image
101 && transform == other.transform
102 && (gradient == other.gradient
103 || (gradient != nullptr && other.gradient != nullptr && *gradient == *other.gradient));
104}
105
106bool FillType::operator!= (const FillType& other) const
107{
108 return ! operator== (other);
109}
110
111void FillType::setColour (Colour newColour) noexcept
112{
113 gradient.reset();
114 image = {};
115 colour = newColour;
116}
117
118void FillType::setGradient (const ColourGradient& newGradient)
119{
120 if (gradient != nullptr)
121 {
122 *gradient = newGradient;
123 }
124 else
125 {
126 image = {};
127 gradient.reset (new ColourGradient (newGradient));
129 }
130}
131
132void FillType::setTiledImage (const Image& newImage, const AffineTransform& newTransform) noexcept
133{
134 gradient.reset();
135 image = newImage;
136 transform = newTransform;
138}
139
140void FillType::setOpacity (const float newOpacity) noexcept
141{
142 colour = colour.withAlpha (newOpacity);
143}
144
146{
147 return colour.isTransparent() || (gradient != nullptr && gradient->isInvisible());
148}
149
151{
152 FillType f (*this);
153 f.transform = f.transform.followedBy (t);
154 return f;
155}
156
157} // namespace juce
#define noexcept
Definition DistrhoDefines.h:72
Definition juce_AffineTransform.h:43
Definition juce_ColourGradient.h:38
Definition juce_Colour.h:38
Image image
Definition juce_FillType.h:143
void setColour(Colour newColour) noexcept
Definition juce_FillType.cpp:111
void setGradient(const ColourGradient &newGradient)
Definition juce_FillType.cpp:118
FillType transformed(const AffineTransform &transform) const
Definition juce_FillType.cpp:150
void setOpacity(float newOpacity) noexcept
Definition juce_FillType.cpp:140
AffineTransform transform
Definition juce_FillType.h:146
void setTiledImage(const Image &image, const AffineTransform &transform) noexcept
Definition juce_FillType.cpp:132
Colour colour
Definition juce_FillType.h:130
FillType() noexcept
Definition juce_FillType.cpp:29
~FillType() noexcept
Definition juce_FillType.cpp:94
std::unique_ptr< ColourGradient > gradient
Definition juce_FillType.h:137
bool isInvisible() const noexcept
Definition juce_FillType.cpp:145
Definition juce_Image.h:58
struct huft * t
Definition inflate.c:943
int g
Definition inflate.c:1573
unsigned f
Definition inflate.c:1572
#define jassert(expression)
const Colour black
Definition juce_Colours.h:50
Definition carla_juce.cpp:31
Type * createCopyIfNotNull(const Type *objectToCopy)
Definition juce_Memory.h:60
Definition juce_Uuid.h:141
return c
Definition crypt.c:175
#define const
Definition zconf.h:137