Files
UsdLayerManager/src/ui/IconManager.h
T
indigo 9816fb8759 Stage Editor Panel — sublayer editing with ET control, mute, reorder, dirty state
Replace LayerPanel with StageEditorPanel for full sublayer composition workflow:
- Edit target (ET) checkbox on root/session and each sublayer; pen icon header
- Dirty indicator (*) per layer; muted layers remain visible in list
- Drag-drop and Move Up/Down reordering with undo (LayerReorderCommand)
- Add existing sublayer via file dialog; create new sublayer modal
- Fixed LayerReorderCommand::ApplyOrder using full-stack indices on sublayer-local
  list (silent remove failure → duplicate insert → USD _ValidateEdit error)
- Fixed muted sublayer visibility: walk GetSubLayerPaths() + FindOrOpenRelativeToLayer
  + m_layerRefs to keep muted layers alive and visible

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-14 16:37:30 +08:00

97 lines
3.1 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#pragma once
#include <imgui.h>
#include <string>
#include <unordered_map>
namespace UsdLayerManager {
/// Symbolic icon names used throughout the UI.
enum class Icon {
// Visibility
Eye,
EyeSlash,
// Reference state
Link,
LinkSlash,
// Prim types
Globe, // PseudoRoot / World
Cube, // Mesh / Subdiv
Camera,
Lightbulb, // Light
FolderOpen, // Scope
ObjectGroup, // Xform
Swatchbook, // Material
Code, // Shader
LayerGroup, // Model
CircleDot, // Generic prim
// Viewport manipulator tools
ToolSelect, // cursor / arrow-pointer
ToolMove, // four-directional arrows
ToolRotate, // circular arrows
ToolScale, // expand/compress arrows
// Viewport display toggles
WorldSpace, // globe / world coordinate space
LocalSpace, // coordinate axes / local object space
Grid, // ground grid toggle
Antialias, // anti-aliasing toggle
// Viewport layout modes
LayoutSingle, // single viewport
LayoutHSplit, // two panels side-by-side
LayoutVSplit, // two panels top/bottom
LayoutQuad, // four panels 2×2
// Timeline transport
SkipBack, // go to first frame (|◀)
StepBack, // previous frame (◀◀)
PlayBack, // play in reverse (◀)
Play, // play (▶)
Pause, // pause (⏸)
StepForward, // next frame (▶▶)
SkipEnd, // go to last frame (▶|)
Loop, // loop toggle (↻)
Bounce, // bounce/ping-pong (↔)
// General actions
Refresh, // reload / refresh
FilePlus, // create new file
Pen, // edit / edit target
};
/// Loads SVG files from disk, rasterizes them with NanoSVG, uploads them as
/// OpenGL textures, and hands out ImTextureID handles for use with
/// ImGui::Image() / ImGui::ImageButton().
///
/// Lifecycle: Initialize() after OpenGL is ready, Shutdown() before context
/// is destroyed. One global instance is owned by Application.
class IconManager {
public:
IconManager();
~IconManager();
/// Load and rasterize all icons from the given directory.
/// @param iconDir Path to the directory containing the .svg files.
/// @param sizePixels Rasterisation size in pixels (both axes).
bool Initialize(const std::string& iconDir, int sizePixels = 16);
/// Release all GPU textures.
void Shutdown();
/// Return the ImTextureID for the given icon.
/// Returns a 1×1 transparent fallback texture when the icon is missing.
ImTextureID Get(Icon icon) const;
/// Pixel size the icons were rasterised at.
int SizePixels() const { return m_sizePixels; }
ImVec2 SizeVec() const { return ImVec2(static_cast<float>(m_sizePixels),
static_cast<float>(m_sizePixels)); }
private:
bool LoadSVG(Icon icon, const std::string& path);
void CreateFallback();
int m_sizePixels = 16;
ImTextureID m_fallback = ImTextureID_Invalid;
std::unordered_map<int, ImTextureID> m_textures; // key = (int)Icon
};
} // namespace UsdLayerManager