Keys: More...
#include <canvas_private.hpp>
Public Member Functions | |
image_shape (const config &cfg, wfl::action_function_symbol_table &functions) | |
Constructor. More... | |
void | draw (wfl::map_formula_callable &variables) override |
Draws the canvas. More... | |
![]() | |
shape (const config &cfg) | |
virtual | ~shape () |
bool | immutable () const |
Private Types | |
enum class | resize_mode { scale , scale_sharp , stretch , tile , tile_center , tile_highres } |
Determines the way an image will be resized. More... | |
Private Member Functions | |
resize_mode | get_resize_mode (const std::string &resize_mode) |
Converts a string to a resize mode. More... | |
Static Private Member Functions | |
static void | dimension_validation (unsigned value, const std::string &name, const std::string &key) |
Private Attributes | |
typed_formula< unsigned > | x_ |
The x coordinate of the image. More... | |
typed_formula< unsigned > | y_ |
The y coordinate of the image. More... | |
typed_formula< unsigned > | w_ |
The width of the image. More... | |
typed_formula< unsigned > | h_ |
The height of the image. More... | |
typed_formula< std::string > | image_name_ |
Name of the image. More... | |
resize_mode | resize_mode_ |
The resize mode for an image. More... | |
typed_formula< bool > | mirror_ |
Mirror the image over the vertical axis. More... | |
wfl::formula | actions_formula_ |
Keys:
Key | Type | Default | Description |
---|---|---|---|
x | f_unsigned | 0 | The x coordinate of the top left corner. |
y | f_unsigned | 0 | The y coordinate of the top left corner. |
w | f_unsigned | 0 | The width of the image, if not zero the image will be scaled to the desired width. |
h | f_unsigned | 0 | The height of the image, if not zero the image will be scaled to the desired height. |
resize_mode | resize_mode | scale | Determines how an image is scaled to fit the wanted size. |
vertical_mirror | f_bool | false | Mirror the image over the vertical axis. |
name | string | "" | The name of the image. |
debug | string | "" | Debug message to show upon creation this message is not stored. |
Variables:
Key | Type | Description |
---|---|---|
image_width | unsigned | The width of the image, either the requested width or the natural width of the image. This value can be used to set the x (or y) value of the image. (This means x and y are evaluated after the width and height.) |
image_height | unsigned | The height of the image, either the requested height or the natural height of the image. This value can be used to set the y (or x) value of the image. (This means x and y are evaluated after the width and height.) |
image_original_width | unsigned | The width of the image as stored on disk, can be used to set x or w (also y and h can be set). |
image_original_height | unsigned | The height of the image as stored on disk, can be used to set y or h (also x and y can be set). |
Also the general variables are available, see line_shape
Definition at line 316 of file canvas_private.hpp.
|
strongprivate |
Determines the way an image will be resized.
If the image is smaller is needed it needs to resized, how is determined by the value of this enum.
Enumerator | |
---|---|
scale | |
scale_sharp | |
stretch | |
tile | |
tile_center | |
tile_highres |
Definition at line 350 of file canvas_private.hpp.
gui2::image_shape::image_shape | ( | const config & | cfg, |
wfl::action_function_symbol_table & | functions | ||
) |
Constructor.
cfg | The config object to define the image. |
functions | WFL functions to execute. |
Definition at line 251 of file canvas.cpp.
|
staticprivate |
Definition at line 268 of file canvas.cpp.
References _(), and VALIDATE_WITH_DEV_MESSAGE.
Referenced by draw().
|
overridevirtual |
Draws the canvas.
variables | The canvas can have formulas in it's definition, this parameter contains the values for these formulas. |
Implements gui2::canvas::shape.
Definition at line 277 of file canvas.cpp.
References actions_formula_, wfl::map_formula_callable::add(), draw::blit(), DBG_GUI_D, dimension_validation(), ERR_GUI_D, wfl::formula::evaluate(), wfl::variant::execute_variant(), wfl::formula_callable::fake_ptr(), draw::flipped(), image::get_texture(), texture::h(), h, h_, image_name_, image::linear, mirror_, image::nearest, resize_mode_, scale, scale_sharp, stretch, tile, tile_center, tile_highres, draw::tiled(), draw::tiled_highres(), w, texture::w(), w_, x_, and y_.
|
private |
Converts a string to a resize mode.
Definition at line 367 of file canvas.cpp.
References ERR_GUI_E, scale, scale_sharp, stretch, tile, tile_center, and tile_highres.
|
private |
Definition at line 369 of file canvas_private.hpp.
Referenced by draw().
|
private |
|
private |
Name of the image.
This value is only used when the image name is a formula. If it isn't a formula the image will be loaded in the constructor. If it's a formula it will be loaded every draw cycles. This allows 'changing' images.
Definition at line 342 of file canvas_private.hpp.
Referenced by draw().
|
private |
Mirror the image over the vertical axis.
Definition at line 366 of file canvas_private.hpp.
Referenced by draw().
|
private |
The resize mode for an image.
Definition at line 363 of file canvas_private.hpp.
Referenced by draw().
|
private |
|
private |
The x coordinate of the image.
Definition at line 330 of file canvas_private.hpp.
Referenced by draw().
|
private |
The y coordinate of the image.
Definition at line 331 of file canvas_private.hpp.
Referenced by draw().