MexUI stuff
This commit is contained in:
2
third-party/mexui/Core/Entity/Component.js
vendored
2
third-party/mexui/Core/Entity/Component.js
vendored
@@ -1,7 +1,7 @@
|
||||
mexui.Entity.Component = function(moveable)
|
||||
{
|
||||
this.moveable = moveable;
|
||||
|
||||
|
||||
this.moving = false;
|
||||
};
|
||||
mexui.util.extend(mexui.Entity.Component, mexui.Entity.StyleableEntity);
|
||||
|
||||
19
third-party/mexui/Core/Entity/ControlAxis.js
vendored
19
third-party/mexui/Core/Entity/ControlAxis.js
vendored
@@ -3,7 +3,7 @@ mexui.Entity.ControlAxis = function(control, isVertical, manualScrollBar, entrie
|
||||
this.control = control;
|
||||
this.isVertical = isVertical;
|
||||
this.manualScrollBar = manualScrollBar;
|
||||
|
||||
|
||||
this.axisIndex = isVertical ? 1 : 0;
|
||||
this.entriesShown = true;
|
||||
this.entryCountShown = 15;
|
||||
@@ -27,7 +27,7 @@ mexui.Entity.ControlAxis.prototype.initScrollBar = function()
|
||||
var pos = mexui.util.addVec2(this.control.position, new Vec2(this.control.entriesPositionOffset.x, this.control.size.y));
|
||||
this.scrollBar = new mexui.Control.ScrollBar(this.control.window, pos.x, pos.y, this.getDisplayedEntriesLength(), 25, false, this.control.styles.scrollBar);
|
||||
}
|
||||
|
||||
|
||||
if(this.manualScrollBar)
|
||||
this.scrollBar.shown = false;
|
||||
};
|
||||
@@ -73,19 +73,19 @@ mexui.Entity.ControlAxis.prototype.getEntryIndexByPoint = function(point)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
var pos = new Vec2(screenPos.x + this.control.entriesPositionOffset.x, screenPos.y + this.control.entriesPositionOffset.y);
|
||||
var index = Math.floor((point.y - pos.y) / this.control.entrySize[this.axisIndex]);
|
||||
index += this.getEntryStartIndex();
|
||||
|
||||
|
||||
if(index < 0 || index >= this.entries.length)
|
||||
return null;
|
||||
|
||||
|
||||
return index;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
@@ -121,7 +121,7 @@ mexui.Entity.ControlAxis.prototype.getDisplayedEntriesLength = function()
|
||||
mexui.Entity.ControlAxis.prototype.setScrollBarManual = function(manual)
|
||||
{
|
||||
this.manualScrollBar = manual;
|
||||
|
||||
|
||||
if(manual)
|
||||
{
|
||||
this.setScrollBarShown(false);
|
||||
@@ -150,7 +150,7 @@ mexui.Entity.ControlAxis.prototype.checkToShowScrollBar = function()
|
||||
{
|
||||
if(this.manualScrollBar)
|
||||
return;
|
||||
|
||||
|
||||
this.setScrollBarShown(this.shouldDisplayScrollBar(), true);
|
||||
};
|
||||
|
||||
@@ -160,7 +160,7 @@ mexui.Entity.ControlAxis.prototype.getScrolledOffset = function()
|
||||
{
|
||||
if(!this.scrollBar.shown)
|
||||
return 0;
|
||||
|
||||
|
||||
return this.scrollBar.scrolledRatio * this.getScrollableLength();
|
||||
}
|
||||
else
|
||||
@@ -197,3 +197,4 @@ mexui.Entity.ControlAxis.prototype.getDisplayedEntryCount = function()
|
||||
var displayedEntryCount = Math.floor(displayedEntriesLength / this.control.entrySize[this.axisIndex]);
|
||||
return this.entries.length < displayedEntryCount ? this.entries.length : displayedEntryCount;
|
||||
};
|
||||
|
||||
|
||||
@@ -4,14 +4,14 @@ mexui.Entity.ControlWithEntries = function(entriesOutsideControl, manualScrollBa
|
||||
this.entriesPositionOffset = entriesPositionOffset || new Vec2(0, 0);
|
||||
this.entrySize = entrySize || new Vec2(this.size.x, 25);
|
||||
this.entriesSizeOffset = entriesSizeOffset || new Vec2(0, 0);
|
||||
|
||||
|
||||
this.axis = {};
|
||||
this.axis.x = new mexui.Entity.ControlAxis(this, false, manualScrollBar, entriesPositionOffset);
|
||||
this.axis.y = new mexui.Entity.ControlAxis(this, true, manualScrollBar, entriesPositionOffset);
|
||||
|
||||
|
||||
this.axis.x.initScrollBar();
|
||||
this.axis.y.initScrollBar();
|
||||
|
||||
|
||||
this.checkToShowScrollBars();
|
||||
};
|
||||
mexui.util.extend(mexui.Entity.ControlWithEntries, mexui.Component.Control);
|
||||
@@ -46,7 +46,7 @@ mexui.Entity.ControlWithEntries.prototype.onMouseMove = function(e, offset)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(!e.used)
|
||||
this.triggerEvent('onMouseMove', e, offset);
|
||||
};
|
||||
@@ -74,7 +74,7 @@ mexui.Entity.ControlWithEntries.prototype.triggerEvent = function(eventName, e,
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
mexui.Component.Control.prototype[eventName].call(this, e, data);
|
||||
};
|
||||
|
||||
@@ -95,3 +95,4 @@ mexui.Entity.ControlWithEntries.prototype.removeAllEntries = function()
|
||||
this.axis.x.removeAllEntries();
|
||||
this.axis.y.removeAllEntries();
|
||||
};
|
||||
|
||||
|
||||
39
third-party/mexui/Core/Entity/StyleableEntity.js
vendored
39
third-party/mexui/Core/Entity/StyleableEntity.js
vendored
@@ -1,12 +1,12 @@
|
||||
mexui.Entity.StyleableEntity = function(styles)
|
||||
{
|
||||
this.styles = styles;
|
||||
|
||||
|
||||
this.shown = true;
|
||||
//this.hovered = false;
|
||||
|
||||
|
||||
this.transitions = {}; // string controlPartName => Transition transition
|
||||
|
||||
|
||||
/*
|
||||
this.transitionDelayTimer = null;
|
||||
this.transitionStartTime = 0;
|
||||
@@ -26,9 +26,9 @@ mexui.Entity.StyleableEntity.globalDefaultStyles = {
|
||||
textAlign: 0.0,
|
||||
textIndent: 5,
|
||||
textColour: toColour(0, 0, 0, 255),
|
||||
|
||||
|
||||
backgroundColour: toColour(255, 255, 255, 255),
|
||||
|
||||
|
||||
lineWeight: 1
|
||||
}
|
||||
};
|
||||
@@ -39,14 +39,14 @@ mexui.Entity.StyleableEntity.defaultStyles = mexui.util.linkGlobalStyles(mexui.E
|
||||
backgroundColour: toColour(255, 255, 255, 255),
|
||||
borderColour: 'none',
|
||||
textColour: toColour(0, 0, 0, 255),
|
||||
|
||||
|
||||
hover:
|
||||
{
|
||||
backgroundColour: toColour(220, 220, 220, 255),
|
||||
borderColour: 'none',
|
||||
textColour: toColour(0, 0, 0, 255)
|
||||
}/*,
|
||||
|
||||
|
||||
focus:
|
||||
{
|
||||
borderColour: toColour(255, 128, 0, 230),
|
||||
@@ -96,30 +96,30 @@ mexui.Entity.StyleableEntity.prototype.getStyles = function(controlPartName)
|
||||
var isFocused = this.isFocused();
|
||||
var isHovered = this.isHovered();
|
||||
var styles = this.styles[controlPartName];
|
||||
|
||||
|
||||
var transition = this.getTransition(controlPartName);
|
||||
|
||||
|
||||
if(transition.isProcessing())
|
||||
{
|
||||
return mexui.util.getTransitionStyles(styles, ['hover'], transition.getMainToPseudoProgress());
|
||||
}
|
||||
|
||||
|
||||
if(isHovered)
|
||||
{
|
||||
return mexui.util.mergeStyles(styles, ['hover']);
|
||||
}
|
||||
|
||||
|
||||
return styles;
|
||||
};
|
||||
|
||||
mexui.Entity.StyleableEntity.prototype.getEntryStyles = function(data)
|
||||
{
|
||||
var styles = {};
|
||||
|
||||
|
||||
for(var i in data)
|
||||
{
|
||||
var baseStyles = data[i][0].getStyles(data[i][1]);
|
||||
|
||||
|
||||
for(var k in baseStyles)
|
||||
{
|
||||
if(baseStyles.hasOwnProperty(k) && styles[k] === undefined)
|
||||
@@ -128,11 +128,11 @@ mexui.Entity.StyleableEntity.prototype.getEntryStyles = function(data)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for(var i in data)
|
||||
{
|
||||
var baseStyles = data[i][0].getStyles(data[i][1]);
|
||||
|
||||
|
||||
for(var k in baseStyles)
|
||||
{
|
||||
if(styles[k] === undefined)
|
||||
@@ -141,7 +141,7 @@ mexui.Entity.StyleableEntity.prototype.getEntryStyles = function(data)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return styles;
|
||||
};
|
||||
|
||||
@@ -152,10 +152,10 @@ mexui.Entity.StyleableEntity.prototype.onMouseEnter = function()
|
||||
for(var i in controlParts)
|
||||
{
|
||||
var transition = this.getTransition(controlParts[i]);
|
||||
|
||||
|
||||
var delay = this.getTransitionDelayStyle(controlParts[i]);
|
||||
var time = this.getTransitionTimeStyle(controlParts[i]);
|
||||
|
||||
|
||||
transition.onMouseEnter(delay, time);
|
||||
}
|
||||
};
|
||||
@@ -166,7 +166,7 @@ mexui.Entity.StyleableEntity.prototype.onMouseExit = function()
|
||||
for(var i in controlParts)
|
||||
{
|
||||
var transition = this.getTransition(controlParts[i]);
|
||||
|
||||
|
||||
transition.onMouseExit();
|
||||
}
|
||||
};
|
||||
@@ -207,3 +207,4 @@ mexui.Entity.StyleableEntity.prototype.getTransitionTimeStyle = function(control
|
||||
else
|
||||
return mexui.Entity.Transition.defaultTransitionTime;
|
||||
};
|
||||
|
||||
|
||||
15
third-party/mexui/Core/Entity/Transition.js
vendored
15
third-party/mexui/Core/Entity/Transition.js
vendored
@@ -21,10 +21,10 @@ mexui.Entity.Transition.prototype.onMouseEnter = function(transitionDelay, trans
|
||||
if(this.isMouseEntered())
|
||||
return;
|
||||
this.setMouseEntered(true);
|
||||
|
||||
|
||||
this.transitionDelay = transitionDelay;
|
||||
this.transitionTime = transitionTime;
|
||||
|
||||
|
||||
if(transitionDelay > 0)
|
||||
{
|
||||
this.startDelay();
|
||||
@@ -44,7 +44,7 @@ mexui.Entity.Transition.prototype.onMouseExit = function()
|
||||
if(!this.isMouseEntered())
|
||||
return;
|
||||
this.setMouseEntered(false);
|
||||
|
||||
|
||||
if(this.isDelayActive())
|
||||
{
|
||||
this.clearDelayTimer();
|
||||
@@ -82,7 +82,7 @@ mexui.Entity.Transition.prototype.stopProcessing = function()
|
||||
{
|
||||
this.stopInterpolation();
|
||||
}
|
||||
|
||||
|
||||
this.delayTimer = null;
|
||||
this.processing = false;
|
||||
};
|
||||
@@ -129,12 +129,12 @@ mexui.Entity.Transition.prototype.increaseMainToPseudoProgress = function()
|
||||
var timeDiff = mexui.util.time() - this.lastUpdateTime;
|
||||
this.lastUpdateTime = mexui.util.time();
|
||||
var progressDiff = timeDiff / this.transitionTime;
|
||||
|
||||
|
||||
if(this.direction)
|
||||
this.mainToPseudoProgress += progressDiff;
|
||||
else
|
||||
this.mainToPseudoProgress -= progressDiff;
|
||||
|
||||
|
||||
if(this.mainToPseudoProgress < 0.0)
|
||||
{
|
||||
this.mainToPseudoProgress = 0.0;
|
||||
@@ -149,7 +149,7 @@ mexui.Entity.Transition.prototype.increaseMainToPseudoProgress = function()
|
||||
mexui.Entity.Transition.prototype.getMainToPseudoProgress = function()
|
||||
{
|
||||
this.increaseMainToPseudoProgress();
|
||||
|
||||
|
||||
return this.mainToPseudoProgress;
|
||||
};
|
||||
|
||||
@@ -181,3 +181,4 @@ mexui.Entity.Transition.prototype.clearDelayTimer = function()
|
||||
clearTimeout(this.delayTimer);
|
||||
this.delayTimer = null;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user