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;
|
||||
|
||||
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"});
|
||||
|
||||
uiDescriptorLayout = graphics->createDescriptorLayout("pParams");
|
||||
@@ -134,10 +134,14 @@ void UIPass::createRenderPass() {
|
||||
Gfx::SE_ATTACHMENT_LOAD_OP_CLEAR, Gfx::SE_ATTACHMENT_STORE_OP_STORE);
|
||||
colorAttachment.clear.color = {{1.0f, 1.0f, 1.0f, 1.0f}};
|
||||
|
||||
Gfx::RenderTargetLayout layout = Gfx::RenderTargetLayout{
|
||||
.colorAttachments = {colorAttachment},
|
||||
.depthAttachment = depthAttachment,
|
||||
};
|
||||
// the render pass encodes the viewport size, and Vulkan requires a fresh pass object when
|
||||
// that changes. Re-run createRenderPass() from beginFrame on a viewport resize; the
|
||||
// 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 = {
|
||||
{
|
||||
.srcSubpass = ~0U,
|
||||
|
||||
@@ -70,6 +70,7 @@ class UIPass : public RenderPass {
|
||||
Gfx::PGraphicsPipeline uiPipeline;
|
||||
|
||||
UI::PSystem system;
|
||||
UVector2 passSize; // last viewport size the render pass was created at; recreate on resize
|
||||
Array<UI::UIRender> renderElements;
|
||||
Array<RenderElementStyle> elements;
|
||||
Gfx::OShaderBuffer elementBuffer;
|
||||
|
||||
@@ -16,6 +16,7 @@ View::~View() {}
|
||||
void View::resize(URect area) {
|
||||
createInfo.dimensions = area;
|
||||
viewport->resize(area.size.x, area.size.y);
|
||||
viewport->move(area.offset.x, area.offset.y);
|
||||
applyArea(area);
|
||||
}
|
||||
|
||||
|
||||
@@ -46,11 +46,18 @@ void Window::setFocused(PView view) {
|
||||
}
|
||||
|
||||
void Window::onResize(uint32 width, uint32 height) {
|
||||
for (auto& view : views) {
|
||||
// TODO: some sort of layouting algorithm should do this
|
||||
view->resize(URect{
|
||||
.size = UVector2(width, height),
|
||||
.offset = UVector2(0, 0),
|
||||
// one column per view, in registration order. 2 views = a 50/50 split.
|
||||
const uint32 n = views.size();
|
||||
if (n == 0) {
|
||||
return;
|
||||
}
|
||||
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