62 lines
1.1 KiB
C++
62 lines
1.1 KiB
C++
#ifndef WIDGET_H
|
|
#define WIDGET_H
|
|
|
|
#include <climits>
|
|
#include <list>
|
|
|
|
struct Rect {
|
|
int x;
|
|
int y;
|
|
int w;
|
|
int h;
|
|
|
|
inline bool Hit(int hitx, int hity)
|
|
{
|
|
return hitx >= x && hitx < x + w && hity >= y && hity < y + h;
|
|
}
|
|
};
|
|
|
|
struct Colour {
|
|
float r, g, b, a;
|
|
|
|
Colour() {}
|
|
Colour(float r, float g, float b) : r(r), g(g), b(b), a(1.f) {}
|
|
Colour(float r, float g, float b, float a) : r(r), g(g), b(b), a(a) {}
|
|
};
|
|
|
|
/* Forward declaration of PUi for OnPaint() member */
|
|
struct PUi;
|
|
|
|
struct Widget : Rect {
|
|
uint32_t port;
|
|
float min;
|
|
float max;
|
|
float value;
|
|
char group[128];
|
|
char label[128];
|
|
char text[128];
|
|
|
|
bool active;
|
|
|
|
Widget() : port(UINT_MAX) {}
|
|
|
|
virtual ~Widget() {}
|
|
|
|
virtual Widget *GetWidget(int x, int y) { return this; }
|
|
virtual Widget *GetWidget(uint32_t port) { return this->port == port ? this : NULL; }
|
|
virtual float GetNewValue(int x, int y) { return this->value; }
|
|
virtual bool SetValue(float newvalue);
|
|
|
|
virtual void OnPaint(const PUi *pui) const {}
|
|
|
|
void Pad(int xpad, int ypad);
|
|
};
|
|
|
|
struct Frame : Widget {
|
|
Colour colour;
|
|
|
|
/* virtual */ void OnPaint(const PUi *pui) const;
|
|
};
|
|
|
|
#endif /* WIDGET_H */
|