diff --git a/Widgets/Widget.cpp b/Widgets/Widget.cpp index e8b2d5f..b9b922b 100644 --- a/Widgets/Widget.cpp +++ b/Widgets/Widget.cpp @@ -4,6 +4,10 @@ Widget::Widget(int x, int y, int width, int height) : m_surface(nullptr), m_rect{.x = x, .y = y, .w = width, .h = height} { m_surface = SDL_CreateRGBSurfaceWithFormat(0, width, height, 32, SDL_PIXELFORMAT_RGBA8888); + if (nullptr != m_surface) + { + SDL_SetSurfaceBlendMode(m_surface, SDL_BLENDMODE_BLEND); + } } Widget::~Widget() @@ -39,4 +43,9 @@ void Widget::resize(int width, int height) m_surface = SDL_CreateRGBSurfaceWithFormat(0, width, height, 32, SDL_PIXELFORMAT_RGBA8888); m_rect.w = width; m_rect.h = height; + + if (nullptr != m_surface) + { + SDL_SetSurfaceBlendMode(m_surface, SDL_BLENDMODE_BLEND); + } } diff --git a/Widgets/Widget.h b/Widgets/Widget.h index 07bb912..6801d4f 100644 --- a/Widgets/Widget.h +++ b/Widgets/Widget.h @@ -2,6 +2,7 @@ #define WIDGET_H_ #include +#include "../json.hpp" class Widget { diff --git a/Widgets/WidgetText.cpp b/Widgets/WidgetText.cpp index 5ba3615..f160c65 100644 --- a/Widgets/WidgetText.cpp +++ b/Widgets/WidgetText.cpp @@ -30,10 +30,6 @@ m_halign(halign), m_valign(valign), m_text_color(text_color) { - if (nullptr != m_surface) - { - SDL_SetSurfaceBlendMode(m_surface, SDL_BLENDMODE_BLEND); - } } WidgetText::WidgetText(int x, int y, int width, int height, string text, @@ -49,10 +45,6 @@ m_halign(HALIGN_CENTER), m_valign(VALIGN_CENTER), m_text_color{.r = 0, .g = 0, .b = 0, .a = SDL_ALPHA_OPAQUE} { - if (nullptr != m_surface) - { - SDL_SetSurfaceBlendMode(m_surface, SDL_BLENDMODE_BLEND); - } } WidgetText::WidgetText(int x, int y, int width, int height, string text, @@ -66,10 +58,6 @@ m_halign(HALIGN_CENTER), m_valign(VALIGN_CENTER), m_text_color{.r = 0, .g = 0, .b = 0, .a = SDL_ALPHA_OPAQUE} { - if (nullptr != m_surface) - { - SDL_SetSurfaceBlendMode(m_surface, SDL_BLENDMODE_BLEND); - } } void WidgetText::set_text(const string& text) diff --git a/Widgets/WidgetText.h b/Widgets/WidgetText.h index 4135626..fe79313 100644 --- a/Widgets/WidgetText.h +++ b/Widgets/WidgetText.h @@ -7,7 +7,6 @@ #include #include "../sdl_helpers.h" -#include "../json.hpp" class WidgetText : public Widget {