forked from Dynamitos/Seele
Initial editor draft
This commit is contained in:
1 parent
3317705d9c
commit
d3ed573405
4 files changed
+23
-10
No files matched your search
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
using namespace Seele;
|
using namespace Seele;
|
||||||
|
|
||||||
UIPass::UIPass(Gfx::PGraphics graphics, UI::PSystem system) : RenderPass(graphics), system(system) {
|
UIPass::UIPass(Gfx::PGraphics graphics, UI::PSystem system) : RenderPass(graphics), system(system), passSize(0, 0) {
|
||||||
elementBuffer = graphics->createShaderBuffer(ShaderBufferCreateInfo{.name = "RenderStyleElements"});
|
elementBuffer = graphics->createShaderBuffer(ShaderBufferCreateInfo{.name = "RenderStyleElements"});
|
||||||
|
|
||||||
uiDescriptorLayout = graphics->createDescriptorLayout("pParams");
|
uiDescriptorLayout = graphics->createDescriptorLayout("pParams");
|
||||||
@@ -134,10 +134,14 @@ void UIPass::createRenderPass() {
|
|||||||
Gfx::SE_ATTACHMENT_LOAD_OP_CLEAR, Gfx::SE_ATTACHMENT_STORE_OP_STORE);
|
Gfx::SE_ATTACHMENT_LOAD_OP_CLEAR, Gfx::SE_ATTACHMENT_STORE_OP_STORE);
|
||||||
colorAttachment.clear.color = {{1.0f, 1.0f, 1.0f, 1.0f}};
|
colorAttachment.clear.color = {{1.0f, 1.0f, 1.0f, 1.0f}};
|
||||||
|
|
||||||
Gfx::RenderTargetLayout layout = Gfx::RenderTargetLayout{
|
// the render pass encodes the viewport size, and Vulkan requires a fresh pass object when
|
||||||
.colorAttachments = {colorAttachment},
|
// that changes. Re-run createRenderPass() from beginFrame on a viewport resize; the
|
||||||
.depthAttachment = depthAttachment,
|
// pipeline is recreated here from scratch (it embeds renderPass and is size-independent
|
||||||
};
|
// otherwise).
|
||||||
|
if (passSize.x != viewport->getWidth() || passSize.y != viewport->getHeight()) {
|
||||||
|
passSize = UVector2(viewport->getWidth(), viewport->getHeight());
|
||||||
|
createRenderPass();
|
||||||
|
}
|
||||||
Array<Gfx::SubPassDependency> dependency = {
|
Array<Gfx::SubPassDependency> dependency = {
|
||||||
{
|
{
|
||||||
.srcSubpass = ~0U,
|
.srcSubpass = ~0U,
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ class UIPass : public RenderPass {
|
|||||||
Gfx::PGraphicsPipeline uiPipeline;
|
Gfx::PGraphicsPipeline uiPipeline;
|
||||||
|
|
||||||
UI::PSystem system;
|
UI::PSystem system;
|
||||||
|
UVector2 passSize; // last viewport size the render pass was created at; recreate on resize
|
||||||
Array<UI::UIRender> renderElements;
|
Array<UI::UIRender> renderElements;
|
||||||
Array<RenderElementStyle> elements;
|
Array<RenderElementStyle> elements;
|
||||||
Gfx::OShaderBuffer elementBuffer;
|
Gfx::OShaderBuffer elementBuffer;
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ View::~View() {}
|
|||||||
void View::resize(URect area) {
|
void View::resize(URect area) {
|
||||||
createInfo.dimensions = area;
|
createInfo.dimensions = area;
|
||||||
viewport->resize(area.size.x, area.size.y);
|
viewport->resize(area.size.x, area.size.y);
|
||||||
|
viewport->move(area.offset.x, area.offset.y);
|
||||||
applyArea(area);
|
applyArea(area);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,11 +46,18 @@ void Window::setFocused(PView view) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Window::onResize(uint32 width, uint32 height) {
|
void Window::onResize(uint32 width, uint32 height) {
|
||||||
for (auto& view : views) {
|
// one column per view, in registration order. 2 views = a 50/50 split.
|
||||||
// TODO: some sort of layouting algorithm should do this
|
const uint32 n = views.size();
|
||||||
view->resize(URect{
|
if (n == 0) {
|
||||||
.size = UVector2(width, height),
|
return;
|
||||||
.offset = UVector2(0, 0),
|
}
|
||||||
|
const uint32 colWidth = width / n;
|
||||||
|
for (uint32 i = 0; i < n; ++i) {
|
||||||
|
uint32 x = i * colWidth;
|
||||||
|
uint32 w = (i == n - 1) ? (width - x) : colWidth;
|
||||||
|
views[i]->resize(URect{
|
||||||
|
.size = UVector2(w, height),
|
||||||
|
.offset = UVector2(x, 0),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user