40 lines
842 B
C++
40 lines
842 B
C++
#ifndef WIDGET_H_
|
|
#define WIDGET_H_
|
|
|
|
#include <SDL2/SDL.h>
|
|
#include "../json.hpp"
|
|
#include <memory>
|
|
|
|
// Base Widget class for the whole Widget system
|
|
class Widget
|
|
{
|
|
protected:
|
|
// Internal surface for drawing
|
|
SDL_Surface* m_surface;
|
|
|
|
// Holds the size and position of the widget
|
|
SDL_Rect m_rect;
|
|
|
|
public:
|
|
Widget(int x, int y, int width, int height);
|
|
virtual ~Widget();
|
|
|
|
// Method which updates the internal surface with the latest image
|
|
virtual void draw() = 0;
|
|
|
|
// Returns the internal surface
|
|
// Used for bliting to the main surface;
|
|
SDL_Surface* get_internal_surface();
|
|
|
|
// Returns the internal position and size
|
|
SDL_Rect get_rect();
|
|
|
|
// Sets the position of the widget on the screen
|
|
void set_position(int x, int y);
|
|
|
|
// Sets the size of the widget on the screen
|
|
void resize(int width, int height);
|
|
};
|
|
|
|
#endif // WIDGET_H_
|