Added WidgetRect to draw rectangles
This commit is contained in:
39
Widgets/WidgetRect.h
Normal file
39
Widgets/WidgetRect.h
Normal file
@@ -0,0 +1,39 @@
|
||||
#ifndef WIDGET_RECT_H_
|
||||
#define WIDGET_RECT_H_
|
||||
|
||||
#include "Widget.h"
|
||||
|
||||
class WidgetRect : public Widget
|
||||
{
|
||||
protected:
|
||||
// The color of the rectangle
|
||||
// Default - Black (0, 0, 0)
|
||||
SDL_Color m_color;
|
||||
|
||||
// Size of the internal stroke
|
||||
// Set to -1 to fill the space
|
||||
// Default - -1
|
||||
int m_stroke_size;
|
||||
|
||||
// Corner rounding radius
|
||||
// Default - 0;
|
||||
int m_radius;
|
||||
|
||||
public:
|
||||
WidgetRect(int x, int y, int width, int height,
|
||||
int radius, int stroke_size, SDL_Color color);
|
||||
|
||||
WidgetRect(int x, int y, int width, int height,
|
||||
int radius = 0, int stroke_size = -1);
|
||||
|
||||
virtual void draw() override;
|
||||
|
||||
static Widget* builder(const nlohmann::json& j);
|
||||
|
||||
private:
|
||||
// x, y - center of circle
|
||||
// quadrant - 1--4
|
||||
void draw_circle_corner(int x, int y, int quadrant);
|
||||
};
|
||||
|
||||
#endif // WIDGET_RECT_H_
|
||||
Reference in New Issue
Block a user