able to give button a funtion pointer, who will be called when clicked on the button

This commit is contained in:
Remco
2016-06-20 13:42:28 +02:00
parent 2e50d11e07
commit 7758f2c294
3 changed files with 23 additions and 2 deletions
+8
View File
@@ -1,21 +1,29 @@
#pragma once
#include "Text.h"
class Button : public Text
{
private:
typedef void(*action_function)(Button* b);
float width, height;
Vec3f background;
Vec2f planePosition;
bool cursorOnButton;
float alfa;
action_function action = nullptr;
public:
Button(const std::string &text, Vec2f position, float width, float height);
~Button();
void draw();
void update(int x, int y);
void addAction(action_function action);
void setForeground(Vec3f color);
void setBackground(Vec3f color);
};