summaryrefslogtreecommitdiff
path: root/src/gui/interface/AvatarButton.h
blob: d13f7477d0c500abbbe4b0fc99091c000e6a29ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#ifndef AVATARBUTTON_H_
#define AVATARBUTTON_H_

#include <string>

#include "Component.h"
#include "graphics/Graphics.h"
#include "gui/interface/Colour.h"
#include "client/requestbroker/RequestListener.h"

namespace ui
{
class AvatarButton;
class AvatarButtonAction
{
public:
	virtual void ActionCallback(ui::AvatarButton * sender) {}
	virtual ~AvatarButtonAction() {}
};

class AvatarButton : public Component, public RequestListener
{
	VideoBuffer * avatar;
	std::string name;
	bool tried;
public:
	AvatarButton(Point position, Point size, std::string username);
	virtual ~AvatarButton();

	virtual void OnMouseClick(int x, int y, unsigned int button);
	virtual void OnMouseUnclick(int x, int y, unsigned int button);

	virtual void OnMouseEnter(int x, int y);
	virtual void OnMouseLeave(int x, int y);

	virtual void OnContextMenuAction(int item);

	virtual void Draw(const Point& screenPos);
	virtual void Tick(float dt);

	virtual void OnResponseReady(void * imagePtr, int identifier);
	
	virtual void DoAction();

	void SetUsername(std::string username) { name = username; }
	std::string GetUsername() { return name; }
	void SetActionCallback(AvatarButtonAction * action);
protected:
	bool isMouseInside, isButtonDown;
	AvatarButtonAction * actionCallback;
};
}
#endif /* AVATARBUTTON_H_ */