refactor(new_editor): snapshot hosted editor restructuring
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
#include <XCEditor/Shell/UIEditorShellCompose.h>
|
||||
|
||||
#include "Rendering/Assets/BuiltInIcons.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace XCEngine::UI::Editor {
|
||||
@@ -71,70 +73,28 @@ UIEditorShellToolbarLayout BuildUIEditorShellToolbarLayout(
|
||||
return layout;
|
||||
}
|
||||
|
||||
void AppendPlayGlyph(
|
||||
::XCEngine::UI::UIDrawList& drawList,
|
||||
const UIRect& rect,
|
||||
const UIColor& color,
|
||||
float thickness) {
|
||||
const UIPoint a(rect.x + rect.width * 0.38f, rect.y + rect.height * 0.27f);
|
||||
const UIPoint b(rect.x + rect.width * 0.38f, rect.y + rect.height * 0.73f);
|
||||
const UIPoint c(rect.x + rect.width * 0.70f, rect.y + rect.height * 0.50f);
|
||||
drawList.AddLine(a, b, color, thickness);
|
||||
drawList.AddLine(a, c, color, thickness);
|
||||
drawList.AddLine(b, c, color, thickness);
|
||||
}
|
||||
|
||||
void AppendPauseGlyph(
|
||||
::XCEngine::UI::UIDrawList& drawList,
|
||||
const UIRect& rect,
|
||||
const UIColor& color,
|
||||
float thickness) {
|
||||
const float top = rect.y + rect.height * 0.26f;
|
||||
const float bottom = rect.y + rect.height * 0.74f;
|
||||
const float left = rect.x + rect.width * 0.40f;
|
||||
const float right = rect.x + rect.width * 0.60f;
|
||||
drawList.AddLine(UIPoint(left, top), UIPoint(left, bottom), color, thickness);
|
||||
drawList.AddLine(UIPoint(right, top), UIPoint(right, bottom), color, thickness);
|
||||
}
|
||||
|
||||
void AppendStepGlyph(
|
||||
::XCEngine::UI::UIDrawList& drawList,
|
||||
const UIRect& rect,
|
||||
const UIColor& color,
|
||||
float thickness) {
|
||||
const UIPoint a(rect.x + rect.width * 0.30f, rect.y + rect.height * 0.27f);
|
||||
const UIPoint b(rect.x + rect.width * 0.30f, rect.y + rect.height * 0.73f);
|
||||
const UIPoint c(rect.x + rect.width * 0.58f, rect.y + rect.height * 0.50f);
|
||||
const float barX = rect.x + rect.width * 0.70f;
|
||||
drawList.AddLine(a, b, color, thickness);
|
||||
drawList.AddLine(a, c, color, thickness);
|
||||
drawList.AddLine(b, c, color, thickness);
|
||||
drawList.AddLine(
|
||||
UIPoint(barX, rect.y + rect.height * 0.25f),
|
||||
UIPoint(barX, rect.y + rect.height * 0.75f),
|
||||
color,
|
||||
thickness);
|
||||
}
|
||||
|
||||
void AppendToolbarGlyph(
|
||||
::XCEngine::UI::UIDrawList& drawList,
|
||||
const UIRect& rect,
|
||||
UIEditorShellToolbarGlyph glyph,
|
||||
const UIColor& color,
|
||||
float thickness) {
|
||||
switch (glyph) {
|
||||
case UIEditorShellToolbarGlyph::Play:
|
||||
AppendPlayGlyph(drawList, rect, color, thickness);
|
||||
break;
|
||||
case UIEditorShellToolbarGlyph::Pause:
|
||||
AppendPauseGlyph(drawList, rect, color, thickness);
|
||||
break;
|
||||
case UIEditorShellToolbarGlyph::Step:
|
||||
AppendStepGlyph(drawList, rect, color, thickness);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
std::uint8_t iconKind,
|
||||
const App::BuiltInIcons* icons,
|
||||
const UIColor& tintColor) {
|
||||
if (icons == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
const ::XCEngine::UI::UITextureHandle& texture = icons->Resolve(static_cast<App::BuiltInIconKind>(iconKind));
|
||||
if (!texture.IsValid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const float inset = 2.0f;
|
||||
const UIRect iconRect(
|
||||
rect.x + inset,
|
||||
rect.y + inset,
|
||||
rect.width - inset * 2.0f,
|
||||
rect.height - inset * 2.0f);
|
||||
drawList.AddImage(iconRect, texture, tintColor);
|
||||
}
|
||||
|
||||
void AppendUIEditorShellToolbar(
|
||||
@@ -142,7 +102,8 @@ void AppendUIEditorShellToolbar(
|
||||
const UIEditorShellToolbarLayout& layout,
|
||||
const std::vector<UIEditorShellToolbarButton>& buttons,
|
||||
const UIEditorShellToolbarPalette& palette,
|
||||
const UIEditorShellToolbarMetrics& metrics) {
|
||||
const UIEditorShellToolbarMetrics& metrics,
|
||||
const App::BuiltInIcons* builtInIcons) {
|
||||
if (layout.bounds.width <= 0.0f || layout.bounds.height <= 0.0f) {
|
||||
return;
|
||||
}
|
||||
@@ -183,9 +144,9 @@ void AppendUIEditorShellToolbar(
|
||||
AppendToolbarGlyph(
|
||||
drawList,
|
||||
buttonRect,
|
||||
buttons[index].glyph,
|
||||
palette.iconColor,
|
||||
metrics.iconThickness);
|
||||
buttons[index].iconKind,
|
||||
builtInIcons,
|
||||
palette.iconColor);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -378,7 +339,8 @@ void AppendUIEditorShellCompose(
|
||||
const UIEditorShellComposeModel& model,
|
||||
const UIEditorShellComposeState& state,
|
||||
const UIEditorShellComposePalette& palette,
|
||||
const UIEditorShellComposeMetrics& metrics) {
|
||||
const UIEditorShellComposeMetrics& metrics,
|
||||
const App::BuiltInIcons* builtInIcons) {
|
||||
drawList.AddFilledRect(
|
||||
frame.layout.bounds,
|
||||
palette.surfaceColor,
|
||||
@@ -409,7 +371,8 @@ void AppendUIEditorShellCompose(
|
||||
frame.layout.toolbarLayout,
|
||||
model.toolbarButtons,
|
||||
palette.toolbarPalette,
|
||||
metrics.toolbarMetrics);
|
||||
metrics.toolbarMetrics,
|
||||
builtInIcons);
|
||||
|
||||
AppendUIEditorWorkspaceCompose(
|
||||
drawList,
|
||||
|
||||
Reference in New Issue
Block a user