bn::bg_palette_ptr class

std::shared_ptr like smart pointer that retains shared ownership of a background color palette.

Several bg_palette_ptr objects may own the same background color palette.

The background color palette is released when the last remaining bg_palette_ptr owning it is destroyed.

Public static functions

static auto find(const bg_palette_item& palette_item) -> optional<bg_palette_ptr>
Searches for a bg_palette_ptr which contains the given colors.
static auto create(const bg_palette_item& palette_item) -> bg_palette_ptr
Searches for a bg_palette_ptr which contains the given colors. If it is not found, it creates a bg_palette_ptr which contains them.
static auto create_new(const bg_palette_item& palette_item) -> bg_palette_ptr
Creates a bg_palette_ptr which contains the given colors.
static auto create_optional(const bg_palette_item& palette_item) -> optional<bg_palette_ptr>
Searches for a bg_palette_ptr which contains the given colors. If it is not found, it creates a bg_palette_ptr which contains them.
static auto create_new_optional(const bg_palette_item& palette_item) -> optional<bg_palette_ptr>
Creates a bg_palette_ptr which contains the given colors.

Constructors, destructors, conversion operators

bg_palette_ptr(const bg_palette_ptr& other)
Copy constructor.
bg_palette_ptr(bg_palette_ptr&& other) noexcept
Move constructor.
~bg_palette_ptr()
Releases the referenced background color palette if no more bg_palette_ptr objects reference to it.

Public functions

auto operator=(const bg_palette_ptr& other) -> bg_palette_ptr&
Copy assignment operator.
auto operator=(bg_palette_ptr&& other) -> bg_palette_ptr& noexcept
Move assignment operator.
auto id() const -> int
Returns the internal id.
auto colors_count() const -> int
Returns the number of colors contained in this palette.
auto colors() const -> span<const color>
Returns the colors contained in this palette.
void set_colors(const bg_palette_item& palette_item)
Sets the colors contained in this palette.
auto bpp() const -> bpp_mode
Returns the bits per pixel of this palette.
auto inverted() const -> bool
Indicates if the colors of this palette are inverted or not.
void set_inverted(bool inverted)
Sets if the colors of this palette must be inverted or not.
auto grayscale_intensity() const -> fixed
Returns the intensity of the grayscale effect applied to the colors of this palette.
void set_grayscale_intensity(fixed intensity)
Sets the intensity of the grayscale effect applied to the colors of this palette.
auto fade_color() const -> color
Returns the color of the fade effect applied to the colors of this palette.
auto fade_intensity() const -> fixed
Returns the intensity of the fade effect applied to the colors of this palette.
void set_fade_color(color color)
Sets the color of the fade effect applied to the colors of this palette.
void set_fade_intensity(fixed intensity)
Sets the intensity of the fade effect applied to the colors of this palette.
void set_fade(color color, fixed intensity)
Sets the color and the intensity of the fade effect applied to the colors of this palette.
auto rotate_count() const -> int
Returns the number of colors to rotate to the right in this palette.
void set_rotate_count(int count)
Sets the number of colors to rotate to the right in this palette.
void swap(bg_palette_ptr& other)
Exchanges the contents of this bg_palette_ptr with those of the other one.

Friends

void swap(bg_palette_ptr& a, bg_palette_ptr& b)
Exchanges the contents of a bg_palette_ptr with those of another one.
auto operator==(const bg_palette_ptr& a, const bg_palette_ptr& b) -> bool defaulted
Default equal operator.

Function documentation

static optional<bg_palette_ptr> bn::bg_palette_ptr::find(const bg_palette_item& palette_item)

Searches for a bg_palette_ptr which contains the given colors.

Parameters
palette_item bg_palette_item which references the colors to search.
Returns bg_palette_ptr which contains the referenced colors by palette_item if it has been found; bn::nullopt otherwise.

static bg_palette_ptr bn::bg_palette_ptr::create(const bg_palette_item& palette_item)

Searches for a bg_palette_ptr which contains the given colors. If it is not found, it creates a bg_palette_ptr which contains them.

Parameters
palette_item bg_palette_item which references the colors of the palette to search or create.
Returns The requested bg_palette_ptr.

static bg_palette_ptr bn::bg_palette_ptr::create_new(const bg_palette_item& palette_item)

Creates a bg_palette_ptr which contains the given colors.

Parameters
palette_item bg_palette_item which references the colors of the new palette.
Returns The requested bg_palette_ptr.

static optional<bg_palette_ptr> bn::bg_palette_ptr::create_optional(const bg_palette_item& palette_item)

Searches for a bg_palette_ptr which contains the given colors. If it is not found, it creates a bg_palette_ptr which contains them.

Parameters
palette_item bg_palette_item which references the colors of the palette to search or create.
Returns The requested bg_palette_ptr if it could be allocated; bn::nullopt otherwise.

static optional<bg_palette_ptr> bn::bg_palette_ptr::create_new_optional(const bg_palette_item& palette_item)

Creates a bg_palette_ptr which contains the given colors.

Parameters
palette_item bg_palette_item which references the colors of the new palette.
Returns The requested bg_palette_ptr if it could be allocated; bn::nullopt otherwise.

bn::bg_palette_ptr::bg_palette_ptr(const bg_palette_ptr& other)

Copy constructor.

Parameters
other bg_palette_ptr to copy.

bn::bg_palette_ptr::bg_palette_ptr(bg_palette_ptr&& other) noexcept

Move constructor.

Parameters
other bg_palette_ptr to move.

bg_palette_ptr& bn::bg_palette_ptr::operator=(const bg_palette_ptr& other)

Copy assignment operator.

Parameters
other bg_palette_ptr to copy.
Returns Reference to this.

bg_palette_ptr& bn::bg_palette_ptr::operator=(bg_palette_ptr&& other) noexcept

Move assignment operator.

Parameters
other bg_palette_ptr to move.
Returns Reference to this.

void bn::bg_palette_ptr::set_colors(const bg_palette_item& palette_item)

Sets the colors contained in this palette.

Parameters
palette_item bg_palette_item which references the colors to copy to this palette.

void bn::bg_palette_ptr::set_grayscale_intensity(fixed intensity)

Sets the intensity of the grayscale effect applied to the colors of this palette.

Parameters
intensity New intensity in the range [0..1].

void bn::bg_palette_ptr::set_fade_intensity(fixed intensity)

Sets the intensity of the fade effect applied to the colors of this palette.

Parameters
intensity New intensity in the range [0..1].

void bn::bg_palette_ptr::set_fade(color color, fixed intensity)

Sets the color and the intensity of the fade effect applied to the colors of this palette.

Parameters
color New color.
intensity New intensity in the range [0..1].

void bn::bg_palette_ptr::set_rotate_count(int count)

Sets the number of colors to rotate to the right in this palette.

Parameters
count Number of colors to rotate to the right in the range [1 - colors_count() .. colors_count() - 1].

void bn::bg_palette_ptr::swap(bg_palette_ptr& other)

Exchanges the contents of this bg_palette_ptr with those of the other one.

Parameters
other bg_palette_ptr to exchange the contents with.

void swap(bg_palette_ptr& a, bg_palette_ptr& b)

Exchanges the contents of a bg_palette_ptr with those of another one.

Parameters
a First bg_palette_ptr to exchange the contents with.
b Second bg_palette_ptr to exchange the contents with.