Added some runtime protections. Fixed minor things.
This commit is contained in:
parent
3d45fc89fc
commit
af9ebe5fe8
@ -26,6 +26,11 @@ m_radius(radius)
|
|||||||
|
|
||||||
void WidgetRect::draw()
|
void WidgetRect::draw()
|
||||||
{
|
{
|
||||||
|
if (nullptr == m_surface)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Clear surface
|
// Clear surface
|
||||||
SDL_FillRect(m_surface, nullptr, SDL_MapRGBA(m_surface->format, 255, 255, 255, SDL_ALPHA_TRANSPARENT));
|
SDL_FillRect(m_surface, nullptr, SDL_MapRGBA(m_surface->format, 255, 255, 255, SDL_ALPHA_TRANSPARENT));
|
||||||
|
|
||||||
|
|||||||
@ -31,7 +31,7 @@ public:
|
|||||||
|
|
||||||
static std::unique_ptr<Widget> builder(const nlohmann::json& j);
|
static std::unique_ptr<Widget> builder(const nlohmann::json& j);
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
// x, y - center of circle
|
// x, y - center of circle
|
||||||
// quadrant - 1--4
|
// quadrant - 1--4
|
||||||
void draw_circle_corner(int x, int y, int quadrant);
|
void draw_circle_corner(int x, int y, int quadrant);
|
||||||
|
|||||||
@ -170,6 +170,11 @@ void WidgetText::set_color(SDL_Color text_color)
|
|||||||
|
|
||||||
void WidgetText::draw()
|
void WidgetText::draw()
|
||||||
{
|
{
|
||||||
|
if (nullptr == m_surface)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Clear surface
|
// Clear surface
|
||||||
SDL_FillRect(m_surface, nullptr, SDL_MapRGBA(m_surface->format, 255, 255, 255, SDL_ALPHA_TRANSPARENT));
|
SDL_FillRect(m_surface, nullptr, SDL_MapRGBA(m_surface->format, 255, 255, 255, SDL_ALPHA_TRANSPARENT));
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,6 @@
|
|||||||
#define WIDGET_TEXT_H_
|
#define WIDGET_TEXT_H_
|
||||||
|
|
||||||
#include "Widget.h"
|
#include "Widget.h"
|
||||||
#include <SDL2/SDL.h>
|
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user