Skip to content

Commit dedec0f

Browse files
authored
Update: Parameter's tooltip appears even if animated or has input connected (#975)
* Update: Parameters tooltip even if animated or input connected * Tooltip when input has connection
1 parent 93db446 commit dedec0f

File tree

1 file changed

+41
-28
lines changed

1 file changed

+41
-28
lines changed

Editor/UiModel/InputsAndTypes/InputValueUi.cs

Lines changed: 41 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -230,13 +230,13 @@ InputEditStateFlags DrawConnectedParameter()
230230
ImGui.PushStyleColor(ImGuiCol.Text, UiColors.ForegroundFull.Rgba);
231231
ImGui.Button($"{input.Name.AddSpacesForImGuiOutput()}##ParamName", new Vector2(ParameterNameWidth, 0.0f));
232232
ImGui.PopStyleColor();
233-
if (ImGui.BeginPopupContextItem("##parameterOptions", 0))
233+
/*if (ImGui.BeginPopupContextItem("##parameterOptions", 0))
234234
{
235235
if (ImGui.MenuItem("Parameters settings"))
236236
editState = InputEditStateFlags.ShowOptions;
237237
238238
ImGui.EndPopup();
239-
}
239+
}*/
240240

241241
CustomComponents.ContextMenuForItem(() =>
242242
{
@@ -280,6 +280,7 @@ InputEditStateFlags DrawConnectedParameter()
280280

281281
if (ImGui.MenuItem("Parameters settings"))
282282
editState = InputEditStateFlags.ShowOptions;
283+
283284
});
284285

285286
ImGui.PopStyleVar();
@@ -288,14 +289,23 @@ InputEditStateFlags DrawConnectedParameter()
288289
ImGui.PushItemWidth(200.0f);
289290
ImGui.SetNextItemWidth(-1);
290291

291-
string connectedName;
292-
if (typedInputSlot.TryGetFirstConnection(out var connectedSlot))
292+
var connectedName = "???";
293+
if (typedInputSlot.TryGetFirstConnection(out var connectedSlot) && connectedSlot?.Parent != null)
293294
{
294-
connectedName = connectedSlot?.Parent.Symbol.Name ?? "???";
295+
connectedName = !string.IsNullOrWhiteSpace(connectedSlot.Parent.SymbolChild.Name)
296+
? connectedSlot.Parent.SymbolChild.Name
297+
: (!string.IsNullOrWhiteSpace(connectedSlot.Parent.Symbol.Name)
298+
? connectedSlot.Parent.Symbol.Name
299+
: "???");
295300
}
296-
else
301+
if (ImGui.IsItemHovered())
297302
{
298-
connectedName = "???";
303+
var text = "Input: " + connectedName ;
304+
if (!string.IsNullOrEmpty(Description))
305+
{
306+
text += "\n-----";
307+
}
308+
CustomComponents.TooltipForLastItem(text, Description);
299309
}
300310

301311
ImGui.PushStyleColor(ImGuiCol.Text, typeColor.Rgba);
@@ -398,8 +408,7 @@ InputEditStateFlags DrawAnimatedParameter(Curve curve)
398408
});
399409
ImGui.PopStyleVar();
400410

401-
if (ImGui.IsItemHovered())
402-
Icons.DrawIconAtScreenPosition(Icon.Revert, ImGui.GetItemRectMin() + new Vector2(6, 4) * T3Ui.UiScaleFactor);
411+
DrawInputTooltipAndResetIcon(input);
403412

404413
if (isClicked)
405414
{
@@ -452,25 +461,7 @@ InputEditStateFlags DrawNormalParameter()
452461
ImGui.PopStyleColor(hasStyleCount);
453462
}
454463

455-
if (ImGui.IsItemHovered())
456-
{
457-
var text = "";
458-
if (!string.IsNullOrEmpty(Description))
459-
{
460-
text += Description;
461-
}
462-
463-
var additionalNotes = input.IsDefault ? null : "Click to reset to default";
464-
465-
if (!string.IsNullOrEmpty(text) || !string.IsNullOrEmpty(additionalNotes))
466-
{
467-
CustomComponents.TooltipForLastItem(text,
468-
additionalNotes);
469-
}
470-
471-
if (!input.IsDefault)
472-
Icons.DrawIconAtScreenPosition(Icon.Revert, ImGui.GetItemRectMin() + new Vector2(6, 4) * T3Ui.UiScaleFactor);
473-
}
464+
DrawInputTooltipAndResetIcon(input);
474465

475466
if (isClicked)
476467
{
@@ -606,6 +597,28 @@ public virtual void Read(JToken? inputToken)
606597
public Type Type { get; } = typeof(T);
607598

608599
private const Relevancy DefaultRelevancy = Relevancy.Optional;
600+
601+
private void DrawInputTooltipAndResetIcon(Symbol.Child.Input input)
602+
{
603+
if (!ImGui.IsItemHovered())
604+
return;
605+
606+
var text = Description ?? string.Empty;
607+
var additionalNotes = input.IsDefault ? null : "Click to reset to default";
608+
609+
if (!string.IsNullOrEmpty(text) || !string.IsNullOrEmpty(additionalNotes))
610+
{
611+
CustomComponents.TooltipForLastItem(text, additionalNotes);
612+
}
613+
614+
if (!input.IsDefault)
615+
{
616+
Icons.DrawIconAtScreenPosition(
617+
Icon.Revert,
618+
ImGui.GetItemRectMin() + new Vector2(6, 4) * T3Ui.UiScaleFactor
619+
);
620+
}
621+
}
609622
}
610623

611624
internal static class InputArea

0 commit comments

Comments
 (0)