mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-26 06:28:35 +01:00
made elements also show their mouse over graphic when they're being touched
This commit is contained in:
parent
3d1b660c9f
commit
d7f43617c6
3 changed files with 43 additions and 1 deletions
|
@ -259,7 +259,7 @@ namespace MLEM.Ui.Elements {
|
||||||
public float DrawAlpha = 1;
|
public float DrawAlpha = 1;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Stores whether this element is currently being moused over.
|
/// Stores whether this element is currently being moused over or touched.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsMouseOver { get; protected set; }
|
public bool IsMouseOver { get; protected set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -300,6 +300,14 @@ namespace MLEM.Ui.Elements {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public GenericCallback OnMouseExit;
|
public GenericCallback OnMouseExit;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// Event that is called when this element starts being touched
|
||||||
|
/// </summary>
|
||||||
|
public GenericCallback OnTouchEnter;
|
||||||
|
/// <summary>
|
||||||
|
/// Event that is called when this element stops being touched
|
||||||
|
/// </summary>
|
||||||
|
public GenericCallback OnTouchExit;
|
||||||
|
/// <summary>
|
||||||
/// Event that is called when text input is made.
|
/// Event that is called when text input is made.
|
||||||
/// Note that this event is called for every element, even if it is not selected.
|
/// Note that this event is called for every element, even if it is not selected.
|
||||||
/// Also note that if <see cref="TextInputWrapper.RequiresOnScreenKeyboard"/> is true, this event is never called.
|
/// Also note that if <see cref="TextInputWrapper.RequiresOnScreenKeyboard"/> is true, this event is never called.
|
||||||
|
@ -315,6 +323,11 @@ namespace MLEM.Ui.Elements {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public OtherElementCallback OnMousedElementChanged;
|
public OtherElementCallback OnMousedElementChanged;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// Event that is called when the element that is currently being touched changes within the ui system.
|
||||||
|
/// Note that the event fired doesn't necessarily correlate to this specific element.
|
||||||
|
/// </summary>
|
||||||
|
public OtherElementCallback OnTouchedElementChanged;
|
||||||
|
/// <summary>
|
||||||
/// Event that is called when the element that is currently selected changes within the ui system.
|
/// Event that is called when the element that is currently selected changes within the ui system.
|
||||||
/// Note that the event fired doesn't necessarily correlate to this specific element.
|
/// Note that the event fired doesn't necessarily correlate to this specific element.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -362,6 +375,8 @@ namespace MLEM.Ui.Elements {
|
||||||
|
|
||||||
this.OnMouseEnter += element => this.IsMouseOver = true;
|
this.OnMouseEnter += element => this.IsMouseOver = true;
|
||||||
this.OnMouseExit += element => this.IsMouseOver = false;
|
this.OnMouseExit += element => this.IsMouseOver = false;
|
||||||
|
this.OnTouchEnter += element => this.IsMouseOver = true;
|
||||||
|
this.OnTouchExit += element => this.IsMouseOver = false;
|
||||||
this.OnSelected += element => this.IsSelected = true;
|
this.OnSelected += element => this.IsSelected = true;
|
||||||
this.OnDeselected += element => this.IsSelected = false;
|
this.OnDeselected += element => this.IsSelected = false;
|
||||||
this.GetTabNextElement += (backward, next) => next;
|
this.GetTabNextElement += (backward, next) => next;
|
||||||
|
|
|
@ -40,6 +40,10 @@ namespace MLEM.Ui {
|
||||||
/// The <see cref="Element"/> that the mouse is currently over.
|
/// The <see cref="Element"/> that the mouse is currently over.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Element MousedElement { get; private set; }
|
public Element MousedElement { get; private set; }
|
||||||
|
/// <summary>
|
||||||
|
/// The <see cref="Element"/> that is currently touched.
|
||||||
|
/// </summary>
|
||||||
|
public Element TouchedElement { get; private set; }
|
||||||
private readonly Dictionary<string, Element> selectedElements = new Dictionary<string, Element>();
|
private readonly Dictionary<string, Element> selectedElements = new Dictionary<string, Element>();
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The element that is currently selected.
|
/// The element that is currently selected.
|
||||||
|
@ -200,6 +204,16 @@ namespace MLEM.Ui {
|
||||||
this.SelectElement(this.ActiveRoot, held);
|
this.SelectElement(this.ActiveRoot, held);
|
||||||
if (held != null && held.CanBePressed)
|
if (held != null && held.CanBePressed)
|
||||||
this.System.OnElementSecondaryPressed?.Invoke(held);
|
this.System.OnElementSecondaryPressed?.Invoke(held);
|
||||||
|
} else {
|
||||||
|
var held = this.Input.TouchState.Select(l => this.GetElementUnderPos(l.Position)).FirstOrDefault();
|
||||||
|
if (held != this.TouchedElement) {
|
||||||
|
if (this.TouchedElement != null)
|
||||||
|
this.System.OnElementTouchExit?.Invoke(this.TouchedElement);
|
||||||
|
if (held != null)
|
||||||
|
this.System.OnElementTouchEnter?.Invoke(held);
|
||||||
|
this.TouchedElement = held;
|
||||||
|
this.System.OnTouchedElementChanged?.Invoke(held);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -141,6 +141,14 @@ namespace MLEM.Ui {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Element.GenericCallback OnElementMouseExit = e => e.OnMouseExit?.Invoke(e);
|
public Element.GenericCallback OnElementMouseExit = e => e.OnMouseExit?.Invoke(e);
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// Event that is invoked when an <see cref="Element"/> starts being touched
|
||||||
|
/// </summary>
|
||||||
|
public Element.GenericCallback OnElementTouchEnter = e => e.OnTouchEnter?.Invoke(e);
|
||||||
|
/// <summary>
|
||||||
|
/// Event that is invoked when an <see cref="Element"/> stops being touched
|
||||||
|
/// </summary>
|
||||||
|
public Element.GenericCallback OnElementTouchExit = e => e.OnTouchExit?.Invoke(e);
|
||||||
|
/// <summary>
|
||||||
/// Event that is invoked when an <see cref="Element"/>'s display area changes
|
/// Event that is invoked when an <see cref="Element"/>'s display area changes
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Element.GenericCallback OnElementAreaUpdated = e => e.OnAreaUpdated?.Invoke(e);
|
public Element.GenericCallback OnElementAreaUpdated = e => e.OnAreaUpdated?.Invoke(e);
|
||||||
|
@ -149,6 +157,10 @@ namespace MLEM.Ui {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Element.GenericCallback OnMousedElementChanged;
|
public Element.GenericCallback OnMousedElementChanged;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// Event that is invoked when the <see cref="Element"/> that is being touched changes
|
||||||
|
/// </summary>
|
||||||
|
public Element.GenericCallback OnTouchedElementChanged;
|
||||||
|
/// <summary>
|
||||||
/// Event that is invoked when the selected <see cref="Element"/> changes, either through automatic navigation, or by pressing on an element with the mouse
|
/// Event that is invoked when the selected <see cref="Element"/> changes, either through automatic navigation, or by pressing on an element with the mouse
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Element.GenericCallback OnSelectedElementChanged;
|
public Element.GenericCallback OnSelectedElementChanged;
|
||||||
|
@ -184,6 +196,7 @@ namespace MLEM.Ui {
|
||||||
|
|
||||||
TextInputWrapper.Current.AddListener(window, (sender, key, character) => this.ApplyToAll(e => e.OnTextInput?.Invoke(e, key, character)));
|
TextInputWrapper.Current.AddListener(window, (sender, key, character) => this.ApplyToAll(e => e.OnTextInput?.Invoke(e, key, character)));
|
||||||
this.OnMousedElementChanged = e => this.ApplyToAll(t => t.OnMousedElementChanged?.Invoke(t, e));
|
this.OnMousedElementChanged = e => this.ApplyToAll(t => t.OnMousedElementChanged?.Invoke(t, e));
|
||||||
|
this.OnTouchedElementChanged = e => this.ApplyToAll(t => t.OnTouchedElementChanged?.Invoke(t, e));
|
||||||
this.OnSelectedElementChanged = e => this.ApplyToAll(t => t.OnSelectedElementChanged?.Invoke(t, e));
|
this.OnSelectedElementChanged = e => this.ApplyToAll(t => t.OnSelectedElementChanged?.Invoke(t, e));
|
||||||
this.OnSelectedElementDrawn = (element, time, batch, alpha) => {
|
this.OnSelectedElementDrawn = (element, time, batch, alpha) => {
|
||||||
if (this.Controls.IsAutoNavMode && element.SelectionIndicator.HasValue()) {
|
if (this.Controls.IsAutoNavMode && element.SelectionIndicator.HasValue()) {
|
||||||
|
|
Loading…
Reference in a new issue