diff --git a/src/ecma-debugger/stop_at.js b/src/ecma-debugger/stop_at.js index 1bd85dec2..9ed607a54 100755 --- a/src/ecma-debugger/stop_at.js +++ b/src/ecma-debugger/stop_at.js @@ -418,7 +418,7 @@ cls.EcmascriptDebugger["6.0"].StopAt = function() stopAt.stopped_reason == 'new script') { runtime_id = stopAt.runtime_id; - if (!webgl.injected) + if (!webgl.injected && webgl.enabled) { var continue_callback = (function () { this.__continue('run'); }).bind(this); webgl.inject(stopAt.runtime_id, continue_callback); diff --git a/src/webgl/start_view.js b/src/webgl/start_view.js index 6e20836d5..a591293af 100644 --- a/src/webgl/start_view.js +++ b/src/webgl/start_view.js @@ -21,11 +21,13 @@ cls.WebGLStartView = function(id, name, container_class) { if (!this._container) return; - var state = window.webgl.injected - ? snapshot_present - ? "select" - : "snapshot" - : "init"; + var state = window.webgl.enabled + ? window.webgl.injected + ? snapshot_present + ? "select" + : "snapshot" + : "init" + : "enable"; this._container.clearAndRender(window.templates.webgl.start_view(state, info_open)); }; @@ -34,6 +36,12 @@ cls.WebGLStartView = function(id, name, container_class) this._container = null; }; + var on_enable = function(event, target) + { + webgl.enable(); + runtimes.reloadWindow(); + }; + var on_settings = function(msg) { if (msg.id === "webgl-snapshot") @@ -140,6 +148,7 @@ cls.WebGLStartView = function(id, name, container_class) messages.addListener('webgl-clear', on_clear.bind(this)); var eh = window.eventHandlers; + eh.click["webgl-enable"] = on_enable.bind(this); eh.click["webgl-open-settings"] = on_open_settings.bind(this); eh.click["webgl-info-box-toggle"] = on_toggle_info.bind(this); diff --git a/src/webgl/views.js b/src/webgl/views.js index 57502e45e..a9d7f9514 100755 --- a/src/webgl/views.js +++ b/src/webgl/views.js @@ -173,7 +173,7 @@ cls.WebGLGeneralView.create_ui_widgets = function() 'webgl-general', // key-value map { - 'enable-debugger' : true, + 'enable-debugger' : true, // TODO: Actually use this setting for hiding the webgl-mode tab 'highlight-objects' : true, 'first-run' : true, diff --git a/src/webgl/webgl.js b/src/webgl/webgl.js index a5c896388..683442704 100755 --- a/src/webgl/webgl.js +++ b/src/webgl/webgl.js @@ -8,6 +8,7 @@ cls.WebGL.WebGLDebugger = function () { this.injected = false; this.runtime_id = -1; + this.enabled = false; /* Context IDs for wrapped contexts. NOT an object id */ this.contexts = []; @@ -38,10 +39,14 @@ cls.WebGL.WebGLDebugger = function () /* Contains shader used when displaying textures and buffers in the debugger */ this.shaders = {}; + this.enable = function () + { + this.enabled = true; + }; + this.inject = function (rt_id, cont_callback) { - // TODO: Better disabling - if (this.runtime_id !== rt_id && window.settings['webgl-general'].map['enable-debugger']) + if (this.runtime_id !== rt_id) { this.runtime_id = rt_id; window.host_tabs.activeTab.addEventListener("webgl-debugger-ready", diff --git a/src/webgl/webgl_templates.js b/src/webgl/webgl_templates.js index 919e7f734..93162de3e 100644 --- a/src/webgl/webgl_templates.js +++ b/src/webgl/webgl_templates.js @@ -1637,10 +1637,18 @@ window.templates.webgl.collapse_box = function(title, string, button, custom, in window.templates.webgl.start_view = function(state, info_open) { var html = ["div"]; - html.push(["h2", "Welcome to the Dragonfly WebGL Debugger"]); + + // TODO: Do this check at a better place :/ + if (!window.services["ecmascript-debugger"].is_enabled) + { + return window.templates.disabled_view(); + } + + // Add the pre-compositing warning if applicable switch (state) { + case "enable": case "init": var warning = window.settings["webgl-snapshot"].map["pre-composite-capture"]; if (warning) @@ -1657,14 +1665,31 @@ window.templates.webgl.start_view = function(state, info_open) ]; html.push(warning_html); } + break; + } + switch (state) + { + case "enable": html.push(window.templates.webgl.info_box( - "Refresh the page you want to debug", - "The WebGL Debugger needs to be present from the start of the " + + "Enable the WebGL debugger", + "Click the button below to enable the WebGL debugger. This will " + + "refresh the current debugging context window", + [ "span", "Enable the WebGL debugger", + "class", "ui-button", + "handler", "webgl-enable", + "tabindex", "1" + ] + )); + break; + case "init": + html.push(window.templates.webgl.info_box( + "Refresh the window you want to debug", + "The WebGL debugger needs to be present from the start of the " + "execution of the application you want to debug. Click the button " + "below to refresh.", - [ "span", "Initialize WebGL Debugger", - "class", "ui-button reload-window", + [ "span", "Refresh window", + "class", "ui-button", "handler", "reload-window", "tabindex", "1" ]