From 6b8cb2406ef896c308aa5190013dbef3213a36f4 Mon Sep 17 00:00:00 2001 From: indigo Date: Mon, 6 Jul 2026 03:26:39 +0800 Subject: [PATCH] Move preview renderer and HDR pickers above the shader ball Drop the 'Shader Ball' label; the renderer switch and HDR environment dropdowns sit side by side at the top of the preview column, above the swatch. Both pickers take an optional item width. Co-Authored-By: Claude Fable 5 --- src/ui/MaterialEditorPanel.cpp | 12 ++++++------ src/ui/MaterialPreviewRenderer.cpp | 8 ++++---- src/ui/MaterialPreviewRenderer.h | 6 ++++-- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/ui/MaterialEditorPanel.cpp b/src/ui/MaterialEditorPanel.cpp index daa7666..8c223bd 100644 --- a/src/ui/MaterialEditorPanel.cpp +++ b/src/ui/MaterialEditorPanel.cpp @@ -287,8 +287,12 @@ void MaterialEditorPanel::Render() { } void MaterialEditorPanel::RenderPreviewPanel() { - ImGui::TextUnformatted("Shader Ball"); - ImGui::Separator(); + // Renderer switch and HDR environment side by side above the preview. + const float halfWidth = + (ImGui::GetContentRegionAvail().x - ImGui::GetStyle().ItemSpacing.x) * 0.5f; + m_preview.RenderRendererDropdown(halfWidth); + ImGui::SameLine(); + m_preview.RenderLightingDropdown(halfWidth); if (m_stage && !m_materialPath.IsEmpty()) { // Hypershade-style: with a node selected, the ball previews that @@ -324,10 +328,6 @@ void MaterialEditorPanel::RenderPreviewPanel() { ImGui::Dummy(ImVec2(size, size)); } - ImGui::Separator(); - m_preview.RenderRendererDropdown(); - m_preview.RenderLightingDropdown(); - ImGui::Separator(); ImGui::TextUnformatted("Node Properties"); ImGui::Separator(); diff --git a/src/ui/MaterialPreviewRenderer.cpp b/src/ui/MaterialPreviewRenderer.cpp index 3d0b869..8a7c416 100644 --- a/src/ui/MaterialPreviewRenderer.cpp +++ b/src/ui/MaterialPreviewRenderer.cpp @@ -257,9 +257,9 @@ void MaterialPreviewRenderer::UpdateDomeOrientation() { m_dirty = true; } -void MaterialPreviewRenderer::RenderLightingDropdown() { +void MaterialPreviewRenderer::RenderLightingDropdown(float width) { if (!m_initialized) return; - ImGui::SetNextItemWidth(-1.0f); + ImGui::SetNextItemWidth(width); if (ImGui::BeginCombo("##PreviewLighting", kLightPresets[m_lightPreset].label)) { for (int i = 0; i < kLightPresetCount; ++i) { if (ImGui::Selectable(kLightPresets[i].label, i == m_lightPreset) && i != m_lightPreset) @@ -309,13 +309,13 @@ void MaterialPreviewRenderer::SetColorCorrection(int ccMode, const std::string& m_dirty = true; } -void MaterialPreviewRenderer::RenderRendererDropdown() { +void MaterialPreviewRenderer::RenderRendererDropdown(float width) { pxr::TfToken currentId = m_renderer.GetCurrentRendererId(); std::string displayName = currentId.IsEmpty() ? "Renderer" : UsdSceneRenderer::GetRendererDisplayName(currentId); - ImGui::Button(displayName.c_str(), ImVec2(-1.0f, 0.0f)); + ImGui::Button(displayName.c_str(), ImVec2(width, 0.0f)); if (ImGui::IsItemHovered()) ImGui::SetTooltip("Shader-ball render delegate"); diff --git a/src/ui/MaterialPreviewRenderer.h b/src/ui/MaterialPreviewRenderer.h index 5d74211..02ac5ee 100644 --- a/src/ui/MaterialPreviewRenderer.h +++ b/src/ui/MaterialPreviewRenderer.h @@ -50,12 +50,14 @@ public: const std::string& ocioLook); /// Renderer-delegate picker UI (matches the viewport's dropdown pattern). - void RenderRendererDropdown(); + /// width: ImGui item width (-1 = fill available). + void RenderRendererDropdown(float width = -1.0f); /// HDR-environment picker (External / Room / Interior / Sunset). Presets /// map to bundled resources/hdri/*.exr dome-light textures; a preset /// whose file is missing falls back to the distant key light. - void RenderLightingDropdown(); + /// width: ImGui item width (-1 = fill available). + void RenderLightingDropdown(float width = -1.0f); private: void EnsureInitialized();