Grid
This commit is contained in:
@@ -41,6 +41,8 @@ struct App_Data
|
||||
f64 network_sample_delta = 0.2;
|
||||
f64 virt_sample_delta = 0.5;
|
||||
f64 fs_sample_delta = 1.0;
|
||||
|
||||
bool show_grid = false;
|
||||
};
|
||||
|
||||
struct System_Info
|
||||
@@ -200,11 +202,9 @@ int main(int argc, char *argv[])
|
||||
// GUI
|
||||
r_framebuffer_select(&r_render_state.framebuffer_SCREEN);
|
||||
r_clear({0,0,0,0});
|
||||
gui_frame_begin(engine.time);
|
||||
|
||||
process_gui();
|
||||
|
||||
gui_frame_end();
|
||||
log_viewer.Print_New_Messages_On_Console();
|
||||
r_swap();
|
||||
prev_t = engine.time;
|
||||
@@ -242,7 +242,11 @@ bool process_input()
|
||||
{
|
||||
switch(event.key.key_code)
|
||||
{
|
||||
|
||||
case KEY_G:
|
||||
case KEY_F2: {
|
||||
if(event.key.pressed)
|
||||
app_data.show_grid = !app_data.show_grid;
|
||||
} break;
|
||||
default: {
|
||||
// Other keys. Put default to suppress warnings
|
||||
} break;
|
||||
@@ -278,15 +282,16 @@ bool process_input()
|
||||
|
||||
|
||||
|
||||
void system_info_window()
|
||||
void system_info_gui(Gui_Layout_Grid *grid)
|
||||
{
|
||||
Gui_Layout_Grid layout = gui_layout_grid_create_by_divisions(v2{0,0}, v2{40,6}*engine.gui_scaling, 3, 4, 0.2*engine.gui_scaling);
|
||||
gui_window_start(Rect{0.1*engine.gui_scaling, 0.1*engine.gui_scaling, layout.window_size.x, layout.window_size.y}, 0xabcdef01);
|
||||
Rect r = grid->rect_at({0,0}, {4,4});
|
||||
Gui_Layout_Grid layout = gui_layout_grid_create_by_divisions(v2{0,0}, r.size, 4, 4, 0.2*engine.gui_scaling);
|
||||
gui_window_start(r, 0xabcdef01);
|
||||
|
||||
// Host date and time
|
||||
gui_text_aligned(layout.cell(), system_info.hostname, GUI_ALIGN_LEFT);
|
||||
gui_text_aligned(layout.cell(), system_info.cached_time_string, GUI_ALIGN_CENTER);
|
||||
gui_text_aligned(layout.cell(), system_info.cached_date_string, GUI_ALIGN_RIGHT);
|
||||
gui_text_aligned(layout.cell(1), system_info.hostname, GUI_ALIGN_LEFT);
|
||||
gui_text_aligned(layout.cell(2), system_info.cached_time_string, GUI_ALIGN_CENTER);
|
||||
gui_text_aligned(layout.cell(1), system_info.cached_date_string, GUI_ALIGN_RIGHT);
|
||||
|
||||
// Load, Memory, Uptime
|
||||
struct sysinfo sys_info;
|
||||
@@ -300,19 +305,20 @@ void system_info_window()
|
||||
char ram[128]; snprintf(ram, 128, "RAM: %.2f/%.2f GiB", system_info.ram_used / (1024.0*1024.0*1024.0), system_info.ram_total / (1024.0*1024.0*1024.0));
|
||||
|
||||
layout.row(2);
|
||||
gui_text_aligned(layout.cell(), processors, GUI_ALIGN_LEFT);
|
||||
gui_text_aligned(layout.cell(), load, GUI_ALIGN_CENTER);
|
||||
gui_text_aligned(layout.cell(), uptime, GUI_ALIGN_RIGHT);
|
||||
gui_text_aligned(layout.cell(), ram, GUI_ALIGN_LEFT);
|
||||
gui_text_aligned(layout.cell(1), processors, GUI_ALIGN_LEFT);
|
||||
gui_text_aligned(layout.cell(1), ram, GUI_ALIGN_LEFT);
|
||||
gui_text_aligned(layout.cell(2), uptime, GUI_ALIGN_RIGHT);
|
||||
gui_text_aligned(layout.cell(1), load, GUI_ALIGN_LEFT);
|
||||
|
||||
|
||||
gui_window_end();
|
||||
}
|
||||
|
||||
void network_window()
|
||||
void network_gui(Gui_Layout_Grid *grid)
|
||||
{
|
||||
Gui_Layout_Grid layout = gui_layout_grid_create_by_divisions(v2{0,0}, v2{40,18}*engine.gui_scaling, 3, 12, 0.2*engine.gui_scaling);
|
||||
gui_window_start(Rect{0.1*engine.gui_scaling, 7*engine.gui_scaling, layout.window_size.x, layout.window_size.y}, 0xabcdef02);
|
||||
Rect r = grid->rect_at({0,4}, {4,13});
|
||||
Gui_Layout_Grid layout = gui_layout_grid_create_by_divisions(v2{0,0}, r.size, 4, 13, 0.2*engine.gui_scaling);
|
||||
gui_window_start(r, 0xabcdef02);
|
||||
|
||||
Gui_Context *ctx = &global_gui_state.default_context;
|
||||
|
||||
@@ -359,10 +365,11 @@ void network_window()
|
||||
gui_window_end();
|
||||
}
|
||||
|
||||
void vm_window()
|
||||
void vm_gui(Gui_Layout_Grid *grid)
|
||||
{
|
||||
Gui_Layout_Grid layout = gui_layout_grid_create_by_divisions(v2{0,0}, v2{40,6}*engine.gui_scaling, 4, 4, 0.2*engine.gui_scaling);
|
||||
gui_window_start(Rect{0.1*engine.gui_scaling, 26*engine.gui_scaling, layout.window_size.x, layout.window_size.y}, 0xabcdef03);
|
||||
Rect r = grid->rect_at({0,17}, {4,5});
|
||||
Gui_Layout_Grid layout = gui_layout_grid_create_by_divisions(v2{0,0}, r.size, 4, 5, 0.2*engine.gui_scaling);
|
||||
gui_window_start(r, 0xabcdef03);
|
||||
|
||||
Gui_Context *ctx = &global_gui_state.default_context;
|
||||
|
||||
@@ -422,10 +429,11 @@ void vm_window()
|
||||
}
|
||||
|
||||
|
||||
void fs_window()
|
||||
void fs_gui(Gui_Layout_Grid *grid)
|
||||
{
|
||||
Gui_Layout_Grid layout = gui_layout_grid_create_by_divisions(v2{0,0}, v2{16,30}*engine.gui_scaling, 2, 20, 0.2*engine.gui_scaling);
|
||||
gui_window_start(Rect{41*engine.gui_scaling, 0.1*engine.gui_scaling, layout.window_size.x, layout.window_size.y}, 0xabcdef04);
|
||||
Rect r = grid->rect_at({4,0}, {2,22});
|
||||
Gui_Layout_Grid layout = gui_layout_grid_create_by_divisions(v2{0,0}, r.size, 2, 22, 0.2*engine.gui_scaling);
|
||||
gui_window_start(r, 0xabcdef04);
|
||||
|
||||
Gui_Context *ctx = &global_gui_state.default_context;
|
||||
|
||||
@@ -591,11 +599,29 @@ void process_gui()
|
||||
{
|
||||
collect_new_data_if_needed();
|
||||
|
||||
gui_frame_begin(engine.time);
|
||||
|
||||
system_info_window();
|
||||
network_window();
|
||||
vm_window();
|
||||
fs_window();
|
||||
Gui_Layout_Grid layout = gui_layout_grid_create_by_divisions(v2{0,0}, v2{r_render_state.width,r_render_state.height} , 6, 22, 0.5*engine.gui_scaling);
|
||||
|
||||
|
||||
|
||||
system_info_gui(&layout);
|
||||
network_gui(&layout);
|
||||
vm_gui(&layout);
|
||||
fs_gui(&layout);
|
||||
|
||||
gui_frame_end();
|
||||
|
||||
if(app_data.show_grid)
|
||||
{
|
||||
layout.cursor = {0,0};
|
||||
while(layout.cursor.y < layout.max_cells_count.y)
|
||||
{
|
||||
r_2d_immediate_rectangle_outline(layout.cell(), {0,1,0,1});
|
||||
char coords[32]; snprintf(coords, 32, "(%d, %d)", layout.cursor.x - 1, layout.cursor.y);
|
||||
gui_text_aligned(layout.rect(), coords, GUI_ALIGN_CENTER); // abuse: used after gui_frame_end
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void app_init()
|
||||
|
||||
Reference in New Issue
Block a user