MexUI stuff

This commit is contained in:
Vortrex
2022-05-15 22:26:31 -05:00
parent c81f511448
commit 4b7f05a482
42 changed files with 423 additions and 398 deletions

View File

@@ -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;
};