From 1d9f85dfb349227f10cc2b979e0082267dbc87b3 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Thu, 6 Sep 2018 11:45:52 -0400 Subject: [PATCH] button navigator step changed --- .../debugger/debuggerUI/ButtonNavigator.js | 58 +++++++++++-------- src/app/debugger/debuggerUI/Slider.js | 2 +- src/app/debugger/debuggerUI/StepManager.js | 21 ++++++- 3 files changed, 55 insertions(+), 26 deletions(-) diff --git a/src/app/debugger/debuggerUI/ButtonNavigator.js b/src/app/debugger/debuggerUI/ButtonNavigator.js index 12c9e4fa54..5710dc1f53 100644 --- a/src/app/debugger/debuggerUI/ButtonNavigator.js +++ b/src/app/debugger/debuggerUI/ButtonNavigator.js @@ -88,8 +88,6 @@ function ButtonNavigator (_parent, _traceManager) { this.view } -module.exports = ButtonNavigator - ButtonNavigator.prototype.render = function () { var self = this var view = yo`
@@ -130,29 +128,43 @@ ButtonNavigator.prototype.reset = function () { resetWarning(this) } -ButtonNavigator.prototype.stepChanged = function (step) { +ButtonNavigator.prototype.stepChanged = function (stepState, jumpOutDisabled) { + if (stepState === 'invalid') { + // TODO: probably not necessary, already implicit done in the next steps + this.reset() + this.updateAll() + return + } + + this.intoBackDisabled = (stepState === 'initial') + this.overBackDisabled = (stepState === 'initial') + this.jumpPreviousBreakpointDisabled = (stepState === 'initial') + this.jumpNextBreakpointDisabled = (stepState === 'end') + this.intoForwardDisabled = (stepState === 'end') + this.overForwardDisabled = (stepState === 'end') + this.jumpNextBreakpointDisabled = jumpOutDisabled + + this.updateAll() +} + +ButtonNavigator.prototype.old_stepChanged = function (step) { + var self = this this.intoBackDisabled = step <= 0 this.overBackDisabled = step <= 0 - if (!this.traceManager) { - this.intoForwardDisabled = true - this.overForwardDisabled = true - } else { - var self = this - this.traceManager.getLength(function (error, length) { - if (error) { - self.reset() - console.log(error) - } else { - self.jumpNextBreakpointDisabled = step >= length - 1 - self.jumpPreviousBreakpointDisabled = step <= 0 - self.intoForwardDisabled = step >= length - 1 - self.overForwardDisabled = step >= length - 1 - var stepOut = self.traceManager.findStepOut(step) - self.jumpOutDisabled = stepOut === step - } - self.updateAll() - }) - } + this.traceManager.getLength(function (error, length) { + if (error) { + console.log(error) + self.reset() + } else { + self.jumpNextBreakpointDisabled = step >= length - 1 + self.jumpPreviousBreakpointDisabled = step <= 0 + self.intoForwardDisabled = step >= length - 1 + self.overForwardDisabled = step >= length - 1 + var stepOut = self.traceManager.findStepOut(step) + self.jumpOutDisabled = stepOut === step + } + self.updateAll() + }) this.updateAll() } diff --git a/src/app/debugger/debuggerUI/Slider.js b/src/app/debugger/debuggerUI/Slider.js index b3f84c7fce..3ca7eb8ffc 100644 --- a/src/app/debugger/debuggerUI/Slider.js +++ b/src/app/debugger/debuggerUI/Slider.js @@ -63,7 +63,7 @@ class Slider { if (value === this.previousValue) return this.previousValue = value - this.event.trigger('moved', [value]) + this.event.trigger('sliderMoved', [value]) } setValue (value) { diff --git a/src/app/debugger/debuggerUI/StepManager.js b/src/app/debugger/debuggerUI/StepManager.js index 7e223e1e7a..ed8edafb68 100644 --- a/src/app/debugger/debuggerUI/StepManager.js +++ b/src/app/debugger/debuggerUI/StepManager.js @@ -29,7 +29,7 @@ function StepManager (_parent, _traceManager) { this.slider = new Slider((step) => { return this.solidityMode ? this.resolveToReducedTrace(step, 0) : step }) - this.slider.event.register('moved', this, function (step) { + this.slider.event.register('sliderMoved', this, function (step) { self.sliderMoved(step) }) @@ -197,8 +197,25 @@ StepManager.prototype.jumpOut = function () { } StepManager.prototype.changeState = function (step) { + const self = this this.currentStepIndex = step - this.buttonNavigator.stepChanged(step) + + this.traceManager.getLength(function (error, length) { + let stepState = 'valid' + + if (error) { + stepState = 'invalid' + } else if (step <= 0) { + stepState = 'initial' + } else if (step >= length - 1) { + stepState = 'end' + } + + let jumpOutDisabled = (step === self.traceManager.findStepOut(step)) + + self.buttonNavigator.stepChanged(stepState, jumpOutDisabled) + }) + this.event.trigger('stepChanged', [step]) }