diff --git a/src/editor/ui.d b/src/editor/ui.d index fece7a3..0498fb0 100644 --- a/src/editor/ui.d +++ b/src/editor/ui.d @@ -40,9 +40,12 @@ const Vec4[4] CMD_PALETTE_INPUT_COL = [ Vec4(0.17, 0.17, 0.17, 1.0), ]; +const u64 VERTEX_MAX_COUNT = 10000; + // TODO: add setting const f32 TEXT_SIZE = 16.0; + const UIPanel g_ui_nil_panel; UIPanel* g_UI_NIL_PANEL; @@ -446,6 +449,7 @@ Panel(UIPanel* panel) f32 x = panel.rect.x0; f32 y = panel.rect.y0 + TEXT_SIZE; + f32 code_view_width = panel.size.x-lcw-border*2.0-padding*2.0; FontAtlas* atlas = &ctx.atlas_buf.atlas; bool edit = EditModeActive(); U64Vec2 pos = VecPos(&ed.buf); @@ -459,7 +463,8 @@ Panel(UIPanel* panel) x_pos += padding; u64 ch_offset; - auto parts = MakeMultiline(buf.text, panel.size.x-lcw, buf.style); + + auto parts = MakeMultiline(buf.text, code_view_width, buf.style); for(auto n = parts; n != null; n = n.next) { auto l = &n.value; @@ -562,6 +567,8 @@ CommandPalette(CmdPalette* cmd) { DrawChar(&ctx.atlas_buf.atlas, options[i][j], &ch_x, ch_y, Vec4(1.0)); } + + if(y+h > size.y+h) break; } } @@ -679,11 +686,10 @@ InitUICtx(PlatformWindow* window) tab_width: 2, }; - u64 vertex_size = 10000; for(u64 i = 0; i < FRAME_OVERLAP; i += 1) { - ctx.buffers[i].m_vtx = CreateMappedBuffer!(Vertex)(&ctx.rd, BT.Vertex, vertex_size); - ctx.buffers[i].m_idx = CreateMappedBuffer!(u32)(&ctx.rd, BT.Index, cast(u64)(ceil(vertex_size * 1.5))); + ctx.buffers[i].m_vtx = CreateMappedBuffer!(Vertex)(&ctx.rd, BT.Vertex, VERTEX_MAX_COUNT); + ctx.buffers[i].m_idx = CreateMappedBuffer!(u32)(&ctx.rd, BT.Index, cast(u64)(ceil(VERTEX_MAX_COUNT*1.5))); ctx.buffers[i].vtx = ctx.buffers[i].m_vtx.data; ctx.buffers[i].idx = ctx.buffers[i].m_idx.data; } @@ -1202,6 +1208,8 @@ AddUIIndices(UICtx* ctx) ctx.buffers[ctx.f_idx].idx[5] = 3; ctx.buffers[ctx.f_idx].count += 1; + + assert(ctx.buffers[ctx.f_idx].count < VERTEX_MAX_COUNT); } bool