Scene Hierarchy ET switcher + Create Sublayer via Save dialog
- Add edit-target layer combo at top of Scene Hierarchy panel (always visible when stage loaded — session, root, sublayers); routes through LayerManager::SetEditTarget so StageEditor ET checkboxes stay in sync - Replace custom Create Sublayer modal with native SaveFile dialog; LayerManager::CreateNewSublayer creates the file on disk, inserts it at the top of the sublayer stack, and activates it as edit target Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -119,6 +119,63 @@ void SceneHierarchyPanel::Render() {
|
||||
return;
|
||||
}
|
||||
|
||||
// ── Edit-target layer switcher ────────────────────────────────────
|
||||
{
|
||||
struct LayerEntry { SdfLayerHandle layer; std::string label; };
|
||||
std::vector<LayerEntry> layers;
|
||||
|
||||
auto sessionLayer = m_stage->GetSessionLayer();
|
||||
if (sessionLayer)
|
||||
layers.push_back({ sessionLayer, "Session" });
|
||||
|
||||
auto rootLayer = m_stage->GetRootLayer();
|
||||
if (rootLayer) {
|
||||
std::string name = rootLayer->IsAnonymous()
|
||||
? "anonymous"
|
||||
: std::filesystem::path(rootLayer->GetIdentifier()).filename().string();
|
||||
layers.push_back({ rootLayer, "Root: " + name });
|
||||
|
||||
for (const auto& subPath : rootLayer->GetSubLayerPaths()) {
|
||||
auto sub = SdfLayer::FindOrOpenRelativeToLayer(rootLayer, subPath);
|
||||
if (!sub) continue;
|
||||
std::string subName = sub->IsAnonymous()
|
||||
? sub->GetIdentifier()
|
||||
: std::filesystem::path(sub->GetIdentifier()).filename().string();
|
||||
layers.push_back({ SdfLayerHandle(sub), subName });
|
||||
}
|
||||
}
|
||||
|
||||
std::string currentLabel = "\xe2\x80\x94"; // em dash
|
||||
auto etLayer = m_stage->GetEditTarget().GetLayer();
|
||||
if (etLayer) {
|
||||
for (const auto& e : layers) {
|
||||
if (e.layer && e.layer->GetIdentifier() == etLayer->GetIdentifier()) {
|
||||
currentLabel = e.label;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::SetNextItemWidth(-1.0f);
|
||||
if (ImGui::BeginCombo("##layerswitch", currentLabel.c_str(),
|
||||
ImGuiComboFlags_HeightRegular)) {
|
||||
for (const auto& e : layers) {
|
||||
bool isCurrent = (e.layer && etLayer &&
|
||||
e.layer->GetIdentifier() == etLayer->GetIdentifier());
|
||||
if (ImGui::Selectable(e.label.c_str(), isCurrent)) {
|
||||
if (m_layerManager)
|
||||
m_layerManager->SetEditTarget(e.layer->GetIdentifier());
|
||||
else
|
||||
m_stage->SetEditTarget(UsdEditTarget(e.layer));
|
||||
}
|
||||
if (isCurrent)
|
||||
ImGui::SetItemDefaultFocus();
|
||||
}
|
||||
ImGui::EndCombo();
|
||||
}
|
||||
ImGui::Spacing();
|
||||
}
|
||||
|
||||
auto paths = m_propertyManager->GetPrimPaths();
|
||||
if (paths.empty()) {
|
||||
ImGui::TextDisabled("No prims in stage");
|
||||
|
||||
Reference in New Issue
Block a user