Files
2026-07-13 13:13:17 +08:00

66 lines
2.3 KiB
C#

#nullable enable
using ImGuiNET;
using T3.Core.Operator;
using T3.Core.Operator.Slots;
using T3.Editor.Gui.Interaction;
using T3.Editor.Gui.OpUis.WidgetUi;
using T3.Editor.Gui.UiHelpers;
namespace T3.Editor.Gui.OpUis.UIs;
internal static class GetIntVarUi
{
private sealed class Binding : OpUiBinding
{
internal Binding(Instance instance)
{
IsValid = AutoBind(instance);
}
[BindInput("d7662b65-f249-4887-a319-dc2cf7d192f2")]
internal readonly InputSlot<string> VariableName = null!;
[BindOutput("B306B216-630C-4611-90FD-52FF322EBD00")]
internal readonly Slot<int> Result = null!;
}
public static OpUi.CustomUiResult DrawChildUi(Instance instance,
ImDrawListPtr drawList,
ImRect area,
ScalableCanvas canvas,
ref OpUiBinding? data1)
{
data1 ??= new Binding(instance);
var data = (Binding)data1;
if (!data.IsValid)
return OpUi.CustomUiResult.PreventOpenSubGraph;
// Draw reference lines on hover — links to the matching Set op (mirror of the Set side).
if (area.Contains(ImGui.GetMousePos()))
{
OpUi.DrawVariableReferences(drawList, canvas, area.GetCenter(), instance, data.VariableName.Value,
Guid.Parse("7953f704-ebee-498b-8bdd-a2c201dfe278"),
Guid.Parse("bfd87742-aaf5-4fa8-b714-fd275de1c60d"));
}
drawList.PushClipRect(area.Min, area.Max, true);
var value = data.Result.Value;
var name = instance.SymbolChild.Name;
if (!string.IsNullOrWhiteSpace(name))
{
WidgetElements.DrawPrimaryTitle(drawList, area, name, canvas.Scale);
}
else
{
WidgetElements.DrawPrimaryTitle(drawList, area, "Get int: " + data.VariableName.TypedInputValue.Value, canvas.Scale);
}
WidgetElements.DrawSmallValue(drawList, area, $"{value:0}", canvas.Scale);
drawList.PopClipRect();
return OpUi.CustomUiResult.Rendered | OpUi.CustomUiResult.PreventInputLabels | OpUi.CustomUiResult.PreventOpenSubGraph;
}
}