Fixed issues with new cursor modes.

This commit is contained in:
Devine Lu Linvega
2016-12-19 15:01:07 -07:00
parent df8d94d3d5
commit cdbd9e9c0b
6 changed files with 23 additions and 41 deletions

View File

@@ -6,22 +6,24 @@ function Mode_Drag()
this.drag_from = null;
this.mouse_down = function(event)
this.mouse_down = function(position)
{
this.drag_from = new Position(event.clientX,event.clientY);
this.drag_from = position;
}
this.mouse_move = function(event)
this.mouse_move = function(position)
{
if(this.drag_from == null){ return; }
console.log(position);
return;
if(this.drag_from === null){ return; }
var offset_x = this.drag_from.x - event.clientX;
var offset_y = this.drag_from.y - event.clientY;
var offset_x = this.drag_from.x - position.x;
var offset_y = this.drag_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.drag_from = new Position(event.clientX,event.clientY);
this.drag_from = new Position(position.x,position.y);
}
this.mouse_up = function(event)

View File

@@ -6,31 +6,31 @@ function Mode_Guide()
this.live_draw_from = null;
this.mouse_down = function(event)
this.mouse_down = function(position)
{
ronin.overlay.clear();
ronin.overlay.draw_pointer(ronin.position_in_canvas(event));
this.live_draw_from = ronin.position_in_canvas(event);
ronin.overlay.draw_pointer(position);
this.live_draw_from = position;
commander.show();
commander.element_input.focus();
commander.element_input.value = "| "+this.live_draw_from.render();
}
this.mouse_move = function(event)
this.mouse_move = function(position)
{
if(this.live_draw_from == null){ return; }
ronin.overlay.clear();
var rect = new Rect();
rect.width = ronin.position_in_canvas(event).x - this.live_draw_from.x;
rect.height = ronin.position_in_canvas(event).y - this.live_draw_from.y;
rect.width = position.x - this.live_draw_from.x;
rect.height = position.y - this.live_draw_from.y;
ronin.overlay.draw_rect(this.live_draw_from,rect);
commander.element_input.value = "| "+this.live_draw_from.render()+" "+rect.render();
}
this.mouse_up = function(event)
this.mouse_up = function(position)
{
this.live_draw_from = null;
commander.element_input.focus();