1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Made some JUCE classes TriviallyCopyable

This commit is contained in:
Tom Poole 2018-07-10 17:08:38 +01:00
parent 4f2bbd965a
commit 08d67c763f
13 changed files with 42 additions and 109 deletions

View file

@ -1587,19 +1587,17 @@ private:
//==============================================================================
struct InOutChannelPair
{
int16 inChannels = 0, outChannels = 0;
InOutChannelPair() = default;
InOutChannelPair() noexcept {}
InOutChannelPair (const InOutChannelPair& o) noexcept : inChannels (o.inChannels), outChannels (o.outChannels) {}
InOutChannelPair (int16 inCh, int16 outCh) noexcept : inChannels (inCh), outChannels (outCh) {}
InOutChannelPair (const int16 (&config)[2]) noexcept : inChannels (config[0]), outChannels (config[1]) {}
InOutChannelPair& operator= (const InOutChannelPair& o) noexcept { inChannels = o.inChannels; outChannels = o.outChannels; return *this; }
bool operator== (const InOutChannelPair& other) const noexcept
{
return other.inChannels == inChannels && other.outChannels == outChannels;
}
int16 inChannels = 0, outChannels = 0;
};
template <int numLayouts>

View file

@ -41,9 +41,7 @@ class Range
public:
//==============================================================================
/** Constructs an empty range. */
Range() noexcept : start(), end()
{
}
Range() = default;
/** Constructs a range with given start and end values. */
Range (const ValueType startValue, const ValueType endValue) noexcept
@ -52,18 +50,10 @@ public:
}
/** Constructs a copy of another range. */
Range (const Range& other) noexcept
: start (other.start), end (other.end)
{
}
Range (const Range&) = default;
/** Copies another range object. */
Range& operator= (Range other) noexcept
{
start = other.start;
end = other.end;
return *this;
}
Range& operator= (const Range&) = default;
/** Returns the range that lies between two positions (in either order). */
static Range between (const ValueType position1, const ValueType position2) noexcept
@ -301,7 +291,7 @@ public:
private:
//==============================================================================
ValueType start, end;
ValueType start{}, end{};
};
} // namespace juce

View file

@ -140,22 +140,6 @@ namespace ColourHelpers
}
//==============================================================================
Colour::Colour() noexcept
: argb (0, 0, 0, 0)
{
}
Colour::Colour (const Colour& other) noexcept
: argb (other.argb)
{
}
Colour& Colour::operator= (const Colour& other) noexcept
{
argb = other.argb;
return *this;
}
bool Colour::operator== (const Colour& other) const noexcept { return argb.getNativeARGB() == other.argb.getNativeARGB(); }
bool Colour::operator!= (const Colour& other) const noexcept { return argb.getNativeARGB() != other.argb.getNativeARGB(); }
@ -227,11 +211,6 @@ Colour::Colour (PixelAlpha alpha) noexcept
{
}
Colour::~Colour() noexcept
{
}
//==============================================================================
const PixelARGB Colour::getPixelARGB() const noexcept
{

View file

@ -40,10 +40,10 @@ class JUCE_API Colour final
public:
//==============================================================================
/** Creates a transparent black colour. */
Colour() noexcept;
Colour() = default;
/** Creates a copy of another Colour object. */
Colour (const Colour& other) noexcept;
Colour (const Colour&) = default;
/** Creates a colour from a 32-bit ARGB value.
@ -143,10 +143,10 @@ public:
float alpha) noexcept;
/** Destructor. */
~Colour() noexcept;
~Colour() = default;
/** Copies another Colour object. */
Colour& operator= (const Colour& other) noexcept;
Colour& operator= (const Colour&) = default;
/** Compares two colours. */
bool operator== (const Colour& other) const noexcept;
@ -363,7 +363,7 @@ public:
private:
//==============================================================================
PixelARGB argb;
PixelARGB argb { 0, 0, 0, 0 };
};
} // namespace juce

View file

@ -60,8 +60,8 @@ class JUCE_API PixelARGB
{
public:
/** Creates a pixel without defining its colour. */
PixelARGB() noexcept {}
~PixelARGB() noexcept {}
PixelARGB() = default;
~PixelARGB() = default;
PixelARGB (const uint8 a, const uint8 r, const uint8 g, const uint8 b) noexcept
{
@ -367,8 +367,8 @@ class JUCE_API PixelRGB
{
public:
/** Creates a pixel without defining its colour. */
PixelRGB() noexcept {}
~PixelRGB() noexcept {}
PixelRGB() = default;
~PixelRGB() = default;
//==============================================================================
/** Returns a uint32 which represents the pixel in a platform dependent format which is compatible
@ -618,8 +618,8 @@ class JUCE_API PixelAlpha
{
public:
/** Creates a pixel without defining its colour. */
PixelAlpha() noexcept {}
~PixelAlpha() noexcept {}
PixelAlpha() = default;
~PixelAlpha() = default;
//==============================================================================
/** Returns a uint32 which represents the pixel in a platform dependent format which is compatible

View file

@ -43,17 +43,17 @@ class Point
{
public:
/** Creates a point at the origin */
JUCE_CONSTEXPR Point() noexcept : x(), y() {}
JUCE_CONSTEXPR Point() = default;
/** Creates a copy of another point. */
JUCE_CONSTEXPR Point (const Point& other) noexcept : x (other.x), y (other.y) {}
JUCE_CONSTEXPR Point (const Point&) = default;
/** Creates a point from an (x, y) position. */
JUCE_CONSTEXPR Point (ValueType initialX, ValueType initialY) noexcept : x (initialX), y (initialY) {}
//==============================================================================
/** Copies this point from another one. */
Point& operator= (const Point& other) noexcept { x = other.x; y = other.y; return *this; }
Point& operator= (const Point&) = default;
JUCE_CONSTEXPR inline bool operator== (Point other) const noexcept { return x == other.x && y == other.y; }
JUCE_CONSTEXPR inline bool operator!= (Point other) const noexcept { return x != other.x || y != other.y; }
@ -234,8 +234,8 @@ public:
String toString() const { return String (x) + ", " + String (y); }
//==============================================================================
ValueType x; /**< The point's X coordinate. */
ValueType y; /**< The point's Y coordinate. */
ValueType x{}; /**< The point's X coordinate. */
ValueType y{}; /**< The point's Y coordinate. */
};
/** Multiplies the point's coordinates by a scalar value. */

View file

@ -43,16 +43,10 @@ public:
/** Creates a rectangle of zero size.
The default coordinates will be (0, 0, 0, 0).
*/
Rectangle() noexcept
: w(), h()
{
}
Rectangle() = default;
/** Creates a copy of another rectangle. */
Rectangle (const Rectangle& other) noexcept
: pos (other.pos), w (other.w), h (other.h)
{
}
Rectangle (const Rectangle&) = default;
/** Creates a rectangle with a given position and size. */
Rectangle (ValueType initialX, ValueType initialY,
@ -89,15 +83,11 @@ public:
return { left, top, right - left, bottom - top };
}
Rectangle& operator= (const Rectangle& other) noexcept
{
pos = other.pos;
w = other.w; h = other.h;
return *this;
}
/** Creates a copy of another rectangle. */
Rectangle& operator= (const Rectangle&) = default;
/** Destructor. */
~Rectangle() noexcept {}
~Rectangle() = default;
//==============================================================================
/** Returns true if the rectangle's width or height are zero or less */
@ -974,7 +964,7 @@ private:
template <typename OtherType> friend class Rectangle;
Point<ValueType> pos;
ValueType w, h;
ValueType w{}, h{};
static ValueType parseIntAfterSpace (StringRef s) noexcept
{ return static_cast<ValueType> (s.text.findEndOfWhitespace().getIntValue32()); }

View file

@ -693,7 +693,7 @@ namespace EdgeTableFillers
{
if (areRGBComponentsEqual) // if all the component values are the same, we can cheat..
{
memset (dest, colour.getRed(), (size_t) width * 3);
memset ((void*) dest, colour.getRed(), (size_t) width * 3);
}
else
{
@ -735,7 +735,7 @@ namespace EdgeTableFillers
forcedinline void replaceLine (PixelAlpha* dest, const PixelARGB colour, int width) const noexcept
{
if ((size_t) destData.pixelStride == sizeof (*dest))
memset (dest, colour.getAlpha(), (size_t) width);
memset ((void*) dest, colour.getAlpha(), (size_t) width);
else
JUCE_PERFORM_PIXEL_OP_LOOP (setAlpha (colour.getAlpha()))
}
@ -965,7 +965,7 @@ namespace EdgeTableFillers
&& srcData.pixelFormat == Image::RGB
&& destData.pixelFormat == Image::RGB)
{
memcpy (dest, src, (size_t) (width * srcStride));
memcpy ((void*) dest, src, (size_t) (width * srcStride));
}
else
{

View file

@ -27,10 +27,6 @@
namespace juce
{
KeyPress::KeyPress() noexcept
{
}
KeyPress::KeyPress (int code, ModifierKeys m, juce_wchar textChar) noexcept
: keyCode (code), mods (m), textCharacter (textChar)
{
@ -40,19 +36,6 @@ KeyPress::KeyPress (const int code) noexcept : keyCode (code)
{
}
KeyPress::KeyPress (const KeyPress& other) noexcept
: keyCode (other.keyCode), mods (other.mods), textCharacter (other.textCharacter)
{
}
KeyPress& KeyPress::operator= (const KeyPress& other) noexcept
{
keyCode = other.keyCode;
mods = other.mods;
textCharacter = other.textCharacter;
return *this;
}
bool KeyPress::operator== (int otherKeyCode) const noexcept
{
return keyCode == otherKeyCode && ! mods.isAnyModifierKeyDown();

View file

@ -45,7 +45,10 @@ public:
@see isValid
*/
KeyPress() noexcept;
KeyPress() = default;
/** Destructor. */
~KeyPress() = default;
/** Creates a KeyPress for a key and some modifiers.
@ -74,10 +77,10 @@ public:
explicit KeyPress (int keyCode) noexcept;
/** Creates a copy of another KeyPress. */
KeyPress (const KeyPress& other) noexcept;
KeyPress (const KeyPress&) = default;
/** Copies this KeyPress from another one. */
KeyPress& operator= (const KeyPress& other) noexcept;
KeyPress& operator= (const KeyPress&) = default;
/** Compares two KeyPress objects. */
bool operator== (const KeyPress& other) const noexcept;

View file

@ -29,15 +29,7 @@ namespace juce
ModifierKeys ModifierKeys::currentModifiers;
ModifierKeys::ModifierKeys() noexcept : flags (0) {}
ModifierKeys::ModifierKeys (int rawFlags) noexcept : flags (rawFlags) {}
ModifierKeys::ModifierKeys (const ModifierKeys& other) noexcept : flags (other.flags) {}
ModifierKeys& ModifierKeys::operator= (const ModifierKeys other) noexcept
{
flags = other.flags;
return *this;
}
int ModifierKeys::getNumMouseButtonsDown() const noexcept
{

View file

@ -43,7 +43,7 @@ class JUCE_API ModifierKeys
public:
//==============================================================================
/** Creates a ModifierKeys object with no flags set. */
ModifierKeys() noexcept;
ModifierKeys() = default;
/** Creates a ModifierKeys object from a raw set of flags.
@ -54,10 +54,10 @@ public:
ModifierKeys (int flags) noexcept;
/** Creates a copy of another object. */
ModifierKeys (const ModifierKeys& other) noexcept;
ModifierKeys (const ModifierKeys&) = default;
/** Copies this object from another one. */
ModifierKeys& operator= (const ModifierKeys other) noexcept;
ModifierKeys& operator= (const ModifierKeys&) = default;
//==============================================================================
/** Checks whether the 'command' key flag is set (or 'ctrl' on Windows/Linux).
@ -206,7 +206,7 @@ public:
static ModifierKeys getCurrentModifiersRealtime() noexcept;
private:
int flags;
int flags = 0;
};
} // namespace juce

View file

@ -1152,8 +1152,6 @@ void LookAndFeel_V4::drawConcertinaPanelHeader (Graphics& g, const Rectangle<int
p.addRoundedRectangle (bounds.getX(), bounds.getY(), bounds.getWidth(), bounds.getHeight(),
cornerSize, cornerSize, isTopPanel, isTopPanel, false, false);
auto bkg = Colours::grey;
g.setGradientFill (ColourGradient::vertical (Colours::white.withAlpha (isMouseOver ? 0.4f : 0.2f), static_cast<float> (area.getY()),
Colours::darkgrey.withAlpha (0.1f), static_cast<float> (area.getBottom())));
g.fillPath (p);