diff options
Diffstat (limited to 'source/Asura.Editor/controls')
-rw-r--r-- | source/Asura.Editor/controls/binding/_button.cpp | 100 | ||||
-rw-r--r-- | source/Asura.Editor/controls/button.cpp | 4 | ||||
-rw-r--r-- | source/Asura.Editor/controls/button.h | 99 |
3 files changed, 108 insertions, 95 deletions
diff --git a/source/Asura.Editor/controls/binding/_button.cpp b/source/Asura.Editor/controls/binding/_button.cpp index fbae64f..9e6a6bb 100644 --- a/source/Asura.Editor/controls/binding/_button.cpp +++ b/source/Asura.Editor/controls/binding/_button.cpp @@ -1,60 +1,74 @@ #include "../button.h" +using namespace std; using namespace Luax; -namespace AsuraEditor +namespace AsuraEditor { - - LUAX_REGISTRY(Button) + namespace Controls { + + LUAX_REGISTRY(Button) + { + LUAX_REGISTER_METHODS(state, + { "Connect", _Connect }, + { "Disconnect", _Disconnect }, + { "SetImage", _SetImage } + ); + } - // Button.EStatus.xxx - LUAX_REGISTER_ENUM(state, "EStatus", - { "NORMAL", BUTTON_STATUS_NORMAL }, - { "PUSHED", BUTTON_STATUS_PUSHED }, - { "HOVER", BUTTON_STATUS_HOVER }, - { "DISABLED", BUTTON_STATUS_DISABLED }, - { "FOCUSED", BUTTON_STATUS_FOCUSED } - ); - - // Button.EMsg.xxx - LUAX_REGISTER_ENUM(state, "EMessage", - { "CLICK", BUTTON_MSG_CLICK }, - { "HOVER", BUTTON_MSG_HOVER }, - { "FOCUS", BUTTON_MSG_KILLFOCUS } - ); + LUAX_POSTPROCESS(Button) + { + LUAX_REGISTER_ENUM(state, "EButtonStatus", + { "NORMAL", BUTTON_STATUS_NORMAL }, + { "0", 0 }, + { "PUSHED", BUTTON_STATUS_PUSHED }, + { "1", 1 }, + { "HOVER", BUTTON_STATUS_HOVER }, + { "2", 2 }, + { "DISABLED", BUTTON_STATUS_DISABLED }, + { "3", 3 }, + { "FOCUSED", BUTTON_STATUS_FOCUSED }, + { "4", 4 }, + { "STATUS_COUNT", _BUTTON_STATUS_COUNT }, + { "5", 5 } + ); + LUAX_REGISTER_ENUM(state, "EButtonMessage", + { "CLICK", BUTTON_MSG_CLICK }, + { "0", 0 }, + { "HOVER", BUTTON_MSG_HOVER }, + { "1", 1 }, + { "KILLFOCUS", BUTTON_MSG_KILLFOCUS }, + { "2", 2 }, + { "MSG_COUNT", _BUTTON_MSG_COUNT }, + { "3", 3 } + ); - } + } - LUAX_POSTPROCESS(Button) - { + // button:Connect() + LUAX_IMPL_METHOD(Button, _Connect) + { + LUAX_PREPARE(L, Button); - } + return 0; + } - // button:Connect(msg, callback) - LUAX_IMPL_METHOD(Button, _Connect) - { - LUAX_STATE(L); + // button:Disconnect() + LUAX_IMPL_METHOD(Button, _Disconnect) + { + LUAX_PREPARE(L, Button); - Button* self = state.GetUserdata<Button>(1); - int msg = state.CheckValue<int>(2); - if (!lua_isfunction(L, 3)) - return state.ErrorType(3, "callback"); + return 0; + } - LuaxMemberRef ref; - self->SetLuaxMemberRef(state, ref, 3); - if (ref) + // button:SetImage() + LUAX_IMPL_METHOD(Button, _SetImage) { - self->mCallbacksRef.push_back(ref); - Slot slot = Slot(state, (*self), ref.refID); - self->Connect(msg, slot); - } - } + LUAX_PREPARE(L, Button); - // button:SetImage(image) - LUAX_IMPL_METHOD(Button, _SetImage) - { + return 0; + } } - -}
\ No newline at end of file +} diff --git a/source/Asura.Editor/controls/button.cpp b/source/Asura.Editor/controls/button.cpp index 97de284..9910df4 100644 --- a/source/Asura.Editor/controls/button.cpp +++ b/source/Asura.Editor/controls/button.cpp @@ -3,8 +3,4 @@ namespace AsuraEditor { - Button::Button() - { - } - }
\ No newline at end of file diff --git a/source/Asura.Editor/controls/button.h b/source/Asura.Editor/controls/button.h index 3f07c1c..656d7d8 100644 --- a/source/Asura.Editor/controls/button.h +++ b/source/Asura.Editor/controls/button.h @@ -11,69 +11,72 @@ 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> + namespace Controls { - public: - LUAX_DECL_FACTORY(Button); + 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(); + Button(); + ~Button(); - void OnEvent(AEInput::Event& e) override; - void OnPaint() override; + 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(); + 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); + int GetStatus(); + void SetImage(int status, AEGraphics::Image* image); - private: + private: - //------------------------------------------------------------------------------// + //------------------------------------------------------------------------------// - LUAX_DECL_ENUM(ButtonStatus); - LUAX_DECL_ENUM(ButtonMessage); + LUAX_DECL_ENUM(ButtonStatus, 1); + LUAX_DECL_ENUM(ButtonMessage, 1); - LUAX_DECL_METHOD(_Connect); - LUAX_DECL_METHOD(_Disconnect); - LUAX_DECL_METHOD(_SetImage); + 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״̬ͼ + 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; // ص + Luax::LuaxMemberRef mImageRef[_BUTTON_STATUS_COUNT];// ͼ + std::vector<Luax::LuaxMemberRef> mCallbacksRef; // ص - }; + }; + } } #endif
\ No newline at end of file |