summaryrefslogtreecommitdiff
path: root/source/Asura.Editor/controls/button.h
blob: 3f07c1c07b68cb40c17d5ba5b63e5e4a76bc3f87 (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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#ifndef __ASURA_EDITOR_BUTTON_H__
#define __ASURA_EDITOR_BUTTON_H__

#include <vector>

#include <asura-utils/scripting/portable.hpp>
#include <asura-core/graphics/image.h>

#include "../core/signal.h"
#include "widget.h"

namespace AsuraEditor
{

	enum ButtonStatus
	{
		BUTTON_STATUS_NORMAL   = 0,
		BUTTON_STATUS_PUSHED   = 1,
		BUTTON_STATUS_HOVER    = 2,
		BUTTON_STATUS_DISABLED = 3,
		BUTTON_STATUS_FOCUSED  = 4,
		_BUTTON_STATUS_COUNT   = 5,
	};

	enum ButtonMessage
	{
		BUTTON_MSG_CLICK     = 0,
		BUTTON_MSG_HOVER     = 1, 
		BUTTON_MSG_KILLFOCUS = 2,
		_BUTTON_MSG_COUNT    = 3,
	};

	class Button 
		: public Widget
		, public AEScripting::Portable<Button>
	{
	public: 

		LUAX_DECL_FACTORY(Button);

		Button();
		~Button();

		void OnEvent(AEInput::Event& e) override;
		void OnPaint() override;

		void Connect(int msg, Slot callback);
		void Disconnect(int msg);
		void DisconnectAll(int msg);
		void DisconnectAllMsg();

		int GetStatus();
		void SetImage(int status, AEGraphics::Image* image);

	private:

		//------------------------------------------------------------------------------//

		LUAX_DECL_ENUM(ButtonStatus);
		LUAX_DECL_ENUM(ButtonMessage);

		LUAX_DECL_METHOD(_Connect);
		LUAX_DECL_METHOD(_Disconnect);
		LUAX_DECL_METHOD(_SetImage);

		//------------------------------------------------------------------------------//

		int                              mStatus;                        // ǰ״̬
		Signal                           mSignals[_BUTTON_MSG_COUNT];    // 3Ϣsignal
		AEGraphics::Image*               mImage[_BUTTON_STATUS_COUNT];   // 5״̬ͼ

		Luax::LuaxMemberRef              mImageRef[_BUTTON_STATUS_COUNT];// ͼ
		std::vector<Luax::LuaxMemberRef> mCallbacksRef;                  // ص

	};

}

#endif