Skip to content
This repository has been archived by the owner on Mar 1, 2023. It is now read-only.

Commit

Permalink
Added Mouse Queries. Addes to #29
Browse files Browse the repository at this point in the history
  • Loading branch information
antongit committed Aug 17, 2022
1 parent 2582d76 commit b1fba56
Show file tree
Hide file tree
Showing 11 changed files with 214 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/VL.ImGui/Commands/ResetMouseDragDelta.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace VL.ImGui.Widgets
{
[GenerateNode(Category = "ImGui.Commands", GenerateRetained = false)]
internal partial class ResetMouseDragDelta : Widget
{

public bool Enabled { private get; set; } = true;

internal override void Update(Context context)
{
if (Enabled)
ImGuiNET.ImGui.ResetMouseDragDelta();
}
}
}
19 changes: 19 additions & 0 deletions src/VL.ImGui/Widgets/Queries/Mouse/GetMouseClickedCount.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
namespace VL.ImGui.Widgets
{
/// <summary>
/// Return the number of successive mouse-clicks at the time where a click happen (otherwise 0).
/// </summary>
[GenerateNode(Category = "ImGui.Queries")]
internal partial class GetMouseClickedCount : Widget
{

public ImGuiNET.ImGuiMouseButton Flag { private get; set; }

public int Value { get; private set; }

internal override void Update(Context context)
{
Value = ImGuiNET.ImGui.GetMouseClickedCount(Flag);
}
}
}
23 changes: 23 additions & 0 deletions src/VL.ImGui/Widgets/Queries/Mouse/GetMouseDragDelta.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using Stride.Core.Mathematics;

namespace VL.ImGui.Widgets
{
/// <summary>
/// Return the delta from the initial clicking position while the mouse button is pressed or was just released. This is locked and return 0.0f until the mouse moves past a distance threshold at least once (if lock_threshold < -1.0f, uses io.MouseDraggingThreshold)
/// </summary>
[GenerateNode(Category = "ImGui.Queries")]
internal partial class GetMouseDragDelta : Widget
{
public ImGuiNET.ImGuiMouseButton Flags { private get; set; }

public float Threshold { private get; set; } = -2.0f;

public Vector2 Value { get; private set; }

internal override void Update(Context context)
{
var value = ImGuiNET.ImGui.GetMouseDragDelta(Flags, Threshold);
Value = value.ToVL();
}
}
}
16 changes: 16 additions & 0 deletions src/VL.ImGui/Widgets/Queries/Mouse/GetMousePos.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Stride.Core.Mathematics;

namespace VL.ImGui.Widgets
{
[GenerateNode(Category = "ImGui.Queries")]
internal partial class GetMousePos : Widget
{
public Vector2 Value { get; private set; }

internal override void Update(Context context)
{
var value = ImGuiNET.ImGui.GetMousePos();
Value = value.ToVL();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Stride.Core.Mathematics;

namespace VL.ImGui.Widgets
{
/// <summary>
/// Retrieve mouse position at the time of opening popup.
/// </summary>
[GenerateNode(Category = "ImGui.Queries", GenerateRetained = false)]
internal partial class GetMousePosOnOpeningCurrentPopup : Widget
{
public Vector2 Value { get; private set; }

internal override void Update(Context context)
{
var value = ImGuiNET.ImGui.GetMousePosOnOpeningCurrentPopup();
Value = value.ToVL();
}
}
}
21 changes: 21 additions & 0 deletions src/VL.ImGui/Widgets/Queries/Mouse/IsMouseClicked.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
namespace VL.ImGui.Widgets
{
/// <summary>
/// Did mouse button clicked?
/// </summary>
[GenerateNode(Category = "ImGui.Queries")]
internal partial class IsMouseClicked : Widget
{

public ImGuiNET.ImGuiMouseButton Flags { private get; set; }

public bool Repeat { private get; set; } = true;

public bool Value { get; private set; }

internal override void Update(Context context)
{
Value = ImGuiNET.ImGui.IsMouseClicked(Flags, Repeat);
}
}
}
19 changes: 19 additions & 0 deletions src/VL.ImGui/Widgets/Queries/Mouse/IsMouseDoubleClicked.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
namespace VL.ImGui.Widgets
{
/// <summary>
/// Did mouse button double-clicked?
/// </summary>
[GenerateNode(Category = "ImGui.Queries")]
internal partial class IsMouseDoubleClicked : Widget
{

public ImGuiNET.ImGuiMouseButton Flags { private get; set; }

public bool Value { get; private set; }

internal override void Update(Context context)
{
Value = ImGuiNET.ImGui.IsMouseDoubleClicked(Flags);
}
}
}
19 changes: 19 additions & 0 deletions src/VL.ImGui/Widgets/Queries/Mouse/IsMouseDown.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
namespace VL.ImGui.Widgets
{
/// <summary>
/// Is mouse button held?
/// </summary>
[GenerateNode(Category = "ImGui.Queries")]
internal partial class IsMouseDown : Widget
{

public ImGuiNET.ImGuiMouseButton Flags { private get; set; }

public bool Value { get; private set; }

internal override void Update(Context context)
{
Value = ImGuiNET.ImGui.IsMouseDown(Flags);
}
}
}
21 changes: 21 additions & 0 deletions src/VL.ImGui/Widgets/Queries/Mouse/IsMouseDragging.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
namespace VL.ImGui.Widgets
{
/// <summary>
/// Is mouse dragging? (if lock_threshold < -1.0f, uses io.MouseDraggingThreshold)
/// </summary>
[GenerateNode(Category = "ImGui.Queries")]
internal partial class IsMouseDragging : Widget
{

public ImGuiNET.ImGuiMouseButton Flags { private get; set; }

public float Threshold { private get; set; } = -2.0f;

public bool Value { get; private set; }

internal override void Update(Context context)
{
Value = ImGuiNET.ImGui.IsMouseDragging(Flags, Threshold);
}
}
}
23 changes: 23 additions & 0 deletions src/VL.ImGui/Widgets/Queries/Mouse/IsMouseHoveringRect.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using Stride.Core.Mathematics;

namespace VL.ImGui.Widgets
{
/// <summary>
/// Is mouse hovering given bounding rect (in screen space). clipped by current clipping settings, but disregarding of other consideration of focus/window ordering/popup-block.
/// </summary>
[GenerateNode(Category = "ImGui.Queries")]
internal partial class IsMouseHoveringRect : Widget
{

public Vector2 Min { private get; set; }
public Vector2 Max { private get; set; }
public bool Clip { private get; set; }

public bool Value { get; private set; }

internal override void Update(Context context)
{
Value = ImGuiNET.ImGui.IsMouseHoveringRect(Min.ToImGui(), Max.ToImGui(), Clip);
}
}
}
19 changes: 19 additions & 0 deletions src/VL.ImGui/Widgets/Queries/Mouse/IsMouseReleased.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
namespace VL.ImGui.Widgets
{
/// <summary>
/// Did mouse button released?
/// </summary>
[GenerateNode(Category = "ImGui.Queries")]
internal partial class IsMouseReleased : Widget
{

public ImGuiNET.ImGuiMouseButton Flags { private get; set; }

public bool Value { get; private set; }

internal override void Update(Context context)
{
Value = ImGuiNET.ImGui.IsMouseReleased(Flags);
}
}
}

0 comments on commit b1fba56

Please sign in to comment.