Skip to content

Commit

Permalink
further steps towards keeping symbol browser inside its graph canvas
Browse files Browse the repository at this point in the history
  • Loading branch information
domportera committed Oct 7, 2022
1 parent ea1b62f commit 2327207
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions T3/Gui/Graph/Interaction/SymbolBrowser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand All @@ -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))
{
Expand Down

0 comments on commit 2327207

Please sign in to comment.