1.8
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
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. More...
 
void auto_scale_image (bool enable)
 Enable/disable the auto scale of the image. More...
 
void draw (Painter &painter, const Rect &rect) override
 
EGT_NODISCARD float hscale () const
 Get the horizontal scale value. More...
 
void hscale (float hscale)
 Set the horizontal scale value. More...
 
Imageimage ()
 Get a non-const reference to the image. More...
 
EGT_NODISCARD const Imageimage () const
 Get a const reference of the image. More...
 
void image (const Image &image)
 Set a new Image. More...
 
EGT_NODISCARD AlignFlags image_align () const
 Get the image alignment. More...
 
void image_align (const AlignFlags &align)
 Set the alignment of the image relative to the text. More...
 
EGT_NODISCARD SizeF image_scale () const
 Get both scale values. More...
 
void image_scale (const SizeF &scale)
 Scale the image in both direction. More...
 
void image_scale (float scale)
 Scale the image in both direction with the same ratio. More...
 
bool keep_image_ratio () const
 Get the keep image ratio state. More...
 
void keep_image_ratio (bool enable)
 Enable/disable ratio preservation while scaling the image. More...
 
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. More...
 
void scale_image (float hscale, float vscale, bool approximate=false)
 Scale the image. More...
 
void scale_image (float scale, bool approximate=false)
 Scale the image. More...
 
void serialize (Serializer &serializer) const override
 
EGT_NODISCARD bool show_label () const
 Get the show label state. More...
 
void show_label (bool value)
 Enable/disable showing the label text. More...
 
EGT_NODISCARD std::string type () const override
 
EGT_NODISCARD std::string uri () const
 Get the URI of the current image. More...
 
void uri (const std::string &uri)
 Load a new Image from an uri. More...
 
EGT_NODISCARD float vscale () const
 Get the vertical scale value. More...
 
void vscale (float vscale)
 Set the vertical scale value. More...
 

Static Public Member Functions

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

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. More...
 
AlignFlags m_image_align {AlignFlag::left | AlignFlag::expand}
 Alignment of the image relative to the text. More...
 
bool m_show_label {true}
 When true, the label text is shown. More...
 

Constructor & Destructor Documentation

◆ ImageHolder() [1/9]

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]

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]

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]

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]

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]

ImageHolder ( Serializer::Properties props)
inlineexplicitnoexcept
Parameters
[in]propslist of arguments and its properties.

◆ ImageHolder() [7/9]

ImageHolder ( const ImageHolder< T, id_bg, id_border, id_text > &  )
deletenoexcept

◆ ImageHolder() [8/9]

ImageHolder ( ImageHolder< T, id_bg, id_border, id_text > &&  )
defaultnoexcept

◆ ~ImageHolder()

virtual ~ImageHolder ( )
virtualdefault

◆ ImageHolder() [9/9]

ImageHolder ( Serializer::Properties props,
bool  is_derived 
)
inlineexplicitprotectednoexcept

Member Function Documentation

◆ auto_scale_image() [1/2]

bool auto_scale_image ( ) const
inline

Get the auto scale image state.

◆ auto_scale_image() [2/2]

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()

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()

void deserialize ( Serializer::Properties props)
inlineprotected

◆ draw()

void draw ( Painter painter,
const Rect rect 
)
inlineoverride

◆ hscale() [1/2]

EGT_NODISCARD float hscale ( ) const
inline

Get the horizontal scale value.

◆ hscale() [2/2]

void hscale ( float  hscale)
inline

Set the horizontal scale value.

◆ image() [1/3]

Image& image ( )
inline

Get a non-const reference to the image.

◆ image() [2/3]

EGT_NODISCARD const Image& image ( ) const
inline

Get a const reference of the image.

◆ image() [3/3]

void image ( const Image image)
inline

Set a new Image.

Parameters
[in]imageThe new image to use.

◆ image_align() [1/2]

EGT_NODISCARD AlignFlags image_align ( ) const
inline

Get the image alignment.

◆ image_align() [2/2]

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]

EGT_NODISCARD SizeF image_scale ( ) const
inline

Get both scale values.

◆ image_scale() [2/3]

void image_scale ( const SizeF scale)
inline

Scale the image in both direction.

◆ image_scale() [3/3]

void image_scale ( float  scale)
inline

Scale the image in both direction with the same ratio.

◆ keep_image_ratio() [1/2]

bool keep_image_ratio ( ) const
inline

Get the keep image ratio state.

◆ keep_image_ratio() [2/2]

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()

EGT_NODISCARD Size min_size_hint ( ) const
inlineoverride

◆ operator=() [1/2]

ImageHolder& operator= ( const ImageHolder< T, id_bg, id_border, id_text > &  )
deletenoexcept

◆ operator=() [2/2]

ImageHolder& operator= ( ImageHolder< T, id_bg, id_border, id_text > &&  )
defaultnoexcept

◆ refresh()

void refresh ( )
inlineprotected

◆ reset_uri()

void reset_uri ( )
inline

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

◆ scale_image() [1/2]

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]

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()

void serialize ( Serializer serializer) const
inlineoverride

◆ show_label() [1/2]

EGT_NODISCARD bool show_label ( ) const
inline

Get the show label state.

◆ show_label() [2/2]

void show_label ( bool  value)
inline

Enable/disable showing the label text.

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

◆ type()

EGT_NODISCARD std::string type ( ) const
inlineoverride

◆ uri() [1/2]

EGT_NODISCARD std::string uri ( ) const
inline

Get the URI of the current image.

◆ uri() [2/2]

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]

EGT_NODISCARD float vscale ( ) const
inline

Get the vertical scale value.

◆ vscale() [2/2]

void vscale ( float  vscale)
inline

Set the vertical scale value.

Member Data Documentation

◆ m_image

Image m_image
protected

The image. Allowed to be empty.

◆ m_image_align

AlignFlags m_image_align {AlignFlag::left | AlignFlag::expand}
protected

Alignment of the image relative to the text.

◆ m_show_label

bool m_show_label {true}
protected

When true, the label text is shown.