diff options
author | chai <chaifix@163.com> | 2019-04-02 21:45:33 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2019-04-02 21:45:33 +0800 |
commit | af7bdaa10ee71a319dc55c3c7556fa43a95c9dc9 (patch) | |
tree | 58611985001b78c5a76b78ae146fdb07dde31c1d /source/Asura.Editor/controls/binding/_button.cpp | |
parent | 250e30d73f09e9da2b5a81d0fbae63744ae12a73 (diff) |
*misc
Diffstat (limited to 'source/Asura.Editor/controls/binding/_button.cpp')
-rw-r--r-- | source/Asura.Editor/controls/binding/_button.cpp | 100 |
1 files changed, 57 insertions, 43 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 +} |