ASW Lib
A.D.S. Games SDL Wrapper Library. A library targeted at Allegro4 users who want to switch to SDL3 and use modern c++.
Loading...
Searching...
No Matches
image.cpp
Go to the documentation of this file.
2
5
6void asw::ui::Image::set_texture(const asw::Texture& tex, bool auto_size)
7{
8 texture = tex;
9 if (auto_size && texture != nullptr) {
11 }
12}
13
15{
16 if (texture != nullptr) {
17 asw::draw::stretch_sprite(texture, transform);
18 }
19
20 Widget::draw(ctx);
21}
Vec2< T > size
The size of the rectangle.
Definition geometry.h:728
Shared state for the UI system.
Definition context.h:97
asw::Texture texture
The texture to draw.
Definition image.h:23
void set_texture(const asw::Texture &tex, bool auto_size=true)
Set the texture, optionally resizing the widget to match.
Definition image.cpp:6
void draw(Context &ctx) override
Draw the image.
Definition image.cpp:14
asw::Quad< float > transform
The transform (position and size) of the widget.
Definition widget.h:192
virtual void draw(Context &ctx)
Draw this widget and its children.
Definition widget.cpp:163
Routines for drawing sprites and primitives to the screen.
Image widget for the ASW UI module.
void stretch_sprite(const asw::Texture &tex, const asw::Quad< float > &position)
Draw a sprite with the option to stretch it.
Definition draw.cpp:232
asw::Vec2< float > get_texture_size(const asw::Texture &tex)
Get texture size.
Definition util.cpp:74
std::shared_ptr< SDL_Texture > Texture
Alias for a shared pointer to an SDL_Texture.
Definition types.h:76
General utility functions.