added separators
This commit is contained in:
parent
669c1a55e2
commit
5ee1ae6d17
@ -282,6 +282,12 @@ PrevSiblingPanel(UIItem* panel)
|
||||
return result;
|
||||
}
|
||||
|
||||
UIItem*
|
||||
PeekParent()
|
||||
{
|
||||
return g_ui_ctx.top_parent == g_UI_NIL_NODE ? g_UI_NIL : g_ui_ctx.top_parent.item;
|
||||
}
|
||||
|
||||
UIItem*
|
||||
PopParent()
|
||||
{
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import dlib;
|
||||
|
||||
import ui;
|
||||
import std.format : sformat;
|
||||
|
||||
UIItem*
|
||||
Root()
|
||||
@ -15,13 +16,34 @@ Root()
|
||||
UIItem*
|
||||
Panel(string id, f32 x_pct, f32 y_pct, Axis2D layout_axis, Vec4 color)
|
||||
{
|
||||
UIItem* prev_panel = PeekSiblingPanel();
|
||||
UIItem* parent = PeekParent();
|
||||
|
||||
if (!Nil(prev_panel) && parent != prev_panel)
|
||||
{
|
||||
f32 sep_y = 1.0, sep_x = 1.0;
|
||||
if (parent.layout_axis == A2D.X)
|
||||
{
|
||||
sep_x = 0.005;
|
||||
//x_pct -= 0.005;
|
||||
}
|
||||
else
|
||||
{
|
||||
sep_y = 0.005;
|
||||
//y_pct -= 0.005;
|
||||
}
|
||||
|
||||
u8[128] buf;
|
||||
(cast(char[])buf).sformat("sep_%s", id);
|
||||
|
||||
Separator(buf, sep_x, sep_y);
|
||||
}
|
||||
|
||||
SetColor(color);
|
||||
SetLayoutAxis(layout_axis);
|
||||
UIItem* item = BuildItem(id, UISize(ST.Percentage, x_pct), UISize(ST.Percentage, y_pct), UIF.DrawBackground);
|
||||
|
||||
UIItem* prev_panel = PrevSiblingPanel(item);
|
||||
|
||||
Logf("%s %s", id, !Nil(prev_panel));
|
||||
UIItem* sibling = PrevSiblingPanel(item);
|
||||
|
||||
PushSiblingPanel(item);
|
||||
PushParent(item);
|
||||
@ -29,6 +51,16 @@ Panel(string id, f32 x_pct, f32 y_pct, Axis2D layout_axis, Vec4 color)
|
||||
return item;
|
||||
}
|
||||
|
||||
UIItem*
|
||||
Separator(u8[] id, f32 x_pct, f32 y_pct)
|
||||
{
|
||||
SetColor(Vec4(0.0, 0.0, 0.0, 1.0));
|
||||
|
||||
UIItem* item = BuildItem(id, UISize(ST.Percentage, x_pct), UISize(ST.Percentage, y_pct), UIF.DrawBackground);
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
void
|
||||
EndPanel()
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user