Network: better prensentation
This commit is contained in:
BIN
assets/icons/harddisk-symbolic.png
Normal file
BIN
assets/icons/harddisk-symbolic.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.3 KiB |
BIN
assets/icons/lan-symbolic.png
Normal file
BIN
assets/icons/lan-symbolic.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
BIN
assets/icons/memory-symbolic.png
Normal file
BIN
assets/icons/memory-symbolic.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
BIN
assets/icons/network-vpn-symbolic.png
Normal file
BIN
assets/icons/network-vpn-symbolic.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.6 KiB |
BIN
assets/icons/network-wireless-symbolic.png
Normal file
BIN
assets/icons/network-wireless-symbolic.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.8 KiB |
BIN
assets/icons/processor-symbolic.png
Normal file
BIN
assets/icons/processor-symbolic.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.5 KiB |
@@ -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
|
// Windows
|
||||||
bool gui_window_start(Gui_Context *ctx, Rect r, Gui_Id id)
|
bool gui_window_start(Gui_Context *ctx, Rect r, Gui_Id id)
|
||||||
|
|||||||
@@ -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(Gui_Context *ctx, Rect r, char *text, u64 max_size);
|
||||||
bool gui_text_input(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
|
// 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(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);
|
bool gui_window_start(Rect r, Gui_Id id);
|
||||||
|
|||||||
@@ -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);
|
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
|
// 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++)
|
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{
|
glyphs.info[i] = gui_glyph_info{
|
||||||
.codepoint = 0xFFFFFFFF,
|
.codepoint = 0xFFFFFFFF,
|
||||||
.box = {0,0,0,0},
|
.box = {0,0,0,0},
|
||||||
.position = v2u{glyphs.glyph_max_size.x * i, 0},
|
.position = position,
|
||||||
.advance = 0,
|
.advance = 0,
|
||||||
.next = i + 1, // Last .next will be >= capacity (== capacity to be precise), so we will consider it to be NULL
|
.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))
|
.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
|
// 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);
|
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);
|
memset(texture_data, 0, sizeof(u8) * texture_size.x * texture_size.y);
|
||||||
|
|
||||||
|
|||||||
330
code/main.cpp
330
code/main.cpp
@@ -28,6 +28,14 @@ void process_gui();
|
|||||||
void app_init();
|
void app_init();
|
||||||
void app_deinit();
|
void app_deinit();
|
||||||
|
|
||||||
|
enum Section_Status
|
||||||
|
{
|
||||||
|
SECTION_STATUS_NONE,
|
||||||
|
SECTION_STATUS_OK,
|
||||||
|
SECTION_STATUS_WARNING,
|
||||||
|
SECTION_STATUS_ERROR
|
||||||
|
};
|
||||||
|
|
||||||
struct App_Data
|
struct App_Data
|
||||||
{
|
{
|
||||||
f64 glib_iteration_t = -1;
|
f64 glib_iteration_t = -1;
|
||||||
@@ -62,6 +70,8 @@ struct System_Info
|
|||||||
u64 ram_total;
|
u64 ram_total;
|
||||||
u64 ram_used;
|
u64 ram_used;
|
||||||
u64 ram_available;
|
u64 ram_available;
|
||||||
|
|
||||||
|
Section_Status status;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Network_Device
|
struct Network_Device
|
||||||
@@ -75,6 +85,8 @@ struct Network_Info
|
|||||||
{
|
{
|
||||||
s32 device_count;
|
s32 device_count;
|
||||||
Network_Device devices[32];
|
Network_Device devices[32];
|
||||||
|
|
||||||
|
Section_Status status;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Virt_Domain
|
struct Virt_Domain
|
||||||
@@ -95,6 +107,8 @@ struct Virt_Info
|
|||||||
{
|
{
|
||||||
s32 domain_count;
|
s32 domain_count;
|
||||||
Virt_Domain domains[32];
|
Virt_Domain domains[32];
|
||||||
|
|
||||||
|
Section_Status status;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct FS_Entry
|
struct FS_Entry
|
||||||
@@ -110,6 +124,8 @@ struct FS_Info
|
|||||||
{
|
{
|
||||||
s32 fs_count;
|
s32 fs_count;
|
||||||
FS_Entry fs[32];
|
FS_Entry fs[32];
|
||||||
|
|
||||||
|
Section_Status status;
|
||||||
};
|
};
|
||||||
|
|
||||||
System_Info system_info;
|
System_Info system_info;
|
||||||
@@ -118,6 +134,46 @@ Virt_Info virt_info;
|
|||||||
FS_Info fs_info;
|
FS_Info fs_info;
|
||||||
App_Data app_data;
|
App_Data app_data;
|
||||||
|
|
||||||
|
Gui_Style style_default;
|
||||||
|
void style_select(Gui_Context *ctx, Section_Status status)
|
||||||
|
{
|
||||||
|
|
||||||
|
switch(status)
|
||||||
|
{
|
||||||
|
case SECTION_STATUS_NONE: {
|
||||||
|
ctx->style.button_color = style_default.button_color;
|
||||||
|
ctx->style.button_color_hovered = style_default.button_color_hovered;
|
||||||
|
ctx->style.window_background_color = style_default.window_background_color;
|
||||||
|
ctx->style.window_background_color_inactive = style_default.window_background_color_inactive;
|
||||||
|
ctx->style.window_border_color = style_default.window_border_color;
|
||||||
|
ctx->style.window_border_color_inactive = style_default.window_border_color_inactive;
|
||||||
|
} break;
|
||||||
|
case SECTION_STATUS_OK: {
|
||||||
|
ctx->style.button_color_hovered = ctx->style.button_color = v4{0,1,0,1};
|
||||||
|
ctx->style.window_background_color_inactive = ctx->style.window_background_color = v4{0,.6,0,1};
|
||||||
|
ctx->style.window_border_color_inactive = ctx->style.window_border_color = v4{0,1,0,1};
|
||||||
|
} break;
|
||||||
|
case SECTION_STATUS_WARNING: {
|
||||||
|
ctx->style.button_color_hovered = ctx->style.button_color = v4{1,.8,0,1};
|
||||||
|
ctx->style.window_background_color_inactive = ctx->style.window_background_color = v4{.6,.5,0,1};
|
||||||
|
ctx->style.window_border_color_inactive = ctx->style.window_border_color = v4{1,.8,0,1};
|
||||||
|
} break;
|
||||||
|
case SECTION_STATUS_ERROR: {
|
||||||
|
ctx->style.button_color_hovered = ctx->style.button_color = v4{1,0,0,1};
|
||||||
|
ctx->style.window_background_color_inactive = ctx->style.window_background_color = v4{0.6,0,0,1};
|
||||||
|
ctx->style.window_border_color_inactive = ctx->style.window_border_color = v4{1,0,0,1};
|
||||||
|
} break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Icons
|
||||||
|
r_texture icon_disk;
|
||||||
|
r_texture icon_lan;
|
||||||
|
r_texture icon_ram;
|
||||||
|
r_texture icon_vpn;
|
||||||
|
r_texture icon_wifi;
|
||||||
|
r_texture icon_cpu;
|
||||||
|
|
||||||
|
|
||||||
u32 seconds_to_duration_text(char *text, f64 seconds, bool show_millis = false)
|
u32 seconds_to_duration_text(char *text, f64 seconds, bool show_millis = false)
|
||||||
{
|
{
|
||||||
@@ -147,10 +203,16 @@ u32 seconds_to_duration_text(char *text, f64 seconds, bool show_millis = false)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void load_image(const char *filename, u8 **data, s32 *width, s32 *height, s32 *channels)
|
r_texture load_image_monochrome(const char *filename)
|
||||||
{
|
{
|
||||||
|
s32 width, height, channels;
|
||||||
stbi_set_flip_vertically_on_load(false);
|
stbi_set_flip_vertically_on_load(false);
|
||||||
*data = stbi_load(filename, width, height, channels, 4);
|
u8 *data = stbi_load(filename, &width, &height, &channels, 1);
|
||||||
|
|
||||||
|
for(u64 i = 0; i < (width*height); i++) // Flipped colors
|
||||||
|
data[i] = 0xFF - data[i];
|
||||||
|
|
||||||
|
return r_texture_create(data, {width, height}, R_TEXTURE_ALPHA);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -284,94 +346,188 @@ bool process_input()
|
|||||||
|
|
||||||
void system_info_gui(Gui_Layout_Grid *grid)
|
void system_info_gui(Gui_Layout_Grid *grid)
|
||||||
{
|
{
|
||||||
Rect r = grid->rect_at({0,0}, {4,4});
|
Gui_Context *ctx = &global_gui_state.default_context;
|
||||||
Gui_Layout_Grid layout = gui_layout_grid_create_by_divisions(v2{0,0}, r.size, 4, 4, 0.2*engine.gui_scaling);
|
|
||||||
|
// No window info
|
||||||
|
// Clock and date
|
||||||
|
system_info.time = time(NULL);
|
||||||
|
struct tm *time_info = localtime(&system_info.time);
|
||||||
|
char clock[64], timezone[64];
|
||||||
|
strftime(clock, 128, "%H:%M:%S", time_info);
|
||||||
|
strftime(timezone, 128, "%Z", time_info);
|
||||||
|
|
||||||
|
f32 old_font_size = ctx->style.font_size;
|
||||||
|
ctx->style.font_size *= 3;
|
||||||
|
gui_text_aligned(grid->rect_at({2,1}, {2,2}), clock, GUI_ALIGN_CENTER);
|
||||||
|
ctx->style.font_size = old_font_size;
|
||||||
|
gui_text_aligned(grid->rect_at({2,3}, {2,1}), timezone, GUI_ALIGN_CENTER);
|
||||||
|
gui_text_aligned(grid->rect_at({2,0}, {2,1}), system_info.cached_date_string, GUI_ALIGN_CENTER);
|
||||||
|
|
||||||
|
// Host
|
||||||
|
gui_text_aligned(grid->rect_at({0,0}, {2,1}), system_info.hostname, GUI_ALIGN_LEFT);
|
||||||
|
// Uptime
|
||||||
|
char uptime[128] = "Uptime: "; seconds_to_duration_text(uptime + strlen("Uptime: "), system_info.uptime);
|
||||||
|
gui_text_aligned(grid->rect_at({4,0}, {2,1}), uptime, GUI_ALIGN_RIGHT);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Window with cpu n., load, ram
|
||||||
|
Rect r = grid->rect_at({4,1}, {2,3});
|
||||||
|
Gui_Layout_Grid layout = gui_layout_grid_create_by_divisions(v2{0,0}, r.size, 2, 3, 0.2*engine.gui_scaling);
|
||||||
|
|
||||||
|
style_select(ctx, system_info.status);
|
||||||
gui_window_start(r, 0xabcdef01);
|
gui_window_start(r, 0xabcdef01);
|
||||||
|
style_select(ctx, SECTION_STATUS_NONE);
|
||||||
|
|
||||||
// Host date and time
|
|
||||||
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;
|
|
||||||
sysinfo(&sys_info);
|
|
||||||
char uptime[128] = "Uptime: "; seconds_to_duration_text(uptime + strlen("Uptime: "), sys_info.uptime);
|
|
||||||
|
|
||||||
char load[128]; snprintf(load, 128, "Load: %.2f %.2f %.2f", system_info.load[0], system_info.load[1], system_info.load[2]);
|
char load[128]; snprintf(load, 128, "Load: %.2f %.2f %.2f", system_info.load[0], system_info.load[1], system_info.load[2]);
|
||||||
|
|
||||||
char processors[128]; snprintf(processors, 128, "CPUs: %d/%d", system_info.cpus_active, system_info.cpus_total);
|
char processors[128]; snprintf(processors, 128, "CPUs: %d/%d", system_info.cpus_active, system_info.cpus_total);
|
||||||
|
|
||||||
|
// slider for ram?
|
||||||
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));
|
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(2), processors, GUI_ALIGN_LEFT);
|
||||||
gui_text_aligned(layout.cell(1), processors, GUI_ALIGN_LEFT);
|
gui_text_aligned(layout.cell(2), ram, GUI_ALIGN_LEFT);
|
||||||
gui_text_aligned(layout.cell(1), ram, GUI_ALIGN_LEFT);
|
gui_text_aligned(layout.cell(2), load, 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();
|
gui_window_end();
|
||||||
}
|
}
|
||||||
|
|
||||||
void network_gui(Gui_Layout_Grid *grid)
|
void network_gui(Gui_Layout_Grid *grid)
|
||||||
{
|
{
|
||||||
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;
|
Gui_Context *ctx = &global_gui_state.default_context;
|
||||||
|
|
||||||
|
Rect r = grid->rect_at({0,4}, {3,13});
|
||||||
|
Gui_Layout_Grid layout = gui_layout_grid_create_by_divisions(v2{0,0}, r.size, 3, 13, 0.2*engine.gui_scaling);
|
||||||
|
|
||||||
|
style_select(ctx, network_info.status);
|
||||||
|
gui_window_start(r, 0xabcdef02);
|
||||||
|
style_select(ctx, SECTION_STATUS_NONE);
|
||||||
|
|
||||||
|
gui_text_aligned(layout.cell(GUI_LAYOUT_MAX_CELLS), "Network", GUI_ALIGN_CENTER);
|
||||||
|
layout.row();
|
||||||
|
|
||||||
|
r = layout.rect_at({0,1}, layout.max_cells_count - v2s{0,1});
|
||||||
|
layout = gui_layout_grid_create_by_divisions(r.position, r.size, 3, 3, 0.2*engine.gui_scaling);
|
||||||
|
|
||||||
for(s32 i = 0; i < network_info.device_count; i++)
|
for(s32 i = 0; i < network_info.device_count; i++)
|
||||||
{
|
{
|
||||||
Network_Device *device = &network_info.devices[i];
|
Network_Device *device = &network_info.devices[i];
|
||||||
|
|
||||||
gui_button(layout.cell(), device->name);
|
if(device->type != NM_DEVICE_TYPE_ETHERNET && device->type != NM_DEVICE_TYPE_WIFI && device->type != NM_DEVICE_TYPE_WIREGUARD)
|
||||||
|
continue;
|
||||||
|
|
||||||
gui_id_stack_push(ctx, gui_id_from_pointer(ctx, device->name));
|
gui_id_stack_push(ctx, gui_id_from_pointer(ctx, device->name));
|
||||||
|
|
||||||
switch(device->type)
|
|
||||||
{
|
{
|
||||||
case NM_DEVICE_TYPE_ETHERNET: gui_button(layout.cell(), "ETHERNET"); break;
|
Section_Status status = SECTION_STATUS_OK;
|
||||||
case NM_DEVICE_TYPE_WIFI: gui_button(layout.cell(), "WIFI"); break;
|
if(device->state == NM_DEVICE_STATE_PREPARE ||
|
||||||
case NM_DEVICE_TYPE_TUN: gui_button(layout.cell(), "TAP or TUN"); break;
|
device->state == NM_DEVICE_STATE_CONFIG ||
|
||||||
case NM_DEVICE_TYPE_BRIDGE: gui_button(layout.cell(), "BRIDGE"); break;
|
device->state == NM_DEVICE_STATE_IP_CONFIG ||
|
||||||
case NM_DEVICE_TYPE_VLAN: gui_button(layout.cell(), "VLAN"); break;
|
device->state == NM_DEVICE_STATE_IP_CHECK)
|
||||||
case NM_DEVICE_TYPE_WIREGUARD: gui_button(layout.cell(), "WIREGUARD"); break;
|
{
|
||||||
default: gui_button(layout.cell(), ""); break;
|
// Bump status
|
||||||
}
|
if(status < SECTION_STATUS_WARNING)
|
||||||
|
status = SECTION_STATUS_WARNING;
|
||||||
|
}
|
||||||
|
else if(device->state != NM_DEVICE_STATE_ACTIVATED)
|
||||||
|
{
|
||||||
|
// Bump status
|
||||||
|
if(status < SECTION_STATUS_ERROR)
|
||||||
|
status = SECTION_STATUS_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
switch(device->state)
|
Rect r = layout.cell();
|
||||||
{
|
style_select(ctx, status);
|
||||||
case NM_DEVICE_STATE_UNKNOWN: gui_button(layout.cell(), "UNKNOWN"); break;
|
gui_panel(r);
|
||||||
case NM_DEVICE_STATE_UNMANAGED: gui_button(layout.cell(), "UNMANAGED"); break;
|
style_select(ctx, SECTION_STATUS_NONE);
|
||||||
case NM_DEVICE_STATE_UNAVAILABLE: gui_button(layout.cell(), "UNAVAILABLE"); break;
|
|
||||||
case NM_DEVICE_STATE_DISCONNECTED: gui_button(layout.cell(), "DISCONNECTED"); break;
|
Gui_Layout_Grid layout = gui_layout_grid_create_by_divisions(r.position, r.size, 9, 4, 0.1*engine.gui_scaling);
|
||||||
case NM_DEVICE_STATE_PREPARE: gui_button(layout.cell(), "PREPARE"); break;
|
|
||||||
case NM_DEVICE_STATE_CONFIG: gui_button(layout.cell(), "CONFIG"); break;
|
const char *type_text = "";
|
||||||
case NM_DEVICE_STATE_NEED_AUTH: gui_button(layout.cell(), "NEED_AUTH"); break;
|
r_texture *icon = &icon_lan;
|
||||||
case NM_DEVICE_STATE_IP_CONFIG: gui_button(layout.cell(), "IP_CONFIG"); break;
|
switch(device->type)
|
||||||
case NM_DEVICE_STATE_IP_CHECK: gui_button(layout.cell(), "IP_CHECK"); break;
|
{
|
||||||
case NM_DEVICE_STATE_SECONDARIES: gui_button(layout.cell(), "SECONDARIES"); break;
|
case NM_DEVICE_TYPE_ETHERNET: {
|
||||||
case NM_DEVICE_STATE_ACTIVATED: gui_button(layout.cell(), "ACTIVATED"); break;
|
icon = &icon_lan;
|
||||||
case NM_DEVICE_STATE_DEACTIVATING: gui_button(layout.cell(), "DEACTIVATING"); break;
|
type_text = "Ethernet";
|
||||||
case NM_DEVICE_STATE_FAILED: gui_button(layout.cell(), "FAILED"); break;
|
} break;
|
||||||
default: gui_button(layout.cell(), ""); break;
|
case NM_DEVICE_TYPE_WIFI: {
|
||||||
|
icon = &icon_wifi;
|
||||||
|
type_text = "WiFi";
|
||||||
|
} break;
|
||||||
|
case NM_DEVICE_TYPE_TUN: {
|
||||||
|
icon = &icon_vpn;
|
||||||
|
type_text = "TAP/TUN";
|
||||||
|
} break;
|
||||||
|
case NM_DEVICE_TYPE_BRIDGE: {
|
||||||
|
icon = &icon_lan;
|
||||||
|
type_text = "Bridge";
|
||||||
|
} break;
|
||||||
|
case NM_DEVICE_TYPE_VLAN: {
|
||||||
|
icon = &icon_lan;
|
||||||
|
type_text = "vlan";
|
||||||
|
} break;
|
||||||
|
case NM_DEVICE_TYPE_WIREGUARD: {
|
||||||
|
icon = &icon_vpn;
|
||||||
|
type_text = "VPN";
|
||||||
|
} break;
|
||||||
|
default: {
|
||||||
|
icon = &icon_lan;
|
||||||
|
type_text = "";
|
||||||
|
} break;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *state_text = "";
|
||||||
|
switch(device->state)
|
||||||
|
{
|
||||||
|
case NM_DEVICE_STATE_UNKNOWN: state_text = "UNKNOWN"; break;
|
||||||
|
case NM_DEVICE_STATE_UNMANAGED: state_text = "UNMANAGED"; break;
|
||||||
|
case NM_DEVICE_STATE_UNAVAILABLE: state_text = "UNAVAILABLE"; break;
|
||||||
|
case NM_DEVICE_STATE_DISCONNECTED: state_text = "DISCONNECTED"; break;
|
||||||
|
case NM_DEVICE_STATE_PREPARE: state_text = "PREPARE"; break;
|
||||||
|
case NM_DEVICE_STATE_CONFIG: state_text = "CONFIG"; break;
|
||||||
|
case NM_DEVICE_STATE_NEED_AUTH: state_text = "NEED_AUTH"; break;
|
||||||
|
case NM_DEVICE_STATE_IP_CONFIG: state_text = "IP_CONFIG"; break;
|
||||||
|
case NM_DEVICE_STATE_IP_CHECK: state_text = "IP_CHECK"; break;
|
||||||
|
case NM_DEVICE_STATE_SECONDARIES: state_text = "SECONDARIES"; break;
|
||||||
|
case NM_DEVICE_STATE_ACTIVATED: state_text = "ACTIVATED"; break;
|
||||||
|
case NM_DEVICE_STATE_DEACTIVATING: state_text = "DEACTIVATING"; break;
|
||||||
|
case NM_DEVICE_STATE_FAILED: state_text = "FAILED"; break;
|
||||||
|
default: gui_button(layout.cell(), ""); break;
|
||||||
|
}
|
||||||
|
|
||||||
|
Rect icon_r = layout.cell(1);
|
||||||
|
icon_r.position += (icon_r.size - v2{1,1}*minimum(icon_r.size.x, icon_r.size.y)) * .5;
|
||||||
|
icon_r.size = v2{1,1} * minimum(icon_r.size.x, icon_r.size.y);
|
||||||
|
gui_image(icon_r, icon);
|
||||||
|
gui_text(layout.cell(layout.max_cells_count.x - layout.cursor.x), device->name);
|
||||||
|
|
||||||
|
layout.cell(1);
|
||||||
|
gui_text(layout.cell(layout.max_cells_count.x - layout.cursor.x), type_text);
|
||||||
|
|
||||||
|
layout.row(2);
|
||||||
|
layout.cell(1);
|
||||||
|
gui_text(layout.cell(layout.max_cells_count.x - layout.cursor.x), state_text);
|
||||||
}
|
}
|
||||||
|
|
||||||
gui_id_stack_pop(ctx);
|
gui_id_stack_pop(ctx);
|
||||||
layout.row();
|
|
||||||
}
|
}
|
||||||
gui_window_end();
|
gui_window_end();
|
||||||
}
|
}
|
||||||
|
|
||||||
void vm_gui(Gui_Layout_Grid *grid)
|
void vm_gui(Gui_Layout_Grid *grid)
|
||||||
{
|
{
|
||||||
|
Gui_Context *ctx = &global_gui_state.default_context;
|
||||||
|
|
||||||
Rect r = grid->rect_at({0,17}, {4,5});
|
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_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;
|
style_select(ctx, virt_info.status);
|
||||||
|
gui_window_start(r, 0xabcdef03);
|
||||||
|
style_select(ctx, SECTION_STATUS_NONE);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Gui_Style old_style = ctx->style;
|
Gui_Style old_style = ctx->style;
|
||||||
@@ -431,12 +587,16 @@ void vm_gui(Gui_Layout_Grid *grid)
|
|||||||
|
|
||||||
void fs_gui(Gui_Layout_Grid *grid)
|
void fs_gui(Gui_Layout_Grid *grid)
|
||||||
{
|
{
|
||||||
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;
|
Gui_Context *ctx = &global_gui_state.default_context;
|
||||||
|
|
||||||
|
Rect r = grid->rect_at({4,4}, {2,18});
|
||||||
|
Gui_Layout_Grid layout = gui_layout_grid_create_by_divisions(v2{0,0}, r.size, 2, 18, 0.2*engine.gui_scaling);
|
||||||
|
|
||||||
|
style_select(ctx, fs_info.status);
|
||||||
|
gui_window_start(r, 0xabcdef04);
|
||||||
|
style_select(ctx, SECTION_STATUS_NONE);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for(s32 i = 0; i < fs_info.fs_count; i++)
|
for(s32 i = 0; i < fs_info.fs_count; i++)
|
||||||
{
|
{
|
||||||
@@ -509,6 +669,9 @@ void collect_new_data_if_needed()
|
|||||||
system_info.ram_used = sys_info.totalram * sys_info.mem_unit - system_info.ram_available;
|
system_info.ram_used = sys_info.totalram * sys_info.mem_unit - system_info.ram_available;
|
||||||
|
|
||||||
|
|
||||||
|
// Status
|
||||||
|
system_info.status = SECTION_STATUS_NONE;
|
||||||
|
|
||||||
app_data.system_sample_t = engine.time;
|
app_data.system_sample_t = engine.time;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -526,6 +689,30 @@ void collect_new_data_if_needed()
|
|||||||
network_info.devices[i].state = nm_device_get_state(device);
|
network_info.devices[i].state = nm_device_get_state(device);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update section status
|
||||||
|
network_info.status = SECTION_STATUS_OK;
|
||||||
|
for(int i = 0; i < network_info.device_count; i++)
|
||||||
|
{
|
||||||
|
Network_Device *device = &network_info.devices[i];
|
||||||
|
if(device->type == NM_DEVICE_TYPE_ETHERNET || device->type == NM_DEVICE_TYPE_WIREGUARD)
|
||||||
|
{
|
||||||
|
if(device->state == NM_DEVICE_STATE_PREPARE ||
|
||||||
|
device->state == NM_DEVICE_STATE_CONFIG ||
|
||||||
|
device->state == NM_DEVICE_STATE_IP_CONFIG ||
|
||||||
|
device->state == NM_DEVICE_STATE_IP_CHECK)
|
||||||
|
{
|
||||||
|
// Bump status
|
||||||
|
if(network_info.status < SECTION_STATUS_WARNING)
|
||||||
|
network_info.status = SECTION_STATUS_WARNING;
|
||||||
|
}
|
||||||
|
else if(device->state != NM_DEVICE_STATE_ACTIVATED)
|
||||||
|
{
|
||||||
|
// Bump status
|
||||||
|
if(network_info.status < SECTION_STATUS_ERROR)
|
||||||
|
network_info.status = SECTION_STATUS_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
app_data.network_sample_t = engine.time;
|
app_data.network_sample_t = engine.time;
|
||||||
}
|
}
|
||||||
@@ -560,6 +747,25 @@ void collect_new_data_if_needed()
|
|||||||
|
|
||||||
p_free(domains);
|
p_free(domains);
|
||||||
|
|
||||||
|
// Update section status
|
||||||
|
virt_info.status = SECTION_STATUS_OK;
|
||||||
|
for(int i = 0; i < virt_info.domain_count; i++)
|
||||||
|
{
|
||||||
|
Virt_Domain *domain = &virt_info.domains[i];
|
||||||
|
if(domain->state == VIR_DOMAIN_PAUSED ||
|
||||||
|
domain->state == VIR_DOMAIN_PMSUSPENDED)
|
||||||
|
{
|
||||||
|
// Bump status
|
||||||
|
if(virt_info.status < SECTION_STATUS_WARNING)
|
||||||
|
virt_info.status = SECTION_STATUS_WARNING;
|
||||||
|
}
|
||||||
|
else if(domain->state != VIR_DOMAIN_RUNNING)
|
||||||
|
{
|
||||||
|
// Bump status
|
||||||
|
if(virt_info.status < SECTION_STATUS_ERROR)
|
||||||
|
virt_info.status = SECTION_STATUS_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
app_data.virt_sample_t = engine.time;
|
app_data.virt_sample_t = engine.time;
|
||||||
}
|
}
|
||||||
@@ -592,6 +798,8 @@ void collect_new_data_if_needed()
|
|||||||
}
|
}
|
||||||
|
|
||||||
endmntent(file);
|
endmntent(file);
|
||||||
|
|
||||||
|
fs_info.status = SECTION_STATUS_NONE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -635,6 +843,16 @@ void app_init()
|
|||||||
virt_connection = virConnectOpenReadOnly("qemu:///system");
|
virt_connection = virConnectOpenReadOnly("qemu:///system");
|
||||||
|
|
||||||
collect_static_data();
|
collect_static_data();
|
||||||
|
|
||||||
|
style_default = global_gui_state.default_context.style;
|
||||||
|
|
||||||
|
// Icons
|
||||||
|
icon_disk = load_image_monochrome("assets/icons/harddisk-symbolic.png");
|
||||||
|
icon_lan = load_image_monochrome("assets/icons/lan-symbolic.png");
|
||||||
|
icon_ram = load_image_monochrome("assets/icons/memory-symbolic.png");
|
||||||
|
icon_vpn = load_image_monochrome("assets/icons/network-vpn-symbolic.png");
|
||||||
|
icon_wifi = load_image_monochrome("assets/icons/network-wireless-symbolic.png");
|
||||||
|
icon_cpu = load_image_monochrome("assets/icons/processor-symbolic.png");
|
||||||
}
|
}
|
||||||
|
|
||||||
void app_deinit()
|
void app_deinit()
|
||||||
|
|||||||
@@ -103,6 +103,9 @@ void r_init()
|
|||||||
|
|
||||||
// Render state
|
// Render state
|
||||||
r_size_update(width, height);
|
r_size_update(width, height);
|
||||||
|
|
||||||
|
// Parameters
|
||||||
|
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &r_render_state.max_texture_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void r_deinit()
|
void r_deinit()
|
||||||
|
|||||||
@@ -29,6 +29,9 @@ struct r_state
|
|||||||
// Quads
|
// Quads
|
||||||
u32 gl_screen_quad_VAO;
|
u32 gl_screen_quad_VAO;
|
||||||
u32 gl_screen_quad_VBO;
|
u32 gl_screen_quad_VBO;
|
||||||
|
|
||||||
|
// Parameters
|
||||||
|
s32 max_texture_size;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern r_state r_render_state;
|
extern r_state r_render_state;
|
||||||
|
|||||||
Reference in New Issue
Block a user