Network: better prensentation

This commit is contained in:
2023-09-30 02:39:12 +02:00
parent fc92f629a6
commit a345141a71
12 changed files with 314 additions and 58 deletions

View File

@@ -506,6 +506,27 @@ bool gui_text_input(Rect r, char *text, u64 max_size)
}
// Panels
void gui_panel(Gui_Context *ctx, Rect r)
{
Gui_Id widget_id = 0;
bool behaviuor = gui_button_behaviuor(ctx, widget_id, r);
bool is_inactive = true;
v4 background_color = is_inactive ? ctx->style.window_background_color_inactive :
ctx->style.window_background_color;
v4 border_color = is_inactive ? ctx->style.window_border_color_inactive :
ctx->style.window_border_color;
Rect background_rect = {r.x + 0.5, r.y + 0.5, floor(r.w)-1.0, floor(r.h)-1.0};
r_2d_immediate_rounded_rectangle(background_rect, ctx->style.window_corner_radius, background_color);
r_2d_immediate_rounded_rectangle_outline(background_rect, ctx->style.window_corner_radius, border_color, 1.0);
}
void gui_panel(Rect r)
{
gui_panel(&global_gui_state.default_context, r);
}
// Windows
bool gui_window_start(Gui_Context *ctx, Rect r, Gui_Id id)

View File

@@ -170,6 +170,10 @@ bool gui_image(Rect r, const u8 *bmp, u32 width, u32 height, u32 channels, u32 f
bool gui_text_input(Gui_Context *ctx, Rect r, char *text, u64 max_size);
bool gui_text_input(Rect r, char *text, u64 max_size);
// Panels
void gui_panel(Gui_Context *ctx, Rect r);
void gui_panel(Rect r);
// Windows
bool gui_window_start(Gui_Context *ctx, Rect r, Gui_Id id); // You have to provide some kind of unique id to identify windows
bool gui_window_start(Rect r, Gui_Id id);

View File

@@ -340,12 +340,19 @@ static gui_glyph_texture gui_glyph_texture_create(f32 font_size, u32 capacity)
LOG(LOG_DEBUG, "Font size %f not in cache. Slot size (%d %d)", font_size, glyphs.glyph_max_size.x, glyphs.glyph_max_size.y);
// Precompile some info data
v2u texture_slots;
texture_slots.x = r_render_state.max_texture_size / glyphs.glyph_max_size.x;
texture_slots.y = (glyphs.capacity + texture_slots.x) / texture_slots.x;
for(u32 i = 0; i < glyphs.capacity; i++)
{
v2u position = {
i % texture_slots.x * glyphs.glyph_max_size.x,
i / texture_slots.x * glyphs.glyph_max_size.y
};
glyphs.info[i] = gui_glyph_info{
.codepoint = 0xFFFFFFFF,
.box = {0,0,0,0},
.position = v2u{glyphs.glyph_max_size.x * i, 0},
.position = position,
.advance = 0,
.next = i + 1, // Last .next will be >= capacity (== capacity to be precise), so we will consider it to be NULL
.previous = ((i == 0) ? glyphs.capacity : (i - 1))
@@ -355,7 +362,7 @@ static gui_glyph_texture gui_glyph_texture_create(f32 font_size, u32 capacity)
}
// Initialize texture
v2s texture_size = v2s{glyphs.glyph_max_size.x * glyphs.capacity, glyphs.glyph_max_size.y};
v2s texture_size = glyphs.glyph_max_size * V2S(texture_slots);
u8 *texture_data = (u8*)p_alloc(sizeof(u8) * texture_size.x * texture_size.y);
memset(texture_data, 0, sizeof(u8) * texture_size.x * texture_size.y);