Browse Source

Moving the UI debug window to a static method (now that static methods are supported! Thanks @mattbenic), hooking up debug window to development menu

Josh Engebretson 10 years ago
parent
commit
34fdaa9732

+ 7 - 1
Script/AtomicEditor/ui/frames/menus/MainFrameMenu.ts

@@ -175,6 +175,11 @@ class MainFrameMenu extends Atomic.ScriptObject {
                 return true;
             }
 
+            if (refid == "developer show uidebugger") {
+                Atomic.UI.debugShowSettingsWindow(EditorUI.getView());
+                return true;
+            }
+
         } else if (target.id == "menu tools popup") {
 
             if (refid == "tools toggle profiler") {
@@ -272,7 +277,8 @@ var buildItems = {
 
 var developerItems = {
 
-    "Show Console": ["developer show console"]
+    "Show Console": ["developer show console"],
+    "Show UI Debugger": ["developer show uidebugger"]
 
 };
 

+ 11 - 0
Source/Atomic/UI/UI.cpp

@@ -912,5 +912,16 @@ bool UI::OnWidgetInvokeEvent(tb::TBWidget *widget, const tb::TBWidgetEvent &ev)
     return false;
 }
 
+void UI::DebugShowSettingsWindow(UIWidget* parent)
+{
+
+#ifdef TB_RUNTIME_DEBUG_INFO
+    if (parent && parent->GetInternalWidget())
+        tb::ShowDebugInfoSettingsWindow(parent->GetInternalWidget());
+#endif
+
+}
+
+
 
 }

+ 3 - 0
Source/Atomic/UI/UI.h

@@ -114,6 +114,9 @@ public:
 
     UIWidget* GetHoveredWidget();
 
+    // Debugging
+    static void DebugShowSettingsWindow(UIWidget* parent);
+
 private:
 
     static WeakPtr<Context> uiContext_;

+ 0 - 19
Source/AtomicJS/Javascript/JSUIAPI.cpp

@@ -149,22 +149,6 @@ int UI_DebugGetWrappedWidgetCount(duk_context* ctx)
     return 1;
 }
 
-int UI_DebugShowSettingsWindow(duk_context* ctx)
-{
-    UIWidget* widget = js_to_class_instance<UIWidget>(ctx, 0, 0);
-
-    if (!widget)
-        return 0;
-
-#ifdef TB_RUNTIME_DEBUG_INFO
-    if (widget->GetInternalWidget())
-        tb::ShowDebugInfoSettingsWindow(widget->GetInternalWidget());
-#endif
-
-
-    return 0;
-}
-
 void jsapi_init_ui(JSVM* vm)
 {
     duk_context* ctx = vm->GetJSContext();
@@ -179,9 +163,6 @@ void jsapi_init_ui(JSVM* vm)
     duk_push_c_function(ctx, UI_DebugGetUIKeepAliveCount, 0);
     duk_put_prop_string(ctx, -2, "debugGetUIKeepAliveCount");
 
-    duk_push_c_function(ctx, UI_DebugShowSettingsWindow, 1);
-    duk_put_prop_string(ctx, -2, "debugShowSettingsWindow");
-
     duk_pop_2(ctx);
 
     js_class_get_prototype(ctx, "Atomic", "UIButton");