added separators
This commit is contained in:
parent
669c1a55e2
commit
5ee1ae6d17
@ -282,6 +282,12 @@ PrevSiblingPanel(UIItem* panel)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UIItem*
|
||||||
|
PeekParent()
|
||||||
|
{
|
||||||
|
return g_ui_ctx.top_parent == g_UI_NIL_NODE ? g_UI_NIL : g_ui_ctx.top_parent.item;
|
||||||
|
}
|
||||||
|
|
||||||
UIItem*
|
UIItem*
|
||||||
PopParent()
|
PopParent()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import dlib;
|
import dlib;
|
||||||
|
|
||||||
import ui;
|
import ui;
|
||||||
|
import std.format : sformat;
|
||||||
|
|
||||||
UIItem*
|
UIItem*
|
||||||
Root()
|
Root()
|
||||||
@ -15,13 +16,34 @@ Root()
|
|||||||
UIItem*
|
UIItem*
|
||||||
Panel(string id, f32 x_pct, f32 y_pct, Axis2D layout_axis, Vec4 color)
|
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);
|
SetColor(color);
|
||||||
SetLayoutAxis(layout_axis);
|
SetLayoutAxis(layout_axis);
|
||||||
UIItem* item = BuildItem(id, UISize(ST.Percentage, x_pct), UISize(ST.Percentage, y_pct), UIF.DrawBackground);
|
UIItem* item = BuildItem(id, UISize(ST.Percentage, x_pct), UISize(ST.Percentage, y_pct), UIF.DrawBackground);
|
||||||
|
|
||||||
UIItem* prev_panel = PrevSiblingPanel(item);
|
UIItem* sibling = PrevSiblingPanel(item);
|
||||||
|
|
||||||
Logf("%s %s", id, !Nil(prev_panel));
|
|
||||||
|
|
||||||
PushSiblingPanel(item);
|
PushSiblingPanel(item);
|
||||||
PushParent(item);
|
PushParent(item);
|
||||||
@ -29,6 +51,16 @@ Panel(string id, f32 x_pct, f32 y_pct, Axis2D layout_axis, Vec4 color)
|
|||||||
return item;
|
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
|
void
|
||||||
EndPanel()
|
EndPanel()
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user