Added setters for Widget properties

This commit is contained in:
2025-12-18 12:24:19 +02:00
parent 40df0f6e0c
commit 3f4e42d7ce
6 changed files with 73 additions and 0 deletions

View File

@@ -22,6 +22,43 @@ m_bg_color(bg_color)
}
}
void WidgetImage::set_filename(const string& filename)
{
if (m_image_surface != nullptr)
{
SDL_FreeSurface(m_image_surface);
m_image_surface = nullptr;
}
m_filename = filename;
m_image_surface = IMG_Load(m_filename.c_str());
if (nullptr == m_image_surface)
{
// TODO: Print errors
}
}
void WidgetImage::set_resize(ImageResize type)
{
m_resize_type = type;
}
void WidgetImage::set_halign(HorizontalAlign halign)
{
m_halign = halign;
}
void WidgetImage::set_valign(VerticalAlign valign)
{
m_valign = valign;
}
void WidgetImage::set_bg_color(SDL_Color bg_color)
{
m_bg_color = bg_color;
}
void WidgetImage::draw()
{
if (nullptr == m_surface)