Shortcut to move canvas content.
This commit is contained in:
@@ -70,35 +70,36 @@ function Canvas(rune)
|
||||
|
||||
this.widget_cursor = function()
|
||||
{
|
||||
return "Drag";
|
||||
return "Move";
|
||||
}
|
||||
|
||||
// Cursor
|
||||
|
||||
this.drag_from = null;
|
||||
this.move_from = null;
|
||||
|
||||
this.mouse_down = function(position)
|
||||
{
|
||||
this.drag_from = ronin.position_in_window(position);
|
||||
this.move_from = ronin.position_in_window(position);
|
||||
}
|
||||
|
||||
this.mouse_move = function(position)
|
||||
{
|
||||
if(this.drag_from === null){ return; }
|
||||
if(this.move_from === null){ return; }
|
||||
|
||||
position = ronin.position_in_window(position);
|
||||
|
||||
var offset_x = this.drag_from.x - position.x;
|
||||
var offset_y = this.drag_from.y - position.y;
|
||||
var offset_x = this.move_from.x - position.x;
|
||||
var offset_y = this.move_from.y - position.y;
|
||||
|
||||
ronin.surface.style.left = ronin.surface.style.left ? parseInt(ronin.surface.style.left) - offset_x : offset_x;
|
||||
ronin.surface.style.top = ronin.surface.style.top ? parseInt(ronin.surface.style.top) - offset_y : offset_y;
|
||||
this.context().globalCompositeOperation = "copy";
|
||||
this.context().drawImage(this.context().canvas, -offset_x, -offset_y);
|
||||
this.context().globalCompositeOperation = "source-over"
|
||||
|
||||
this.drag_from = new Position(position.x,position.y);
|
||||
this.move_from = new Position(position.x,position.y);
|
||||
}
|
||||
|
||||
this.mouse_up = function(event)
|
||||
{
|
||||
this.drag_from = null;
|
||||
this.move_from = null;
|
||||
}
|
||||
}
|
9
scripts/modules/planner.js
Normal file
9
scripts/modules/planner.js
Normal file
@@ -0,0 +1,9 @@
|
||||
function Planner(rune)
|
||||
{
|
||||
Module.call(this,rune);
|
||||
|
||||
this.widget_cursor = function()
|
||||
{
|
||||
return "Planner";
|
||||
}
|
||||
}
|
49
scripts/modules/surface.js
Normal file
49
scripts/modules/surface.js
Normal file
@@ -0,0 +1,49 @@
|
||||
function Surface(rune)
|
||||
{
|
||||
Module.call(this,rune);
|
||||
|
||||
this.element = null;
|
||||
this.parameters = [Any];
|
||||
|
||||
this.active = function(cmd)
|
||||
{
|
||||
}
|
||||
|
||||
this.passive = function(cmd)
|
||||
{
|
||||
}
|
||||
|
||||
this.widget_cursor = function()
|
||||
{
|
||||
return "Drag";
|
||||
}
|
||||
|
||||
// Cursor
|
||||
|
||||
this.drag_from = null;
|
||||
|
||||
this.mouse_down = function(position)
|
||||
{
|
||||
this.drag_from = ronin.position_in_window(position);
|
||||
}
|
||||
|
||||
this.mouse_move = function(position)
|
||||
{
|
||||
if(this.drag_from === null){ return; }
|
||||
|
||||
position = ronin.position_in_window(position);
|
||||
|
||||
var offset_x = this.drag_from.x - position.x;
|
||||
var offset_y = this.drag_from.y - position.y;
|
||||
|
||||
ronin.surface.element.style.left = ronin.surface.element.style.left ? parseInt(ronin.surface.element.style.left) - offset_x : offset_x;
|
||||
ronin.surface.element.style.top = ronin.surface.element.style.top ? parseInt(ronin.surface.element.style.top) - offset_y : offset_y;
|
||||
|
||||
this.drag_from = new Position(position.x,position.y);
|
||||
}
|
||||
|
||||
this.mouse_up = function(event)
|
||||
{
|
||||
this.drag_from = null;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user