From 9e2960df72af05b1cdd80309dba0772b9364c505 Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Sat, 24 Dec 2016 16:19:54 -0700 Subject: [PATCH] Fixed drag --- scripts/core/cursor.js | 2 +- scripts/modules/canvas.js | 36 -------------------------------- scripts/modules/surface.js | 2 +- scripts/modules/surface.layer.js | 35 +++++++++++++++++++++++++++++++ 4 files changed, 37 insertions(+), 38 deletions(-) delete mode 100644 scripts/modules/canvas.js diff --git a/scripts/core/cursor.js b/scripts/core/cursor.js index 7e8ee41..86ef33a 100644 --- a/scripts/core/cursor.js +++ b/scripts/core/cursor.js @@ -7,7 +7,7 @@ function Cursor() { if(event.ctrltKey === true && event.altKey === true && event.shiftKey === true){ /* */ } else if(event.shiftKey === true && event.ctrlKey === true){ this.set_mode(ronin.eye); } - else if(event.shiftKey === true && event.altKey === true){ this.set_mode(ronin.canvas); } + else if(event.shiftKey === true && event.altKey === true){ this.set_mode(ronin.surface.active_layer); } else if(event.ctrltKey === true && event.altKey === true){ this.set_mode(ronin.eye); } else if(event.ctrlKey === true){ this.set_mode(ronin.overlay); } else if(event.altKey === true){ this.set_mode(ronin.surface); } diff --git a/scripts/modules/canvas.js b/scripts/modules/canvas.js deleted file mode 100644 index 4f59b55..0000000 --- a/scripts/modules/canvas.js +++ /dev/null @@ -1,36 +0,0 @@ -function Canvas(rune) -{ - Module.call(this,rune); - - this.parameters = [Rect,Position,Color,Bang]; - - // Cursor - - this.move_from = null; - - this.mouse_down = function(position) - { - this.move_from = ronin.position_in_window(position); - } - - this.mouse_move = function(position) - { - if(this.move_from === null){ return; } - - position = ronin.position_in_window(position); - - var offset_x = this.move_from.x - position.x; - var offset_y = this.move_from.y - position.y; - - this.context().globalCompositeOperation = "copy"; - this.context().drawImage(this.context().canvas, -offset_x, -offset_y); - this.context().globalCompositeOperation = "source-over" - - this.move_from = new Position(position.x,position.y); - } - - this.mouse_up = function(event) - { - this.move_from = null; - } -} \ No newline at end of file diff --git a/scripts/modules/surface.js b/scripts/modules/surface.js index 7b28a29..22d2776 100644 --- a/scripts/modules/surface.js +++ b/scripts/modules/surface.js @@ -79,7 +79,7 @@ function Surface(rune) this.widget_cursor = function() { - return "Move"; + return "Drag"; } // Layers diff --git a/scripts/modules/surface.layer.js b/scripts/modules/surface.layer.js index 63661f3..1ff89e3 100644 --- a/scripts/modules/surface.layer.js +++ b/scripts/modules/surface.layer.js @@ -35,4 +35,39 @@ function Layer(name) { return this.element.getContext('2d'); } + + // + + this.widget_cursor = function() + { + return "Move"; + } + + this.move_from = null; + + this.mouse_down = function(position) + { + this.move_from = ronin.position_in_window(position); + } + + this.mouse_move = function(position) + { + if(this.move_from === null){ return; } + + position = ronin.position_in_window(position); + + var offset_x = this.move_from.x - position.x; + var offset_y = this.move_from.y - position.y; + + this.context().globalCompositeOperation = "copy"; + this.context().drawImage(this.context().canvas, -offset_x, -offset_y); + this.context().globalCompositeOperation = "source-over" + + this.move_from = new Position(position.x,position.y); + } + + this.mouse_up = function(event) + { + this.move_from = null; + } } \ No newline at end of file