1.10
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
ImageHolder< T, id_bg, id_border, id_text > Class Template Reference

#include <imageholder.h>

Inheritance diagram for ImageHolder< T, id_bg, id_border, id_text >:
Inheritance graph
[legend]

Public Member Functions

 ImageHolder (const Image &image, const std::string &text, const Rect &rect, const AlignFlags &text_align=T::default_text_align()) noexcept
 
 ImageHolder (const Image &image, const std::string &text={}, const AlignFlags &text_align=T::default_text_align()) noexcept
 
 ImageHolder (const ImageHolder &) noexcept=delete
 
 ImageHolder (const std::string &text={}, const AlignFlags &text_align=T::default_text_align()) noexcept
 
 ImageHolder (Frame &parent, const Image &image, const std::string &text, const Rect &rect, const AlignFlags &text_align=T::default_text_align()) noexcept
 
 ImageHolder (Frame &parent, const Image &image={}, const std::string &text={}, const AlignFlags &text_align=T::default_text_align()) noexcept
 
 ImageHolder (ImageHolder &&) noexcept=default
 
 ImageHolder (Serializer::Properties &props) noexcept
 
virtual ~ImageHolder ()=default
 
bool auto_scale_image () const
 Get the auto scale image state.
 
void auto_scale_image (bool enable)
 Enable/disable the auto scale of the image.
 
void draw (Painter &painter, const Rect &rect) override
 
EGT_NODISCARD float hscale () const
 Get the horizontal scale value.
 
void hscale (float hscale)
 Set the horizontal scale value.
 
Imageimage ()
 Get a non-const reference to the image.
 
EGT_NODISCARD const Imageimage () const
 Get a const reference of the image.
 
void image (const Image &image)
 Set a new Image.
 
EGT_NODISCARD AlignFlags image_align () const
 Get the image alignment.
 
void image_align (const AlignFlags &align)
 Set the alignment of the image relative to the text.
 
EGT_NODISCARD SizeF image_scale () const
 Get both scale values.
 
void image_scale (const SizeF &scale)
 Scale the image in both direction.
 
void image_scale (float scale)
 Scale the image in both direction with the same ratio.
 
bool keep_image_ratio () const
 Get the keep image ratio state.
 
void keep_image_ratio (bool enable)
 Enable/disable ratio preservation while scaling the image.
 
EGT_NODISCARD Size min_size_hint () const override
 
ImageHolderoperator= (const ImageHolder &) noexcept=delete
 
ImageHolderoperator= (ImageHolder &&) noexcept=default
 
void reset_uri ()
 Reset the URI, therefore clear the current image, if any.
 
void scale_image (float hscale, float vscale, bool approximate=false)
 Scale the image.
 
void scale_image (float scale, bool approximate=false)
 Scale the image.
 
void serialize (Serializer &serializer) const override
 
EGT_NODISCARD bool show_label () const
 Get the show label state.
 
void show_label (bool value)
 Enable/disable showing the label text.
 
EGT_NODISCARD std::string type () const override
 
EGT_NODISCARD std::string uri () const
 Get the URI of the current image.
 
void uri (const std::string &uri)
 Load a new Image from an uri.
 
EGT_NODISCARD float vscale () const
 Get the vertical scale value.
 
void vscale (float vscale)
 Set the vertical scale value.
 

Static Public Member Functions

static void default_draw (ImageHolder &widget, Painter &painter, const Rect &rect)
 Default draw method for the widget.
 

Protected Member Functions

 ImageHolder (Serializer::Properties &props, bool is_derived) noexcept
 
void deserialize (Serializer::Properties &props)
 
void refresh ()
 

Protected Attributes

Image m_image
 The image. Allowed to be empty.
 
AlignFlags m_image_align {AlignFlag::left | AlignFlag::expand}
 Alignment of the image relative to the text.
 
bool m_show_label {true}
 When true, the label text is shown.
 

Constructor & Destructor Documentation

◆ ImageHolder() [1/9]

template<class T , Palette::ColorId id_bg, Palette::ColorId id_border, Palette::ColorId id_text>
ImageHolder ( const std::string &  text = {},
const AlignFlags text_align = T::default_text_align() 
)
inlineexplicitnoexcept
Parameters
[in]textThe text to display.
[in]text_alignAlignment for the text.

◆ ImageHolder() [2/9]

template<class T , Palette::ColorId id_bg, Palette::ColorId id_border, Palette::ColorId id_text>
ImageHolder ( const Image image,
const std::string &  text = {},
const AlignFlags text_align = T::default_text_align() 
)
inlineexplicitnoexcept
Parameters
[in]imageThe image to display.
[in]textThe text to display.
[in]text_alignAlignment for the text.

◆ ImageHolder() [3/9]

template<class T , Palette::ColorId id_bg, Palette::ColorId id_border, Palette::ColorId id_text>
ImageHolder ( const Image image,
const std::string &  text,
const Rect rect,
const AlignFlags text_align = T::default_text_align() 
)
inlineexplicitnoexcept
Parameters
[in]imageThe image to display.
[in]textThe text to display.
[in]rectInitial rectangle of the widget.
[in]text_alignAlignment for the text.

◆ ImageHolder() [4/9]

template<class T , Palette::ColorId id_bg, Palette::ColorId id_border, Palette::ColorId id_text>
ImageHolder ( Frame parent,
const Image image = {},
const std::string &  text = {},
const AlignFlags text_align = T::default_text_align() 
)
inlineexplicitnoexcept
Parameters
[in]parentThe parent Frame.
[in]imageThe image to display.
[in]textThe text to display.
[in]text_alignAlignment for the text.

◆ ImageHolder() [5/9]

template<class T , Palette::ColorId id_bg, Palette::ColorId id_border, Palette::ColorId id_text>
ImageHolder ( Frame parent,
const Image image,
const std::string &  text,
const Rect rect,
const AlignFlags text_align = T::default_text_align() 
)
inlinenoexcept
Parameters
[in]parentThe parent Frame.
[in]imageThe image to display.
[in]textThe text to display.
[in]rectInitial rectangle of the widget.
[in]text_alignAlignment for the text.

◆ ImageHolder() [6/9]

template<class T , Palette::ColorId id_bg, Palette::ColorId id_border, Palette::ColorId id_text>
ImageHolder ( Serializer::Properties props)
inlineexplicitnoexcept
Parameters
[in]propslist of arguments and its properties.

◆ ImageHolder() [7/9]

template<class T , Palette::ColorId id_bg, Palette::ColorId id_border, Palette::ColorId id_text>
ImageHolder ( const ImageHolder< T, id_bg, id_border, id_text > &  )
deletenoexcept

◆ ImageHolder() [8/9]

template<class T , Palette::ColorId id_bg, Palette::ColorId id_border, Palette::ColorId id_text>
ImageHolder ( ImageHolder< T, id_bg, id_border, id_text > &&  )
defaultnoexcept

◆ ~ImageHolder()

template<class T , Palette::ColorId id_bg, Palette::ColorId id_border, Palette::ColorId id_text>
virtual ~ImageHolder ( )
virtualdefault

◆ ImageHolder() [9/9]

template<class T , Palette::ColorId id_bg, Palette::ColorId id_border, Palette::ColorId id_text>
ImageHolder ( Serializer::Properties props,
bool  is_derived 
)
inlineexplicitprotectednoexcept

Member Function Documentation

◆ auto_scale_image() [1/2]

template<class T , Palette::ColorId id_bg, Palette::ColorId id_border, Palette::ColorId id_text>
bool auto_scale_image ( ) const
inline

Get the auto scale image state.

◆ auto_scale_image() [2/2]

template<class T , Palette::ColorId id_bg, Palette::ColorId id_border, Palette::ColorId id_text>
void auto_scale_image ( bool  enable)
inline

Enable/disable the auto scale of the image.

If enabled, the image will be automatically scaled to fit within the button box. By default, set to true.

◆ default_draw()

template<class T , Palette::ColorId id_bg, Palette::ColorId id_border, Palette::ColorId id_text>
static void default_draw ( ImageHolder< T, id_bg, id_border, id_text > &  widget,
Painter painter,
const Rect rect 
)
inlinestatic

Default draw method for the widget.

◆ deserialize()

template<class T , Palette::ColorId id_bg, Palette::ColorId id_border, Palette::ColorId id_text>
void deserialize ( Serializer::Properties props)
inlineprotected

◆ draw()

template<class T , Palette::ColorId id_bg, Palette::ColorId id_border, Palette::ColorId id_text>
void draw ( Painter painter,
const Rect rect 
)
inlineoverride

◆ hscale() [1/2]

template<class T , Palette::ColorId id_bg, Palette::ColorId id_border, Palette::ColorId id_text>
EGT_NODISCARD float hscale ( ) const
inline

Get the horizontal scale value.

◆ hscale() [2/2]

template<class T , Palette::ColorId id_bg, Palette::ColorId id_border, Palette::ColorId id_text>
void hscale ( float  hscale)
inline

Set the horizontal scale value.

◆ image() [1/3]

template<class T , Palette::ColorId id_bg, Palette::ColorId id_border, Palette::ColorId id_text>
Image & image ( )
inline

Get a non-const reference to the image.

◆ image() [2/3]

template<class T , Palette::ColorId id_bg, Palette::ColorId id_border, Palette::ColorId id_text>
EGT_NODISCARD const Image & image ( ) const
inline

Get a const reference of the image.

◆ image() [3/3]

template<class T , Palette::ColorId id_bg, Palette::ColorId id_border, Palette::ColorId id_text>
void image ( const Image image)
inline

Set a new Image.

Parameters
[in]imageThe new image to use.

◆ image_align() [1/2]

template<class T , Palette::ColorId id_bg, Palette::ColorId id_border, Palette::ColorId id_text>
EGT_NODISCARD AlignFlags image_align ( ) const
inline

Get the image alignment.

◆ image_align() [2/2]

template<class T , Palette::ColorId id_bg, Palette::ColorId id_border, Palette::ColorId id_text>
void image_align ( const AlignFlags align)
inline

Set the alignment of the image relative to the text.

Parameters
[in]alignOnly left, right, top, and bottom alignments are supported.

◆ image_scale() [1/3]

template<class T , Palette::ColorId id_bg, Palette::ColorId id_border, Palette::ColorId id_text>
EGT_NODISCARD SizeF image_scale ( ) const
inline

Get both scale values.

◆ image_scale() [2/3]

template<class T , Palette::ColorId id_bg, Palette::ColorId id_border, Palette::ColorId id_text>
void image_scale ( const SizeF scale)
inline

Scale the image in both direction.

◆ image_scale() [3/3]

template<class T , Palette::ColorId id_bg, Palette::ColorId id_border, Palette::ColorId id_text>
void image_scale ( float  scale)
inline

Scale the image in both direction with the same ratio.

◆ keep_image_ratio() [1/2]

template<class T , Palette::ColorId id_bg, Palette::ColorId id_border, Palette::ColorId id_text>
bool keep_image_ratio ( ) const
inline

Get the keep image ratio state.

◆ keep_image_ratio() [2/2]

template<class T , Palette::ColorId id_bg, Palette::ColorId id_border, Palette::ColorId id_text>
void keep_image_ratio ( bool  enable)
inline

Enable/disable ratio preservation while scaling the image.

If enabled, the original image ratio won't be changed during the image auto scale operation. By default, set to true.

◆ min_size_hint()

template<class T , Palette::ColorId id_bg, Palette::ColorId id_border, Palette::ColorId id_text>
EGT_NODISCARD Size min_size_hint ( ) const
inlineoverride

Reimplemented in StringItem.

◆ operator=() [1/2]

template<class T , Palette::ColorId id_bg, Palette::ColorId id_border, Palette::ColorId id_text>
ImageHolder & operator= ( const ImageHolder< T, id_bg, id_border, id_text > &  )
deletenoexcept

◆ operator=() [2/2]

template<class T , Palette::ColorId id_bg, Palette::ColorId id_border, Palette::ColorId id_text>
ImageHolder & operator= ( ImageHolder< T, id_bg, id_border, id_text > &&  )
defaultnoexcept

◆ refresh()

template<class T , Palette::ColorId id_bg, Palette::ColorId id_border, Palette::ColorId id_text>
void refresh ( )
inlineprotected

◆ reset_uri()

template<class T , Palette::ColorId id_bg, Palette::ColorId id_border, Palette::ColorId id_text>
void reset_uri ( )
inline

Reset the URI, therefore clear the current image, if any.

◆ scale_image() [1/2]

template<class T , Palette::ColorId id_bg, Palette::ColorId id_border, Palette::ColorId id_text>
void scale_image ( float  hscale,
float  vscale,
bool  approximate = false 
)
inline

Scale the image.

Change the scale of the image.

Parameters
[in]hscaleHorizontal scale [0.0 - 1.0], with 1.0 being 100%.
[in]vscaleVertical scale [0.0 - 1.0], with 1.0 being 100%.
[in]approximateApproximate the scale to increase image cache hit efficiency.

This scales relative to the original size of the image. Not the result of any subsequent Image::resize() or Image::scale() call.

See also
Image::scale().
Warning
This does not damage the widget.

◆ scale_image() [2/2]

template<class T , Palette::ColorId id_bg, Palette::ColorId id_border, Palette::ColorId id_text>
void scale_image ( float  scale,
bool  approximate = false 
)
inline

Scale the image.

Parameters
[in]scaleVertical and horizontal scale [0.0 - 1.0], with 1.0 being 100%.
[in]approximateApproximate the scale to increase image cache hit efficiency.
Warning
This does not damage the widget.

◆ serialize()

template<class T , Palette::ColorId id_bg, Palette::ColorId id_border, Palette::ColorId id_text>
void serialize ( Serializer serializer) const
inlineoverride

◆ show_label() [1/2]

template<class T , Palette::ColorId id_bg, Palette::ColorId id_border, Palette::ColorId id_text>
EGT_NODISCARD bool show_label ( ) const
inline

Get the show label state.

◆ show_label() [2/2]

template<class T , Palette::ColorId id_bg, Palette::ColorId id_border, Palette::ColorId id_text>
void show_label ( bool  value)
inline

Enable/disable showing the label text.

Parameters
[in]valueWhen true, the label text is shown.

◆ type()

template<class T , Palette::ColorId id_bg, Palette::ColorId id_border, Palette::ColorId id_text>
EGT_NODISCARD std::string type ( ) const
inlineoverride

◆ uri() [1/2]

template<class T , Palette::ColorId id_bg, Palette::ColorId id_border, Palette::ColorId id_text>
EGT_NODISCARD std::string uri ( ) const
inline

Get the URI of the current image.

◆ uri() [2/2]

template<class T , Palette::ColorId id_bg, Palette::ColorId id_border, Palette::ColorId id_text>
void uri ( const std::string &  uri)
inline

Load a new Image from an uri.

Parameters
[in]uriThe URI of the image to load.

◆ vscale() [1/2]

template<class T , Palette::ColorId id_bg, Palette::ColorId id_border, Palette::ColorId id_text>
EGT_NODISCARD float vscale ( ) const
inline

Get the vertical scale value.

◆ vscale() [2/2]

template<class T , Palette::ColorId id_bg, Palette::ColorId id_border, Palette::ColorId id_text>
void vscale ( float  vscale)
inline

Set the vertical scale value.

Member Data Documentation

◆ m_image

template<class T , Palette::ColorId id_bg, Palette::ColorId id_border, Palette::ColorId id_text>
Image m_image
protected

The image. Allowed to be empty.

◆ m_image_align

template<class T , Palette::ColorId id_bg, Palette::ColorId id_border, Palette::ColorId id_text>
AlignFlags m_image_align {AlignFlag::left | AlignFlag::expand}
protected

Alignment of the image relative to the text.

◆ m_show_label

template<class T , Palette::ColorId id_bg, Palette::ColorId id_border, Palette::ColorId id_text>
bool m_show_label {true}
protected

When true, the label text is shown.