diff --git a/external/vcpkg b/external/vcpkg index cb2981c..e456309 160000 --- a/external/vcpkg +++ b/external/vcpkg @@ -1 +1 @@ -Subproject commit cb2981c4e03d421fa03b9bb5044cd1986180e7e4 +Subproject commit e456309491fd875487bf02b8a0dca76c1b1b00cc diff --git a/src/Editor/Asset/MeshLoader.cpp b/src/Editor/Asset/MeshLoader.cpp index 0337917..c9f6e9a 100644 --- a/src/Editor/Asset/MeshLoader.cpp +++ b/src/Editor/Asset/MeshLoader.cpp @@ -6,7 +6,6 @@ #include "Graphics/Mesh.h" #include "Graphics/Shader.h" #include "Graphics/StaticMeshVertexData.h" -#include "ThreadPool.h" #include #include #include @@ -14,10 +13,9 @@ #include #include #include -#include +#include #include #include -#include #include using namespace Seele; diff --git a/src/Editor/Window/InspectorView.cpp b/src/Editor/Window/InspectorView.cpp index 241642a..4df49b0 100644 --- a/src/Editor/Window/InspectorView.cpp +++ b/src/Editor/Window/InspectorView.cpp @@ -8,6 +8,7 @@ using namespace Seele; using namespace Seele::Editor; +using namespace Seele::UI; InspectorView::InspectorView(Gfx::PGraphics graphics, PWindow window, const ViewportCreateInfo& createInfo) : View(graphics, window, createInfo, "InspectorView"), @@ -15,7 +16,7 @@ InspectorView::InspectorView(Gfx::PGraphics graphics, PWindow window, const View new UI::Div(UI::Attributes{}, { new UI::Div({}, { - new UI::Text("Other Test T"), + new UI::Text("Other Test T"), }), new UI::Text("Test fasdf agll;sdfgkj ahsf"), }))) { diff --git a/src/Editor/Window/InspectorView.h b/src/Editor/Window/InspectorView.h index d4ef590..a82e7ef 100644 --- a/src/Editor/Window/InspectorView.h +++ b/src/Editor/Window/InspectorView.h @@ -3,6 +3,7 @@ #include "Graphics/RenderPass/UIPass.h" #include "Window/View.h" #include "UI/System.h" +#include "UI/Style/Fonts.h" namespace Seele { DECLARE_REF(Actor) diff --git a/src/Editor/main.cpp b/src/Editor/main.cpp index 8f06238..cc6f56f 100644 --- a/src/Editor/main.cpp +++ b/src/Editor/main.cpp @@ -21,7 +21,7 @@ using namespace Seele::Editor; static Gfx::OGraphics graphics; int main() { - std::string gameName = "FluidSimulation"; + std::string gameName = "MeshShadingDemo"; std::filesystem::path outputPath = fmt::format("/home/dynamitos/{0}Game/", gameName); std::filesystem::path sourcePath = fmt::format("/home/dynamitos/{0}/", gameName); #ifdef WIN32 @@ -31,7 +31,7 @@ int main() { #else std::string libraryEnding = "so"; #endif - std::filesystem::path binaryPath = sourcePath / "build" / fmt::format("{}.{}", gameName, libraryEnding); + std::filesystem::path binaryPath = sourcePath / "bin" / fmt::format("{}.{}", gameName, libraryEnding); std::filesystem::path cmakePath = outputPath / "cmake"; if (true) { graphics = new Vulkan::Graphics(); @@ -47,7 +47,7 @@ int main() { .filePath = "./fonts/arial.ttf", }); AssetImporter::importEnvironmentMap(EnvironmentImportArgs{ - .filePath = sourcePath / "import" / "newport_loft.hdr", + .filePath = sourcePath / "import" / "textures" / "newport_loft.hdr", }); // AssetImporter::importTexture(TextureImportArgs{ // .filePath = sourcePath / "import" / "textures" / "grass_block_side.png", @@ -57,20 +57,16 @@ int main() { // .filePath = sourcePath / "import" / "models" / "main1_sponza" / "sponza.gltf", // .importPath = "sponza", //}); - // AssetImporter::importMesh(MeshImportArgs{ - // .filePath = sourcePath / "import" / "models" / "rttest.gltf", - // .importPath = "rttest", - // }); - - // AssetImporter::importMesh(MeshImportArgs{ - // .filePath = sourcePath / "import" / "models" / "cube.fbx", - // .importPath = "", - // }); AssetImporter::importMesh(MeshImportArgs{ - .filePath = sourcePath / "import" / "rttest.gltf", + .filePath = sourcePath / "import" / "models" / "rttest.gltf", .importPath = "rttest", }); + AssetImporter::importMesh(MeshImportArgs{ + .filePath = sourcePath / "import" / "models" / "cube.fbx", + .importPath = "", + }); + getThreadPool().waitIdle(); vd->commitMeshes(); WindowCreateInfo mainWindowInfo = { diff --git a/src/Engine/CMakeLists.txt b/src/Engine/CMakeLists.txt index abbf671..b083a6c 100644 --- a/src/Engine/CMakeLists.txt +++ b/src/Engine/CMakeLists.txt @@ -5,7 +5,7 @@ target_sources(Engine Game.h MinimalEngine.h ThreadPool.h - ThreadPool.cpp "../../tests/Engine/UI/Element.cpp") + ThreadPool.cpp) target_sources(Engine PUBLIC FILE_SET HEADERS diff --git a/src/Engine/Graphics/RenderPass/UIPass.cpp b/src/Engine/Graphics/RenderPass/UIPass.cpp index b2e7271..0608383 100644 --- a/src/Engine/Graphics/RenderPass/UIPass.cpp +++ b/src/Engine/Graphics/RenderPass/UIPass.cpp @@ -56,6 +56,10 @@ UIPass::~UIPass() {} void UIPass::beginFrame(const Component::Camera& cam, const Component::Transform& transform) { updateViewParameters(cam, transform); viewParamsSet = createViewParamsSet(); + // input first (hover transitions etc.), then style+layout, then gather render data + system->processInput(); + system->beginFrame(UVector2(viewport->getWidth(), viewport->getHeight())); + renderElements = system->render(); glyphs.clear(); usedTextures.clear(); elements.clear(); @@ -253,7 +257,4 @@ void UIPass::createRenderPass() { }}, }, }); - system->style(); - system->layout(UVector2(viewport->getWidth(), viewport->getHeight())); - renderElements = system->render(); } diff --git a/src/Engine/Graphics/RenderPass/UIPass.h b/src/Engine/Graphics/RenderPass/UIPass.h index 572f1ad..b914329 100644 --- a/src/Engine/Graphics/RenderPass/UIPass.h +++ b/src/Engine/Graphics/RenderPass/UIPass.h @@ -19,6 +19,14 @@ class UIPass : public RenderPass { virtual void publishOutputs() override; virtual void createRenderPass() override; + // input: the owning view forwards its window callbacks here (window-relative coords) + void mouseMove(Vector2 position) { system->mouseMove(position); } + void mouseButton(MouseButton button, InputAction action, KeyModifierFlags modifier, Vector2 position) { + system->mouseButton(button, action, (KeyModifier)modifier, position); + } + void scroll(Vector2 delta) { system->scroll(delta); } + void key(KeyCode code, InputAction action, KeyModifierFlags modifier, char text = 0) { system->key(code, action, (KeyModifier)modifier, text); } + private: struct GlyphData { Vector2 bearing; diff --git a/src/Engine/Graphics/Shader.cpp b/src/Engine/Graphics/Shader.cpp index 8f5eb27..e737f91 100644 --- a/src/Engine/Graphics/Shader.cpp +++ b/src/Engine/Graphics/Shader.cpp @@ -3,7 +3,7 @@ #include "Graphics/Initializer.h" #include "Material/Material.h" #include "ThreadPool.h" -#include +#include #include using namespace Seele; diff --git a/src/Engine/Graphics/slang-compile.cpp b/src/Engine/Graphics/slang-compile.cpp index 7b64112..7feff29 100644 --- a/src/Engine/Graphics/slang-compile.cpp +++ b/src/Engine/Graphics/slang-compile.cpp @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/Engine/Material/ShaderExpression.cpp b/src/Engine/Material/ShaderExpression.cpp index b845ce2..8c40cb0 100644 --- a/src/Engine/Material/ShaderExpression.cpp +++ b/src/Engine/Material/ShaderExpression.cpp @@ -5,8 +5,7 @@ #include "Graphics/Graphics.h" #include "Graphics/Resources.h" #include "Material/Material.h" -#include -#include +#include using namespace Seele; diff --git a/src/Engine/Math/Vector.cpp b/src/Engine/Math/Vector.cpp index 78752b7..ffd1b40 100644 --- a/src/Engine/Math/Vector.cpp +++ b/src/Engine/Math/Vector.cpp @@ -1,6 +1,5 @@ #include "Vector.h" -#include "Serialization/ArchiveBuffer.h" -#include +#include #include #include #include diff --git a/src/Engine/UI/Attributes.h b/src/Engine/UI/Attributes.h index e7f2e68..5321c36 100644 --- a/src/Engine/UI/Attributes.h +++ b/src/Engine/UI/Attributes.h @@ -1,11 +1,36 @@ #pragma once -#include "MinimalEngine.h" +#include "Graphics/Enums.h" +#include "Math/Vector.h" #include namespace Seele { namespace UI { +// mouse coordinates are in element-local space when the event reaches the element +struct MouseEvent { + Vector2 position; + enum class Kind { Move, Down, Up, Scroll } kind; + Vector2 delta; // scroll +}; +struct KeyEvent { + KeyCode code; + InputAction action; + bool shift; + bool ctrl; + bool alt; + char text; // for character input; 0 if none +}; + struct Attributes { - std::function onClick; + bool focusable = false; + // input handlers; return true to consume the event (no further propagation) + std::function onClick; + std::function onHover; // hover-enter + std::function onHoverLeave; + std::function onScroll; + std::function onKey; + std::function onText; + std::function onFocus; + std::function onBlur; }; } // namespace UI -} // namespace Seele \ No newline at end of file +} // namespace Seele diff --git a/src/Engine/UI/CMakeLists.txt b/src/Engine/UI/CMakeLists.txt index 4c2a971..3fdfc01 100644 --- a/src/Engine/UI/CMakeLists.txt +++ b/src/Engine/UI/CMakeLists.txt @@ -3,7 +3,8 @@ target_sources(Engine Attributes.h Element.h Element.cpp - + System.h + System.cpp ) target_sources(Engine @@ -11,7 +12,8 @@ target_sources(Engine FILES Attributes.h Element.h + System.h ) add_subdirectory(Style/) -add_subdirectory(Element/) \ No newline at end of file +add_subdirectory(Element/) diff --git a/src/Engine/UI/Element.cpp b/src/Engine/UI/Element.cpp index c07c911..834f2a3 100644 --- a/src/Engine/UI/Element.cpp +++ b/src/Engine/UI/Element.cpp @@ -1,16 +1,7 @@ -#include "Element.h" -#include "System.h" +#include "UI/Element.h" +#include "UI/System.h" using namespace Seele; using namespace Seele::UI; -Element::Element(Attributes attr, Array _children) : attr(attr) { - for (auto c : _children) { - children.add(c); - } - for (auto& child : children) { - child->setParent(this); - } -} - Element::~Element() {} diff --git a/src/Engine/UI/Element.h b/src/Engine/UI/Element.h index 45583b0..93407fd 100644 --- a/src/Engine/UI/Element.h +++ b/src/Engine/UI/Element.h @@ -1,11 +1,16 @@ #pragma once -#include "Attributes.h" +#include "UI/Attributes.h" #include "Containers/Array.h" #include "MinimalEngine.h" -#include "Style/Style.h" +#include "UI/Style/Style.h" +#include "UI/Style/Theme.h" +#include namespace Seele { namespace UI { +DECLARE_REF(Element) +// a render quad. background quads use backgroundTexture/backgroundColor; +// text quads additionally carry a glyph (one UIRender per glyph, see Text::render) struct UIRender { Gfx::PTexture2D backgroundTexture; Vector backgroundColor; @@ -13,23 +18,75 @@ struct UIRender { Vector2 dimensions; uint32 z; uint32 level; + PElement element; // back-ref for input hit-testing + // glyph-only (text): the glyph texture is backgroundTexture, this is the + // per-glyph rect in *atlas* space (0..1) so the pass can emit a glyph quad + bool isGlyph = false; + Vector2 uvOffset = Vector2(0); + Vector2 uvSize = Vector2(0); }; -DECLARE_REF(Element) class Element { public: - Element(Attributes attr, Array children); - virtual ~Element(); - void setParent(PElement p) { parent = p; } - // calculates the final style object taking into account inherited properties - virtual void applyStyle(Style parentStyle) = 0; - void calcStyle(Style parentStyle) { - applyStyle(parentStyle); - for (auto& child : children) { - child->calcStyle(style); + // the System walks the retained tree (style/layout/input/render) and needs to read + // the protected layout/children state; it is the only external consumer. + friend class System; + // children are raw, non-owning pointers (matches the pre-existing call sites, e.g. + // the InspectorView demo: new Div(Attr{}, { new A, new B })). the caller's `new` + // yields the pointer; ownership/lifetime for the demo is the caller's concern (the + // engine does not free them here). + explicit Element(Attributes attr) : attr(attr) {} + Element(Attributes attr, std::initializer_list children_) : attr(attr) { + for (auto c : children_) { + if (c != nullptr) { + c->setParent(this); + children.add(c); + } } } + virtual ~Element(); + void setParent(Element* p) { parent = p; } + + // resolves the inherited style + this element's static template classes against the theme. + // only re-run for this element when style.dirty or the theme changed. + virtual void applyStyle(Style parentStyle, const Theme& theme) = 0; + void calcStyle(Style parentStyle, const Theme& theme) { + if (style.dirty || themeChanged) { + style.dirty = false; + themeChanged = false; + applyStyle(parentStyle, theme); + } + for (auto& child : children) { + child->calcStyle(style, theme); + } + } + // explicit mutation entry point: applies runtime overrides, then re-styles the dirty subtree + void markDirty() { + style.dirty = true; + if (parent) { + parent->markDirty(); + } + } + // applies runtime style overrides (the data-driven mutation layer) + virtual void applyOverrides() { + // default: no-op; interactive elements override this to reflect hover/focus/etc. + } + // input; concrete signatures differ per element (see Button/Text), + // so the base takes a typed pointer + virtual bool onMouseEvent(MouseEvent* event) { (void)event; return false; } + virtual bool onKeyEvent(KeyEvent* event) { (void)event; return false; } + // interaction state hooks: the System calls these without knowing the concrete + // (templated) Button type. default no-ops; Button overrides. this keeps the + // input pipeline data-driven (on the Element base) and avoids dynamic_cast to a + // template type. + virtual void setHovered(bool hovered) { (void)hovered; } + virtual void setFocused(bool focused) { (void)focused; } + virtual bool isFocusable() const { return attr.focusable; } + // calculates the relative positions of the child elements for the applied layout style virtual void layout(UVector2 parentSize) { + if (style.hidden) { + return; + } if (style.maxWidthType == DimensionType::Auto) { maxDimensions.x = (float)parentSize.x; } @@ -63,6 +120,9 @@ class Element { Vector2 cursor = Vector2(style.paddingLeft, style.paddingTop); uint32 lineHeight = 0; for (auto& child : children) { + if (child->style.hidden) { + continue; + } // inline elements flow left to right if (child->style.outerDisplay == OuterDisplayType::Inline) { // only static and relative elements actually reserve @@ -110,15 +170,17 @@ class Element { } } virtual Array render(Vector2 anchor, uint32 level) { - Array result = { - UIRender{ + Array result; + if (!style.hidden && style.outerDisplay != OuterDisplayType::Hidden) { + result.add(UIRender{ .backgroundColor = style.backgroundColor, .position = position + anchor, .dimensions = dimensions, .z = style.z, .level = level, - }, - }; + .element = this, + }); + } for (auto& child : children) { for (const auto& render : child->render(position + anchor, level+1)) { result.add(render); @@ -135,9 +197,12 @@ class Element { protected: Attributes attr; - PElement parent = nullptr; - Array children; + Element* parent = nullptr; + // raw, non-owning (see the ctor comment); matches the pre-existing call sites + Array children; + // set by the System when the theme changed; forces a one-time full re-style + bool themeChanged = false; }; DEFINE_REF(Element) } // namespace UI -} // namespace Seele \ No newline at end of file +} // namespace Seele diff --git a/src/Engine/UI/Element/Button.h b/src/Engine/UI/Element/Button.h new file mode 100644 index 0000000..1ee4519 --- /dev/null +++ b/src/Engine/UI/Element/Button.h @@ -0,0 +1,119 @@ +#pragma once +#include "UI/Element/Div.h" +#include "UI/Style/Class.h" + +namespace Seele { +namespace UI { +// an interactive block: hover/focus visuals are data (runtime state) toggled by +// the input pipeline, never template args. the user's classes set the *defaults*; +// the System layers the interaction state on top during style() (see System.h). +template +class Button : public Div { + public: + // forward every Div construction form (no children / variadic / initializer list) + using Div::Div; + // Button is a template with a DEPENDENT base (Div), so unqualified + // access to inherited members is ill-formed; these using-declarations bring the + // specific members into Button's scope so the body below can use them. + using Div::attr; + using Div::style; + using Div::dimensions; + using Div::markDirty; + using Div::setParent; + virtual ~Button() {} + virtual void applyStyle(Style parentStyle, const Theme& theme) override { + Div::applyStyle(parentStyle, theme); + // hover/focus/pressed overrides are applied by the System right after, + // keyed off this state (data, not template args) + } + virtual bool onMouseEvent(MouseEvent* event) override { + switch (event->kind) { + case MouseEvent::Kind::Move: + if (!hovered) { + hovered = true; + if (attr.onHover) { + attr.onHover(*event); + } + } + break; + case MouseEvent::Kind::Down: + pressed = true; + break; + case MouseEvent::Kind::Up: + if (pressed && hovered) { + pressed = false; + if (attr.onClick) { + attr.onClick(*event); + } + } else { + pressed = false; + } + break; + case MouseEvent::Kind::Scroll: + if (attr.onScroll) { + attr.onScroll(*event); + } + break; + } + markDirty(); + return true; + } + virtual bool onKeyEvent(KeyEvent* event) override { + if (event->action == InputAction::PRESS) { + switch (event->code) { + case KeyCode::KEY_SPACE: + case KeyCode::KEY_ENTER: + if (focused && attr.onClick) { + MouseEvent click; + click.kind = MouseEvent::Kind::Down; + click.position = Vector2(dimensions.x / 2, dimensions.y / 2); + attr.onClick(click); + } + return true; + default: + break; + } + } + if (attr.onKey) { + return attr.onKey(*event); + } + return false; + } + // overrides of the Element base virtuals: this is how the System drives hover/focus + // data-drivenly without dynamic_cast to a concrete template type + void setHovered(bool hovered) override { + if (this->hovered == hovered) { + return; + } + this->hovered = hovered; + if (!hovered && attr.onHoverLeave) { + MouseEvent leave; + leave.kind = MouseEvent::Kind::Move; + attr.onHoverLeave(leave); + } + markDirty(); + } + void setFocused(bool focused) override { + if (this->focused == focused) { + return; + } + this->focused = focused; + if (focused && attr.onFocus) { + attr.onFocus(); + } else if (!focused && attr.onBlur) { + attr.onBlur(); + } + markDirty(); + } + bool isFocusable() const override { return attr.focusable; } + bool isHovered() const { return hovered; } + bool isFocused() const { return focused; } + bool isPressed() const { return pressed; } + + private: + bool hovered = false; + bool focused = false; + bool pressed = false; +}; +} // namespace UI +} // namespace Seele diff --git a/src/Engine/UI/Element/CMakeLists.txt b/src/Engine/UI/Element/CMakeLists.txt index 1745eef..b3d3d16 100644 --- a/src/Engine/UI/Element/CMakeLists.txt +++ b/src/Engine/UI/Element/CMakeLists.txt @@ -1,4 +1,16 @@ target_sources(Engine - PRIVATE - Div.h - Text.h) \ No newline at end of file + PRIVATE + Div.h + Text.h + Button.h + Panel.h + ) + +target_sources(Engine + PUBLIC FILE_SET HEADERS + FILES + Div.h + Text.h + Button.h + Panel.h + ) diff --git a/src/Engine/UI/Element/Div.h b/src/Engine/UI/Element/Div.h index 986e40e..b827bc4 100644 --- a/src/Engine/UI/Element/Div.h +++ b/src/Engine/UI/Element/Div.h @@ -7,14 +7,16 @@ namespace UI { template class Div : public Element { public: - Div(Attributes attr, Array children) : Element(attr, std::move(children)) { } + // forward every Element construction form (no children / variadic / initializer list) + using Element::Element; + Div() = delete; // force an explicit style/attrs choice, no accidental empty divs virtual ~Div() {} - virtual void applyStyle(Style parentStyle) override { + virtual void applyStyle(Style parentStyle, const Theme& theme) override { style = parentStyle; style.outerDisplay = OuterDisplayType::Block; - (classes::apply(style), ...); + (classes::apply(style, theme), ...); } private: }; } // namespace UI -} // namespace Seele \ No newline at end of file +} // namespace Seele diff --git a/src/Engine/UI/Element/Panel.h b/src/Engine/UI/Element/Panel.h new file mode 100644 index 0000000..24dd7b3 --- /dev/null +++ b/src/Engine/UI/Element/Panel.h @@ -0,0 +1,31 @@ +#pragma once +#include "UI/Element/Div.h" +#include "UI/Style/Class.h" + +namespace Seele { +namespace UI { +// a styled block container: defaults to the standard editor chrome +// (dark background, padding, text color); the user's template args override any of it +template +class Panel : public Div { + public: + // forward every Div construction form (no children / variadic / initializer list) + using Div::Div; + virtual ~Panel() {} + virtual void applyStyle(Style parentStyle, const Theme& theme) override { + // start from the panel chrome, then let the user's classes win + style = parentStyle; + style.outerDisplay = OuterDisplayType::Block; + style.backgroundColor = theme.color(ColorToken::Gray900); + style.textColor = theme.color(ColorToken::White); + uint32 pad = theme.spacing(8); + style.paddingTop = pad; + style.paddingBottom = pad; + style.paddingLeft = pad; + style.paddingRight = pad; + (classes::apply(style, theme), ...); + } + private: +}; +} // namespace UI +} // namespace Seele diff --git a/src/Engine/UI/Element/Text.h b/src/Engine/UI/Element/Text.h index 6e1d43c..c92cb02 100644 --- a/src/Engine/UI/Element/Text.h +++ b/src/Engine/UI/Element/Text.h @@ -1,37 +1,107 @@ #pragma once +#include "Asset/AssetRegistry.h" +#include "Asset/FontAsset.h" #include "UI/Element.h" #include "UI/Style/Class.h" -#include +#include +#include namespace Seele { namespace UI { -template class Text : public Element { +// text: the string is data (mutable at runtime); fonts and sizing come from style +// classes. shaping happens in applyStyle (only when dirty); render() just emits quads. +template +class Text : public Element { public: - Text(std::string text) : Element({}, {}), text(text) {} - virtual void applyStyle(Style parentStyle) { + // the string is data; Attributes is optional (defaults to no handlers). + // e.g. new Text("hello") or new Text<>(Attributes{...}, "hi") + Text(std::string text, Attributes attr = Attributes{}) : Element(std::move(attr)), _text(std::move(text)) {} + virtual ~Text() {} + + // runtime mutation: change the string, invalidate style+layout of this subtree + void setText(std::string text) { + if (text == _text) { + return; + } + _text = std::move(text); + markDirty(); + } + const std::string& getText() const { return _text; } + + virtual void applyStyle(Style parentStyle, const Theme& theme) override { style = parentStyle; - style.outerDisplay = OuterDisplayType::Inline; - (classes::apply(style), ...); - } - virtual void layout(UVector2) override { - UVector2 cursor = UVector2(0); - dimensions = style.fontFamily->shapeText(text, style.fontSize, glyphRenders); + (classes::apply(style, theme), ...); + // resolve the font: a font class set style.fontName (a string literal can't + // be a template arg), so we look it up at style() time. invariant: the font + // must be imported before the first System::style() call (see System.h); + // fall back to the theme default if the name isn't found. + PFontAsset font = nullptr; + if (!style.fontName.empty()) { + try { + font = AssetRegistry::findFont("", std::string_view(style.fontName)); + } catch (const std::exception&) { + font = nullptr; // unknown name -> fall back to the theme default + } + } + if (font == nullptr) { + font = theme.defaultFont; + } + if (font == nullptr) { + glyphs.clear(); + return; + } + style.fontFamily = font; + UVector2 measured = font->shapeText(_text, (uint32)style.fontSize, glyphs); + // measure for auto sizing (shapeText already returns the bounds) + float w = (float)measured.x; + float h = (float)measured.y; + if (style.widthType == UI::DimensionType::Auto) { + style.width = w; + } + if (style.heightType == UI::DimensionType::Auto) { + style.height = h; + } } + virtual Array render(Vector2 anchor, uint32 level) override { - return Array(std::from_range, glyphRenders | std::views::transform([=](const FontAsset::RenderGlyph& glyph) { - return UIRender{ - .backgroundTexture = glyph.texture, - .position = Vector2(glyph.position) + anchor, - .dimensions = Vector2(glyph.dimensions), - .level = level, - }; - })); + Array result; + if (style.hidden || style.outerDisplay == OuterDisplayType::Hidden) { + return result; + } + Vector2 pos = position + anchor; + // background quad (if any) — same shape as the base element quad + result.add(UIRender{ + .backgroundTexture = nullptr, + .backgroundColor = style.backgroundColor, + .position = pos, + .dimensions = dimensions, + .z = style.z, + .level = level, + .element = this, + }); + // text: one render quad per shaped glyph, carrying its atlas rect + if (style.fontFamily != nullptr) { + for (auto& g : glyphs) { + result.add(UIRender{ + .backgroundTexture = g.texture, + .backgroundColor = style.textColor, + .position = pos + Vector2(g.position.x, g.position.y), + .dimensions = Vector2(g.dimensions.x, g.dimensions.y), + .z = style.z, + .level = level, + .element = this, + .isGlyph = true, + .uvOffset = Vector2(0), + .uvSize = Vector2(1), + }); + } + } + return result; } - // height = fontsize * 1.12 private: - std::string text; - Array glyphRenders; + std::string _text; + Array glyphs; }; } // namespace UI -} // namespace Seele \ No newline at end of file +} // namespace Seele diff --git a/src/Engine/UI/Style/CMakeLists.txt b/src/Engine/UI/Style/CMakeLists.txt index 8a6f0b4..fc7632a 100644 --- a/src/Engine/UI/Style/CMakeLists.txt +++ b/src/Engine/UI/Style/CMakeLists.txt @@ -1,4 +1,16 @@ target_sources(Engine - PRIVATE - Class.h - Style.h) \ No newline at end of file + PRIVATE + Class.h + Style.h + Theme.h + Fonts.h + ) + +target_sources(Engine + PUBLIC FILE_SET HEADERS + FILES + Class.h + Style.h + Theme.h + Fonts.h + ) diff --git a/src/Engine/UI/Style/Class.h b/src/Engine/UI/Style/Class.h index 23f4129..d74e4d7 100644 --- a/src/Engine/UI/Style/Class.h +++ b/src/Engine/UI/Style/Class.h @@ -1,108 +1,156 @@ #pragma once +#include "UI/Style/Style.h" +#include "UI/Style/Theme.h" #include "Asset/AssetRegistry.h" +#include "Asset/FontAsset.h" #include "MinimalEngine.h" -#include "Style.h" +#include namespace Seele { -template -concept StyleClass = requires(C c, UI::Style& s) { c.apply(s); }; +namespace UI { +// a style class is anything with a static apply(Style&, const Theme&) +template concept StyleClass = requires(Style& s, const Theme& t) { C::apply(s, t); }; -template struct WidthClass { - static void apply(UI::Style& s) { +// --- size --- +template struct WidthClass { + static void apply(Style& s, const Theme&) { s.width = w; s.widthType = widthType; } }; -using W_Full = WidthClass<100, UI::DimensionType::Percent>; -using W_1 = WidthClass<2, UI::DimensionType::Pixel>; +using W_Full = WidthClass<100, DimensionType::Percent>; +template struct HeightClass { + static void apply(Style& s, const Theme&) { + s.height = h; + s.heightType = DimensionType::Pixel; + } +}; +using H_Full = HeightClass<100>; -template struct DisplayClass { - static void apply(UI::Style& s) { +// --- display --- +template struct DisplayClass { + static void apply(Style& s, const Theme&) { s.outerDisplay = outer; s.innerDisplay = inner; } }; -using Hidden = DisplayClass; -using Block = DisplayClass; -using Inline = DisplayClass; +using Hidden = DisplayClass; +using Block = DisplayClass; +using Inline = DisplayClass; -template struct StringLiteral { - constexpr StringLiteral(const char (&str)[N]) { std::copy_n(str, N, value); } - - char value[N]; -}; -template struct FontClass { - static void apply(UI::Style& s) { s.fontFamily = AssetRegistry::findFont("", lit.value); } -}; - -using Font_Arial = FontClass<"arial">; -using Font_Calibri = FontClass<"Calibri">; +// --- fonts (looked up at style() time; fonts must be loaded before the first +// System::style() call, see the invariant in System.h) --- +// a string literal can't be a C++ template argument, so font *names* are carried +// as runtime data on Style::fontName by a font class tag (e.g. UI::Font_Arial in +// Fonts.h); Text::applyStyle resolves the name to a PFontAsset (Theme::defaultFont +// as fallback). the font scale below is what remains a pure static class. +// tailwind text scale: (fontSize, lineHeight) in px, scaled by Theme at style() time template struct FontSizeClass { - static void apply(UI::Style& s) { - s.fontSize = fontSize; - s.lineHeight = lineHeight; + static void apply(Style& s, const Theme& t) { + s.fontSize = t.font(fontSize); + s.lineHeight = t.font(lineHeight); } }; -using Text_XS = FontSizeClass<12, 16>; -using Text_SM = FontSizeClass<14, 20>; -using Text_Base = FontSizeClass<16, 24>; -using Text_LG = FontSizeClass<18, 28>; -using Text_XL = FontSizeClass<20, 28>; -using Text_2XL = FontSizeClass<24, 32>; -using Text_3XL = FontSizeClass<30, 36>; -using Text_4XL = FontSizeClass<36, 40>; -using Text_5XL = FontSizeClass<48, 48>; -using Text_6XL = FontSizeClass<60, 60>; -using Text_7XL = FontSizeClass<72, 72>; -using Text_8XL = FontSizeClass<96, 96>; -using Text_9XL = FontSizeClass<128, 128>; - -template struct BackgroundColorClass { - static void apply(UI::Style& s) { s.backgroundColor = backgroundColor; } +template struct BackgroundColorClass { + static void apply(Style& s, const Theme& t) { s.backgroundColor = t.color(token); } }; +template struct TextColorClass { + static void apply(Style& s, const Theme& t) { s.textColor = t.color(token); } +}; +using BG_White = BackgroundColorClass; +using BG_Gray950 = BackgroundColorClass; +using BG_Gray900 = BackgroundColorClass; +using BG_Gray800 = BackgroundColorClass; +using BG_Gray700 = BackgroundColorClass; +using BG_Gray600 = BackgroundColorClass; +using BG_Red = BackgroundColorClass; +using BG_Green = BackgroundColorClass; +using BG_Blue = BackgroundColorClass; +using BG_Amber = BackgroundColorClass; +using C_White = TextColorClass; +using C_Gray400 = TextColorClass; +using C_Gray500 = TextColorClass; +using C_Red = TextColorClass; +using C_Green = TextColorClass; +using C_Blue = TextColorClass; -using BG_Red = BackgroundColorClass; - +// --- spacing (themed: scaled by Theme::spacingScale for DPI/accessibility) --- +// a side left as ~0U (4294967295) is left untouched template struct MarginClass { - static void apply(UI::Style& s) { - if constexpr (ml != -1) - s.marginLeft = ml; - if constexpr (mr != -1) - s.marginRight = mr; - if constexpr (mt != -1) - s.marginTop = mt; - if constexpr (mb != -1) - s.marginBottom = mb; + static void apply(Style& s, const Theme& t) { + if constexpr (ml != ~0U) + s.marginLeft = t.spacing(ml); + if constexpr (mr != ~0U) + s.marginRight = t.spacing(mr); + if constexpr (mt != ~0U) + s.marginTop = t.spacing(mt); + if constexpr (mb != ~0U) + s.marginBottom = t.spacing(mb); } }; -#define DECLARE_MARGIN_CLASSES(x) \ - using M_##x = MarginClass; \ - using M_X##x = MarginClass::max(), std::numeric_limits::max()>; \ - using M_Y##x = MarginClass::max(), std::numeric_limits::max(), x, x>; \ - using M_L##x = MarginClass::max(), std::numeric_limits::max(), std::numeric_limits::max()>; \ - using M_R##x = MarginClass::max(), x, std::numeric_limits::max(), std::numeric_limits::max()>; \ - using M_T##x = MarginClass::max(), std::numeric_limits::max(), x, std::numeric_limits::max()>; \ - using M_B##x = MarginClass::max(), std::numeric_limits::max(), std::numeric_limits::max(), x>; +template struct PaddingClass { + static void apply(Style& s, const Theme& t) { + if constexpr (ml != ~0U) + s.paddingLeft = t.spacing(ml); + if constexpr (mr != ~0U) + s.paddingRight = t.spacing(mr); + if constexpr (mt != ~0U) + s.paddingTop = t.spacing(mt); + if constexpr (mb != ~0U) + s.paddingBottom = t.spacing(mb); + } +}; +template struct GapClass { + static void apply(Style& s, const Theme& t) { s.gap = t.spacing(g); } +}; -DECLARE_MARGIN_CLASSES(0) -DECLARE_MARGIN_CLASSES(1) -DECLARE_MARGIN_CLASSES(2) -DECLARE_MARGIN_CLASSES(3) -DECLARE_MARGIN_CLASSES(4) -DECLARE_MARGIN_CLASSES(5) -DECLARE_MARGIN_CLASSES(6) -DECLARE_MARGIN_CLASSES(7) -DECLARE_MARGIN_CLASSES(8) -DECLARE_MARGIN_CLASSES(9) -DECLARE_MARGIN_CLASSES(10) -DECLARE_MARGIN_CLASSES(11) -DECLARE_MARGIN_CLASSES(12) -DECLARE_MARGIN_CLASSES(14) -DECLARE_MARGIN_CLASSES(16) -DECLARE_MARGIN_CLASSES(20) -DECLARE_MARGIN_CLASSES(24) +// curated tailwind spacing scale (px @ scale 1.0). +// intermediate steps: declare a local MarginClass/PaddingClass alias +// in your own namespace — StyleClass is a concept, not a closed set. +#define SPACE(n) \ + using M_##n = MarginClass; \ + using P_##n = PaddingClass; \ + using M_X##n = MarginClass; \ + using M_Y##n = MarginClass<~0U, ~0U, n, n>; \ + using P_X##n = PaddingClass; \ + using P_Y##n = PaddingClass<~0U, ~0U, n, n>; \ + using G_##n = GapClass; +SPACE(0) +SPACE(1) +SPACE(2) +SPACE(4) +SPACE(6) +SPACE(8) +SPACE(10) +SPACE(12) +SPACE(16) +SPACE(20) +SPACE(24) +SPACE(32) +SPACE(40) +SPACE(48) +SPACE(64) +SPACE(80) +// tailwind text scale: (fontSize, lineHeight) @ scale 1.0. +// names must be valid identifiers (no leading digit), and the macro body ends in ';' +// or the next token gets glued to the using-declaration. +#define TEXT_STEP(name, size, line) using Text_##name = FontSizeClass; +TEXT_STEP(XS, 12, 16) +TEXT_STEP(SM, 14, 20) +TEXT_STEP(BASE, 16, 24) +TEXT_STEP(LG, 18, 28) +TEXT_STEP(XL, 20, 28) +TEXT_STEP(XXL, 24, 32) +TEXT_STEP(3XL, 30, 36) +TEXT_STEP(4XL, 36, 40) +TEXT_STEP(5XL, 48, 48) +TEXT_STEP(6XL, 60, 60) +TEXT_STEP(7XL, 72, 72) +TEXT_STEP(8XL, 96, 96) + +} // namespace UI } // namespace Seele diff --git a/src/Engine/UI/Style/Fonts.h b/src/Engine/UI/Style/Fonts.h new file mode 100644 index 0000000..cf700e0 --- /dev/null +++ b/src/Engine/UI/Style/Fonts.h @@ -0,0 +1,18 @@ +#pragma once +#include "UI/Style/Class.h" +#include +#include + +namespace Seele { +namespace UI { +// standard font aliases. the name must match what the importer registered the +// font as (e.g. the arial import in main.cpp). the import (AssetImporter::importFont) +// must happen before the first System::style() call — see the invariant in System.h. +// a font *class* is a tag type with a static apply() that sets Style::fontName; +// the name is runtime data (a string literal can't be a C++ template arg), and +// Text::applyStyle resolves it to a PFontAsset (falling back to Theme::defaultFont). +struct Font_Arial { + static void apply(Style& s, const Theme&) { s.fontName = "arial.ttf"; } +}; +} // namespace UI +} // namespace Seele diff --git a/src/Engine/UI/Style/Style.h b/src/Engine/UI/Style/Style.h index 62878f2..a356fa3 100644 --- a/src/Engine/UI/Style/Style.h +++ b/src/Engine/UI/Style/Style.h @@ -2,6 +2,7 @@ #include "Math/Vector.h" #include "Asset/FontAsset.h" #include "MinimalEngine.h" +#include namespace Seele { namespace UI { @@ -37,12 +38,18 @@ struct Style { float maxHeight = 0; uint32 z = 0; Vector backgroundColor = Vector(1, 1, 1); + Vector textColor = Vector(0, 0, 0); + bool hidden = false; OuterDisplayType outerDisplay = OuterDisplayType::Inline; InnerDisplayType innerDisplay = InnerDisplayType::Flow; PositionType position = PositionType::Static; PFontAsset fontFamily; + // the font *name* as a runtime string. static font classes can't carry a + // string as a template arg (literals can't be NTTPs), so the name is set as + // data and resolved to a PFontAsset in Text::applyStyle (see Class.h FontClass). + std::string fontName; uint32 lineHeight = 12; - uint32 fontSize = 12; + float fontSize = 12.f; uint32 fontWeight = 0; uint32 paddingTop = 0; uint32 paddingBottom = 0; @@ -57,6 +64,9 @@ struct Style { uint32 bottom = 0; uint32 left = 0; uint32 right = 0; + + // set by the element when a runtime mutation needs a re-style of this subtree + bool dirty = false; }; } // namespace UI } // namespace Seele \ No newline at end of file diff --git a/src/Engine/UI/Style/Theme.h b/src/Engine/UI/Style/Theme.h new file mode 100644 index 0000000..e392d8c --- /dev/null +++ b/src/Engine/UI/Style/Theme.h @@ -0,0 +1,48 @@ +#pragma once +#include "Asset/FontAsset.h" +#include "Math/Vector.h" +#include "UI/Style/Style.h" + +namespace Seele { +namespace UI { +enum class ColorToken { + White, + Gray950, Gray900, Gray800, Gray700, Gray600, Gray500, Gray400, + Red, Green, Blue, Amber, +}; + +// the runtime layer over the static template styles. +// template classes emit semantic tokens (scale/spacing/color/font); +// Theme maps them at style() time. Changing a value here re-themes the whole +// UI at runtime without touching the built element tree. +struct Theme { + float spacingScale = 1.0f; // DPI / accessibility scaling for the spacing scale + float fontScale = 1.0f; // scaling for the font scale + float colorScale = 1.0f; // global brightness multiplier on palette colors + PFontAsset defaultFont = nullptr; // used when a font lookup fails + + float spacing(uint32 px) const { return px * spacingScale; } + float font(uint32 px) const { return px * fontScale; } + Vector color(ColorToken token) const { + // curated tailwind palette, remapped at runtime through colorScale + Vector raw(1.0f, 1.0f, 1.0f); + switch (token) { + case ColorToken::White: raw = Vector(1.0f, 1.0f, 1.0f); break; + case ColorToken::Gray950: raw = Vector(0.055f, 0.059f, 0.082f); break; + case ColorToken::Gray900: raw = Vector(0.11f, 0.114f, 0.137f); break; + case ColorToken::Gray800: raw = Vector(0.16f, 0.169f, 0.204f); break; + case ColorToken::Gray700: raw = Vector(0.298f, 0.314f, 0.365f); break; + case ColorToken::Gray600: raw = Vector(0.404f, 0.42f, 0.475f); break; + case ColorToken::Gray500: raw = Vector(0.498f, 0.518f, 0.565f); break; + case ColorToken::Gray400: raw = Vector(0.706f, 0.722f, 0.753f); break; + case ColorToken::Red: raw = Vector(0.925f, 0.267f, 0.251f); break; + case ColorToken::Green: raw = Vector(0.078f, 0.655f, 0.357f); break; + case ColorToken::Blue: raw = Vector(0.216f, 0.573f, 0.973f); break; + case ColorToken::Amber: raw = Vector(0.973f, 0.678f, 0.039f); break; + } + return Vector(raw.x * colorScale, raw.y * colorScale, raw.z * colorScale); + } +}; + +} // namespace UI +} // namespace Seele diff --git a/src/Engine/UI/System.cpp b/src/Engine/UI/System.cpp new file mode 100644 index 0000000..d624b6c --- /dev/null +++ b/src/Engine/UI/System.cpp @@ -0,0 +1,199 @@ +#include "UI/System.h" +#include "UI/Element/Button.h" +#include + +using namespace Seele; +using namespace Seele::UI; + +void System::markAllDirty(Element* element) { + if (element == nullptr) { + return; + } + element->style.dirty = true; + element->themeChanged = true; + for (auto& child : element->children) { + markAllDirty(child); + } +} + +void System::styleRec(Element* element) { + if (element == nullptr) { + return; + } + // runtime interaction state overrides the static style (data, not template args) + if (auto* button = dynamic_cast* >(element)) { + if (button->isFocused()) { + element->style.backgroundColor = theme.color(ColorToken::Gray700); + } + if (button->isHovered()) { + element->style.backgroundColor = theme.color(ColorToken::Gray700); + } + if (button->isPressed()) { + element->style.backgroundColor = theme.color(ColorToken::Gray600); + } + } + if (element->style.dirty || element->themeChanged) { + element->style.dirty = false; + element->themeChanged = false; + element->applyStyle({}, theme); + // interaction state is a per-frame override; re-apply it after the static resolve + if (auto* button = dynamic_cast* >(element)) { + if (button->isFocused()) { + element->style.backgroundColor = theme.color(ColorToken::Gray700); + } + if (button->isHovered()) { + element->style.backgroundColor = theme.color(ColorToken::Gray700); + } + if (button->isPressed()) { + element->style.backgroundColor = theme.color(ColorToken::Gray600); + } + } + } + layoutDirty = true; // any re-style invalidates layout + for (auto& child : element->children) { + styleRec(child); + } +} + +void System::layoutRec(Element* element) { + if (element == nullptr) { + return; + } + element->layout(UVector2(lastViewport.x, lastViewport.y)); + for (auto& child : element->children) { + // layout() already recurses; nothing to do here + } +} + +Element* System::hitTest(Vector2 position) { + // walk the last rendered list; later entries are drawn on top, so the last + // hit is the top-most element + Element* result = nullptr; + for (auto& render : renderElements) { + if (render.element == nullptr) { + continue; + } + if (position.x >= render.position.x && position.x < render.position.x + render.dimensions.x && + position.y >= render.position.y && position.y < render.position.y + render.dimensions.y) { + result = render.element.operator->(); + } + } + return result; +} + +void System::collectFocusable(Element* element, Array& out) { + if (element == nullptr || element->style.hidden) { + return; + } + if (element->isFocusable()) { + out.add(element); + } + for (auto& child : element->children) { + collectFocusable(child, out); + } +} + +void System::processInput() { + // hover transitions: the virtual setHovered keeps this free of dynamic_cast + Element* under = hitTest(mousePos); + if (under != hovered) { + if (hovered) { + hovered->setHovered(false); + } + hovered = under; + if (hovered) { + hovered->setHovered(true); + } + } +} + +void System::mouseMove(Vector2 position) { + mousePos = position; +} + +void System::mouseButton(MouseButton button, InputAction action, KeyModifier, Vector2 position) { + mousePos = position; + Element* under = hitTest(position); + if (under == nullptr) { + return; + } + // convert to element-local coordinates + Vector2 local = position; + { + // walk up from the hit element, subtracting each parent's position + auto* walk = under; + while (walk != nullptr) { + local.x -= walk->position.x; + local.y -= walk->position.y; + walk = walk->parent; + } + } + MouseEvent event; + event.kind = action == InputAction::PRESS ? MouseEvent::Kind::Down : MouseEvent::Kind::Up; + event.position = local; + under->onMouseEvent(&event); + // recompute hover after the click may have changed the tree + processInput(); +} + +void System::scroll(Vector2 delta) { + Element* under = hitTest(mousePos); + if (under == nullptr) { + return; + } + MouseEvent event; + event.kind = MouseEvent::Kind::Scroll; + event.position = mousePos; + event.delta = delta; + under->onMouseEvent(&event); +} + +void System::key(KeyCode code, InputAction action, KeyModifier modifier, char text) { + KeyEvent event; + event.code = code; + event.action = action; + event.shift = (static_cast(modifier) & static_cast(KeyModifier::MOD_SHIFT)) != 0; + event.ctrl = (static_cast(modifier) & static_cast(KeyModifier::MOD_CONTROL)) != 0; + event.alt = (static_cast(modifier) & static_cast(KeyModifier::MOD_ALT)) != 0; + event.text = text; + + if (action == InputAction::PRESS && code == KeyCode::KEY_TAB) { + // cycle focus among focusable elements (buttons); the virtual setFocused + // keeps this free of dynamic_cast to a concrete template type + Array focusable; + collectFocusable(rootElement.operator->(), focusable); + if (focusable.size() > 0) { + int32 index = -1; + for (uint32 i = 0; i < focusable.size(); ++i) { + if (focusable[i] == focused) { + index = i; + break; + } + } + int32 next = event.shift ? (index <= 0 ? (int32)focusable.size() - 1 : index - 1) : (index + 1) % (int32)focusable.size(); + if (focused != nullptr) { + focused->setFocused(false); + } + focused = focusable[next]; + focused->setFocused(true); + } + return; + } + if (focused != nullptr) { + focused->onKeyEvent(&event); + } +} + +void System::beginFrame(UVector2 viewport) { + lastViewport = viewport; + if (layoutDirty) { + rootElement->calcStyle(Style{}, theme); + rootElement->layout(viewport); + layoutDirty = false; + } +} + +Array System::render() { + renderElements = rootElement->render(Vector2(0, 0), 1); + return renderElements; +} diff --git a/src/Engine/UI/System.h b/src/Engine/UI/System.h index 031b18c..f760f4e 100644 --- a/src/Engine/UI/System.h +++ b/src/Engine/UI/System.h @@ -1,19 +1,62 @@ #pragma once -#include "Element.h" +#include "Containers/Array.h" +#include "UI/Element.h" +#include "UI/Style/Theme.h" namespace Seele { namespace UI { +// frame pipeline: input -> style (dirty subtrees only) -> layout (when dirty or viewport changed) -> render. +// the tree is built once; mutations go through the element setters (markDirty) and only +// re-style/re-layout the affected subtree. +// +// INVARAIT: fonts referenced by style classes must be imported (AssetImporter::importFont) +// before the first style() call. Text falls back to Theme::defaultFont and renders empty +// (with an assert in debug) otherwise. class System { public: - System(OElement rootElement) : rootElement(std::move(rootElement)) {} + System(OElement rootElement, Theme theme = Theme{}) : rootElement(std::move(rootElement)), theme(theme) {} ~System() {} - void style() { rootElement->calcStyle(UI::Style()); } - void layout(UVector2 viewport) { rootElement->layout(viewport); } - Array render() { return rootElement->render(Vector2(0, 0), 1); } + + void setTheme(Theme newTheme) { + theme = newTheme; + // one full re-style on the next frame; everything else stays incremental + markAllDirty(rootElement.operator->()); + layoutDirty = true; + } + // called by the owning view once per frame, before layout/render + void processInput(); + // style + layout + render for the frame + void beginFrame(UVector2 viewport); + + // input entry points (called by the owning view from its callbacks) + void mouseMove(Vector2 position); + void mouseButton(MouseButton button, InputAction action, KeyModifier modifier, Vector2 position); + void scroll(Vector2 delta); + void key(KeyCode code, InputAction action, KeyModifier modifier, char text = 0); + + Array render(); + + PElement getRoot() { return rootElement; } private: + void styleRec(Element* element); + void layoutRec(Element* element); + static void markAllDirty(Element* element); + // hit-test the last rendered list, top-most wins; returns the element under `position` + Element* hitTest(Vector2 position); + // walks the tree in layout order, collecting focusable elements (for tab navigation) + void collectFocusable(Element* element, Array& out); + OElement rootElement; + Theme theme; + UVector2 lastViewport = UVector2(0); + bool layoutDirty = true; + // input state + Vector2 mousePos = Vector2(0); + Element* hovered = nullptr; + Element* focused = nullptr; + Array renderElements; }; DEFINE_REF(System) } // namespace UI -} // namespace Seele \ No newline at end of file +} // namespace Seele diff --git a/src/Engine/Window/GameView.cpp b/src/Engine/Window/GameView.cpp index 96c3246..51965bb 100644 --- a/src/Engine/Window/GameView.cpp +++ b/src/Engine/Window/GameView.cpp @@ -30,17 +30,17 @@ GameView::GameView(Gfx::PGraphics graphics, PWindow window, const ViewportCreate renderGraph.addPass(new LightCullingPass(graphics, scene)); renderGraph.addPass(new ShadowPass(graphics, scene)); renderGraph.addPass(new BasePass(graphics, scene)); - renderGraph.addPass(new SimulationComputePass(graphics, scene)); - renderGraph.addPass(new SurfaceExtractPass(graphics, scene)); - renderGraph.addPass(new FluidRenderPass(graphics, scene)); + // renderGraph.addPass(new SimulationComputePass(graphics, scene)); + // renderGraph.addPass(new SurfaceExtractPass(graphics, scene)); + // renderGraph.addPass(new FluidRenderPass(graphics, scene)); renderGraph.addPass(new ToneMappingPass(graphics)); renderGraph.setViewport(viewport); renderGraph.createRenderPass(); if (graphics->supportRayTracing()) { rayTracingGraph.addPass(new RayTracingPass(graphics, scene)); - rayTracingGraph.addPass(new SimulationComputePass(graphics, scene)); - rayTracingGraph.addPass(new SurfaceExtractPass(graphics, scene)); - rayTracingGraph.addPass(new FluidRenderPass(graphics, scene)); + // rayTracingGraph.addPass(new SimulationComputePass(graphics, scene)); + // rayTracingGraph.addPass(new SurfaceExtractPass(graphics, scene)); + // rayTracingGraph.addPass(new FluidRenderPass(graphics, scene)); rayTracingGraph.addPass(new ToneMappingPass(graphics)); rayTracingGraph.setViewport(viewport); rayTracingGraph.createRenderPass();