From 2327207785cc6c7a990e5b1b7982b2b5c94f378d Mon Sep 17 00:00:00 2001 From: Dom Date: Wed, 5 Oct 2022 02:42:45 -0400 Subject: [PATCH] further steps towards keeping symbol browser inside its graph canvas --- T3/Gui/Graph/Interaction/SymbolBrowser.cs | 24 +++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/T3/Gui/Graph/Interaction/SymbolBrowser.cs b/T3/Gui/Graph/Interaction/SymbolBrowser.cs index 76194eb5da..2f1057fe32 100644 --- a/T3/Gui/Graph/Interaction/SymbolBrowser.cs +++ b/T3/Gui/Graph/Interaction/SymbolBrowser.cs @@ -90,8 +90,7 @@ public void Draw() if (highlightedSymbolUi != null) { - ImGui.SetCursorPos(posInWindow + new Vector2(250, _size.Y + 1)); - DrawDescriptionPanel(highlightedSymbolUi, new Vector2(250, _resultListSize.Y)); + DrawDescriptionPanelLeftOrRight(posInWindow, highlightedSymbolUi); } ImGui.PopStyleVar(2); @@ -304,6 +303,23 @@ private void DrawMatchesList(out SymbolUi highlightedSymbolUi) highlightedSymbolUi = itemForHelp; } + + private void DrawDescriptionPanelLeftOrRight(Vector2 posInWindow, SymbolUi highlightedSymbolUi) + { + float width = _resultListSize.X; + bool shouldShiftToRight = posInWindow.X + width > GraphCanvas.Current.WindowSize.X; + float xPositionOffset = shouldShiftToRight ? -width : width; + float xPosition = posInWindow.X + xPositionOffset; + + Vector2 position = new Vector2(xPosition, posInWindow.Y + _size.Y + 1); + + if (xPosition > 0) + { + ImGui.SetCursorPos(position); + DrawDescriptionPanel(highlightedSymbolUi, _resultListSize); + } + } + private void DrawDescriptionPanel(SymbolUi itemForHelp, Vector2 size) { if (itemForHelp == null) @@ -317,8 +333,8 @@ private void DrawDescriptionPanel(SymbolUi itemForHelp, Vector2 size) return; ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, Vector2.One); // Padding between panels - - if (ImGui.BeginChildFrame(998, size)) + + if (ImGui.BeginChildFrame(998, size, ImGuiWindowFlags.ChildWindow)) { if (!string.IsNullOrEmpty(itemForHelp.Description)) {