Fixed drag

This commit is contained in:
Devine Lu Linvega 2016-12-24 16:19:54 -07:00
parent 4c104ab1fb
commit 9e2960df72
4 changed files with 37 additions and 38 deletions

View File

@ -7,7 +7,7 @@ function Cursor()
{ {
if(event.ctrltKey === true && event.altKey === true && event.shiftKey === true){ /* */ } 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.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.ctrltKey === true && event.altKey === true){ this.set_mode(ronin.eye); }
else if(event.ctrlKey === true){ this.set_mode(ronin.overlay); } else if(event.ctrlKey === true){ this.set_mode(ronin.overlay); }
else if(event.altKey === true){ this.set_mode(ronin.surface); } else if(event.altKey === true){ this.set_mode(ronin.surface); }

View File

@ -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;
}
}

View File

@ -79,7 +79,7 @@ function Surface(rune)
this.widget_cursor = function() this.widget_cursor = function()
{ {
return "Move"; return "Drag";
} }
// Layers // Layers

View File

@ -35,4 +35,39 @@ function Layer(name)
{ {
return this.element.getContext('2d'); 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;
}
} }