by keepamovin | 2025-05-11 20:21:22+00:00
Interesting! I was just looking at raylib for this kind of thing: super light weight, cross platform, reliable, ideally C-based method to get GUI.

Raylib and raygui is truly incredible from my point of view. I succeeded in getting the macOS and Windows builds going on a bunch of cute little novel (not stock standard in the repo) examples in a matter of hours with AI help. I'm inspired by all I can do with this.

For ages I felt "cut off" from the world of Desktop GUI because it was so verbose, and had high friction - need a bunch of tooling, set up, and so on. And then everything was fragile. I like to work quickly, with feedback, and PoCs and results. I think in raylib I have found a method that really achieves this. For instance, check out this tiny little "text_input.c"

#define RAYGUI_IMPLEMENTATION #include <raylib.h> #include "deps/raygui.h" #define WINDOW_WIDTH 800 #define WINDOW_HEIGHT 600 #define MAX_INPUT_CHARS 32 int main(void) { InitWindow(WINDOW_WIDTH, WINDOW_HEIGHT, "Text Input Demo"); SetTargetFPS(60); // Load a larger font for better text appearance Font font = LoadFontEx("resources/fonts/arial.ttf", 32, 0, 0); if (font.texture.id == 0) { font = GetFontDefault(); // Fallback to default font if loading fails } // Set the font for raygui controls GuiSetFont(font); // Customize raygui styles (using BGR order for hex values) GuiSetStyle(BUTTON, TEXT_ALIGNMENT, TEXT_ALIGN_CENTER); GuiSetStyle(BUTTON, BASE_COLOR_NORMAL, 0x50AF4CFF); // Green (B=80, G=175, R=76, A=255) ‚Üí R=76, G=175, B=80 GuiSetStyle(BUTTON, TEXT_COLOR_NORMAL, 0xFFFFFFFF); // White text GuiSetStyle(BUTTON, BASE_COLOR_PRESSED, 0x6ABB66FF); // Lighter green GuiSetStyle(BUTTON, TEXT_COLOR_PRESSED, 0xFFFFFFFF); GuiSetStyle(BUTTON, BASE_COLOR_FOCUSED, 0x84C781FF); // Hover color GuiSetStyle(BUTTON, TEXT_COLOR_FOCUSED, 0xFFFFFFFF); GuiSetStyle(BUTTON, BORDER_WIDTH, 2); GuiSetStyle(BUTTON, BORDER_COLOR_NORMAL, 0x327D2EFF); // Dark green border // Adjust font size for raygui controls (optional, since font is already 32pt) GuiSetStyle(DEFAULT, TEXT_SIZE, 20); // Slightly smaller for button and text box to fit better GuiSetStyle(DEFAULT, TEXT_SPACING, 1); char inputText[MAX_INPUT_CHARS + 1] = "\0"; // Buffer for text input bool textBoxEditMode = false; // Tracks if the text box is being edited bool messageSubmitted = false; // Tracks if a message has been submitted float effectTimer = 0.0f; // Timer for the flash effect const float effectDuration = 0.5f; // Flash duration in seconds while (!WindowShouldClose()) { // Update effect timer if (effectTimer > 0) { effectTimer -= GetFrameTime(); } BeginDrawing(); // Set background color based on effect if (effectTimer > 0) { ClearBackground((Color){ 255, 255, 150, 255 }); // Yellow flash (RGB order) } else { ClearBackground(RAYWHITE); } // Center the text box and button int textBoxWidth = 200; int textBoxHeight = 40; int buttonWidth = 120; int buttonHeight = 40; int textBoxX = (WINDOW_WIDTH - textBoxWidth) / 2; int textBoxY = (WINDOW_HEIGHT - textBoxHeight) / 2 - 40; int buttonX = (WINDOW_WIDTH - buttonWidth) / 2; int buttonY = textBoxY + textBoxHeight + 10; // Draw the text box if (GuiTextBox((Rectangle){ (float)textBoxX, (float)textBoxY, textBoxWidth, textBoxHeight }, inputText, MAX_INPUT_CHARS, textBoxEditMode)) { textBoxEditMode = !textBoxEditMode; // Toggle edit mode on click } // Draw the button if (GuiButton((Rectangle){ (float)buttonX, (float)buttonY, buttonWidth, buttonHeight }, "Submit")) { messageSubmitted = true; effectTimer = effectDuration; // Start the flash effect TraceLog(LOG_INFO, "Message submitted: %s", inputText); } // Display the submitted message if (messageSubmitted && inputText[0] != '\0') { const char *label = "Message: "; char displayText[256]; snprintf(displayText, sizeof(displayText), "%s%s", label, inputText); int textWidth = MeasureTextEx(font, displayText, 32, 1).x; int textX = (WINDOW_WIDTH - textWidth) / 2; int textY = buttonY + buttonHeight + 20; DrawTextEx(font, displayText, (Vector2){ (float)textX, (float)textY }, 32, 1, (Color){ 33, 150, 243, 255 }); // Bright blue (RGB order) } EndDrawing(); } UnloadFont(font); CloseWindow(); return 0; }

I love it! I feel unleashed again to program in graphics and games and real GUI! The first real paid programming job I had was using a lot of ps5 in Java and JavaScript (Open Processing) and I dug it! :)

And the file sizes are sweet (to me):

- macOS: text_input - 123736

- Windows: text_input.exe - 538909

Two dependencies to distribute with on Windows: glfw3.dll and libraylib.dll (322K and 2.1MB respectively)

Raylib was built to make game programming fun. And maybe I will use it for that! :) But right now I want to use it for GUI. The issue with Qt and others, is while I like the idea of standard-Andy controls, I don't want to pay a commercial license - when I figure "it can't be that hard to get what I want" - as I plan to use this stuff for commercial/proprietary control-panes and layers on my existing products: BrowserBox, DiskerNet, and more.

At the same time I really respect what Qt have done growing their business and might be inspired or even emulate some of their model myself in my business.