diff options
Diffstat (limited to 'source/Asura.Editor')
-rw-r--r-- | source/Asura.Editor/core/signal.h | 52 | ||||
-rw-r--r-- | source/Asura.Editor/core/slot.h | 43 | ||||
-rw-r--r-- | source/Asura.Editor/dui_module.cpp | 8 | ||||
-rw-r--r-- | source/Asura.Editor/dui_module.h | 18 | ||||
-rw-r--r-- | source/Asura.Editor/editor.h | 17 | ||||
-rw-r--r-- | source/Asura.Editor/events/events.h | 24 | ||||
-rw-r--r-- | source/Asura.Editor/graphics/shader.h | 21 | ||||
-rw-r--r-- | source/Asura.Editor/scripts/asset_view.lua (renamed from source/Asura.Editor/graphics/shader.cpp) | 0 | ||||
-rw-r--r-- | source/Asura.Editor/scripts/main.lua | 3 | ||||
-rw-r--r-- | source/Asura.Editor/scripts/scene_view.lua | 1 | ||||
-rw-r--r-- | source/Asura.Editor/widgets/binding/_button.cpp | 60 | ||||
-rw-r--r-- | source/Asura.Editor/widgets/button.cpp | 10 | ||||
-rw-r--r-- | source/Asura.Editor/widgets/button.h | 54 | ||||
-rw-r--r-- | source/Asura.Editor/widgets/label.h | 11 | ||||
-rw-r--r-- | source/Asura.Editor/widgets/widget.h | 27 | ||||
-rw-r--r-- | source/Asura.Editor/window/window.h | 14 |
16 files changed, 287 insertions, 76 deletions
diff --git a/source/Asura.Editor/core/signal.h b/source/Asura.Editor/core/signal.h new file mode 100644 index 0000000..f1ab9b4 --- /dev/null +++ b/source/Asura.Editor/core/signal.h @@ -0,0 +1,52 @@ +#ifndef __ASRUA_EDTIRO_SIGNAL_H__ +#define __ASRUA_EDTIRO_SIGNAL_H__ + +#include <vector> + +#include <asura-lib-utils/scripting/portable.hpp> + +#include "../widgets/widget.h" +#include "slot.h" + +namespace AsuraEditor +{ + + /// + /// ؼ¼ + /// + class Signal + { + public: + Signal(); + + /// + /// Fire¼connectļߣãconnectĺ + /// + void operator()(void* userdata) + { + for (auto callback : mCallbacks) + callback(); + } + + /// + /// עص + /// + void Connect(const Slot& callback) + { + mCallbacks.push_back(callback); + } + + /// + /// + /// + void Disconnect(); + + private: + + std::vector<Slot> mCallbacks; // + + }; + +} + +#endif
\ No newline at end of file diff --git a/source/Asura.Editor/core/slot.h b/source/Asura.Editor/core/slot.h new file mode 100644 index 0000000..ff565cf --- /dev/null +++ b/source/Asura.Editor/core/slot.h @@ -0,0 +1,43 @@ +#ifndef __ASURA_EDITOR_SLOT_H__ +#define __ASURA_EDITOR_SLOT_H__ + +#include <asura-lib-utils/scripting/portable.hpp> +#include <asura-lib-core/input/event.h> + +#include "../widgets/widget.h" + +namespace AsuraEditor +{ + + /// + /// Ӧsignalıհ + /// + class Slot + { + public: + Slot(Luax::LuaxState& state, Widget& widget, int refID) + : mState(state) + , mRefID(refID) + , mWidget(widget) + { + } + + void operator()() + { + mWidget.PushLuaxMemberRef(mState, mRefID); + if (lua_isfunction(mState, -1)) // callback + { + mState.Call(0, 0); + } + } + + private: + Luax::LuaxState& mState; + Widget& mWidget; + int mRefID; + + }; + +} + +#endif
\ No newline at end of file diff --git a/source/Asura.Editor/dui_module.cpp b/source/Asura.Editor/dui_module.cpp index e69de29..63b7361 100644 --- a/source/Asura.Editor/dui_module.cpp +++ b/source/Asura.Editor/dui_module.cpp @@ -0,0 +1,8 @@ +#include "dui_module.h" + +namespace AsuraEditor +{ + + + +} diff --git a/source/Asura.Editor/dui_module.h b/source/Asura.Editor/dui_module.h index abcaca5..48c341f 100644 --- a/source/Asura.Editor/dui_module.h +++ b/source/Asura.Editor/dui_module.h @@ -1,6 +1,24 @@ #ifndef __ASRUA_EDITOR_DIRECTUI_MODULE_H__ #define __ASRUA_EDITOR_DIRECTUI_MODULE_H__ +#include <asura-lib-utils/module.h> +namespace AsuraEditor +{ + + /// + /// Direct UI module. + /// + class DUIModule : public AsuraEngine::Module + { + public: + + void Initialize(Luax::LuaxState& state) override; + + void Finalize(Luax::LuaxState& state) override; + + }; + +} #endif
\ No newline at end of file diff --git a/source/Asura.Editor/editor.h b/source/Asura.Editor/editor.h index 6555c81..b56852f 100644 --- a/source/Asura.Editor/editor.h +++ b/source/Asura.Editor/editor.h @@ -1,14 +1,29 @@ #ifndef __ASURA_EDITOR_H__ #define __ASURA_EDITOR_H__ +#include <asura-lib-utils/scripting/portable.hpp> + namespace AsuraEditor { /// - /// + /// ༭ʵ /// class Editor { + public: + + /// + /// ýlua State + /// + Luax::LuaxState& GetLuaxState(); + + private: + + /// + /// еstate + /// + lua_State* mMainState; }; diff --git a/source/Asura.Editor/events/events.h b/source/Asura.Editor/events/events.h deleted file mode 100644 index bbe5cc3..0000000 --- a/source/Asura.Editor/events/events.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef __ASUSRA_EDITOR_EVENT_H__ -#define __ASUSRA_EDITOR_EVENT_H__ - -namespace AsuraEditor -{ - namespace Events - { - - enum EventType - { - GRAPHIC_EVENT, - KEYBOARD_EVENT, - MOUSE_EVENT - }; - - enum GraphicEvent - { - EVENT_PAINT, - }; - - } -} - -#endif
\ No newline at end of file diff --git a/source/Asura.Editor/graphics/shader.h b/source/Asura.Editor/graphics/shader.h deleted file mode 100644 index 7511e1c..0000000 --- a/source/Asura.Editor/graphics/shader.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef __ASURA_EDITOR_SHADER_H__ -#define __ASURA_EDITOR_SHADER_H__ - -#include <Asura.h> - -namespace AsuraEditor -{ - - /// - /// ༭ʹõshaderluaӿڡ - /// - class Shader : public AEGraphics::Shader - { - public: - - - }; - -} - -#endif
\ No newline at end of file diff --git a/source/Asura.Editor/graphics/shader.cpp b/source/Asura.Editor/scripts/asset_view.lua index e69de29..e69de29 100644 --- a/source/Asura.Editor/graphics/shader.cpp +++ b/source/Asura.Editor/scripts/asset_view.lua diff --git a/source/Asura.Editor/scripts/main.lua b/source/Asura.Editor/scripts/main.lua index a513f87..76fab7a 100644 --- a/source/Asura.Editor/scripts/main.lua +++ b/source/Asura.Editor/scripts/main.lua @@ -1,5 +1,4 @@ -local Editor = require("Asura.Editor") --༭ ---༭Asura.Editor/Scriptsʵ +--༭Asura.Editor/scriptsʵ diff --git a/source/Asura.Editor/scripts/scene_view.lua b/source/Asura.Editor/scripts/scene_view.lua index ff96b2c..db4790f 100644 --- a/source/Asura.Editor/scripts/scene_view.lua +++ b/source/Asura.Editor/scripts/scene_view.lua @@ -1,2 +1 @@ -- 场景窗口 - diff --git a/source/Asura.Editor/widgets/binding/_button.cpp b/source/Asura.Editor/widgets/binding/_button.cpp new file mode 100644 index 0000000..463aef6 --- /dev/null +++ b/source/Asura.Editor/widgets/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.CheckParam<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/widgets/button.cpp b/source/Asura.Editor/widgets/button.cpp index e69de29..97de284 100644 --- a/source/Asura.Editor/widgets/button.cpp +++ b/source/Asura.Editor/widgets/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/widgets/button.h b/source/Asura.Editor/widgets/button.h index 00f1c99..8edc919 100644 --- a/source/Asura.Editor/widgets/button.h +++ b/source/Asura.Editor/widgets/button.h @@ -1,29 +1,69 @@ #ifndef __ASURA_EDITOR_BUTTON_H__ #define __ASURA_EDITOR_BUTTON_H__ -// Asura.Engine Headers -#include <Scripting/Luax.hpp> +#include <vector> -#include "Widget.h" +#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: 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); + + LUAX_DECL_FACTORY(Button); private: - // Image mIcon; // ͼ꣬Ҫ - // Text mText; //ť + 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_DECL_FACTORY(Button); // AsuraEditor.Button + Luax::LuaxMemberRef mImageRef[_BUTTON_STATUS_COUNT];// ͼ + std::vector<Luax::LuaxMemberRef> mCallbacksRef; // ص }; diff --git a/source/Asura.Editor/widgets/label.h b/source/Asura.Editor/widgets/label.h index 6889818..1d053f8 100644 --- a/source/Asura.Editor/widgets/label.h +++ b/source/Asura.Editor/widgets/label.h @@ -1,15 +1,22 @@ #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; }; diff --git a/source/Asura.Editor/widgets/widget.h b/source/Asura.Editor/widgets/widget.h index 5fb18f1..9ffd1fb 100644 --- a/source/Asura.Editor/widgets/widget.h +++ b/source/Asura.Editor/widgets/widget.h @@ -1,21 +1,40 @@ #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 AusraEditor +namespace AsuraEditor { - + /// /// Asura EditorĿؼȾں¼ѯֻ¼Ӧӿڡ /// ASURA_ABSTRACT class Widget + : public virtual AEScripting::NativeAccessor { public: - // ؼлƷ - virtual void Draw() = 0; + /// + /// ؼֻбڵѡΪfocusʱŻᴦ룬ԺܸЧ + /// + virtual void OnEvent(AEInput::Event& e) = 0; + + /// + /// + /// + virtual void OnPaint() = 0; + + protected: + + AEMath::Vector2i mPos; + AEMath::Recti mBBox; }; diff --git a/source/Asura.Editor/window/window.h b/source/Asura.Editor/window/window.h deleted file mode 100644 index 7b265ef..0000000 --- a/source/Asura.Editor/window/window.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef __ASURA_EDITOR_WINDOW_H__ -#define __ASURA_EDITOR_WINDOW_H__ - -namespace AsuraEditor -{ - - class Window - { - - }; - -} - -#endif
\ No newline at end of file |