MexUI stuff
This commit is contained in:
6
third-party/mexui/Core/Control/Button.js
vendored
6
third-party/mexui/Core/Control/Button.js
vendored
@@ -1,7 +1,7 @@
|
||||
mexui.util.createControlConstructor('Button', false, function(window, x, y, w, h, text, styles, callback)
|
||||
{
|
||||
mexui.Component.Control.call(this, window, x, y, w, h, this.linkControlStyles('Button', styles), callback);
|
||||
|
||||
|
||||
this.text = text;
|
||||
});
|
||||
|
||||
@@ -31,10 +31,10 @@ mexui.Control.Button.prototype.onKeyDown = function(e, key, mods)
|
||||
mexui.Control.Button.prototype.render = function()
|
||||
{
|
||||
var pos = this.getScreenPosition();
|
||||
|
||||
|
||||
mexui.native.drawRectangle(pos, this.size, this.getStyles('main'));
|
||||
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'));
|
||||
};
|
||||
46
third-party/mexui/Core/Control/Date.js
vendored
46
third-party/mexui/Core/Control/Date.js
vendored
@@ -1,15 +1,15 @@
|
||||
mexui.util.createControlConstructor('Date', false, function(window, x, y, w, h, text, styles, callback)
|
||||
{
|
||||
mexui.Control.TextInput.call(this, window, x, y, w, h, text, this.linkControlStyles('Date', styles), callback, false, false);
|
||||
|
||||
|
||||
this.day = 1;
|
||||
this.month = 1;
|
||||
this.year = 2019;
|
||||
|
||||
|
||||
this.inputShown = false;
|
||||
this.valueBoxSize = new Vec2(50, 30);
|
||||
this.arrowBoxSize = new Vec2(25, 22);
|
||||
|
||||
|
||||
this.maxYearOffset = 10;
|
||||
this.minYearCallback = ()=>{ return 1900; };
|
||||
this.maxYearCallback = ()=>{ return new Date().getFullYear() + this.maxYearOffset; }
|
||||
@@ -40,42 +40,42 @@ mexui.Control.Date.prototype.onMouseDown = function(e)
|
||||
var propIndex = (Math.ceil((arrowIndex + 1) / 2)) - 1;
|
||||
var propName = mexui.Control.Date.units[propIndex];
|
||||
var isIncrease = (arrowIndex % 2) == 1;
|
||||
|
||||
|
||||
if(isIncrease)
|
||||
this[propName]++;
|
||||
else
|
||||
this[propName]--;
|
||||
|
||||
|
||||
if(this.day == 0)
|
||||
this.day = 31;
|
||||
else if(this.day == 32)
|
||||
this.day = 1;
|
||||
|
||||
|
||||
if(this.month == 0)
|
||||
this.month = 12;
|
||||
else if(this.month == 13)
|
||||
this.month = 1;
|
||||
|
||||
|
||||
var minYear = this.minYearCallback();
|
||||
var maxYear = this.maxYearCallback();
|
||||
if(this.year < minYear)
|
||||
this.year = minYear;
|
||||
else if(this.year > maxYear)
|
||||
this.year = maxYear;
|
||||
|
||||
|
||||
this.generateText();
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(this.isCursorOverControl())
|
||||
{
|
||||
this.inputShown = !this.inputShown;
|
||||
e.used = true;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if(this.inputShown)
|
||||
{
|
||||
this.inputShown = false;
|
||||
@@ -89,18 +89,18 @@ mexui.Control.Date.prototype.renderAfter = function()
|
||||
{
|
||||
if(!this.inputShown)
|
||||
return;
|
||||
|
||||
|
||||
var screenPos = this.getScreenPosition();
|
||||
|
||||
|
||||
var pos = new Vec2(screenPos.x, screenPos.y);
|
||||
for(var i=0; i<3; i++)
|
||||
{
|
||||
mexui.native.drawRectangle(pos, this.valueBoxSize, this.getStyles('main'));
|
||||
mexui.native.drawText(pos, this.valueBoxSize, this[mexui.Control.Date.units[i]], this.getStyles('main'));
|
||||
|
||||
|
||||
pos.x += this.valueBoxSize.x;
|
||||
}
|
||||
|
||||
|
||||
pos = new Vec2(screenPos.x, screenPos.y);
|
||||
pos.y += this.valueBoxSize.y;
|
||||
for(var i=0; i<3; i++)
|
||||
@@ -108,10 +108,10 @@ mexui.Control.Date.prototype.renderAfter = function()
|
||||
for(var i2=0; i2<2; i2++)
|
||||
{
|
||||
var text = (i2 % 2) == 0 ? '<' : '>';
|
||||
|
||||
|
||||
mexui.native.drawRectangle(pos, this.arrowBoxSize, this.getStyles('main'));
|
||||
mexui.native.drawText(pos, this.arrowBoxSize, text, this.getStyles('main'));
|
||||
|
||||
|
||||
pos.x += this.arrowBoxSize.x;
|
||||
}
|
||||
}
|
||||
@@ -133,16 +133,16 @@ mexui.Control.Date.prototype.validateInputCallback = function(e, character)
|
||||
mexui.Control.Date.prototype.validateValueCallback = function(e)
|
||||
{
|
||||
var parts = this.getText().split('/');
|
||||
|
||||
|
||||
if(parts.length != 3)
|
||||
return false;
|
||||
|
||||
|
||||
for(var i in parts)
|
||||
{
|
||||
var partAsStr = parts[i];
|
||||
if(partAsStr === '')
|
||||
return false;
|
||||
|
||||
|
||||
if(i == 0)
|
||||
{
|
||||
if(!mexui.util.isDayIdWithOptionalSuffix(partAsStr))
|
||||
@@ -159,18 +159,18 @@ mexui.Control.Date.prototype.validateValueCallback = function(e)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
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);
|
||||
|
||||
|
||||
if(cursorPos.x >= firstArrowStartPos.x && cursorPos.y >= firstArrowStartPos.y && cursorPos.x <= lastArrowEndPos.x && cursorPos.y <= lastArrowEndPos.y)
|
||||
{
|
||||
return Math.floor((cursorPos.x - firstArrowStartPos.x) / this.arrowBoxSize.x);
|
||||
|
||||
38
third-party/mexui/Core/Control/DropDown.js
vendored
38
third-party/mexui/Core/Control/DropDown.js
vendored
@@ -2,11 +2,11 @@ mexui.util.createControlConstructor('DropDown', true, function(window, x, y, w,
|
||||
{
|
||||
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));
|
||||
|
||||
|
||||
this.axis.y.entriesShown = false;
|
||||
|
||||
|
||||
this.text = text;
|
||||
|
||||
|
||||
this.arrowShown = true;
|
||||
this.selectedEntryIndex = -1;
|
||||
this.hoveredEntryIndex = -1;
|
||||
@@ -18,7 +18,7 @@ mexui.util.linkBaseControlStyles('DropDown', {
|
||||
{
|
||||
backgroundColour: toColour(255, 255, 255, 255),
|
||||
textColour: toColour(0, 0, 0, 255),
|
||||
|
||||
|
||||
hover:
|
||||
{
|
||||
backgroundColour: toColour(80, 80, 80, 255),
|
||||
@@ -34,7 +34,7 @@ mexui.Control.DropDown.prototype.onMouseDown = function(e)
|
||||
{
|
||||
if(this.axis.y.entries.length == 0)
|
||||
return;
|
||||
|
||||
|
||||
var hitButton = this.isCursorOverControl();
|
||||
if(hitButton)
|
||||
{
|
||||
@@ -51,7 +51,7 @@ mexui.Control.DropDown.prototype.onMouseDown = function(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(!e.used)
|
||||
mexui.Entity.ControlWithEntries.prototype.onMouseDown.call(this, e);
|
||||
};
|
||||
@@ -81,20 +81,20 @@ mexui.Control.DropDown.prototype.onKeyDown = function(e, key, mods)
|
||||
mexui.Control.DropDown.prototype.render = function()
|
||||
{
|
||||
var pos = this.getScreenPosition();
|
||||
|
||||
|
||||
mexui.native.drawRectangle(pos, this.size, this.getStyles('main'));
|
||||
|
||||
|
||||
var text = this.selectedEntryIndex == -1 ? this.text : this.axis.y.entries[this.selectedEntryIndex].text;
|
||||
mexui.native.drawText(pos, this.size, text, this.getStyles('main'));
|
||||
|
||||
|
||||
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'));
|
||||
}
|
||||
|
||||
|
||||
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'));
|
||||
};
|
||||
@@ -105,31 +105,31 @@ mexui.Control.DropDown.prototype.renderAfter = function()
|
||||
{
|
||||
var pos = this.getScreenPosition();
|
||||
var pos2 = new Vec2(pos.x, pos.y);
|
||||
|
||||
|
||||
pos.x += this.entriesPositionOffset.x;
|
||||
pos.y += this.entriesPositionOffset.y;
|
||||
|
||||
|
||||
pos2.x += this.entriesPositionOffset.x;
|
||||
pos2.y += this.entriesPositionOffset.y;
|
||||
|
||||
|
||||
for(var i=this.axis.y.getEntryStartIndex(),j=this.axis.y.getEntryEndIndex(); i<j; i++)
|
||||
{
|
||||
var item = this.axis.y.entries[i];
|
||||
if(!item)
|
||||
break;
|
||||
|
||||
|
||||
//this.hovered = i == this.axis.y.hoveredEntryIndex;
|
||||
|
||||
|
||||
mexui.native.drawRectangle(pos, this.entrySize, this.getStyles('item'));
|
||||
mexui.native.drawText(pos, this.entrySize, item.text, this.getStyles('item'));
|
||||
|
||||
|
||||
pos.y += this.entrySize.y;
|
||||
}
|
||||
|
||||
|
||||
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.Entity.ControlWithEntries.prototype.renderAfter.call(this);
|
||||
};
|
||||
|
||||
|
||||
29
third-party/mexui/Core/Control/Grid.js
vendored
29
third-party/mexui/Core/Control/Grid.js
vendored
@@ -30,54 +30,54 @@ mexui.util.linkBaseControlStyles('Grid', {
|
||||
mexui.Control.Grid.prototype.render = function()
|
||||
{
|
||||
var pos = this.getScreenPosition();
|
||||
|
||||
|
||||
mexui.native.drawRectangle(pos, this.size, this.getStyles('main'));
|
||||
|
||||
|
||||
var startX = pos.x;
|
||||
var maxColumnHeight = 0;
|
||||
for(var i in this.axis.x.entries)
|
||||
{
|
||||
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'));
|
||||
|
||||
|
||||
startX += column.width;
|
||||
mexui.native.drawAALine(new Vec2(startX, pos.y), new Vec2(startX, pos.y + this.size.y), this.getStyles('column'));
|
||||
|
||||
|
||||
if(column.height > maxColumnHeight)
|
||||
{
|
||||
maxColumnHeight = column.height;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var startY = pos.y + maxColumnHeight;
|
||||
mexui.native.drawAALine(new Vec2(pos.x, startY), new Vec2(pos.x + this.size.x, startY), this.getStyles('row'));
|
||||
|
||||
|
||||
for(var i=this.axis.y.getEntryStartIndex(),j=this.axis.y.getEntryEndIndex(); i<j; i++)
|
||||
{
|
||||
var row = this.axis.y.entries[i];
|
||||
if(!row)
|
||||
break;
|
||||
|
||||
|
||||
startX = pos.x;
|
||||
for(var i2 in row.cells)
|
||||
{
|
||||
var column = this.axis.x.entries[i2];
|
||||
var cell = row.cells[i2];
|
||||
var cellText = cell.text;
|
||||
|
||||
|
||||
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);
|
||||
|
||||
|
||||
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'));
|
||||
}
|
||||
|
||||
|
||||
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'));
|
||||
};
|
||||
@@ -104,7 +104,7 @@ mexui.Control.Grid.prototype.row = function(cellsData, styles)
|
||||
cells[i] = new mexui.Component.Entry(this, 1, cellsData[i] + '');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var entry = new mexui.Entry.GridRow(this, cells, styles);
|
||||
this.axis.y.addEntry(entry);
|
||||
return entry;
|
||||
@@ -127,3 +127,4 @@ mexui.Control.Grid.prototype.getAllEntriesLength = function(axisIndex)
|
||||
return this.axis.y.getAllEntriesLength2();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
4
third-party/mexui/Core/Control/Hour.js
vendored
4
third-party/mexui/Core/Control/Hour.js
vendored
@@ -13,9 +13,9 @@ mexui.Control.Hour.prototype.validateInputCallback = function(e, character)
|
||||
mexui.Control.Hour.prototype.validateValueCallback = function(e)
|
||||
{
|
||||
var _int = parseInt(this.getText());
|
||||
|
||||
|
||||
if(_int < 1 || _int > 23)
|
||||
return false;
|
||||
|
||||
|
||||
return true;
|
||||
};
|
||||
37
third-party/mexui/Core/Control/Image.js
vendored
37
third-party/mexui/Core/Control/Image.js
vendored
@@ -1,24 +1,13 @@
|
||||
mexui.util.createControlConstructor('Image', false, function(window, x, y, w, h, filePath, styles)
|
||||
mexui.util.createControlConstructor('Image', false, function(window, x, y, w, h, filePath, styles, callback)
|
||||
{
|
||||
mexui.Component.Control.call(this, window, x, y, w, h, this.linkControlStyles('Image', styles));
|
||||
|
||||
mexui.Component.Control.call(this, window, x, y, w, h, this.linkControlStyles('Image', styles), callback);
|
||||
|
||||
this.image = mexui.native.loadImage(filePath);
|
||||
});
|
||||
|
||||
// default styles
|
||||
mexui.util.linkBaseControlStyles('Image', {});
|
||||
|
||||
// render
|
||||
mexui.Control.Image.prototype.render = function()
|
||||
{
|
||||
var pos = this.getScreenPosition();
|
||||
|
||||
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'));
|
||||
};
|
||||
|
||||
// input
|
||||
mexui.Control.Image.prototype.onMouseDown = function(e)
|
||||
{
|
||||
@@ -27,4 +16,24 @@ mexui.Control.Image.prototype.onMouseDown = function(e)
|
||||
e.used = true;
|
||||
this.checkToCallCallback();
|
||||
}
|
||||
};
|
||||
|
||||
mexui.Control.Image.prototype.onKeyDown = function(e, key, mods)
|
||||
{
|
||||
if(this.isFocused() && (key == SDLK_RETURN || key == SDLK_RETURN2 || key == SDLK_KP_ENTER || key == SDLK_SPACE))
|
||||
{
|
||||
e.used = true;
|
||||
this.checkToCallCallback();
|
||||
}
|
||||
};
|
||||
|
||||
// render
|
||||
mexui.Control.Image.prototype.render = function()
|
||||
{
|
||||
var pos = this.getScreenPosition();
|
||||
|
||||
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'));
|
||||
};
|
||||
11
third-party/mexui/Core/Control/List.js
vendored
11
third-party/mexui/Core/Control/List.js
vendored
@@ -2,7 +2,7 @@ mexui.util.createControlConstructor('List', true, function(window, x, y, w, h, s
|
||||
{
|
||||
mexui.Component.Control.call(this, window, x, y, w, h, this.linkControlStyles('List', styles), callback);
|
||||
mexui.Entity.ControlWithEntries.call(this, false, false);
|
||||
|
||||
|
||||
this.activeRow = null;
|
||||
this.rowHeight = 25;
|
||||
});
|
||||
@@ -35,19 +35,19 @@ mexui.Control.List.prototype.render = function()
|
||||
{
|
||||
var pos = this.getScreenPosition();
|
||||
var pos2 = new Vec2(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'));
|
||||
|
||||
|
||||
pos.y += this.rowHeight;
|
||||
mexui.native.drawAALine(pos, new Vec2(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'));
|
||||
};
|
||||
@@ -59,3 +59,4 @@ mexui.Control.List.prototype.row = function(text)
|
||||
this.axis.y.addEntry(entry);
|
||||
return entry;
|
||||
};
|
||||
|
||||
|
||||
4
third-party/mexui/Core/Control/Minute.js
vendored
4
third-party/mexui/Core/Control/Minute.js
vendored
@@ -13,9 +13,9 @@ mexui.Control.Minute.prototype.validateInputCallback = function(e, character)
|
||||
mexui.Control.Minute.prototype.validateValueCallback = function(e)
|
||||
{
|
||||
var _int = parseInt(this.getText());
|
||||
|
||||
|
||||
if(_int < 1 || _int > 59)
|
||||
return false;
|
||||
|
||||
|
||||
return true;
|
||||
};
|
||||
2
third-party/mexui/Core/Control/Password.js
vendored
2
third-party/mexui/Core/Control/Password.js
vendored
@@ -1,7 +1,7 @@
|
||||
mexui.util.createControlConstructor('Password', false, function(window, x, y, w, h, text, styles, callback)
|
||||
{
|
||||
mexui.Control.TextInput.call(this, window, x, y, w, h, text, this.linkControlStyles('Password', styles), callback, false, true);
|
||||
|
||||
|
||||
this.masked = true;
|
||||
});
|
||||
mexui.util.extend(mexui.Control.Password, mexui.Control.TextInput);
|
||||
12
third-party/mexui/Core/Control/ProgressBar.js
vendored
12
third-party/mexui/Core/Control/ProgressBar.js
vendored
@@ -1,9 +1,9 @@
|
||||
mexui.util.createControlConstructor('ProgressBar', false, function(window, x, y, w, h, text, styles)
|
||||
{
|
||||
mexui.Component.Control.call(this, window, x, y, w, h, this.linkControlStyles('ProgressBar', styles));
|
||||
|
||||
|
||||
this.text = text;
|
||||
|
||||
|
||||
this.progress = 0.0;
|
||||
});
|
||||
|
||||
@@ -12,7 +12,7 @@ mexui.util.linkBaseControlStyles('ProgressBar', {
|
||||
innerBar:
|
||||
{
|
||||
backgroundColour: toColour(0, 255, 0, 255),
|
||||
|
||||
|
||||
hover:
|
||||
{
|
||||
backgroundColour: toColour(80, 255, 0, 255)
|
||||
@@ -24,12 +24,12 @@ mexui.util.linkBaseControlStyles('ProgressBar', {
|
||||
mexui.Control.ProgressBar.prototype.render = function()
|
||||
{
|
||||
var pos = this.getScreenPosition();
|
||||
|
||||
|
||||
mexui.native.drawRectangle(pos, this.size, this.getStyles('main'));
|
||||
|
||||
|
||||
var innerBarSize = new Vec2(this.size.x * this.progress, this.size.y);
|
||||
mexui.native.drawRectangle(pos, innerBarSize, this.getStyles('innerBar'));
|
||||
|
||||
|
||||
if(this.text != '')
|
||||
mexui.native.drawText(pos, this.size, this.text, this.getStyles('main'));
|
||||
};
|
||||
18
third-party/mexui/Core/Control/RadioButton.js
vendored
18
third-party/mexui/Core/Control/RadioButton.js
vendored
@@ -1,10 +1,10 @@
|
||||
mexui.util.createControlConstructor('RadioButton', false, function(window, x, y, w, h, groupId, text, styles, callback)
|
||||
{
|
||||
mexui.Component.Control.call(this, window, x, y, w, h, this.linkControlStyles('RadioButton', styles), callback);
|
||||
|
||||
|
||||
this.groupId = groupId;
|
||||
this.text = text;
|
||||
|
||||
|
||||
this.checked = this.isFirstRadioInGroup();
|
||||
this.textMarginLeft = 5;
|
||||
});
|
||||
@@ -42,14 +42,14 @@ mexui.Control.RadioButton.prototype.onKeyDown = function(e, key, mods)
|
||||
mexui.Control.RadioButton.prototype.render = function()
|
||||
{
|
||||
var pos = this.getScreenPosition();
|
||||
|
||||
|
||||
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.drawText(mexui.util.addVec2(pos, new Vec2(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'));
|
||||
};
|
||||
@@ -68,11 +68,11 @@ mexui.Control.RadioButton.prototype.getGroupRadios = function()
|
||||
for(var i in windows)
|
||||
{
|
||||
var window = mexui.windows[i];
|
||||
|
||||
|
||||
for(var i2 in window.controls)
|
||||
{
|
||||
var control = window.controls[i2];
|
||||
|
||||
|
||||
if((control instanceof mexui.Control.RadioButton) && this.groupId == control.groupId)
|
||||
{
|
||||
radios.push(control);
|
||||
@@ -103,7 +103,7 @@ mexui.Control.RadioButton.prototype.setChecked = function()
|
||||
var checkedRadio = this.getCheckedRadio();
|
||||
if(checkedRadio != this.checked)
|
||||
checkedRadio.checked = false;
|
||||
|
||||
|
||||
this.checked = !this.checked;
|
||||
this.checkToCallCallback();
|
||||
};
|
||||
@@ -1,7 +1,7 @@
|
||||
mexui.util.createControlConstructor('RangedInteger', false, function(window, x, y, w, h, min, max, text, styles, callback)
|
||||
{
|
||||
mexui.Control.TextInput.call(this, window, x, y, w, h, text, this.linkControlStyles('RangedInteger', styles), callback, false, false);
|
||||
|
||||
|
||||
this.min = min === undefined ? 0 : min;
|
||||
this.max = max === undefined ? 100 : max;
|
||||
});
|
||||
@@ -18,7 +18,7 @@ mexui.Control.RangedInteger.prototype.validateValueCallback = function(e)
|
||||
var text = this.getText();
|
||||
if(!mexui.util.isInt(text))
|
||||
return false;
|
||||
|
||||
|
||||
var _int = parseInt(text);
|
||||
return _int >= this.min && _int <= this.max;
|
||||
};
|
||||
@@ -1,7 +1,7 @@
|
||||
mexui.util.createControlConstructor('RangedNumber', false, function(window, x, y, w, h, min, max, text, styles, callback)
|
||||
{
|
||||
mexui.Control.TextInput.call(this, window, x, y, w, h, text, this.linkControlStyles('RangedNumber', styles), callback, false, false);
|
||||
|
||||
|
||||
this.min = min === undefined ? 0.0 : min;
|
||||
this.max = max === undefined ? 100.0 : max;
|
||||
});
|
||||
@@ -18,7 +18,7 @@ mexui.Control.RangedNumber.prototype.validateValueCallback = function(e)
|
||||
var text = this.getText();
|
||||
if(!mexui.util.isFloat(text))
|
||||
return false;
|
||||
|
||||
|
||||
var number = parseFloat(text);
|
||||
return number >= this.min && number <= this.max;
|
||||
};
|
||||
12
third-party/mexui/Core/Control/ScrollBar.js
vendored
12
third-party/mexui/Core/Control/ScrollBar.js
vendored
@@ -1,11 +1,11 @@
|
||||
mexui.util.createControlConstructor('ScrollBar', false, function(window, x, y, w, h, isVertical, styles, callback)
|
||||
{
|
||||
mexui.Component.Control.call(this, window, x, y, w, h, this.linkControlStyles('ScrollBar', styles), callback);
|
||||
|
||||
|
||||
this.isVertical = isVertical;
|
||||
this.axisIndex = isVertical ? 1 : 0;
|
||||
this.otherAxisIndex = isVertical ? 0 : 1;
|
||||
|
||||
|
||||
this.barHigherLength = 50;
|
||||
this.scrolledRatio = 0.0;
|
||||
this.isScrolling = false;
|
||||
@@ -16,7 +16,7 @@ mexui.util.linkBaseControlStyles('ScrollBar', {
|
||||
main:
|
||||
{
|
||||
backgroundColour: toColour(0, 0, 0, 190),
|
||||
|
||||
|
||||
hover:
|
||||
{
|
||||
backgroundColour: toColour(0, 0, 0, 150)
|
||||
@@ -25,7 +25,7 @@ mexui.util.linkBaseControlStyles('ScrollBar', {
|
||||
innerBar:
|
||||
{
|
||||
backgroundColour: toColour(79, 161, 246, 190),
|
||||
|
||||
|
||||
hover:
|
||||
{
|
||||
backgroundColour: toColour(79, 161, 246, 150)
|
||||
@@ -69,7 +69,7 @@ mexui.Control.ScrollBar.prototype.onMouseMove = function(e, offset)
|
||||
this.clampScrolledRatio();
|
||||
e.used = true;
|
||||
}
|
||||
|
||||
|
||||
if(!e.used)
|
||||
mexui.Component.Control.prototype.onMouseMove.call(this, e, offset);
|
||||
};
|
||||
@@ -100,7 +100,7 @@ mexui.Control.ScrollBar.prototype.getInnerBarPosition = function()
|
||||
{
|
||||
var screenPos = this.getScreenPosition();
|
||||
var pos = new Vec2(screenPos.x, screenPos.y);
|
||||
|
||||
|
||||
var minPos = pos[this.axisIndex] + 1;
|
||||
var maxPos = pos[this.axisIndex] + this.size[this.axisIndex] - 2;
|
||||
pos[this.axisIndex] = minPos + (this.scrolledRatio * (maxPos - minPos - this.barHigherLength));
|
||||
|
||||
4
third-party/mexui/Core/Control/Second.js
vendored
4
third-party/mexui/Core/Control/Second.js
vendored
@@ -13,9 +13,9 @@ mexui.Control.Second.prototype.validateInputCallback = function(e, character)
|
||||
mexui.Control.Second.prototype.validateValueCallback = function(e)
|
||||
{
|
||||
var _int = parseInt(this.getText());
|
||||
|
||||
|
||||
if(_int < 1 || _int > 59)
|
||||
return false;
|
||||
|
||||
|
||||
return true;
|
||||
};
|
||||
19
third-party/mexui/Core/Control/Slider.js
vendored
19
third-party/mexui/Core/Control/Slider.js
vendored
@@ -4,14 +4,14 @@ mexui.util.createControlConstructor('Slider', false, function(window, x, y, w, h
|
||||
text = text === undefined ? '' : text;
|
||||
minText = minText === undefined ? '' : minText;
|
||||
maxText = maxText === undefined ? '' : maxText;
|
||||
|
||||
|
||||
mexui.Component.Control.call(this, window, x, y, w, h, this.linkControlStyles('Slider', styles), callback);
|
||||
|
||||
|
||||
this.isVertical = isVertical;
|
||||
this.text = text;
|
||||
this.minText = minText;
|
||||
this.maxText = maxText;
|
||||
|
||||
|
||||
this.progress = 0.0;
|
||||
this.axisIndex = isVertical ? 1 : 0;
|
||||
this.innerBarSize = new Vec2(30, 25);
|
||||
@@ -57,7 +57,7 @@ mexui.Control.Slider.prototype.onMouseMove = function(e, offset)
|
||||
{
|
||||
if(!this.sliding)
|
||||
return false;
|
||||
|
||||
|
||||
this.progress += this.getProgressIncreaseByPixels(offset);
|
||||
this.clampProgress();
|
||||
e.used = true;
|
||||
@@ -68,21 +68,21 @@ mexui.Control.Slider.prototype.render = function()
|
||||
{
|
||||
var pos = this.getScreenPosition();
|
||||
var pos2 = new Vec2(pos.x, pos.y);
|
||||
|
||||
|
||||
mexui.native.drawRectangle(pos, this.size, this.getStyles('main'));
|
||||
mexui.native.drawRectangle(this.getInnerBarPosition(), this.innerBarSize, this.getStyles('innerBar'));
|
||||
|
||||
|
||||
pos.y += this.size.y;
|
||||
mexui.native.drawText(pos, this.size, this.minText, this.getStyles('minText'));
|
||||
|
||||
|
||||
var offset = (this.size.x - mexui.native.getTextWidth(this.text, this.getStyles('main'))) / 2;
|
||||
pos.x += offset;
|
||||
mexui.native.drawText(pos, this.size, this.text, this.getStyles('main'));
|
||||
pos.x -= offset;
|
||||
|
||||
|
||||
pos.x += this.size.x - mexui.native.getTextWidth(this.maxText, this.getStyles('maxText'));
|
||||
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'));
|
||||
};
|
||||
@@ -113,3 +113,4 @@ mexui.Control.Slider.prototype.clampProgress = function()
|
||||
else if(this.progress > 1.0)
|
||||
this.progress = 1.0;
|
||||
};
|
||||
|
||||
|
||||
24
third-party/mexui/Core/Control/TabPanel.js
vendored
24
third-party/mexui/Core/Control/TabPanel.js
vendored
@@ -2,7 +2,7 @@ mexui.util.createControlConstructor('TabPanel', true, function(window, x, y, w,
|
||||
{
|
||||
mexui.Component.Control.call(this, window, x, y, w, h, this.linkControlStyles('TabPanel', styles));
|
||||
mexui.Entity.ControlWithEntries.call(this, false, false);
|
||||
|
||||
|
||||
this.activeTabIndex = 0;
|
||||
});
|
||||
|
||||
@@ -13,7 +13,7 @@ mexui.util.linkBaseControlStyles('TabPanel', {
|
||||
backgroundColour: toColour(240, 20, 20, 200),
|
||||
borderColour: toColour(120, 20, 20, 225),
|
||||
textColour: toColour(0, 0, 0, 255),
|
||||
|
||||
|
||||
hover:
|
||||
{
|
||||
backgroundColour: toColour(240, 20, 20, 150),
|
||||
@@ -29,24 +29,24 @@ mexui.Control.TabPanel.prototype.onMouseDown = function(e)
|
||||
if(e.button == 0)
|
||||
{
|
||||
var pos = this.getScreenPosition();
|
||||
|
||||
|
||||
var tabX = pos.x;
|
||||
for(var i in this.axis.x.entries)
|
||||
{
|
||||
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);
|
||||
|
||||
|
||||
if(mexui.util.isCursorInRectangle(tabPos, tabSize))
|
||||
{
|
||||
tab.setActive();
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
tabX += tabSize.x;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
var tab = this.axis.x.getEntryByCursor();
|
||||
if(tab)
|
||||
@@ -59,22 +59,22 @@ mexui.Control.TabPanel.prototype.onMouseDown = function(e)
|
||||
mexui.Control.TabPanel.prototype.render = function()
|
||||
{
|
||||
var pos = this.getScreenPosition();
|
||||
|
||||
|
||||
mexui.native.drawRectangle(pos, this.size, this.getStyles('main'));
|
||||
|
||||
|
||||
var tabX = pos.x;
|
||||
for(var i in this.axis.x.entries)
|
||||
{
|
||||
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);
|
||||
mexui.native.drawRectangle(tabPos, tabSize, this.getStyles('tab'));
|
||||
mexui.native.drawText(tabPos, tabSize, tab.text, this.getStyles('tab'));
|
||||
|
||||
|
||||
tabX += tabSize.x;
|
||||
}
|
||||
|
||||
|
||||
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'));
|
||||
};
|
||||
|
||||
6
third-party/mexui/Core/Control/Text.js
vendored
6
third-party/mexui/Core/Control/Text.js
vendored
@@ -1,7 +1,7 @@
|
||||
mexui.util.createControlConstructor('Text', false, function(window, x, y, w, h, text, styles)
|
||||
{
|
||||
mexui.Component.Control.call(this, window, x, y, w, h, this.linkControlStyles('Text', styles));
|
||||
|
||||
|
||||
this.text = text;
|
||||
});
|
||||
|
||||
@@ -12,9 +12,9 @@ mexui.util.linkBaseControlStyles('Text', {});
|
||||
mexui.Control.Text.prototype.render = function()
|
||||
{
|
||||
var pos = this.getScreenPosition();
|
||||
|
||||
|
||||
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'));
|
||||
};
|
||||
2
third-party/mexui/Core/Control/TextArea.js
vendored
2
third-party/mexui/Core/Control/TextArea.js
vendored
@@ -1,7 +1,7 @@
|
||||
mexui.util.createControlConstructor('TextArea', false, function(window, x, y, w, h, text, styles, callback)
|
||||
{
|
||||
mexui.Control.TextInput.call(this, window, x, y, w, h, text, this.linkControlStyles('TextArea', styles), callback, false, true);
|
||||
|
||||
|
||||
this.multiLine = true;
|
||||
});
|
||||
mexui.util.extend(mexui.Control.TextArea, mexui.Control.TextInput);
|
||||
46
third-party/mexui/Core/Control/TextInput.js
vendored
46
third-party/mexui/Core/Control/TextInput.js
vendored
@@ -3,11 +3,11 @@ mexui.util.createControlConstructor('TextInput', false, function(window, x, y, w
|
||||
text = text || '';
|
||||
if(singleCharacter)
|
||||
multiLineSupported = false;
|
||||
|
||||
|
||||
mexui.Component.Control.call(this, window, x, y, w, h, this.linkControlStyles('TextInput', styles), callback);
|
||||
|
||||
|
||||
this.lines = text ? mexui.util.splitLines(text) : [''];
|
||||
|
||||
|
||||
this.caretPosition = new Vec2(0, 0);
|
||||
this.multiLineSupported = multiLineSupported === undefined ? true : multiLineSupported;
|
||||
this.multiLine = this.multiLineSupported ? mexui.util.doesContainEOLChar(text) : false;
|
||||
@@ -17,7 +17,7 @@ mexui.util.createControlConstructor('TextInput', false, function(window, x, y, w
|
||||
this.caretShownForBlink = true;
|
||||
this.lineHeight = 25;
|
||||
this.maxLength = this.singleCharacter ? 1 : false;
|
||||
|
||||
|
||||
this.validValue = true;
|
||||
});
|
||||
|
||||
@@ -44,7 +44,7 @@ mexui.Control.TextInput.prototype.onMouseDown = function(e)
|
||||
this.caretPosition = this.getCaretPositionByCursor();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
mexui.Component.Control.prototype.onMouseDown.call(this, e);
|
||||
};
|
||||
|
||||
@@ -57,11 +57,11 @@ mexui.Control.TextInput.prototype.onCharacter = function(e, character)
|
||||
if(!isValid1 && isValid1 !== undefined)
|
||||
return;
|
||||
*/
|
||||
|
||||
|
||||
var isValid2 = this.validateInputCallback ? this.validateInputCallback(e, character) : true;
|
||||
if(!isValid2)
|
||||
return;
|
||||
|
||||
|
||||
if(this.singleCharacter)
|
||||
{
|
||||
this.resetText();
|
||||
@@ -73,7 +73,7 @@ mexui.Control.TextInput.prototype.onCharacter = function(e, character)
|
||||
this.lines[this.caretPosition.y] = this.getTextWithNewCharacter(character);
|
||||
this.caretPosition.x++;
|
||||
}
|
||||
|
||||
|
||||
this.checkToCallCallback();
|
||||
this.validateValue(e);
|
||||
}
|
||||
@@ -83,9 +83,9 @@ mexui.Control.TextInput.prototype.onKeyDown = function(e, key, mods)
|
||||
{
|
||||
if(mexui.focusedControl != this)
|
||||
return;
|
||||
|
||||
|
||||
var controlIsDown = (mods & KMOD_CTRL) == KMOD_CTRL;
|
||||
|
||||
|
||||
switch(key)
|
||||
{
|
||||
case SDLK_LEFT:
|
||||
@@ -156,7 +156,7 @@ mexui.Control.TextInput.prototype.onKeyDown = function(e, key, mods)
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if(this.multiLine)
|
||||
{
|
||||
switch(key)
|
||||
@@ -199,7 +199,7 @@ mexui.Control.TextInput.prototype.onKeyDown = function(e, key, mods)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
this.validateValue(e);
|
||||
};
|
||||
|
||||
@@ -208,9 +208,9 @@ mexui.Control.TextInput.prototype.render = function()
|
||||
{
|
||||
var pos = this.getScreenPosition();
|
||||
var pos2 = new Vec2(pos.x, pos.y);
|
||||
|
||||
|
||||
mexui.native.drawRectangle(pos, this.size, this.getStyles('main'));
|
||||
|
||||
|
||||
if(this.isEmpty())
|
||||
{
|
||||
mexui.native.drawText(pos, this.size, this.placeholder, this.getStyles('placeholder'));
|
||||
@@ -222,18 +222,18 @@ mexui.Control.TextInput.prototype.render = function()
|
||||
{
|
||||
var displayedText = this.masked ? '*'.repeat(this.lines[i].length) : this.lines[i];
|
||||
mexui.native.drawText(pos, lineSize, displayedText, this.getStyles('main'));
|
||||
|
||||
|
||||
pos.y += this.lineHeight;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var valueIsInvalid = !this.isEmpty() && !this.validValue;
|
||||
|
||||
|
||||
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'));
|
||||
|
||||
|
||||
if(this.caretShownForBlink)
|
||||
{
|
||||
var pos = this.getScreenPosition();
|
||||
@@ -246,7 +246,7 @@ mexui.Control.TextInput.prototype.render = function()
|
||||
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'));
|
||||
};
|
||||
@@ -269,7 +269,7 @@ mexui.Control.TextInput.prototype.clampCaretPosition = function()
|
||||
this.caretPosition.y = 0;
|
||||
else if(this.caretPosition.y > (this.lines.length - 1))
|
||||
this.caretPosition.y = this.lines.length - 1;
|
||||
|
||||
|
||||
if(this.caretPosition.x < 0)
|
||||
this.caretPosition.x = 0;
|
||||
else if(this.caretPosition.x > this.lines[this.caretPosition.y].length)
|
||||
@@ -287,7 +287,7 @@ mexui.Control.TextInput.prototype.getCaretLineIndexByCursor = function()
|
||||
{
|
||||
var yPos = gui.cursorPosition.y - this.getScreenPosition().y;
|
||||
var lineIndex = Math.floor(yPos / this.lineHeight);
|
||||
|
||||
|
||||
if(lineIndex < 0)
|
||||
return 0;
|
||||
else if(lineIndex > (this.lines.length - 1))
|
||||
@@ -301,12 +301,12 @@ mexui.Control.TextInput.prototype.getCharIndexByCursor = function(lineIndex)
|
||||
var xPos = gui.cursorPosition.x - this.getScreenPosition().x;
|
||||
var line = this.lines[lineIndex];
|
||||
var lineStyles = this.getStyles('caret');
|
||||
|
||||
|
||||
for(var i=0,j=line.length; i<j; i++)
|
||||
{
|
||||
var text = line.substr(0, i + 1);
|
||||
var textWidth = mexui.native.getTextWidth(text, lineStyles);
|
||||
|
||||
|
||||
if(xPos < textWidth)
|
||||
return i;
|
||||
}
|
||||
|
||||
48
third-party/mexui/Core/Control/Time.js
vendored
48
third-party/mexui/Core/Control/Time.js
vendored
@@ -1,11 +1,11 @@
|
||||
mexui.util.createControlConstructor('Time', false, function(window, x, y, w, h, text, styles, callback)
|
||||
{
|
||||
mexui.Control.TextInput.call(this, window, x, y, w, h, text, this.linkControlStyles('Time', styles), callback, false, false);
|
||||
|
||||
|
||||
this.hour = 0;
|
||||
this.minute = 0;
|
||||
this.second = 0;
|
||||
|
||||
|
||||
this.inputShown = false;
|
||||
this.valueBoxSize = new Vec2(50, 30);
|
||||
this.arrowBoxSize = new Vec2(25, 22);
|
||||
@@ -35,29 +35,29 @@ mexui.Control.Time.prototype.onMouseDown = function(e)
|
||||
var propIndex = (Math.ceil((arrowIndex + 1) / 2)) - 1;
|
||||
var propName = mexui.Control.Time.units[propIndex];
|
||||
var isIncrease = (arrowIndex % 2) == 1;
|
||||
|
||||
|
||||
if(isIncrease)
|
||||
this[propName]++;
|
||||
else
|
||||
this[propName]--;
|
||||
|
||||
|
||||
this[propName] %= propIndex == 0 ? 24 : 60;
|
||||
if(this[propName] == -1)
|
||||
this[propName] = propIndex == 0 ? 23 : 59;
|
||||
|
||||
|
||||
this.generateText();
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(this.isCursorOverControl())
|
||||
{
|
||||
this.inputShown = !this.inputShown;
|
||||
e.used = true;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if(this.inputShown)
|
||||
{
|
||||
this.inputShown = false;
|
||||
@@ -71,18 +71,18 @@ mexui.Control.Time.prototype.renderAfter = function()
|
||||
{
|
||||
if(!this.inputShown)
|
||||
return;
|
||||
|
||||
|
||||
var screenPos = this.getScreenPosition();
|
||||
|
||||
|
||||
var pos = new Vec2(screenPos.x, screenPos.y);
|
||||
for(var i=0; i<3; i++)
|
||||
{
|
||||
mexui.native.drawRectangle(pos, this.valueBoxSize, this.getStyles('main'));
|
||||
mexui.native.drawText(pos, this.valueBoxSize, this[mexui.Control.Time.units[i]], this.getStyles('main'));
|
||||
|
||||
|
||||
pos.x += this.valueBoxSize.x;
|
||||
}
|
||||
|
||||
|
||||
pos = new Vec2(screenPos.x, screenPos.y);
|
||||
pos.y += this.valueBoxSize.y;
|
||||
for(var i=0; i<3; i++)
|
||||
@@ -90,10 +90,10 @@ mexui.Control.Time.prototype.renderAfter = function()
|
||||
for(var i2=0; i2<2; i2++)
|
||||
{
|
||||
var text = (i2 % 2) == 0 ? '<' : '>';
|
||||
|
||||
|
||||
mexui.native.drawRectangle(pos, this.arrowBoxSize, this.getStyles('main'));
|
||||
mexui.native.drawText(pos, this.arrowBoxSize, text, this.getStyles('main'));
|
||||
|
||||
|
||||
pos.x += this.arrowBoxSize.x;
|
||||
}
|
||||
}
|
||||
@@ -115,42 +115,42 @@ mexui.Control.Time.prototype.validateInputCallback = function(e, character)
|
||||
mexui.Control.Time.prototype.validateValueCallback = function(e)
|
||||
{
|
||||
var parts = this.getText().split(':');
|
||||
|
||||
|
||||
if(parts.length != 3)
|
||||
return false;
|
||||
|
||||
|
||||
for(var i in parts)
|
||||
{
|
||||
var partAsStr = parts[i];
|
||||
if(partAsStr === '')
|
||||
return false;
|
||||
|
||||
|
||||
var part = parseInt(partAsStr);
|
||||
|
||||
|
||||
if(partAsStr.length == 2 && partAsStr.substr(0, 1) == '0')
|
||||
partAsStr = partAsStr.substr(1);
|
||||
|
||||
|
||||
if(!mexui.util.isPositiveInt(partAsStr))
|
||||
return false;
|
||||
|
||||
|
||||
if(part < 0)
|
||||
return false;
|
||||
|
||||
|
||||
if(part > (i == 0 ? 23 : 59))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
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);
|
||||
|
||||
|
||||
if(cursorPos.x >= firstArrowStartPos.x && cursorPos.y >= firstArrowStartPos.y && cursorPos.x <= lastArrowEndPos.x && cursorPos.y <= lastArrowEndPos.y)
|
||||
{
|
||||
return Math.floor((cursorPos.x - firstArrowStartPos.x) / this.arrowBoxSize.x);
|
||||
|
||||
31
third-party/mexui/Core/Control/Tree.js
vendored
31
third-party/mexui/Core/Control/Tree.js
vendored
@@ -2,7 +2,7 @@ mexui.util.createControlConstructor('Tree', true, function(window, x, y, w, h, s
|
||||
{
|
||||
mexui.Component.Control.call(this, window, x, y, w, h, this.linkControlStyles('Tree', styles));
|
||||
mexui.Entity.ControlWithEntries.call(this, false, false);
|
||||
|
||||
|
||||
this.rowHeight = 25;
|
||||
this.rowLevelIndentation = 10;
|
||||
this.scrollMultiplier = 10.0;
|
||||
@@ -32,10 +32,10 @@ mexui.Control.Tree.prototype.onMouseDown = function(e)
|
||||
{
|
||||
var pos = this.getScreenPosition();
|
||||
pos.y -= this.axis.y.getScrolledOffset();
|
||||
|
||||
|
||||
this.testRowClick(e, this.axis.y.entries, pos);
|
||||
}
|
||||
|
||||
|
||||
if(!e.used)
|
||||
mexui.Entity.ControlWithEntries.prototype.onMouseDown.call(this, e);
|
||||
};
|
||||
@@ -45,9 +45,9 @@ mexui.Control.Tree.prototype.render = function()
|
||||
{
|
||||
var pos = this.getScreenPosition();
|
||||
pos.y -= this.axis.y.getScrolledOffset();
|
||||
|
||||
|
||||
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'));
|
||||
};
|
||||
@@ -58,23 +58,23 @@ mexui.Control.Tree.prototype.renderRows = function(rows, level, pos)
|
||||
{
|
||||
var row = rows[i];
|
||||
var shouldDraw = pos.y >= this.getScreenPosition().y && pos.y <= (this.getScreenPosition().y + this.size.y);
|
||||
|
||||
|
||||
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.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'));
|
||||
}
|
||||
|
||||
|
||||
pos.y += this.rowHeight;
|
||||
|
||||
|
||||
if(shouldDraw)
|
||||
{
|
||||
mexui.native.drawAALine(pos, new Vec2(pos.x + this.size.x, pos.y), this.getStyles('rowLine'));
|
||||
}
|
||||
|
||||
|
||||
if(row.rows.length > 0 && row.open)
|
||||
{
|
||||
pos.x += this.rowLevelIndentation;
|
||||
@@ -106,7 +106,7 @@ mexui.Control.Tree.prototype.testRowClick = function(e, rows, pos)
|
||||
for(var i in rows)
|
||||
{
|
||||
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);
|
||||
if(mexui.util.isCursorInRectangle(rowPos, rowSize))
|
||||
@@ -115,9 +115,9 @@ mexui.Control.Tree.prototype.testRowClick = function(e, rows, pos)
|
||||
e.used = true;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
pos.y += this.rowHeight;
|
||||
|
||||
|
||||
if(row.rows.length > 0 && row.open)
|
||||
{
|
||||
this.testRowClick(e, row.rows, pos);
|
||||
@@ -132,10 +132,10 @@ mexui.Control.Tree.prototype.onClickRow = function(row)
|
||||
if(row.rows.length > 0)
|
||||
{
|
||||
//var scrollableLengthBefore = this.axis.y.getScrollableLength();
|
||||
|
||||
|
||||
row.open = !row.open;
|
||||
this.checkToShowScrollBars();
|
||||
|
||||
|
||||
/*
|
||||
if(this.scrollBars[1].shown)
|
||||
{
|
||||
@@ -153,3 +153,4 @@ mexui.Control.Tree.prototype.row = function(text)
|
||||
this.axis.y.addEntry(entry);
|
||||
return entry;
|
||||
};
|
||||
|
||||
|
||||
4
third-party/mexui/Core/Control/Week.js
vendored
4
third-party/mexui/Core/Control/Week.js
vendored
@@ -13,9 +13,9 @@ mexui.Control.Week.prototype.validateInputCallback = function(e, character)
|
||||
mexui.Control.Week.prototype.validateValueCallback = function(e)
|
||||
{
|
||||
var _int = parseInt(this.getText());
|
||||
|
||||
|
||||
if(_int < 1 || _int > 52)
|
||||
return false;
|
||||
|
||||
|
||||
return true;
|
||||
};
|
||||
2
third-party/mexui/Core/Control/Year.js
vendored
2
third-party/mexui/Core/Control/Year.js
vendored
@@ -1,7 +1,7 @@
|
||||
mexui.util.createControlConstructor('Year', false, function(window, x, y, w, h, text, styles, callback)
|
||||
{
|
||||
mexui.Control.TextInput.call(this, window, x, y, w, h, text, this.linkControlStyles('Year', styles), callback, false, false);
|
||||
|
||||
|
||||
this.maxYearOffset = 10;
|
||||
this.minYearCallback = ()=>{ return 1900; };
|
||||
this.maxYearCallback = ()=>{ return new Date().getFullYear() + this.maxYearOffset; }
|
||||
|
||||
Reference in New Issue
Block a user