Union::Properties::ImagePropertyGroup Class

class Union::Properties::ImagePropertyGroup

A property group describing properties of an image. More...

Header: #include <ImagePropertyGroup.h>
CMake: find_package(Union REQUIRED)
target_link_libraries(mytarget PRIVATE Union::Union)

Public Functions

ImagePropertyGroup()
ImagePropertyGroup(const Union::Properties::ImagePropertyGroup &other)
ImagePropertyGroup(Union::Properties::ImagePropertyGroup &&other)
std::optional<Union::Properties::ImageFlags> flags() const
bool hasAnyValue() const
std::optional<qreal> height() const
bool isEmpty() const
std::optional<Union::Color> maskColor() const
T safePropertyLookup(const T &defaultValue, LookupFunctions... functions) const
void setFlags(const std::optional<Union::Properties::ImageFlags> &newValue)
void setHeight(const std::optional<qreal> &newValue)
void setMaskColor(const std::optional<Union::Color> &newValue)
void setSource(const std::optional<std::filesystem::path> &newValue)
void setWidth(const std::optional<qreal> &newValue)
void setXOffset(const std::optional<qreal> &newValue)
void setYOffset(const std::optional<qreal> &newValue)
std::optional<std::filesystem::path> source() const
QString toString(int indentation = 0, Union::Properties::ToStringFlags flags = ToStringFlags{}) const
std::optional<qreal> width() const
std::optional<qreal> xOffset() const
std::optional<qreal> yOffset() const
Union::Properties::ImagePropertyGroup &operator=(Union::Properties::ImagePropertyGroup &&other)
Union::Properties::ImagePropertyGroup &operator=(const Union::Properties::ImagePropertyGroup &other)

Static Public Members

std::unique_ptr<Union::Properties::ImagePropertyGroup> empty()
void resolveProperties(const Union::Properties::ImagePropertyGroup *source, Union::Properties::ImagePropertyGroup *destination)
QDebug operator<<(QDebug debug, Union::Properties::ImagePropertyGroup *type)
bool operator==(const Union::Properties::ImagePropertyGroup &left, const Union::Properties::ImagePropertyGroup &right)

Detailed Description

Member Function Documentation

ImagePropertyGroup::ImagePropertyGroup()

Default constructor. Constructs a null instance.

A null instance in this case means an instance that does not have any values for its properties. This includes property groups.

ImagePropertyGroup::ImagePropertyGroup(const Union::Properties::ImagePropertyGroup &other)

Copy constructor.

ImagePropertyGroup::ImagePropertyGroup(Union::Properties::ImagePropertyGroup &&other)

Move constructor.

[static] std::unique_ptr<Union::Properties::ImagePropertyGroup> ImagePropertyGroup::empty()

Create and return an empty ImagePropertyGroup instance.

This will create an empty ImagePropertyGroup instance, which is defined as an instance with all of its values default-constructed. Note that this is different from a default-constructed instance which will have all its values unset.

std::optional<Union::Properties::ImageFlags> ImagePropertyGroup::flags() const

A set of flags to use for this image.

See also setFlags().

bool ImagePropertyGroup::hasAnyValue() const

Returns if this property group has any value set.

Note that for any property that is also a property group, this will also check if that group has any value.

std::optional<qreal> ImagePropertyGroup::height() const

The height to use for the image. If unset, the source's image height is used.

See also setHeight().

bool ImagePropertyGroup::isEmpty() const

Returns if this property is considered empty.

A property is considered empty if it has no values or if the values it contains are all considered empty values.

std::optional<Union::Color> ImagePropertyGroup::maskColor() const

The color to use for rendering the image when the image is used as a mask.

See also setMaskColor().

[static] void ImagePropertyGroup::resolveProperties(const Union::Properties::ImagePropertyGroup *source, Union::Properties::ImagePropertyGroup *destination)

Copy property values from source to destination if destination does not have a property value.

This will recursively copy property values of grouped properties.

source The source property group to copy from. destination The destination property group to copy to.

template <typename T, typename... LookupFunctions> requires (std::is_member_function_pointer_v<LookupFunctions> && ...) T ImagePropertyGroup::safePropertyLookup(const T &defaultValue, LookupFunctions... functions) const

Perform safe property lookup of a property or the property of a subgroup.

This should be called with a list of property getter pointer-to-member functions in functions that indicate which properties to access. Each subgroup access will be checked to make sure the subgroup exists. If any of them does not exist, defaultValue will be returned. The final property lookup can be any member function of the final group. If that returns a pointer or std::optional<>, it is checked to see if it has a value. If it does, that value is returned. If not, defaultValue is returned. For functions returning anything else, the value returned by the function is returned.

Example usage:

// Lookup the value of the property "spacing" of the "layout" group.
auto spacing = StylePropertyGroup->safePropertyLookup(0.0, &StylePropertyGroup::layout, &LayoutPropertyGroup::spacing);

void ImagePropertyGroup::setFlags(const std::optional<Union::Properties::ImageFlags> &newValue)

Set the value of flags.

newValue The new value or std::nullopt to unset the value.

See also flags().

void ImagePropertyGroup::setHeight(const std::optional<qreal> &newValue)

Set the value of height.

newValue The new value or std::nullopt to unset the value.

See also height().

void ImagePropertyGroup::setMaskColor(const std::optional<Union::Color> &newValue)

Set the value of maskColor.

newValue The new value or std::nullopt to unset the value.

See also maskColor().

void ImagePropertyGroup::setSource(const std::optional<std::filesystem::path> &newValue)

Set the value of source.

newValue The new value or std::nullopt to unset the value.

See also source().

void ImagePropertyGroup::setWidth(const std::optional<qreal> &newValue)

Set the value of width.

newValue The new value or std::nullopt to unset the value.

See also width().

void ImagePropertyGroup::setXOffset(const std::optional<qreal> &newValue)

Set the value of xOffset.

newValue The new value or std::nullopt to unset the value.

See also xOffset().

void ImagePropertyGroup::setYOffset(const std::optional<qreal> &newValue)

Set the value of yOffset.

newValue The new value or std::nullopt to unset the value.

See also yOffset().

std::optional<std::filesystem::path> ImagePropertyGroup::source() const

The path to an image to use as source for this image.

See also setSource().

QString ImagePropertyGroup::toString(int indentation = 0, Union::Properties::ToStringFlags flags = ToStringFlags{}) const

Returns a string representation of this property group.

This is intended for debugging.

indentation The amount of indentation to apply. Defaults to 0. flags A set of flags that control conversion behavior.

std::optional<qreal> ImagePropertyGroup::width() const

The width to use for the image. If unset, the source's image width is used.

See also setWidth().

std::optional<qreal> ImagePropertyGroup::xOffset() const

An offset on placement of the image horizontally.

See also setXOffset().

std::optional<qreal> ImagePropertyGroup::yOffset() const

An offset on placement of the image vertically.

See also setYOffset().

Union::Properties::ImagePropertyGroup &ImagePropertyGroup::operator=(Union::Properties::ImagePropertyGroup &&other)

Move assignment operator.

Union::Properties::ImagePropertyGroup &ImagePropertyGroup::operator=(const Union::Properties::ImagePropertyGroup &other)

Copy assignment operator.

Related Non-Members

QDebug operator<<(QDebug debug, Union::Properties::ImagePropertyGroup *type)

QDebug support for ImagePropertyGroup.

bool operator==(const Union::Properties::ImagePropertyGroup &left, const Union::Properties::ImagePropertyGroup &right)

Equality comparison for ImagePropertyGroup.