Improved layout and added widget.

This commit is contained in:
Devine Lu Linvega
2016-11-25 13:57:07 -06:00
parent ee67ec8da2
commit 173401554d
10 changed files with 78 additions and 58 deletions

View File

@@ -41,6 +41,7 @@ function Brush()
if(cmd.value()){
this.size = cmd.value().float;
}
ronin.widget.update();
}
this.passive = function(cmd)
@@ -67,7 +68,7 @@ function Brush()
{
if(this.is_drawing === false){return;}
this.position = new Position(e.clientX - parseFloat(ronin.canvas.element.style.left),e.clientY- parseFloat(ronin.canvas.element.style.top));
this.position = new Position(e.clientX - parseFloat(ronin.surface.style.left) - parseFloat(ronin.canvas.element.style.left),e.clientY- parseFloat(ronin.surface.style.top) - parseFloat(ronin.canvas.element.style.top));
for (i = 0; i < this.pointers.length; i++) {
this.pointers[i].draw();
@@ -92,4 +93,8 @@ function Brush()
}
}
this.widget = function()
{
return "> "+this.size+" <span style='color:"+this.color.render()+"'>"+this.color.render()+"</span> ";
}
}

View File

@@ -37,6 +37,11 @@ function Canvas(element)
this.element.setAttribute('height',rect.height+"px");
this.element.style.left = (window.innerWidth/2)-(rect.width/2);
this.element.style.top = (window.innerHeight/2)-(rect.height/2);
ronin.widget.element.style.left = (window.innerWidth/2)-(rect.width/2);
ronin.widget.element.style.top = (window.innerHeight/2)+(rect.height/2);
ronin.widget.update();
}
this.context = function()
@@ -49,28 +54,8 @@ function Canvas(element)
this.context().clearRect(0, 0, this.element.width, this.element.height);
}
// Drag
this.drag_from = null;
this.drag_start = function(e)
this.widget = function()
{
this.drag_from = new Position(e.clientX,e.clientY);
}
this.drag = function(e)
{
if(e.which != 2){ return; }
var offset_x = this.drag_from.x - e.clientX;
this.element.style.left = parseInt(this.element.style.left) - offset_x;
var offset_y = this.drag_from.y - e.clientY;
this.element.style.top = parseInt(this.element.style.top) - offset_y;
this.drag_from = new Position(e.clientX,e.clientY);
}
this.drag_stop = function(e)
{
this.drag_from = null;
return "@ "+this.element.width+"x"+this.element.height+" ";
}
}

View File

@@ -1,44 +0,0 @@
function Hint(element)
{
Module.call(this);
this.element = element;
this.update = function()
{
if(ronin.module){
this.element.innerHTML = this.message(ronin.module,commander.cmd);
this.element.style.display = "block";
}
else{
this.element.innerHTML = this.default();
this.element.style.display = "block";
}
}
this.message = function(module,cmd)
{
var s = "<span class='module'>"+module.constructor.name+"</span>";
var e = 0;
while(e < 10){
if(!module.parameters[e]){ break; }
var param_name = module.parameters[e].name;
s += cmd[param_name.toLowerCase()]() ? "<span class='value'>"+cmd[param_name.toLowerCase()]().render()+"</span>" : "<span class='param'>"+param_name+"</span>";
e += 1;
}
return s;
}
this.default = function()
{
var s = "<span class='module'>Modules</span>";
for (var key in ronin.modules){
s += "<span class='param'>"+ronin.modules[key].constructor.name+"<span> <span class='value'>"+key+"</span> ";
}
return s;
}
}

View File

@@ -137,29 +137,4 @@ function Overlay(element)
{
this.context().clearRect(0, 0, ronin.canvas.element.width, ronin.canvas.element.height);
}
// Drag
this.drag_from = null;
this.drag_start = function(e)
{
this.drag_from = new Position(e.clientX,e.clientY);
}
this.drag = function(e)
{
if(e.which != 2){ return; }
var offset_x = this.drag_from.x - e.clientX;
this.element.style.left = parseInt(this.element.style.left) - offset_x;
var offset_y = this.drag_from.y - e.clientY;
this.element.style.top = parseInt(this.element.style.top) - offset_y;
this.drag_from = new Position(e.clientX,e.clientY);
}
this.drag_stop = function(e)
{
this.drag_from = null;
}
}