Lots of stuff

This commit is contained in:
Vortrex
2020-12-11 01:51:55 -06:00
parent ecc495de5c
commit fbaafa6c0c
67 changed files with 5755 additions and 4208 deletions

View File

@@ -36,5 +36,5 @@ mexui.Control.Button.prototype.render = function()
mexui.native.drawText(pos, this.size, this.text, this.getStyles('main'));
if(this.isFocused())
mexui.native.drawRectangleBorder(mexui.util.subtractVec2(pos,new Vec2(2,2)), mexui.util.addVec2(this.size,new Vec2(3,3)), this.getStyles('focused'));
mexui.native.drawRectangleBorder(mexui.util.subtractVec2(pos,toVector2(2,2)), mexui.util.addVec2(this.size,toVector2(3,3)), this.getStyles('focused'));
};

View File

@@ -46,19 +46,19 @@ mexui.Control.CheckBox.prototype.render = function()
mexui.native.drawRectangle(pos, this.size, this.getStyles('main'));
if(this.checked)
mexui.native.drawRectangle(mexui.util.addVec2(pos, new Vec2(1, 1)), new Vec2(this.size.x - 2, this.size.y - 2), this.getStyles('innerBox'));
mexui.native.drawRectangle(mexui.util.addVec2(pos, toVector2(1, 1)), toVector2(this.size.x - 2, this.size.y - 2), this.getStyles('innerBox'));
mexui.native.drawText(mexui.util.addVec2(pos, new Vec2(this.size.x + this.textMarginLeft, 2)), this.size, this.text, this.getStyles('main'));
mexui.native.drawText(mexui.util.addVec2(pos, toVector2(this.size.x + this.textMarginLeft, 2)), this.size, this.text, this.getStyles('main'));
if(this.isFocused())
mexui.native.drawRectangleBorder(mexui.util.subtractVec2(pos,new Vec2(2,2)), mexui.util.addVec2(this.size,new Vec2(3,3)), this.getStyles('focused'));
mexui.native.drawRectangleBorder(mexui.util.subtractVec2(pos,toVector2(2,2)), mexui.util.addVec2(this.size,toVector2(3,3)), this.getStyles('focused'));
};
// model
mexui.Control.CheckBox.prototype.getSizeForInput = function()
{
var textWidth = mexui.native.getTextWidth(this.text, this.getStyles('main'));
return new Vec2(this.size.x + this.textMarginLeft + textWidth, this.size.y);
return toVector2(this.size.x + this.textMarginLeft + textWidth, this.size.y);
};
mexui.Control.CheckBox.prototype.toggleChecked = function()

View File

@@ -7,8 +7,8 @@ mexui.util.createControlConstructor('Date', false, function(window, x, y, w, h,
this.year = 2019;
this.inputShown = false;
this.valueBoxSize = new Vec2(50, 30);
this.arrowBoxSize = new Vec2(25, 22);
this.valueBoxSize = toVector2(50, 30);
this.arrowBoxSize = toVector2(25, 22);
this.maxYearOffset = 10;
this.minYearCallback = ()=>{ return 1900; };
@@ -92,7 +92,7 @@ mexui.Control.Date.prototype.renderAfter = function()
var screenPos = this.getScreenPosition();
var pos = new Vec2(screenPos.x, screenPos.y);
var pos = toVector2(screenPos.x, screenPos.y);
for(var i=0; i<3; i++)
{
mexui.native.drawRectangle(pos, this.valueBoxSize, this.getStyles('main'));
@@ -101,7 +101,7 @@ mexui.Control.Date.prototype.renderAfter = function()
pos.x += this.valueBoxSize.x;
}
pos = new Vec2(screenPos.x, screenPos.y);
pos = toVector2(screenPos.x, screenPos.y);
pos.y += this.valueBoxSize.y;
for(var i=0; i<3; i++)
{
@@ -168,8 +168,8 @@ mexui.Control.Date.prototype.getArrowIndexByCursor = function()
var cursorPos = gui.cursorPosition;
var screenPos = this.getScreenPosition();
var firstArrowStartPos = new Vec2(screenPos.x, screenPos.y + this.valueBoxSize.y);
var lastArrowEndPos = new Vec2(screenPos.x + (this.arrowBoxSize.x * 6), screenPos.y + this.valueBoxSize.y + this.arrowBoxSize.y);
var firstArrowStartPos = toVector2(screenPos.x, screenPos.y + this.valueBoxSize.y);
var lastArrowEndPos = toVector2(screenPos.x + (this.arrowBoxSize.x * 6), screenPos.y + this.valueBoxSize.y + this.arrowBoxSize.y);
if(cursorPos.x >= firstArrowStartPos.x && cursorPos.y >= firstArrowStartPos.y && cursorPos.x <= lastArrowEndPos.x && cursorPos.y <= lastArrowEndPos.y)
{

View File

@@ -1,7 +1,7 @@
mexui.util.createControlConstructor('DropDown', true, function(window, x, y, w, h, text, styles, callback)
{
mexui.Component.Control.call(this, window, x, y, w, h, this.linkControlStyles('DropDown', styles), callback);
mexui.Entity.ControlWithEntries.call(this, true, true, new Vec2(0, h), new Vec2(w + 120, 25));
mexui.Entity.ControlWithEntries.call(this, true, true, toVector2(0, h), toVector2(w + 120, 25));
this.axis.y.entriesShown = false;
@@ -89,14 +89,14 @@ mexui.Control.DropDown.prototype.render = function()
if(this.arrowShown)
{
var pos2 = new Vec2(pos.x + this.size.x - (25 + 3), pos.y + 0);
mexui.native.drawImage(pos2, new Vec2(25, 25), mexui.images.downArrow, this.getStyles('main'));
var pos2 = toVector2(pos.x + this.size.x - (25 + 3), pos.y + 0);
mexui.native.drawImage(pos2, toVector2(25, 25), mexui.images.downArrow, this.getStyles('main'));
}
mexui.Entity.ControlWithEntries.prototype.render.call(this);
if(this.isFocused())
mexui.native.drawRectangleBorder(mexui.util.subtractVec2(pos,new Vec2(2,2)), mexui.util.addVec2(this.size,new Vec2(3,3)), this.getStyles('focused'));
mexui.native.drawRectangleBorder(mexui.util.subtractVec2(pos,toVector2(2,2)), mexui.util.addVec2(this.size,toVector2(3,3)), this.getStyles('focused'));
};
mexui.Control.DropDown.prototype.renderAfter = function()
@@ -104,7 +104,7 @@ mexui.Control.DropDown.prototype.renderAfter = function()
if(this.axis.y.entriesShown)
{
var pos = this.getScreenPosition();
var pos2 = new Vec2(pos.x, pos.y);
var pos2 = toVector2(pos.x, pos.y);
pos.x += this.entriesPositionOffset.x;
pos.y += this.entriesPositionOffset.y;
@@ -127,7 +127,7 @@ mexui.Control.DropDown.prototype.renderAfter = function()
}
if(this.isFocused())
mexui.native.drawRectangleBorder(mexui.util.subtractVec2(pos2,new Vec2(2,2)), mexui.util.addVec2(new Vec2(this.entrySize.x,this.axis.y.getDisplayedEntriesLength()),new Vec2(3,3)), this.getStyles('focused'));
mexui.native.drawRectangleBorder(mexui.util.subtractVec2(pos2,toVector2(2,2)), mexui.util.addVec2(toVector2(this.entrySize.x,this.axis.y.getDisplayedEntriesLength()),toVector2(3,3)), this.getStyles('focused'));
}
mexui.Entity.ControlWithEntries.prototype.renderAfter.call(this);

View File

@@ -1,7 +1,7 @@
mexui.util.createControlConstructor('Grid', true, function(window, x, y, w, h, styles)
{
mexui.Component.Control.call(this, window, x, y, w, h, this.linkControlStyles('Grid', styles));
mexui.Entity.ControlWithEntries.call(this, false, false, new Vec2(0, 25), new Vec2(this.size.x, 25), new Vec2(0, -25));
mexui.Entity.ControlWithEntries.call(this, false, false, toVector2(0, 25), toVector2(this.size.x, 25), toVector2(0, -25));
});
// default styles
@@ -39,10 +39,10 @@ mexui.Control.Grid.prototype.render = function()
{
var column = this.axis.x.entries[i];
mexui.native.drawText(new Vec2(startX, pos.y), new Vec2(column.width, column.height), column.text, this.getStyles('header'));
mexui.native.drawText(toVector2(startX, pos.y), toVector2(column.width, column.height), column.text, this.getStyles('header'));
startX += column.width;
mexui.native.drawAALine(new Vec2(startX, pos.y), new Vec2(startX, pos.y + this.size.y), this.getStyles('column'));
mexui.native.drawAALine(toVector2(startX, pos.y), toVector2(startX, pos.y + this.size.y), this.getStyles('column'));
if(column.height > maxColumnHeight)
{
@@ -51,7 +51,7 @@ mexui.Control.Grid.prototype.render = function()
}
var startY = pos.y + maxColumnHeight;
mexui.native.drawAALine(new Vec2(pos.x, startY), new Vec2(pos.x + this.size.x, startY), this.getStyles('row'));
mexui.native.drawAALine(toVector2(pos.x, startY), toVector2(pos.x + this.size.x, startY), this.getStyles('row'));
for(var i=this.axis.y.getEntryStartIndex(),j=this.axis.y.getEntryEndIndex(); i<j; i++)
{
@@ -68,18 +68,18 @@ mexui.Control.Grid.prototype.render = function()
var styles = this.getEntryStyles([[cell,'main'], [row,'main'], [this,'row'], [this,'cell']]);
mexui.native.drawRectangle(new Vec2(startX, startY), new Vec2(column.width, column.height), styles);
mexui.native.drawText(new Vec2(startX, startY), new Vec2(column.width, column.height), cellText, styles);
mexui.native.drawRectangle(toVector2(startX, startY), toVector2(column.width, column.height), styles);
mexui.native.drawText(toVector2(startX, startY), toVector2(column.width, column.height), cellText, styles);
startX += column.width;
}
startY += row.rowHeight;
mexui.native.drawAALine(new Vec2(pos.x, startY), new Vec2(pos.x + this.size.x, startY), this.getStyles('row'));
mexui.native.drawAALine(toVector2(pos.x, startY), toVector2(pos.x + this.size.x, startY), this.getStyles('row'));
}
if(this.isFocused())
mexui.native.drawRectangleBorder(mexui.util.subtractVec2(pos,new Vec2(2,2)), mexui.util.addVec2(this.size,new Vec2(3,3)), this.getStyles('focused'));
mexui.native.drawRectangleBorder(mexui.util.subtractVec2(pos,toVector2(2,2)), mexui.util.addVec2(this.size,toVector2(3,3)), this.getStyles('focused'));
};
// model

View File

@@ -16,5 +16,5 @@ mexui.Control.Image.prototype.render = function()
mexui.native.drawImage(pos, this.size, this.image, this.getStyles('main'));
if(this.isFocused())
mexui.native.drawRectangleBorder(mexui.util.subtractVec2(pos,new Vec2(2,2)), mexui.util.addVec2(this.size,new Vec2(3,3)), this.getStyles('focused'));
mexui.native.drawRectangleBorder(mexui.util.subtractVec2(pos,toVector2(2,2)), mexui.util.addVec2(this.size,toVector2(3,3)), this.getStyles('focused'));
};

View File

@@ -34,22 +34,22 @@ mexui.Control.List.prototype.onMouseDown = function(e)
mexui.Control.List.prototype.render = function()
{
var pos = this.getScreenPosition();
var pos2 = new Vec2(pos.x, pos.y);
var pos2 = toVector2(pos.x, pos.y);
for(var i in this.axis.y.entries)
{
var row = this.axis.y.entries[i];
var rowText = row.text;
mexui.native.drawRectangle(pos, new Vec2(this.size.x, this.rowHeight), this.getStyles('row'));
mexui.native.drawText(pos, new Vec2(this.size.x, this.rowHeight), rowText, this.getStyles('row'));
mexui.native.drawRectangle(pos, toVector2(this.size.x, this.rowHeight), this.getStyles('row'));
mexui.native.drawText(pos, toVector2(this.size.x, this.rowHeight), rowText, this.getStyles('row'));
pos.y += this.rowHeight;
mexui.native.drawAALine(pos, new Vec2(pos.x + this.size.x, pos.y), this.getStyles('rowLine'));
mexui.native.drawAALine(pos, toVector2(pos.x + this.size.x, pos.y), this.getStyles('rowLine'));
}
if(this.isFocused())
mexui.native.drawRectangleBorder(mexui.util.subtractVec2(pos2,new Vec2(2,2)), mexui.util.addVec2(this.size,new Vec2(3,3)), this.getStyles('focused'));
mexui.native.drawRectangleBorder(mexui.util.subtractVec2(pos2,toVector2(2,2)), mexui.util.addVec2(this.size,toVector2(3,3)), this.getStyles('focused'));
};
// model

View File

@@ -27,7 +27,7 @@ mexui.Control.ProgressBar.prototype.render = function()
mexui.native.drawRectangle(pos, this.size, this.getStyles('main'));
var innerBarSize = new Vec2(this.size.x * this.progress, this.size.y);
var innerBarSize = toVector2(this.size.x * this.progress, this.size.y);
mexui.native.drawRectangle(pos, innerBarSize, this.getStyles('innerBar'));
if(this.text != '')

View File

@@ -46,19 +46,19 @@ mexui.Control.RadioButton.prototype.render = function()
mexui.native.drawRectangle(pos, this.size, this.getStyles('main'));
if(this.checked)
mexui.native.drawRectangle(mexui.util.addVec2(pos, new Vec2(2, 2)), new Vec2(this.size.x - 4, this.size.y - 4), this.getStyles('innerBox'));
mexui.native.drawRectangle(mexui.util.addVec2(pos, toVector2(2, 2)), toVector2(this.size.x - 4, this.size.y - 4), this.getStyles('innerBox'));
mexui.native.drawText(mexui.util.addVec2(pos, new Vec2(this.size.x + this.textMarginLeft, 2)), this.size, this.text, this.getStyles('main'));
mexui.native.drawText(mexui.util.addVec2(pos, toVector2(this.size.x + this.textMarginLeft, 2)), this.size, this.text, this.getStyles('main'));
if(this.isFocused())
mexui.native.drawRectangleBorder(mexui.util.subtractVec2(pos,new Vec2(2,2)), mexui.util.addVec2(this.size,new Vec2(3,3)), this.getStyles('focused'));
mexui.native.drawRectangleBorder(mexui.util.subtractVec2(pos,toVector2(2,2)), mexui.util.addVec2(this.size,toVector2(3,3)), this.getStyles('focused'));
};
// model
mexui.Control.RadioButton.prototype.getSizeForInput = function()
{
var textWidth = mexui.native.getTextWidth(this.text, this.getStyles('main'));
return new Vec2(this.size.x + this.textMarginLeft + textWidth, this.size.y);
return toVector2(this.size.x + this.textMarginLeft + textWidth, this.size.y);
};
mexui.Control.RadioButton.prototype.getGroupRadios = function()

View File

@@ -99,7 +99,7 @@ mexui.Control.ScrollBar.prototype.clampScrolledRatio = function()
mexui.Control.ScrollBar.prototype.getInnerBarPosition = function()
{
var screenPos = this.getScreenPosition();
var pos = new Vec2(screenPos.x, screenPos.y);
var pos = toVector2(screenPos.x, screenPos.y);
var minPos = pos[this.axisIndex] + 1;
var maxPos = pos[this.axisIndex] + this.size[this.axisIndex] - 2;
@@ -110,7 +110,7 @@ mexui.Control.ScrollBar.prototype.getInnerBarPosition = function()
mexui.Control.ScrollBar.prototype.getInnerBarSize = function()
{
var size = new Vec2(this.size.x, this.size.y);
var size = toVector2(this.size.x, this.size.y);
size[this.axisIndex] = this.barHigherLength;
size[this.otherAxisIndex] -= 2;
return size;

View File

@@ -14,7 +14,7 @@ mexui.util.createControlConstructor('Slider', false, function(window, x, y, w, h
this.progress = 0.0;
this.axisIndex = isVertical ? 1 : 0;
this.innerBarSize = new Vec2(30, 25);
this.innerBarSize = toVector2(30, 25);
});
// default styles
@@ -67,7 +67,7 @@ mexui.Control.Slider.prototype.onMouseMove = function(e, offset)
mexui.Control.Slider.prototype.render = function()
{
var pos = this.getScreenPosition();
var pos2 = new Vec2(pos.x, pos.y);
var pos2 = toVector2(pos.x, pos.y);
mexui.native.drawRectangle(pos, this.size, this.getStyles('main'));
mexui.native.drawRectangle(this.getInnerBarPosition(), this.innerBarSize, this.getStyles('innerBar'));
@@ -84,7 +84,7 @@ mexui.Control.Slider.prototype.render = function()
mexui.native.drawText(pos, this.size, this.maxText, this.getStyles('maxText'));
if(this.isFocused())
mexui.native.drawRectangleBorder(mexui.util.subtractVec2(pos2,new Vec2(2,2)), mexui.util.addVec2(this.size,new Vec2(3,3)), this.getStyles('focused'));
mexui.native.drawRectangleBorder(mexui.util.subtractVec2(pos2,toVector2(2,2)), mexui.util.addVec2(this.size,toVector2(3,3)), this.getStyles('focused'));
};
// model
@@ -98,7 +98,7 @@ mexui.Control.Slider.prototype.getInnerBarPosition = function()
var pos = this.getScreenPosition();
pos[this.axisIndex] = mexui.util.interpolateScalar(pos.x, (pos.x + this.size.x) - this.innerBarSize.x, this.progress);
pos.y -= 3;
return new Vec2(pos.x, pos.y);
return toVector2(pos.x, pos.y);
};
mexui.Control.Slider.prototype.getProgressIncreaseByPixels = function(offset)

View File

@@ -35,8 +35,8 @@ mexui.Control.TabPanel.prototype.onMouseDown = function(e)
{
var tab = this.axis.x.entries[i];
var tabPos = new Vec2(tabX, pos.y);
var tabSize = new Vec2(mexui.native.getTextWidth(tab.text, this.getStyles('tab')) + 10, 25);
var tabPos = toVector2(tabX, pos.y);
var tabSize = toVector2(mexui.native.getTextWidth(tab.text, this.getStyles('tab')) + 10, 25);
if(mexui.util.isCursorInRectangle(tabPos, tabSize))
{
@@ -67,8 +67,8 @@ mexui.Control.TabPanel.prototype.render = function()
{
var tab = this.axis.x.entries[i];
var tabPos = new Vec2(tabX, pos.y);
var tabSize = new Vec2(mexui.native.getTextWidth(tab.text, this.getStyles('tab')) + 10, 25);
var tabPos = toVector2(tabX, pos.y);
var tabSize = toVector2(mexui.native.getTextWidth(tab.text, this.getStyles('tab')) + 10, 25);
mexui.native.drawRectangle(tabPos, tabSize, this.getStyles('tab'));
mexui.native.drawText(tabPos, tabSize, tab.text, this.getStyles('tab'));
@@ -76,7 +76,7 @@ mexui.Control.TabPanel.prototype.render = function()
}
if(this.isFocused())
mexui.native.drawRectangleBorder(mexui.util.subtractVec2(pos,new Vec2(2,2)), mexui.util.addVec2(this.size,new Vec2(3,3)), this.getStyles('focused'));
mexui.native.drawRectangleBorder(mexui.util.subtractVec2(pos,toVector2(2,2)), mexui.util.addVec2(this.size,toVector2(3,3)), this.getStyles('focused'));
};
// model

View File

@@ -16,5 +16,5 @@ mexui.Control.Text.prototype.render = function()
mexui.native.drawText(pos, this.size, this.text, this.getStyles('main'));
if(this.isFocused())
mexui.native.drawRectangleBorder(mexui.util.subtractVec2(pos,new Vec2(2,2)), mexui.util.addVec2(this.size,new Vec2(3,3)), this.getStyles('focused'));
mexui.native.drawRectangleBorder(mexui.util.subtractVec2(pos,toVector2(2,2)), mexui.util.addVec2(this.size,toVector2(3,3)), this.getStyles('focused'));
};

View File

@@ -8,7 +8,7 @@ mexui.util.createControlConstructor('TextInput', false, function(window, x, y, w
this.lines = text ? mexui.util.splitLines(text) : [''];
this.caretPosition = new Vec2(0, 0);
this.caretPosition = toVector2(0, 0);
this.multiLineSupported = multiLineSupported === undefined ? true : multiLineSupported;
this.multiLine = this.multiLineSupported ? mexui.util.doesContainEOLChar(text) : false;
this.masked = false;
@@ -143,7 +143,7 @@ mexui.Control.TextInput.prototype.onKeyDown = function(e, key, mods)
case SDLK_BACKSPACE:
if(this.caretPosition.x != 0)
{
this.deleteCharacter(new Vec2(this.caretPosition.x - 1, this.caretPosition.y));
this.deleteCharacter(toVector2(this.caretPosition.x - 1, this.caretPosition.y));
this.caretPosition.x--;
this.checkToCallCallback();
}
@@ -207,7 +207,7 @@ mexui.Control.TextInput.prototype.onKeyDown = function(e, key, mods)
mexui.Control.TextInput.prototype.render = function()
{
var pos = this.getScreenPosition();
var pos2 = new Vec2(pos.x, pos.y);
var pos2 = toVector2(pos.x, pos.y);
mexui.native.drawRectangle(pos, this.size, this.getStyles('main'));
@@ -217,7 +217,7 @@ mexui.Control.TextInput.prototype.render = function()
}
else
{
var lineSize = new Vec2(this.size.x, this.lineHeight);
var lineSize = toVector2(this.size.x, this.lineHeight);
for(var i=0,j=this.lines.length; i<j; i++)
{
var displayedText = this.masked ? '*'.repeat(this.lines[i].length) : this.lines[i];
@@ -232,7 +232,7 @@ mexui.Control.TextInput.prototype.render = function()
if(this.isFocused())
{
if(!valueIsInvalid)
mexui.native.drawRectangleBorder(mexui.util.subtractVec2(pos2,new Vec2(2,2)), mexui.util.addVec2(this.size,new Vec2(3,3)), this.getStyles('focused'));
mexui.native.drawRectangleBorder(mexui.util.subtractVec2(pos2,toVector2(2,2)), mexui.util.addVec2(this.size,toVector2(3,3)), this.getStyles('focused'));
if(this.caretShownForBlink)
{
@@ -240,15 +240,15 @@ mexui.Control.TextInput.prototype.render = function()
var text = this.lines[this.caretPosition.y].substr(0, this.caretPosition.x);
var displayedText = this.masked ? '*'.repeat(text.length) : text;
var textWidth = mexui.native.getTextWidth(displayedText, this.getStyles('main'));
var caretPosOffset = new Vec2(5 + textWidth, (this.caretPosition.y * this.lineHeight) + 1);
var caretPosOffset = toVector2(5 + textWidth, (this.caretPosition.y * this.lineHeight) + 1);
var caretPoint1 = mexui.util.addVec2(pos, caretPosOffset);
var caretPoint2 = new Vec2(caretPoint1.x, caretPoint1.y + 22);
var caretPoint2 = toVector2(caretPoint1.x, caretPoint1.y + 22);
mexui.native.drawAALine(caretPoint1, caretPoint2, this.getStyles('caret'));
}
}
if(valueIsInvalid)
mexui.native.drawRectangleBorder(mexui.util.subtractVec2(pos2,new Vec2(2,2)), mexui.util.addVec2(this.size,new Vec2(3,3)), this.getStyles('invalidValue'));
mexui.native.drawRectangleBorder(mexui.util.subtractVec2(pos2,toVector2(2,2)), mexui.util.addVec2(this.size,toVector2(3,3)), this.getStyles('invalidValue'));
};
// model
@@ -280,7 +280,7 @@ mexui.Control.TextInput.prototype.getCaretPositionByCursor = function()
{
var lineIndex = this.getCaretLineIndexByCursor();
var charIndex = this.getCharIndexByCursor(lineIndex);
return new Vec2(charIndex, lineIndex);
return toVector2(charIndex, lineIndex);
};
mexui.Control.TextInput.prototype.getCaretLineIndexByCursor = function()

View File

@@ -7,8 +7,8 @@ mexui.util.createControlConstructor('Time', false, function(window, x, y, w, h,
this.second = 0;
this.inputShown = false;
this.valueBoxSize = new Vec2(50, 30);
this.arrowBoxSize = new Vec2(25, 22);
this.valueBoxSize = toVector2(50, 30);
this.arrowBoxSize = toVector2(25, 22);
});
mexui.util.extend(mexui.Control.Time, mexui.Control.TextInput);
@@ -74,7 +74,7 @@ mexui.Control.Time.prototype.renderAfter = function()
var screenPos = this.getScreenPosition();
var pos = new Vec2(screenPos.x, screenPos.y);
var pos = toVector2(screenPos.x, screenPos.y);
for(var i=0; i<3; i++)
{
mexui.native.drawRectangle(pos, this.valueBoxSize, this.getStyles('main'));
@@ -83,7 +83,7 @@ mexui.Control.Time.prototype.renderAfter = function()
pos.x += this.valueBoxSize.x;
}
pos = new Vec2(screenPos.x, screenPos.y);
pos = toVector2(screenPos.x, screenPos.y);
pos.y += this.valueBoxSize.y;
for(var i=0; i<3; i++)
{
@@ -148,8 +148,8 @@ mexui.Control.Time.prototype.getArrowIndexByCursor = function()
var cursorPos = gui.cursorPosition;
var screenPos = this.getScreenPosition();
var firstArrowStartPos = new Vec2(screenPos.x, screenPos.y + this.valueBoxSize.y);
var lastArrowEndPos = new Vec2(screenPos.x + (this.arrowBoxSize.x * 6), screenPos.y + this.valueBoxSize.y + this.arrowBoxSize.y);
var firstArrowStartPos = toVector2(screenPos.x, screenPos.y + this.valueBoxSize.y);
var lastArrowEndPos = toVector2(screenPos.x + (this.arrowBoxSize.x * 6), screenPos.y + this.valueBoxSize.y + this.arrowBoxSize.y);
if(cursorPos.x >= firstArrowStartPos.x && cursorPos.y >= firstArrowStartPos.y && cursorPos.x <= lastArrowEndPos.x && cursorPos.y <= lastArrowEndPos.y)
{

View File

@@ -49,7 +49,7 @@ mexui.Control.Tree.prototype.render = function()
this.renderRows(this.axis.y.entries, 0, pos);
if(this.isFocused())
mexui.native.drawRectangleBorder(mexui.util.subtractVec2(pos,new Vec2(2,2)), mexui.util.addVec2(this.size,new Vec2(3,3)), this.getStyles('focused'));
mexui.native.drawRectangleBorder(mexui.util.subtractVec2(pos,toVector2(2,2)), mexui.util.addVec2(this.size,toVector2(3,3)), this.getStyles('focused'));
};
mexui.Control.Tree.prototype.renderRows = function(rows, level, pos)
@@ -62,17 +62,17 @@ mexui.Control.Tree.prototype.renderRows = function(rows, level, pos)
if(shouldDraw)
{
if(row.rows.length > 0)
mexui.native.drawText(new Vec2(pos.x - (this.rowLevelIndentation * 2), pos.y), new Vec2(this.size.x, this.rowHeight), row.open ? '-' : '+', this.getStyles('rowIcon'));
mexui.native.drawText(toVector2(pos.x - (this.rowLevelIndentation * 2), pos.y), toVector2(this.size.x, this.rowHeight), row.open ? '-' : '+', this.getStyles('rowIcon'));
mexui.native.drawRectangle(pos, new Vec2(this.size.x - (this.rowLevelIndentation * level), this.rowHeight), this.getStyles('row'));
mexui.native.drawText(pos, new Vec2(this.size.x, this.rowHeight), row.text, this.getStyles('row'));
mexui.native.drawRectangle(pos, toVector2(this.size.x - (this.rowLevelIndentation * level), this.rowHeight), this.getStyles('row'));
mexui.native.drawText(pos, toVector2(this.size.x, this.rowHeight), row.text, this.getStyles('row'));
}
pos.y += this.rowHeight;
if(shouldDraw)
{
mexui.native.drawAALine(pos, new Vec2(pos.x + this.size.x, pos.y), this.getStyles('rowLine'));
mexui.native.drawAALine(pos, toVector2(pos.x + this.size.x, pos.y), this.getStyles('rowLine'));
}
if(row.rows.length > 0 && row.open)
@@ -107,8 +107,8 @@ mexui.Control.Tree.prototype.testRowClick = function(e, rows, pos)
{
var row = rows[i];
var rowPos = new Vec2(pos.x - (this.rowLevelIndentation * 2), pos.y);
var rowSize = new Vec2(this.size.x + (this.rowLevelIndentation * 2), this.rowHeight);
var rowPos = toVector2(pos.x - (this.rowLevelIndentation * 2), pos.y);
var rowSize = toVector2(this.size.x + (this.rowLevelIndentation * 2), this.rowHeight);
if(mexui.util.isCursorInRectangle(rowPos, rowSize))
{
this.onClickRow(row);