summaryrefslogtreecommitdiff
path: root/Editor/GUI/GUIWindow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Editor/GUI/GUIWindow.cpp')
-rw-r--r--Editor/GUI/GUIWindow.cpp42
1 files changed, 29 insertions, 13 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)