tweak ugui api, add some usefult functions
This commit is contained in:
parent
2014c67bfd
commit
c4a3dd3a26
@ -62,7 +62,7 @@ alias ElemCache = cache::Cache{Id, Elem, MAX_ELEMENTS};
|
|||||||
|
|
||||||
alias CmdQueue = fifo::Fifo{Cmd};
|
alias CmdQueue = fifo::Fifo{Cmd};
|
||||||
|
|
||||||
faultdef INVALID_SIZE, EVENT_UNSUPPORTED, UNEXPECTED_ELEMENT, WRONG_ELEMENT_TYPE;
|
faultdef INVALID_SIZE, EVENT_UNSUPPORTED, UNEXPECTED_ELEMENT, WRONG_ELEMENT_TYPE, WRONG_ID;
|
||||||
|
|
||||||
const Rect DIV_FILL = { .x = 0, .y = 0, .w = 0, .h = 0 };
|
const Rect DIV_FILL = { .x = 0, .y = 0, .w = 0, .h = 0 };
|
||||||
|
|
||||||
|
@ -224,3 +224,13 @@ fn Id Ctx.get_font_id(&ctx, String label)
|
|||||||
{
|
{
|
||||||
return (Id)label.hash();
|
return (Id)label.hash();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn Atlas*? Ctx.get_font_atlas(&ctx, String name)
|
||||||
|
{
|
||||||
|
// TODO: use the font name, for now there is only one font
|
||||||
|
if (name.hash() != ctx.font.id) {
|
||||||
|
return WRONG_ID?;
|
||||||
|
}
|
||||||
|
|
||||||
|
return &ctx.font.atlas;
|
||||||
|
}
|
||||||
|
@ -193,7 +193,7 @@ struct Color{
|
|||||||
char r, g, b, a;
|
char r, g, b, a;
|
||||||
}
|
}
|
||||||
|
|
||||||
macro Color uint.to_rgba(uint u)
|
macro Color uint.to_rgba(u)
|
||||||
{
|
{
|
||||||
return {
|
return {
|
||||||
.r = (char)((u >> 24) & 0xff),
|
.r = (char)((u >> 24) & 0xff),
|
||||||
@ -202,3 +202,9 @@ macro Color uint.to_rgba(uint u)
|
|||||||
.a = (char)((u >> 0) & 0xff)
|
.a = (char)((u >> 0) & 0xff)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
macro uint Color.to_uint(c)
|
||||||
|
{
|
||||||
|
uint u = c.r | (c.g << 8) | (c.b << 16) | (c.a << 24);
|
||||||
|
return u;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user