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
src
modules
ui
image.cpp
Go to the documentation of this file.
1
#include "
./asw/modules/ui/image.h
"
2
3
#include "
./asw/modules/draw.h
"
4
#include "
./asw/modules/util.h
"
5
6
void
asw::ui::Image::set_texture
(
const
asw::Texture
& tex,
bool
auto_size)
7
{
8
texture
= tex;
9
if
(auto_size &&
texture
!=
nullptr
) {
10
transform
.
size
=
asw::util::get_texture_size
(
texture
);
11
}
12
}
13
14
void
asw::ui::Image::draw
(
Context
& ctx)
15
{
16
if
(texture !=
nullptr
) {
17
asw::draw::stretch_sprite
(texture, transform);
18
}
19
20
Widget::draw
(ctx);
21
}
asw::Quad::size
Vec2< T > size
The size of the rectangle.
Definition
geometry.h:728
asw::ui::Context
Shared state for the UI system.
Definition
context.h:97
asw::ui::Image::texture
asw::Texture texture
The texture to draw.
Definition
image.h:23
asw::ui::Image::set_texture
void set_texture(const asw::Texture &tex, bool auto_size=true)
Set the texture, optionally resizing the widget to match.
Definition
image.cpp:6
asw::ui::Image::draw
void draw(Context &ctx) override
Draw the image.
Definition
image.cpp:14
asw::ui::Widget::transform
asw::Quad< float > transform
The transform (position and size) of the widget.
Definition
widget.h:192
asw::ui::Widget::draw
virtual void draw(Context &ctx)
Draw this widget and its children.
Definition
widget.cpp:163
draw.h
Routines for drawing sprites and primitives to the screen.
image.h
Image widget for the ASW UI module.
asw::draw::stretch_sprite
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::util::get_texture_size
asw::Vec2< float > get_texture_size(const asw::Texture &tex)
Get texture size.
Definition
util.cpp:74
asw::Texture
std::shared_ptr< SDL_Texture > Texture
Alias for a shared pointer to an SDL_Texture.
Definition
types.h:76
util.h
General utility functions.
Generated by
1.12.0