diff options
Diffstat (limited to 'source/Asura.Editor/controls')
22 files changed, 217 insertions, 0 deletions
diff --git a/source/Asura.Editor/controls/binding/_button.cpp b/source/Asura.Editor/controls/binding/_button.cpp new file mode 100644 index 0000000..fbae64f --- /dev/null +++ b/source/Asura.Editor/controls/binding/_button.cpp @@ -0,0 +1,60 @@ +#include "../button.h" + +using namespace Luax; + +namespace AsuraEditor +{ + + LUAX_REGISTRY(Button) + { + + // 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) + { + + } + + // button:Connect(msg, callback) + LUAX_IMPL_METHOD(Button, _Connect) + { + LUAX_STATE(L); + + Button* self = state.GetUserdata<Button>(1); + int msg = state.CheckValue<int>(2); + if (!lua_isfunction(L, 3)) + return state.ErrorType(3, "callback"); + + LuaxMemberRef ref; + self->SetLuaxMemberRef(state, ref, 3); + if (ref) + { + self->mCallbacksRef.push_back(ref); + Slot slot = Slot(state, (*self), ref.refID); + self->Connect(msg, slot); + } + } + + // button:SetImage(image) + LUAX_IMPL_METHOD(Button, _SetImage) + { + + } + +}
\ No newline at end of file diff --git a/source/Asura.Editor/controls/button.cpp b/source/Asura.Editor/controls/button.cpp new file mode 100644 index 0000000..97de284 --- /dev/null +++ b/source/Asura.Editor/controls/button.cpp @@ -0,0 +1,10 @@ +#include "button.h" + +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 new file mode 100644 index 0000000..14cd041 --- /dev/null +++ b/source/Asura.Editor/controls/button.h @@ -0,0 +1,79 @@ +#ifndef __ASURA_EDITOR_BUTTON_H__ +#define __ASURA_EDITOR_BUTTON_H__ + +#include <vector> + +#include <asura-lib-utils/scripting/portable.hpp> +#include <asura-lib-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
\ No newline at end of file diff --git a/source/Asura.Editor/controls/checkbox.cpp b/source/Asura.Editor/controls/checkbox.cpp new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/source/Asura.Editor/controls/checkbox.cpp diff --git a/source/Asura.Editor/controls/checkbox.h b/source/Asura.Editor/controls/checkbox.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/source/Asura.Editor/controls/checkbox.h diff --git a/source/Asura.Editor/controls/hslider.cpp b/source/Asura.Editor/controls/hslider.cpp new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/source/Asura.Editor/controls/hslider.cpp diff --git a/source/Asura.Editor/controls/hslider.h b/source/Asura.Editor/controls/hslider.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/source/Asura.Editor/controls/hslider.h diff --git a/source/Asura.Editor/controls/hvslider.cpp b/source/Asura.Editor/controls/hvslider.cpp new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/source/Asura.Editor/controls/hvslider.cpp diff --git a/source/Asura.Editor/controls/hvslider.h b/source/Asura.Editor/controls/hvslider.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/source/Asura.Editor/controls/hvslider.h diff --git a/source/Asura.Editor/controls/label.cpp b/source/Asura.Editor/controls/label.cpp new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/source/Asura.Editor/controls/label.cpp diff --git a/source/Asura.Editor/controls/label.h b/source/Asura.Editor/controls/label.h new file mode 100644 index 0000000..1d053f8 --- /dev/null +++ b/source/Asura.Editor/controls/label.h @@ -0,0 +1,25 @@ +#ifndef __ASURA_EDITOR_LABEL_H__ +#define __ASURA_EDITOR_LABEL_H__ + +#include <asura-lib-utils/scripting/portable.hpp> +#include <asura-lib-core/graphics/image.h> + +#include "widget.h" + +namespace AsuraEditor +{ + + class Label + : public Widget + , public AEScripting::Portable<Label> + { + public: + + void OnEvent(AEInput::Event& e) override; + void OnPaint() override; + + }; + +} + +#endif
\ No newline at end of file diff --git a/source/Asura.Editor/controls/panel.cpp b/source/Asura.Editor/controls/panel.cpp new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/source/Asura.Editor/controls/panel.cpp diff --git a/source/Asura.Editor/controls/panel.h b/source/Asura.Editor/controls/panel.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/source/Asura.Editor/controls/panel.h diff --git a/source/Asura.Editor/controls/progress.cpp b/source/Asura.Editor/controls/progress.cpp new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/source/Asura.Editor/controls/progress.cpp diff --git a/source/Asura.Editor/controls/progress.h b/source/Asura.Editor/controls/progress.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/source/Asura.Editor/controls/progress.h diff --git a/source/Asura.Editor/controls/radio_button.cpp b/source/Asura.Editor/controls/radio_button.cpp new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/source/Asura.Editor/controls/radio_button.cpp diff --git a/source/Asura.Editor/controls/radio_button.h b/source/Asura.Editor/controls/radio_button.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/source/Asura.Editor/controls/radio_button.h diff --git a/source/Asura.Editor/controls/textbox.cpp b/source/Asura.Editor/controls/textbox.cpp new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/source/Asura.Editor/controls/textbox.cpp diff --git a/source/Asura.Editor/controls/textbox.h b/source/Asura.Editor/controls/textbox.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/source/Asura.Editor/controls/textbox.h diff --git a/source/Asura.Editor/controls/vslider.cpp b/source/Asura.Editor/controls/vslider.cpp new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/source/Asura.Editor/controls/vslider.cpp diff --git a/source/Asura.Editor/controls/vslider.h b/source/Asura.Editor/controls/vslider.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/source/Asura.Editor/controls/vslider.h diff --git a/source/Asura.Editor/controls/widget.h b/source/Asura.Editor/controls/widget.h new file mode 100644 index 0000000..9ffd1fb --- /dev/null +++ b/source/Asura.Editor/controls/widget.h @@ -0,0 +1,43 @@ +#ifndef __ASURA_EDITOR_WIDGET_H__ +#define __ASURA_EDITOR_WIDGET_H__ + +#include <list> + +#include <asura-lib-utils/scripting/portable.hpp> +#include <asura-lib-utils/type.h> +#include <asura-lib-utils/math/rect.hpp> +#include <asura-lib-utils/math/vector2.hpp> +#include <asura-lib-core/input/event.h> + +namespace AsuraEditor +{ + + /// + /// Asura EditorĿؼȾں¼ѯֻ¼Ӧӿڡ + /// + ASURA_ABSTRACT class Widget + : public virtual AEScripting::NativeAccessor + { + + public: + + /// + /// ؼֻбڵѡΪfocusʱŻᴦ룬ԺܸЧ + /// + virtual void OnEvent(AEInput::Event& e) = 0; + + /// + /// + /// + virtual void OnPaint() = 0; + + protected: + + AEMath::Vector2i mPos; + AEMath::Recti mBBox; + + }; + +} + +#endif
\ No newline at end of file |