Compare commits

..

No commits in common. "7b7aac8df4184b0e8de2bde64735fcf7c4d066fb" and "bca29c537cfdf818577f79cc5a279d1412b9dcda" have entirely different histories.

4 changed files with 10 additions and 40 deletions

16
TODO
View File

@ -1,38 +1,32 @@
# TODOs, semi-random sorting
[x] Implement glyph draw command
[x] Implement div.view and scrollbars
[x] Port font system from C to C3 (rewrite1)
[ ] Port font system from C to C3 (rewrite1)
[ ] Update ARCHITECTURE.md
[ ] Write a README.md
[ ] Use an arena allocator for cache
[ ] Do not redraw if there was no update (no layout and no draw)
[ ] Better handling of the active and focused widgets, try
to maintain focus until mouse release (fix scroll bars)
to maintain focus until mouse release (fix scroll bars)
## Commands
[x] rect commads should have:
_ border width
_ border radius
* border width
* border radius
[x] add a command to update an atlas
## Atlases
[ ] Add an interface to create, destroy, update and get atlases based on their ids
[ ] Implement multiple font atlases
## Fonts
[x] Fix the missing alpha channel
[ ] Fix the missing alpha channel
[x] Fix the alignment
## Raylib
[ ] Implement type (Rect, Color, Point) conversion functions between rl:: and ugui::
[x] Implement pixel radius rounding for border radius
## Widgets
[ ] Dynamic text box to implement an fps counter
[ ] Button with label

View File

@ -45,10 +45,10 @@ struct SftImage
int height;
}
extern fn ZString sft_version() @extern("sft_version");
extern fn char* sft_version() @extern("sft_version");
extern fn SftFont loadmem(void* mem, usz size) @extern("sft_loadmem");
extern fn SftFont loadfile(ZString filename) @extern("sft_loadfile");
extern fn SftFont loadfile(char* filename) @extern("sft_loadfile");
extern fn void freefont(SftFont font) @extern("sft_freefont");
extern fn int lmetrics(Sft* sft, SftLMetrics* metrics) @extern("sft_lmetrics");

View File

@ -23,28 +23,6 @@ fn void Times.print_stats(&times)
io::printfn("min=%s, max=%s, avg=%s", min, max, avg);
}
const ZString FONT_FS = `
#version 330
// Input vertex attributes (from vertex shader)
in vec2 fragTexCoord;
in vec4 fragColor;
// Input uniform values
uniform sampler2D texture0;
uniform vec4 colDiffuse;
// Output fragment color
out vec4 finalColor;
void main()
{
vec4 alpha = texture(texture0, fragTexCoord);
finalColor = colDiffuse*fragColor;
finalColor.a *= alpha.r;
}
`;
fn int main(String[] args)
{
ugui::Ctx ui;
@ -64,7 +42,6 @@ fn int main(String[] args)
time::Clock clock;
Times ui_times;
Times draw_times;
rl::Shader font_shader = rl::load_shader_from_memory(null, FONT_FS);
// Main loop
while (!rl::window_should_close()) {
@ -196,9 +173,8 @@ fn int main(String[] args)
.x = cmd.sprite.rect.x,
.y = cmd.sprite.rect.y,
};
rl::begin_shader_mode(font_shader);
rl::draw_texture_rec(font_texture, source, position, rl::WHITE);
rl::end_shader_mode();
case ugui::CmdType.CMD_SCISSOR:
if (cmd.scissor.rect.w == 0 && cmd.scissor.rect.h == 0) {
rl::end_scissor_mode();

View File

@ -61,7 +61,7 @@ struct Font {
bool should_update; // should send update_atlas command, resets at frame_end()
}
fn void! Font.load(&font, String name, ZString path, uint height, float scale)
fn void! Font.load(&font, String name, String path, uint height, float scale)
{
font.table.new_init(capacity: FONT_CACHED);
font.id = name.hash();
@ -161,7 +161,7 @@ fn void Font.free(&font)
schrift::freefont(font.sft.font);
}
fn void! Ctx.load_font(&ctx, String name, ZString path, uint height, float scale = 1.0)
fn void! Ctx.load_font(&ctx, String name, String path, uint height, float scale = 1.0)
{
return ctx.font.load(name, path, height, scale);
}