GithubHelp home page GithubHelp logo

zraygui's Introduction

zraygui - Retained GUI based on raylib's raygui

This software is unfinished!! Also, there is a lot of spaghetti code that I will be fixing soon.

zraygui is an attempt of transforming the well-known raygui library, which currently implements an immediate mode GUI (ImGUI) using the raylib framework, into a retained mode GUI. This transition from immediate mode to retained mode brings about a significant shift in how user interfaces are managed and drawn.

What is raylib and raygui?

  • raylib is a popular and lightweight C library designed for making 2D and 3D games. It provides a wealth of features for graphics, audio, and input handling while keeping things simple and accessible.
  • raygui is a companion library for raylib, focusing on creating graphical user interfaces (GUIs). It employs an immediate mode GUI paradigm, where each frame, GUI elements are drawn and handled individually. This approach is efficient and straightforward for simple interfaces but can become complex for larger projects.

Transitioning to Retained Mode with zraygui

zraygui takes the fundamental concept of raygui and evolves it into a retained mode GUI based of Layouts/Panels and Widgets. In retained mode, GUI elements persist beyond the frame they were created in. This approach allows for a more structured and organized GUI construction, particularly for complex applications.

Features Check List:

  • Implement almost every Gui control of raygui.
  • Implement Radio Buttons.
  • Implement Menu bar with sub menus.

Key Benefits of zraygui:

  1. Dynamic Content: Retained mode accommodates dynamic content changes seamlessly. Adding, removing, or altering elements during runtime is more natural and less error-prone.
  2. Widget Listeners: This retained mode brings the benefit of having different kind of listeners such as OnClick or OnHover.
  3. Menu Bar: One of the motivation of this project was to bring an easy way to create a Menu Bar with multiples indented Sub Menus.
  4. Radio Buttons: With an immediate GUI it is impossible (with out saving data in the API source) to implement Radio Buttons. Since zraygui is based on layouts/panels and widgets, we can implement this easily!

Getting Started with zraygui

To begin using zraygui in your raylib-based project, follow these steps:

  1. Copy the zraygui.h file from the src folder and paste it in your project workspace.
  2. Define the ZRAYGUI_IMPLEMENTATION and include the header file in your sources.
  3. Start creating your beautiful Raylib GUI applications with zraygui!

Example

#define ZRAYGUI_IMPLEMENTATION
#include "../src/zraygui.h"

Layout* root;
Widget *button, *label;

void my_callback(Vector2 mousePos) {
    SetWidgetVisible(label, true);
}

int main(void) {
    int w = 250;
    int h = 100;
    InitWindow(w,h,"Hello World - zraygui");

    root = CreateLayout(NULL, L_NONE, WHITE);
    button = CreateButton("Press me!");
    label = CreateLabel("Hello world from zraygui!");

    SetWidgetPos(button, (Vector2){(w - GetWidgetWidth(button)) / 2, (h - GetWidgetHeight(button)) / 4});
    SetWidgetPos(label, (Vector2){(w - GetWidgetWidth(label)) / 2, ((h - GetWidgetHeight(label)) / 2) + 15});
    
    SetWidgetVisible(label, false);

    AddWidget(root, button);
    AddWidget(root, label);
    
    SetWidgetOnClick(button, my_callback);

    while (!WindowShouldClose()) {
        BeginDrawing();
            ClearBackground(WHITE);
            RenderWindow(root);
        EndDrawing();
    }

    return 0;
}

Contributing to zraygui

zraygui is an open-source project that welcomes contributions from the community. Whether you're interested in improving documentation, adding new features, or fixing bugs, your efforts are valued.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.