Moved play buttons into main menu

This commit is contained in:
Simon Lübeß
2024-03-10 15:16:55 +01:00
parent fc475eb468
commit 27c433aba2
+27 -13
View File
@@ -1157,15 +1157,12 @@ namespace GlitchyEditor
_settingsWindow.Show();
ShowCreateNewProjectModal();
ShowPlayControls();
return false;
}
/// Shows the window with Play/Pause, etc. buttons
private void ShowPlayControls()
{
ImGui.PushStyleVar(.WindowPadding, ImGui.Vec2(0, 2));
ImGui.PushStyleVar(.ItemInnerSpacing, ImGui.Vec2(0, 0));
ImGui.PushStyleColor(.Button, ImGui.Vec4(0, 0, 0, 0));
@@ -1180,8 +1177,6 @@ namespace GlitchyEditor
ImGui.PushStyleColor(.ButtonHovered, hoveredColor);
ImGui.PushStyleColor(.ButtonActive, activeColor);
ImGui.Begin("##toolbar", null, .NoDecoration | .NoScrollbar | .NoScrollWithMouse);
float padding = 2.0f;
float size = ImGui.GetWindowHeight() - 2 * padding;
@@ -1247,8 +1242,6 @@ namespace GlitchyEditor
totalWidth = size * 3 + padding * 4;
}
// Display the buttons for play/simulation state
ImGui.SameLine();
ImGui.SetCursorPosX(centerX - totalWidth / 2.0f);
@@ -1279,19 +1272,40 @@ namespace GlitchyEditor
if (ImGui.BeginPopupContextItem())
{
if (ImGui.BeginTable("time_step_table", 2))
{
ImGui.TableNextRow();
ImGui.TableNextColumn();
ImGui.TextUnformatted("Time step:");
ImGui.SameLine();
ImGui.TableNextColumn();
float itemWidth = ImGui.CalcTextSize("1000.000 FPS").x;
ImGui.SetNextItemWidth(itemWidth);
ImGui.DragFloat("##timestep", &_fixedTimestep, 0.001f, 0.001f, 1000.0f, "%.4fs");
ImGui.TableNextRow();
ImGui.TableNextColumn();
float fps = 1.0f / _fixedTimestep;
ImGui.TextUnformatted("Frame rate:");
ImGui.SameLine();
ImGui.TableNextColumn();
ImGui.SetNextItemWidth(itemWidth);
if (ImGui.DragFloat("##fps", &fps, 1.0f, 0.001f, 1000.0f, "%.3f FPS"))
{
_fixedTimestep = 1.0f / fps;
}
ImGui.EndTable();
}
ImGui.EndPopup();
}
@@ -1311,10 +1325,8 @@ namespace GlitchyEditor
ImGui.AttachTooltip("Stop");
}
ImGui.End();
ImGui.PopStyleColor(3);
ImGui.PopStyleVar(2);
ImGui.PopStyleVar(1);
}
private void ShowOpenRecentSceneMenu()
@@ -1431,7 +1443,7 @@ namespace GlitchyEditor
ImGui.Separator();
if (ImGui.MenuItem("Exit"))
Application.Get().Close();
Application.Instance.Close();
ImGui.EndMenu();
}
@@ -1477,6 +1489,8 @@ namespace GlitchyEditor
ImGui.EndMenu();
}
ShowPlayControls();
ImGui.EndMainMenuBar();
}