Refine new_editor scene viewport flow
This commit is contained in:
@@ -14,27 +14,28 @@ using ::XCEngine::UI::UIDrawList;
|
||||
using ::XCEngine::UI::UIPoint;
|
||||
using ::XCEngine::UI::UIRect;
|
||||
|
||||
constexpr float kButtonExtent = 30.0f;
|
||||
constexpr float kButtonSpacing = 6.0f;
|
||||
constexpr float kPanelPadding = 6.0f;
|
||||
constexpr float kButtonExtent = 26.0f;
|
||||
constexpr float kButtonSpacing = 4.0f;
|
||||
constexpr float kPanelPadding = 5.0f;
|
||||
constexpr float kViewportInset = 10.0f;
|
||||
constexpr float kIconInset = 4.0f;
|
||||
constexpr float kPanelCornerRounding = 7.0f;
|
||||
constexpr float kButtonCornerRounding = 5.0f;
|
||||
constexpr float kFallbackFontSize = 11.0f;
|
||||
constexpr float kIconInset = 3.0f;
|
||||
constexpr float kPanelCornerRounding = 6.0f;
|
||||
constexpr float kButtonCornerRounding = 4.0f;
|
||||
constexpr float kFallbackFontSize = 10.0f;
|
||||
|
||||
struct ToolTexturePath {
|
||||
struct ToolButtonSpec {
|
||||
SceneToolMode mode = SceneToolMode::View;
|
||||
const char* label = "";
|
||||
const char* inactiveFile = "";
|
||||
const char* activeFile = "";
|
||||
};
|
||||
|
||||
constexpr std::array<ToolTexturePath, 4> kToolTexturePaths = {{
|
||||
constexpr std::array<ToolButtonSpec, 5> kToolButtonSpecs = {{
|
||||
{ SceneToolMode::View, "View", "view_move_tool.png", "view_move_tool_on.png" },
|
||||
{ SceneToolMode::Translate, "Move", "move_tool.png", "move_tool_on.png" },
|
||||
{ SceneToolMode::Rotate, "Rotate", "rotate_tool.png", "rotate_tool_on.png" },
|
||||
{ SceneToolMode::Scale, "Scale", "scale_tool.png", "scale_tool_on.png" }
|
||||
{ SceneToolMode::Scale, "Scale", "scale_tool.png", "scale_tool_on.png" },
|
||||
{ SceneToolMode::Transform, "Transform", "transform_tool.png", "transform_tool_on.png" }
|
||||
}};
|
||||
|
||||
bool ContainsPoint(const UIRect& rect, const UIPoint& point) {
|
||||
@@ -62,8 +63,8 @@ bool SceneViewportToolOverlay::Initialize(
|
||||
const std::filesystem::path iconRoot =
|
||||
(repoRoot / "editor" / "resources" / "Icons").lexically_normal();
|
||||
bool loadedAnyTexture = false;
|
||||
for (std::size_t index = 0; index < kToolTexturePaths.size(); ++index) {
|
||||
const ToolTexturePath& path = kToolTexturePaths[index];
|
||||
for (std::size_t index = 0; index < kToolButtonSpecs.size(); ++index) {
|
||||
const ToolButtonSpec& path = kToolButtonSpecs[index];
|
||||
ToolTextureSet& textureSet = m_toolTextures[index];
|
||||
textureSet = {};
|
||||
textureSet.mode = path.mode;
|
||||
@@ -121,13 +122,14 @@ void SceneViewportToolOverlay::BuildFrame(
|
||||
static_cast<float>(m_frame.buttons.size() - 1u) * kButtonSpacing);
|
||||
|
||||
for (std::size_t index = 0; index < m_frame.buttons.size(); ++index) {
|
||||
const ToolButtonSpec& spec = kToolButtonSpecs[index];
|
||||
const ToolTextureSet& textureSet = m_toolTextures[index];
|
||||
SceneViewportToolOverlayButtonFrame& button = m_frame.buttons[index];
|
||||
button = {};
|
||||
button.mode = textureSet.mode;
|
||||
button.label = textureSet.label;
|
||||
button.mode = spec.mode;
|
||||
button.label = spec.label;
|
||||
button.rect = BuildButtonRect(m_frame.panelRect, index);
|
||||
button.active = textureSet.mode == activeMode;
|
||||
button.active = spec.mode == activeMode;
|
||||
button.hovered = index == hoveredIndex;
|
||||
button.pressed = index == pressedIndex;
|
||||
button.texture = button.active
|
||||
|
||||
Reference in New Issue
Block a user