diff options
Diffstat (limited to 'Editor')
-rw-r--r-- | Editor/GUI/GUIWindow.cpp | 42 | ||||
-rw-r--r-- | Editor/GUI/GUIWindow.h | 1 | ||||
-rw-r--r-- | Editor/Scripting/GUI/EditorGUI.bind.cpp | 2 | ||||
-rw-r--r-- | Editor/Scripting/Window/ContainerWindow.bind.cpp | 2 |
4 files changed, 33 insertions, 14 deletions
diff --git a/Editor/GUI/GUIWindow.cpp b/Editor/GUI/GUIWindow.cpp index fe19a95..b680e28 100644 --- a/Editor/GUI/GUIWindow.cpp +++ b/Editor/GUI/GUIWindow.cpp @@ -23,6 +23,15 @@ void GUIWindowProxy::OnGUI(LuaBind::State& state) invoker.Invoke(0); } +void GUIWindowProxy::DoInputEvent(LuaBind::State& state) +{ + MemberInvoker invoker = MemberInvoker(state, owner); + invoker.member = script; + invoker.method = "OnGUI"; + invoker.AddMember(script); + invoker.Invoke(0); +} + void GUIWindowProxy::OnFocus(LuaBind::State& state) { LuaBind::MemberInvoker invoker = MemberInvoker(state, owner); @@ -81,6 +90,7 @@ static bool RedirectMouseWheel(HWND window, WPARAM wParam, LPARAM lParam) //s_ReentrancyCheck = false; return true; } +static PAINTSTRUCT ps; LRESULT CALLBACK GUIWindow::GUIViewWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { @@ -102,12 +112,11 @@ LRESULT CALLBACK GUIWindow::GUIViewWndProc(HWND hWnd, UINT message, WPARAM wPara case WM_PAINT: { - static PAINTSTRUCT ps; - log_info_tag("WndProc", "WM_PAINT %d", _event_count); self->SetAsRenderContext(); self->OnPaint(); + //glFlush(); BeginPaint(self->m_Handle, &ps); EndPaint(self->m_Handle, &ps); @@ -221,7 +230,7 @@ LRESULT CALLBACK GUIWindow::GUIViewWndProc(HWND hWnd, UINT message, WPARAM wPara // self->RequestRepaint(); // } - self->DoPaint(); + //self->DoPaint(); // // Update the scene so that scripts marked with [ExecuteInEditMode] are able to react to screen size changes // GetApplication().SetSceneRepaintDirty(); @@ -321,9 +330,7 @@ void GUIWindow::ProcessEventMessages(UINT message, WPARAM wParam, LPARAM lParam) SCRIPT_GLOBAL.guiBeginOnGUI.Invoke(state); - SetAsRenderContext(); - - m_Script.DoGUI(state); + m_Script.DoInputEvent(state); SCRIPT_GLOBAL.guiEndOnGUI.Invoke(state); } @@ -402,8 +409,17 @@ void GUIWindow::OnLostFocus() void GUIWindow::OnPaint() { + InputEvent e = InputEvent::RepaintEvent(m_Handle); LuaBind::State state = GetVM()->GetCurThread(); - m_Script.OnGUI(state); + + SCRIPT_GLOBAL.setCurrentEvent.AddTable(state, e); + SCRIPT_GLOBAL.setCurrentEvent.Invoke(state); + + SCRIPT_GLOBAL.guiBeginOnGUI.Invoke(state); + + m_Script.DoGUI(state); + + SCRIPT_GLOBAL.guiEndOnGUI.Invoke(state); } void GUIWindow::SetPosition(Rect position) @@ -429,12 +445,12 @@ void GUIWindow::SetAsRenderContext() void GUIWindow::Focus() { log_info("Focus GUIWindow "); - //if (m_Handle) - //{ - // if (::GetForegroundWindow() != m_ContainerWindow->GetWindowHandle()) - // ::SetForegroundWindow(m_ContainerWindow->GetWindowHandle()); - // SetFocus(m_Handle); - //} + if (m_Handle) + { + //if (::GetForegroundWindow() != m_ContainerWindow->GetWindowHandle()) + // ::SetForegroundWindow(m_ContainerWindow->GetWindowHandle()); + SetFocus(m_Handle); + } } void GUIWindow::SetContainerWindow(ContainerWindow* wnd) diff --git a/Editor/GUI/GUIWindow.h b/Editor/GUI/GUIWindow.h index ed79f26..858004c 100644 --- a/Editor/GUI/GUIWindow.h +++ b/Editor/GUI/GUIWindow.h @@ -25,6 +25,7 @@ public: GUIWindowProxy() {} GUIWindowProxy(GUIWindow *owner, LuaBind::MemberRef script); + void DoInputEvent(LuaBind::State& state); void DoGUI(LuaBind::State& state); void DoClean(LuaBind::State& state); diff --git a/Editor/Scripting/GUI/EditorGUI.bind.cpp b/Editor/Scripting/GUI/EditorGUI.bind.cpp index b51e019..e0b94e0 100644 --- a/Editor/Scripting/GUI/EditorGUI.bind.cpp +++ b/Editor/Scripting/GUI/EditorGUI.bind.cpp @@ -80,6 +80,8 @@ static int Text(lua_State* L) const UITextMesh* tm = g_TextMeshGenerator.GetTextMesh(str, font, pixelSize, lineHeight, color, (ETextAnchor)anchor, (ETextAlignment)alignment, wordwrap, preferred); tm->Draw(); + WipeGLError(); + return 0; } diff --git a/Editor/Scripting/Window/ContainerWindow.bind.cpp b/Editor/Scripting/Window/ContainerWindow.bind.cpp index f459c85..f3a8cc7 100644 --- a/Editor/Scripting/Window/ContainerWindow.bind.cpp +++ b/Editor/Scripting/Window/ContainerWindow.bind.cpp @@ -62,7 +62,7 @@ LUA_BIND_IMPL_METHOD(ContainerWindow, _GetSize) { LUA_BIND_PREPARE(L, ContainerWindow); - state.PushLuaObject(self->GetSize()); + state.PushLuaObject<Vector2f>(self->GetSize()); return 1; } |