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

Minor clean-ups around the Justification class.

This commit is contained in:
jules 2013-08-20 17:27:41 +01:00
parent 14b5857440
commit 45b56e2e20
11 changed files with 57 additions and 102 deletions

View file

@ -1,44 +0,0 @@
/*
==============================================================================
This file is part of the JUCE library.
Copyright (c) 2013 - Raw Material Software Ltd.
Permission is granted to use this software under the terms of either:
a) the GPL v2 (or any later version)
b) the Affero GPL v3
Details of these licenses can be found at: www.gnu.org/licenses
JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
To release a closed-source product which uses JUCE, commercial licenses are
available: visit www.juce.com for more information.
==============================================================================
*/
Justification::Justification (const Justification& other) noexcept
: flags (other.flags)
{
}
Justification& Justification::operator= (const Justification& other) noexcept
{
flags = other.flags;
return *this;
}
int Justification::getOnlyVerticalFlags() const noexcept
{
return flags & (top | bottom | verticallyCentred);
}
int Justification::getOnlyHorizontalFlags() const noexcept
{
return flags & (left | right | horizontallyCentred | horizontallyJustified);
}

View file

@ -37,37 +37,40 @@
It is used in various places wherever this kind of information is needed.
*/
class JUCE_API Justification
class Justification
{
public:
//==============================================================================
/** Creates a Justification object using a combination of flags from the Flags enum. */
inline Justification (int justificationFlags) noexcept : flags (justificationFlags) {}
Justification (int justificationFlags) noexcept : flags (justificationFlags) {}
/** Creates a copy of another Justification object. */
Justification (const Justification& other) noexcept;
Justification (const Justification& other) noexcept : flags (other.flags) {}
/** Copies another Justification object. */
Justification& operator= (const Justification& other) noexcept;
Justification& operator= (const Justification& other) noexcept
{
flags = other.flags;
return *this;
}
bool operator== (const Justification& other) const noexcept { return flags == other.flags; }
bool operator!= (const Justification& other) const noexcept { return flags != other.flags; }
//==============================================================================
/** Returns the raw flags that are set for this Justification object. */
inline int getFlags() const noexcept { return flags; }
inline int getFlags() const noexcept { return flags; }
/** Tests a set of flags for this object.
@returns true if any of the flags passed in are set on this object.
*/
inline bool testFlags (int flagsToTest) const noexcept { return (flags & flagsToTest) != 0; }
inline bool testFlags (int flagsToTest) const noexcept { return (flags & flagsToTest) != 0; }
/** Returns just the flags from this object that deal with vertical layout. */
int getOnlyVerticalFlags() const noexcept;
int getOnlyVerticalFlags() const noexcept { return flags & (top | bottom | verticallyCentred); }
/** Returns just the flags from this object that deal with horizontal layout. */
int getOnlyHorizontalFlags() const noexcept;
int getOnlyHorizontalFlags() const noexcept { return flags & (left | right | horizontallyCentred | horizontallyJustified); }
//==============================================================================
/** Adjusts the position of a rectangle to fit it into a space.