z-index still broken, disable horizontal splits for now
This commit is contained in:
parent
b9af40c9d3
commit
f15eda312a
@ -269,8 +269,8 @@ HandleInputs(EditorCtx* ctx, Inputs* inputs)
|
|||||||
} break;
|
} break;
|
||||||
case Input.c:
|
case Input.c:
|
||||||
{
|
{
|
||||||
AddEditor(ctx, GetFocusedPanel(), A2D.Y);
|
//AddEditor(ctx, GetFocusedPanel(), A2D.Y);
|
||||||
taken = true;
|
//taken = true;
|
||||||
} break;
|
} break;
|
||||||
case Input.d:
|
case Input.d:
|
||||||
{
|
{
|
||||||
|
|||||||
145
src/editor/ui.d
145
src/editor/ui.d
@ -646,6 +646,7 @@ EndBuild()
|
|||||||
{
|
{
|
||||||
CalcPositions!(axis)(ctx.root);
|
CalcPositions!(axis)(ctx.root);
|
||||||
}
|
}
|
||||||
|
FixViolations(ctx.root);
|
||||||
PrepRendering(ctx);
|
PrepRendering(ctx);
|
||||||
|
|
||||||
DrawUI(ctx, ctx.root);
|
DrawUI(ctx, ctx.root);
|
||||||
@ -669,7 +670,7 @@ EndBuild()
|
|||||||
static u32 prev_count = 0;
|
static u32 prev_count = 0;
|
||||||
if(prev_count != ctx.item_count)
|
if(prev_count != ctx.item_count)
|
||||||
{
|
{
|
||||||
//PrintNodes(ctx.root);
|
PrintNodes(ctx.root);
|
||||||
prev_count = ctx.item_count;
|
prev_count = ctx.item_count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -710,13 +711,41 @@ PrintNodes(UIItem* item)
|
|||||||
{
|
{
|
||||||
if(!Nil(item))
|
if(!Nil(item))
|
||||||
{
|
{
|
||||||
Logf("x0 %s x1 %s y0 %s y1 %s", item.rect.x0, item.rect.x1, item.rect.y0, item.rect.y1);
|
if(item.culling.vec0 != Vec2(0.0) || item.culling.vec1 != Vec2(0.0))
|
||||||
|
{
|
||||||
|
Logf("%s:", cast(char[])item.key.text);
|
||||||
|
Logf("x0 %s x1 %s y0 %s y1 %s", item.rect.x0, item.rect.x1, item.rect.y0, item.rect.y1);
|
||||||
|
Logf("cull x0 %s x1 %s y0 %s y1 %s\n", item.culling.x0, item.culling.x1, item.culling.y0, item.culling.y1);
|
||||||
|
}
|
||||||
|
|
||||||
PrintNodes(item.first);
|
PrintNodes(item.first);
|
||||||
PrintNodes(item.next);
|
PrintNodes(item.next);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
FixViolations(UIItem* item)
|
||||||
|
{
|
||||||
|
A2D axis = A2D.Y;
|
||||||
|
for(UIItem* i = item; !Nil(i); i = Recurse(i))
|
||||||
|
{
|
||||||
|
if(!Nil(i.parent))
|
||||||
|
{
|
||||||
|
f32 bounds_start = i.parent.rect.vec0.v[axis] - i.parent.culling.vec0.v[axis];
|
||||||
|
if(i.rect.vec0.v[axis] < bounds_start)
|
||||||
|
{
|
||||||
|
i.culling.vec0.v[axis] = bounds_start - i.rect.vec0.v[axis];
|
||||||
|
}
|
||||||
|
|
||||||
|
f32 bounds_end = i.parent.rect.vec1.v[axis] - i.parent.culling.vec1.v[axis];
|
||||||
|
if(i.rect.vec1.v[axis] > bounds_end)
|
||||||
|
{
|
||||||
|
i.culling.vec1.v[axis] = i.rect.vec1.v[axis] - bounds_end;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CalcFixedSizes(UIItem* item)
|
CalcFixedSizes(UIItem* item)
|
||||||
{
|
{
|
||||||
@ -1254,67 +1283,101 @@ DrawGlyph(UIItem* item, Glyph* glyph, f32 scale, f32* x_pos, f32 y, bool highlig
|
|||||||
{
|
{
|
||||||
UICtx* ctx = GetCtx();
|
UICtx* ctx = GetCtx();
|
||||||
Vertex* bg_v = null, v = null;
|
Vertex* bg_v = null, v = null;
|
||||||
f32 h;
|
|
||||||
|
|
||||||
if(glyph.ch == '\t')
|
if(glyph.ch == '\t')
|
||||||
{
|
{
|
||||||
*x_pos += glyph.advance * (GetCtx().tab_width - 1);
|
*x_pos += glyph.advance * (GetCtx().tab_width - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
v = ctx.buffers[ctx.f_idx].vtx.ptr + ctx.buffers[ctx.f_idx].count;
|
|
||||||
|
|
||||||
f32 r = glyph.plane_right * scale;
|
f32 r = glyph.plane_right * scale;
|
||||||
f32 l = glyph.plane_left * scale;
|
f32 l = glyph.plane_left * scale;
|
||||||
|
f32 t = glyph.plane_top * scale;
|
||||||
|
f32 b = glyph.plane_bottom * scale;
|
||||||
f32 w = r - l;
|
f32 w = r - l;
|
||||||
h = (glyph.plane_bottom - glyph.plane_top) * scale;
|
f32 h = b - t;
|
||||||
f32 y_pos = glyph.plane_top * scale;
|
|
||||||
|
|
||||||
v.dst_start.x = *x_pos + l;
|
f32 atlas_r = glyph.atlas_right;
|
||||||
v.dst_start.y = y - y_pos;
|
f32 atlas_l = glyph.atlas_left;
|
||||||
v.dst_end.x = *x_pos + w + l;
|
f32 atlas_t = glyph.atlas_top;
|
||||||
v.dst_end.y = y + h - y_pos;
|
f32 atlas_b = glyph.atlas_bottom;
|
||||||
|
|
||||||
v.z_index = item.z_index;
|
bool skip = false;
|
||||||
|
if(item.culling.x0 != 0.0 || item.culling.x1 != 0.0)
|
||||||
if(glyph.ch != '\t' && glyph.ch != '\n')
|
|
||||||
{
|
{
|
||||||
v.src_start.x = glyph.atlas_left;
|
if(w <= item.culling.x0+item.culling.x1)
|
||||||
v.src_start.y = glyph.atlas_top;
|
|
||||||
v.src_end.x = glyph.atlas_right;
|
|
||||||
v.src_end.y = glyph.atlas_bottom;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
static foreach(axis; A2D.min .. A2D.max)
|
|
||||||
{
|
|
||||||
if(item.culling.vec0.v[axis] != 0.0 || item.culling.vec1.v[axis] != 0.0)
|
|
||||||
{
|
{
|
||||||
f32 length = v.dst_end.v[axis] - v.dst_start.v[axis];
|
skip = true;
|
||||||
f32 start_pct = 1.0-((length-item.culling.vec0.v[axis])/length);
|
}
|
||||||
f32 end_pct = 1.0-((length-item.culling.vec1.v[axis])/length);
|
else
|
||||||
|
{
|
||||||
|
f32 start_pct = 1.0-((w-item.culling.x0)/w);
|
||||||
|
f32 end_pct = 1.0-((w-item.culling.x1)/w);
|
||||||
|
|
||||||
f32 atlas_len = v.src_end.v[axis] - v.src_start.v[axis];
|
f32 atlas_len = atlas_r - atlas_l;
|
||||||
v.src_start.v[axis] -= atlas_len * start_pct;
|
atlas_l += atlas_len * start_pct;
|
||||||
v.src_end.v[axis] -= atlas_len * end_pct;
|
atlas_r -= atlas_len * end_pct;
|
||||||
|
|
||||||
v.dst_start.v[axis] -= item.culling.vec0.v[axis];
|
l += item.culling.x0;
|
||||||
v.dst_end.v[axis] -= item.culling.vec1.v[axis];
|
r -= item.culling.x1;
|
||||||
|
|
||||||
Logf("culling %s %s %s %s start_pct %s end_pct %s", length, item.culling.vec0.v[axis], item.culling.vec1.v[axis], axis, start_pct, end_pct);
|
w = r-l;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
if(highlight)
|
if(!skip && (item.culling.y0 != 0.0 || item.culling.y1 != 0.0))
|
||||||
{
|
{
|
||||||
col = Vec4(Vec3(1.0)-col.xyz, 1.0);
|
if(h <= item.culling.y0+item.culling.y1)
|
||||||
|
{
|
||||||
|
skip = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
f32 start_pct = 1.0-((h-item.culling.y0)/h);
|
||||||
|
f32 end_pct = 1.0-((h-item.culling.y1)/h);
|
||||||
|
|
||||||
|
f32 atlas_len = atlas_b-atlas_t;
|
||||||
|
atlas_t += atlas_len * start_pct;
|
||||||
|
atlas_b -= atlas_len * end_pct;
|
||||||
|
|
||||||
|
t += item.culling.y0;
|
||||||
|
b -= item.culling.y1;
|
||||||
|
|
||||||
|
h = b-t;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!skip)
|
||||||
|
{
|
||||||
|
f32 y_pos = t;
|
||||||
|
|
||||||
v.cols = col;
|
v = ctx.buffers[ctx.f_idx].vtx.ptr + ctx.buffers[ctx.f_idx].count;
|
||||||
|
|
||||||
v.texture = 1;
|
v.dst_start.x = *x_pos + l;
|
||||||
|
v.dst_start.y = y - y_pos;
|
||||||
|
v.dst_end.x = *x_pos + w + l;
|
||||||
|
v.dst_end.y = y + h - y_pos;
|
||||||
|
|
||||||
AddUIIndices(ctx);
|
v.z_index = item.z_index;
|
||||||
|
|
||||||
|
if(glyph.ch != '\t' && glyph.ch != '\n')
|
||||||
|
{
|
||||||
|
v.src_start.x = glyph.atlas_left;
|
||||||
|
v.src_start.y = glyph.atlas_top;
|
||||||
|
v.src_end.x = glyph.atlas_right;
|
||||||
|
v.src_end.y = glyph.atlas_bottom;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(highlight)
|
||||||
|
{
|
||||||
|
col = Vec4(Vec3(1.0)-col.xyz, 1.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
v.cols = col;
|
||||||
|
|
||||||
|
v.texture = 1;
|
||||||
|
|
||||||
|
AddUIIndices(ctx);
|
||||||
|
}
|
||||||
|
|
||||||
*x_pos += glyph.advance * scale;
|
*x_pos += glyph.advance * scale;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -245,9 +245,7 @@ Separator(UIPanel* panel, UIItem* parent, f32* adj_x, f32* adj_y)
|
|||||||
UIItem* item = Get(buf);
|
UIItem* item = Get(buf);
|
||||||
|
|
||||||
f32 prev_z = GetZIndex();
|
f32 prev_z = GetZIndex();
|
||||||
SetZIndex(-5.0);
|
|
||||||
BuildItem(item, UISize(x_t, sep_x), UISize(y_t, sep_y), UIF.DrawBackground|UIF.Draggable);
|
BuildItem(item, UISize(x_t, sep_x), UISize(y_t, sep_y), UIF.DrawBackground|UIF.Draggable);
|
||||||
SetZIndex(prev_z);
|
|
||||||
|
|
||||||
Signal(item);
|
Signal(item);
|
||||||
|
|
||||||
@ -316,18 +314,11 @@ EditorView(UIPanel* panel)
|
|||||||
bool focused = panel == GetFocusedPanel();
|
bool focused = panel == GetFocusedPanel();
|
||||||
|
|
||||||
f32 prev_z = GetZIndex();
|
f32 prev_z = GetZIndex();
|
||||||
if(!focused)
|
|
||||||
{
|
|
||||||
SetZIndex(-1.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
UICtx* ctx = GetCtx();
|
UICtx* ctx = GetCtx();
|
||||||
UIItem* item = Panel(panel, UIF.Clickable);
|
UIItem* item = Panel(panel, UIF.Clickable);
|
||||||
Editor* ed = panel.ed;
|
Editor* ed = panel.ed;
|
||||||
|
|
||||||
|
|
||||||
scope(exit) SetZIndex(prev_z);
|
|
||||||
|
|
||||||
Container(ScratchName(panel.id, "cntr"), UISize(ST.Percentage, 1.0), UISize(ST.Percentage, 1.0), A2D.X);
|
Container(ScratchName(panel.id, "cntr"), UISize(ST.Percentage, 1.0), UISize(ST.Percentage, 1.0), A2D.X);
|
||||||
|
|
||||||
f32 text_size = 16.0;
|
f32 text_size = 16.0;
|
||||||
@ -502,9 +493,7 @@ DrawPanels(UIPanel* panel)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SetZIndex(1.0);
|
|
||||||
Panel(panel);
|
Panel(panel);
|
||||||
SetZIndex(0.0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DrawPanels(panel.first);
|
DrawPanels(panel.first);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user