fix: respect dock layout for top run toolbar
This commit is contained in:
@@ -33,11 +33,10 @@ std::string BuildRunToolbarIconPath(const char* fileName) {
|
||||
}
|
||||
|
||||
const std::string& GetRunToolbarIconPath(size_t index) {
|
||||
static const std::array<const char*, 4> kFileNames = {
|
||||
static const std::array<const char*, 3> kFileNames = {
|
||||
"play_button.png",
|
||||
"pause_button.png",
|
||||
"step_button.png",
|
||||
"stop_button.png"
|
||||
"step_button.png"
|
||||
};
|
||||
static std::array<std::string, kFileNames.size()> s_cachedPaths = {};
|
||||
|
||||
@@ -110,6 +109,11 @@ bool DrawRunToolbarIconButton(
|
||||
MenuBar::MenuBar() : Panel("MenuBar") {}
|
||||
|
||||
void MenuBar::Render() {
|
||||
RenderChrome();
|
||||
RenderOverlays();
|
||||
}
|
||||
|
||||
void MenuBar::RenderChrome() {
|
||||
if (!m_context) {
|
||||
return;
|
||||
}
|
||||
@@ -117,6 +121,13 @@ void MenuBar::Render() {
|
||||
Actions::HandleMenuBarShortcuts(*m_context);
|
||||
Actions::DrawMainMenuBar(*m_context, m_aboutPopup);
|
||||
RenderRunToolbar();
|
||||
}
|
||||
|
||||
void MenuBar::RenderOverlays() {
|
||||
if (!m_context) {
|
||||
return;
|
||||
}
|
||||
|
||||
Actions::DrawMainMenuOverlays(m_context, m_aboutPopup);
|
||||
}
|
||||
|
||||
@@ -147,7 +158,10 @@ void MenuBar::RenderRunToolbar() {
|
||||
|
||||
if (open) {
|
||||
const Actions::ActionBinding playAction =
|
||||
Actions::MakeStartPlayModeAction(m_context->GetRuntimeMode(), m_context->GetSceneManager().HasActiveScene());
|
||||
Actions::MakeTogglePlayModeAction(
|
||||
m_context->GetRuntimeMode(),
|
||||
m_context->GetRuntimeMode() != EditorRuntimeMode::Edit ||
|
||||
m_context->GetSceneManager().HasActiveScene());
|
||||
const bool canPause =
|
||||
m_context->GetRuntimeMode() == EditorRuntimeMode::Play ||
|
||||
m_context->GetRuntimeMode() == EditorRuntimeMode::Paused;
|
||||
@@ -155,10 +169,9 @@ void MenuBar::RenderRunToolbar() {
|
||||
Actions::MakeTogglePauseModeAction(m_context->GetRuntimeMode(), canPause);
|
||||
const Actions::ActionBinding stepAction =
|
||||
Actions::MakeStepPlayModeAction(m_context->GetRuntimeMode() == EditorRuntimeMode::Paused);
|
||||
const Actions::ActionBinding stopAction = Actions::MakeStopPlayModeAction(m_context->GetRuntimeMode());
|
||||
|
||||
const float totalWidth =
|
||||
kRunToolbarButtonExtent * 4.0f + kRunToolbarButtonSpacing * 3.0f;
|
||||
kRunToolbarButtonExtent * 3.0f + kRunToolbarButtonSpacing * 2.0f;
|
||||
const float startX =
|
||||
ImGui::GetCursorPosX() + (std::max)(0.0f, (ImGui::GetContentRegionAvail().x - totalWidth) * 0.5f);
|
||||
const float startY =
|
||||
@@ -170,8 +183,8 @@ void MenuBar::RenderRunToolbar() {
|
||||
playAction,
|
||||
GetRunToolbarIconPath(0),
|
||||
"P",
|
||||
"Available in Edit mode when an active scene exists.")) {
|
||||
Actions::RequestStartPlayMode(*m_context);
|
||||
"Play requires Edit mode with an active scene.")) {
|
||||
Actions::RequestTogglePlayMode(*m_context);
|
||||
}
|
||||
|
||||
ImGui::SameLine(0.0f, kRunToolbarButtonSpacing);
|
||||
@@ -194,16 +207,6 @@ void MenuBar::RenderRunToolbar() {
|
||||
Actions::RequestStepPlayMode(*m_context);
|
||||
}
|
||||
|
||||
ImGui::SameLine(0.0f, kRunToolbarButtonSpacing);
|
||||
if (DrawRunToolbarIconButton(
|
||||
"Stop",
|
||||
stopAction,
|
||||
GetRunToolbarIconPath(3),
|
||||
"S",
|
||||
"Available while runtime is active.")) {
|
||||
Actions::RequestStopPlayMode(*m_context);
|
||||
}
|
||||
|
||||
UI::DrawCurrentWindowBottomBorder();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user