diff --git a/beat/web/toolchains/static/toolchains/js/common.js b/beat/web/toolchains/static/toolchains/js/common.js index 276503c470f169c852b15a25972695f2f8bd8727..81dc52872e21825b0eee5d666226f4d8cdce5cca 100644 --- a/beat/web/toolchains/static/toolchains/js/common.js +++ b/beat/web/toolchains/static/toolchains/js/common.js @@ -56,6 +56,12 @@ beat.toolchains.common.SELECTION_INPUT = 1; beat.toolchains.common.SELECTION_OUTPUT = 2; beat.toolchains.common.SELECTION_FULL = 3; +// Scrollbars +beat.toolchains.common.SCROLLBAR_HOLDER_WIDTH = 15; +beat.toolchains.common.SCROLLBAR_WIDTH = 8; +beat.toolchains.common.SCROLLBAR_OFFSET = 4; +beat.toolchains.common.SCROLLBAR_MARGIN = 200; + /*********************************** UTILITY FUNCTIONS **********************************/ diff --git a/beat/web/toolchains/static/toolchains/js/editor.js b/beat/web/toolchains/static/toolchains/js/editor.js index 2a90b5c3971129cc5ac19d10dbc1cb9ebe87aaab..1f0d75a15f88fb4a1315612a6a246f477a7efc35 100644 --- a/beat/web/toolchains/static/toolchains/js/editor.js +++ b/beat/web/toolchains/static/toolchains/js/editor.js @@ -75,12 +75,6 @@ beat.toolchains.editor.HOVERED_CONNECTION = 10; beat.toolchains.editor.HOVERED_CONNECTION_WITH_CHANNELS = 11; beat.toolchains.editor.HOVERED_INPUT_HANDLE_CONNECTION = 12; -// Scrollbars -beat.toolchains.editor.SCROLLBAR_HOLDER_WIDTH = 15; -beat.toolchains.editor.SCROLLBAR_WIDTH = 8; -beat.toolchains.editor.SCROLLBAR_OFFSET = 4; -beat.toolchains.editor.SCROLLBAR_MARGIN = 200; - /******************************** CLASS: ToolchainEditor ********************************/ @@ -2097,16 +2091,16 @@ beat.toolchains.editor.ToolchainView.prototype._onMouseDown = function(event) var infos = this._getComponentAt(this.mouse_position.x, this.mouse_position.y); // Horizontal scrollbar - if (this.mouse_position.y >= this.canvas.height - beat.toolchains.editor.SCROLLBAR_HOLDER_WIDTH) + if (this.mouse_position.y >= this.canvas.height - beat.toolchains.common.SCROLLBAR_HOLDER_WIDTH) { var view = this; function _incremental_horizontal_scroll() { - if (view.mouse_position.y < view.canvas.height - beat.toolchains.editor.SCROLLBAR_HOLDER_WIDTH) + if (view.mouse_position.y < view.canvas.height - beat.toolchains.common.SCROLLBAR_HOLDER_WIDTH) return; - if (view.mouse_position.x >= view.canvas.width - beat.toolchains.editor.SCROLLBAR_HOLDER_WIDTH) + if (view.mouse_position.x >= view.canvas.width - beat.toolchains.common.SCROLLBAR_HOLDER_WIDTH) return; if (view.mouse_position.x < view.horizontal_scrollbar.position) @@ -2118,7 +2112,7 @@ beat.toolchains.editor.ToolchainView.prototype._onMouseDown = function(event) } // Corner - if (this.mouse_position.x >= this.canvas.width - beat.toolchains.editor.SCROLLBAR_HOLDER_WIDTH) + if (this.mouse_position.x >= this.canvas.width - beat.toolchains.common.SCROLLBAR_HOLDER_WIDTH) { // Nothing to do } @@ -2161,16 +2155,16 @@ beat.toolchains.editor.ToolchainView.prototype._onMouseDown = function(event) } // Vertical scrollbar - else if (this.mouse_position.x >= this.canvas.width - beat.toolchains.editor.SCROLLBAR_HOLDER_WIDTH) + else if (this.mouse_position.x >= this.canvas.width - beat.toolchains.common.SCROLLBAR_HOLDER_WIDTH) { var view = this; function _incremental_vertical_scroll() { - if (view.mouse_position.x < view.canvas.width - beat.toolchains.editor.SCROLLBAR_HOLDER_WIDTH) + if (view.mouse_position.x < view.canvas.width - beat.toolchains.common.SCROLLBAR_HOLDER_WIDTH) return; - if (view.mouse_position.y >= view.canvas.height - beat.toolchains.editor.SCROLLBAR_HOLDER_WIDTH) + if (view.mouse_position.y >= view.canvas.height - beat.toolchains.common.SCROLLBAR_HOLDER_WIDTH) return; if (view.mouse_position.y < view.vertical_scrollbar.position) @@ -4326,7 +4320,7 @@ beat.toolchains.editor.ToolchainView.prototype._onMouseWheel = function(event) var mouse_position = this._getMousePosition(event); // Mouse over the horizontal scrollbar: translate horizontally - if (mouse_position.y >= this.canvas.height - beat.toolchains.editor.SCROLLBAR_HOLDER_WIDTH) + if (mouse_position.y >= this.canvas.height - beat.toolchains.common.SCROLLBAR_HOLDER_WIDTH) { // Scroll up if (event.originalEvent.wheelDelta > 0 || event.originalEvent.detail < 0) @@ -5448,8 +5442,8 @@ beat.toolchains.editor.ToolchainView.prototype._drawScrollbars = function() // Compute all the needed positions / sizes - var horizontal_top = this.canvas.height - beat.toolchains.editor.SCROLLBAR_HOLDER_WIDTH; - var vertical_left = this.canvas.width - beat.toolchains.editor.SCROLLBAR_HOLDER_WIDTH; + var horizontal_top = this.canvas.height - beat.toolchains.common.SCROLLBAR_HOLDER_WIDTH; + var vertical_left = this.canvas.width - beat.toolchains.common.SCROLLBAR_HOLDER_WIDTH; if (this.bounding_box.left !== null) { @@ -5505,27 +5499,27 @@ beat.toolchains.editor.ToolchainView.prototype._drawScrollbars = function() var extended_width = Math.max(bounding_box.right, this.visible_area.left + this.visible_area.width) - Math.min(bounding_box.left, this.visible_area.left); var extended_height = Math.max(bounding_box.bottom, this.visible_area.top + this.visible_area.height) - Math.min(bounding_box.top, this.visible_area.top); - var covered_width = extended_width / this.zoom + beat.toolchains.editor.SCROLLBAR_MARGIN * 2; - var covered_height = extended_height / this.zoom + beat.toolchains.editor.SCROLLBAR_MARGIN * 2; + var covered_width = extended_width / this.zoom + beat.toolchains.common.SCROLLBAR_MARGIN * 2; + var covered_height = extended_height / this.zoom + beat.toolchains.common.SCROLLBAR_MARGIN * 2; var horizontal_x = 0.5 + (visible_area_center_x - bounding_box_center_x) / extended_width * 0.5; var vertical_y = 0.5 + (visible_area_center_y - bounding_box_center_y) / extended_height * 0.5; - this.horizontal_scrollbar.size = ((this.visible_area.width - beat.toolchains.editor.SCROLLBAR_HOLDER_WIDTH) / covered_width) * this.canvas.width / this.zoom; + this.horizontal_scrollbar.size = ((this.visible_area.width - beat.toolchains.common.SCROLLBAR_HOLDER_WIDTH) / covered_width) * this.canvas.width / this.zoom; this.horizontal_scrollbar.position = (this.canvas.width * horizontal_x) - this.horizontal_scrollbar.size / 2; - this.vertical_scrollbar.size = ((this.visible_area.height - beat.toolchains.editor.SCROLLBAR_HOLDER_WIDTH) / covered_height) * this.canvas.height / this.zoom; + this.vertical_scrollbar.size = ((this.visible_area.height - beat.toolchains.common.SCROLLBAR_HOLDER_WIDTH) / covered_height) * this.canvas.height / this.zoom; this.vertical_scrollbar.position = (this.canvas.height * vertical_y) - this.vertical_scrollbar.size / 2; // Draw the holders this.context.fillStyle = '#F9F9F9'; - this.context.fillRect(0.5, horizontal_top + 0.5, this.canvas.width, beat.toolchains.editor.SCROLLBAR_HOLDER_WIDTH); - this.context.fillRect(vertical_left + 0.5, 0.5, beat.toolchains.editor.SCROLLBAR_HOLDER_WIDTH, this.canvas.height); + this.context.fillRect(0.5, horizontal_top + 0.5, this.canvas.width, beat.toolchains.common.SCROLLBAR_HOLDER_WIDTH); + this.context.fillRect(vertical_left + 0.5, 0.5, beat.toolchains.common.SCROLLBAR_HOLDER_WIDTH, this.canvas.height); this.context.strokeStyle = '#E8E8E8'; - this.context.strokeRect(0.5, horizontal_top + 0.5, this.canvas.width - beat.toolchains.editor.SCROLLBAR_HOLDER_WIDTH, 1); - this.context.strokeRect(vertical_left + 0.5, 0.5, 1, this.canvas.height - beat.toolchains.editor.SCROLLBAR_HOLDER_WIDTH); + this.context.strokeRect(0.5, horizontal_top + 0.5, this.canvas.width - beat.toolchains.common.SCROLLBAR_HOLDER_WIDTH, 1); + this.context.strokeRect(vertical_left + 0.5, 0.5, 1, this.canvas.height - beat.toolchains.common.SCROLLBAR_HOLDER_WIDTH); // Draw the horizontal scrollbar @@ -5534,16 +5528,16 @@ beat.toolchains.editor.ToolchainView.prototype._drawScrollbars = function() else this.context.fillStyle = '#C2C2C2'; - _roundRect(this.context, this.horizontal_scrollbar.position + 0.5, horizontal_top + beat.toolchains.editor.SCROLLBAR_OFFSET + 0.5, - this.horizontal_scrollbar.size, beat.toolchains.editor.SCROLLBAR_WIDTH, beat.toolchains.editor.SCROLLBAR_WIDTH / 2, true, false); + _roundRect(this.context, this.horizontal_scrollbar.position + 0.5, horizontal_top + beat.toolchains.common.SCROLLBAR_OFFSET + 0.5, + this.horizontal_scrollbar.size, beat.toolchains.common.SCROLLBAR_WIDTH, beat.toolchains.common.SCROLLBAR_WIDTH / 2, true, false); if ((this.current_action == beat.toolchains.editor.ACTION_SCROLLBAR) && !this.action_data.horizontal) this.context.fillStyle = '#A2A2A2'; else this.context.fillStyle = '#C2C2C2'; - _roundRect(this.context, vertical_left + beat.toolchains.editor.SCROLLBAR_OFFSET + 0.5, this.vertical_scrollbar.position + 0.5, - beat.toolchains.editor.SCROLLBAR_WIDTH, this.vertical_scrollbar.size, beat.toolchains.editor.SCROLLBAR_WIDTH / 2, true, false); + _roundRect(this.context, vertical_left + beat.toolchains.common.SCROLLBAR_OFFSET + 0.5, this.vertical_scrollbar.position + 0.5, + beat.toolchains.common.SCROLLBAR_WIDTH, this.vertical_scrollbar.size, beat.toolchains.common.SCROLLBAR_WIDTH / 2, true, false); this.context.restore(); diff --git a/beat/web/toolchains/static/toolchains/js/viewer.js b/beat/web/toolchains/static/toolchains/js/viewer.js index f3736f024698647fd7a6353b5c7e16773995f6ae..9b2c696a5e6182170fffb7fd4e110a51caf7647b 100644 --- a/beat/web/toolchains/static/toolchains/js/viewer.js +++ b/beat/web/toolchains/static/toolchains/js/viewer.js @@ -687,7 +687,7 @@ beat.toolchains.viewer.ToolchainViewer.prototype._onMouseWheel = function(event) var mouse_position = this._getMousePosition(event); // Mouse over the horizontal scrollbar: translate horizontally - if (mouse_position.y >= this.canvas.height - beat.toolchains.editor.SCROLLBAR_HOLDER_WIDTH) + if (mouse_position.y >= this.canvas.height - beat.toolchains.common.SCROLLBAR_HOLDER_WIDTH) { // Scroll up if (event.originalEvent.wheelDelta > 0 || event.originalEvent.detail < 0)