Custom window size and styling added.

This commit is contained in:
0xC3-dev
2025-08-01 00:08:51 -04:00
parent 6364eadbfe
commit 7594223a21
130 changed files with 856 additions and 3146 deletions

55
main.c
View File

@@ -54,12 +54,13 @@
#define NK_KEYSTATE_BASED_INPUT
#include "nuklear.h"
#include "nuklear_glfw_gl3.h"
#include <Windows.h>
// Window dimensions
static int window_width = 800;
static int window_height = 600;
static int min_window_width = 400;
static int min_window_height = 300;
static int min_window_width = 800;
static int min_window_height = 600;
static GLFWwindow* window = NULL;
// Nuklear context
@@ -244,6 +245,7 @@ struct nk_rect get_scaled_window_rect(void) {
return nk_rect(x, y, scaled_width, scaled_height);
}
// Initialize GLFW and create window
void init_glfw(void) {
// Set error callback
@@ -268,6 +270,8 @@ void init_glfw(void) {
glfwTerminate();
exit(EXIT_FAILURE);
}
//HWND hwnd = glfwGetWin32Window(window);
// Make the window's context current
glfwMakeContextCurrent(window);
@@ -316,10 +320,21 @@ void init_nuklear(void) {
nk_glfw3_font_stash_end(&glfw);
printf("Nuklear initialized successfully\n");
// Override specific colors
ctx->style.window.header.active.data.color = nk_rgb(28, 28, 28);
ctx->style.window.background = nk_rgb(158, 204, 46);
ctx->style.text.color = nk_rgb(158, 204, 46);
// Override padding constraints
//ctx->style.window.group_padding = nk_vec2(10, 10);
//ctx->style.window.spacing = nk_vec2(0, 0);
//ctx->style.window.padding = nk_vec2(0, 0);
ctx->style.button.rounding = 10.f;
// Test minimum window size constraint
printf("Testing minimum window size constraint...\n");
glfwSetWindowSize(window, 200, 150); // Try to set below minimum
glfwSetWindowSize(window, 800, 600); // Try to set below minimum
glfwPollEvents(); // Process the resize event
int test_width, test_height;
@@ -354,7 +369,7 @@ static ui_component_t ui_components[] = {
// Render main UI using modular component system
void render_ui(struct nk_context* ctx) {
// Get responsive window rectangle
struct nk_rect window_rect = get_scaled_window_rect();
struct nk_rect window_rect = nk_rect(0, 0, (float)window_width, (float)window_height);//get_scaled_window_rect();
// Main demo window with title bar showing application name and current window size
char window_title[256];
@@ -363,20 +378,36 @@ void render_ui(struct nk_context* ctx) {
window_width, window_height);
if (nk_begin(ctx, window_title, window_rect,
NK_WINDOW_BORDER|NK_WINDOW_MOVABLE|NK_WINDOW_SCALABLE|
NK_WINDOW_MINIMIZABLE|NK_WINDOW_TITLE)) {
NK_WINDOW_BORDER|NK_WINDOW_TITLE)) {
// Render all enabled UI components
for (int i = 0; i < UI_COMPONENT_COUNT; i++) {
if (ui_components[i].enabled && ui_components[i].render) {
ui_components[i].render(ctx, &ui_state);
//// Render all enabled UI components
//for (int i = 0; i < UI_COMPONENT_COUNT; i++) {
// if (ui_components[i].enabled && ui_components[i].render) {
// ui_components[i].render(ctx, &ui_state);
//
// // Add separator between components (except for the last one)
// if (i < UI_COMPONENT_COUNT - 1) {
// nk_layout_row_dynamic(ctx, 10, 1);
// nk_spacing(ctx, 1);
// }
// }
//}
nk_layout_row_dynamic(ctx, 300, 1);
if (nk_group_begin(ctx, "Window Information:", NK_WINDOW_BORDER | NK_WINDOW_TITLE | NK_WINDOW_NO_SCROLLBAR)) {
nk_layout_row_dynamic(ctx, 30, 1);
for (int i = 0; i < UI_COMPONENT_COUNT; i++) {
if (ui_components[i].enabled && ui_components[i].render) {
ui_components[i].render(ctx, &ui_state);
// Add separator between components (except for the last one)
if (i < UI_COMPONENT_COUNT - 1) {
// Add separator between components (except for the last one)
if (i < UI_COMPONENT_COUNT - 1) {
nk_layout_row_dynamic(ctx, 10, 1);
nk_spacing(ctx, 1);
}
}
}
nk_group_end(ctx);
}
}
nk_end(ctx);