tooll3--t3
66 行
2.4 KiB
C#
66 行
2.4 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 GetBoolVarUi
|
|
{
|
|
private sealed class Binding : OpUiBinding
|
|
{
|
|
internal Binding(Instance instance)
|
|
{
|
|
IsValid = AutoBind(instance);
|
|
}
|
|
|
|
[BindInput("b0821091-68c0-4e34-9f8b-926c0b6ebf94")]
|
|
internal readonly InputSlot<string> VariableName = null!;
|
|
|
|
[BindOutput("B5BB6CD9-58DD-4C9C-AAB3-AE0E21C81822")]
|
|
internal readonly Slot<bool> 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("9a843835-d39c-428f-b996-6334323e8106"),
|
|
Guid.Parse("BFDFCD6E-3B31-4B26-AFF4-3023A6B72810"));
|
|
}
|
|
|
|
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 bool: " + data.VariableName.TypedInputValue.Value, canvas.Scale);
|
|
}
|
|
|
|
WidgetElements.DrawSmallValue(drawList, area, $"{value}", canvas.Scale);
|
|
|
|
drawList.PopClipRect();
|
|
return OpUi.CustomUiResult.Rendered | OpUi.CustomUiResult.PreventInputLabels | OpUi.CustomUiResult.PreventOpenSubGraph;
|
|
}
|
|
} |