glw_imgui - C++ IMGUI implementation

Related tags

GUI glw_imgui
Overview

License

glw_imgui - C++ IMGUI implementation

Immediate Mode UI C++ implementation.

IMGUI is a code-driven, simple and bloat-free GUI system, widely used in modern game engines and games. Best explanation of IMGUI concept is here.

IMGUI: creation, usage and rendering of a button in one line:

Alt text

// simple button
if (gui.button("Cancel"))
	do_cancel_action();

All logic is hidden in the Gui::button() call, rendering commands are issued and added to the render queue. String pooling is used to pack strings in render queue and avoid memory allocation during rendering. Rendering is graphics API independent, platform specific rendering should be implemented (the reference implementation by SDL is provided in the demo project.)

The library has basic suppot for layouting (attachable toolbars, layout serialization), themes (right now colors only), lock-free multithreading (triple buffering).

Gallery

Basic GUI manipulations, various controls, resizable and movable toolbars. Entire UI is built using IMGUI. ScreenShot

The Editor of Glow game engine

Build and run:

Windows: Prerequisites: cmake, C++ compiler

mkdir build
cd build
cmake ..
cmake --build . --target install

Run demo.exe from demo/install/ folder.

Linux: Prerequisites: cmake, C++ compiler, SDL2

Install SDL2

sudo apt-get install libsdl2-dev

Build:

mkdir build
cd build
cmake ..
cmake --build . --target install
cd ../demo/install/
./demo

MacOS: Prerequisites: cmake, C++ compiler, SDL2

Install SDL2

brew update SDL2

Build:

mkdir build
cd build
cmake ..
cmake --build . --target install
cd ../demo/install/
./demo

Sample UI update loop with various controls

	int mouse_x, mouse_y;

	uint keysPressed = handle_input(x, y);
	int w, h;
	SDL_GetWindowSize(gWindow, &w, &h);
	ui.set_text_align(ALIGN_LEFT);

	ui.begin_frame(w, h, x, y, -mouse_wheel, last_char, keysPressed);
	last_char = 0;
	mouse_wheel = 0;

	ui.begin_rollout(rollout);
	static bool collapsed = false;
	if (ui.collapse("Collapse", collapsed))
		collapsed = !collapsed;

	if (!collapsed) {
		ui.indent();
		ui.button("Button1");
		ui.button("Button2");
		ui.button("Button3");
		ui.button("Button4");
		ui.separator(true);

		static char combo_value[100] = "Item1";
		if (ui.combo("Combo Box", combo_value)) {
			if (ui.combo_item("Item1"))
				strcpy(combo_value, "Item1");
			if (ui.combo_item("Item2"))
				strcpy(combo_value, "Item2");
			if (ui.combo_item("Item3"))
				strcpy(combo_value, "Item3");
			if (ui.combo_item("Item4"))
				strcpy(combo_value, "Item4");
		}
		ui.separator();

		static bool checked = false;
		if (ui.check("Checkbox", checked))
			checked = !checked;

		ui.separator(true);
		ui.texture("texture.jpg");
		ui.rectangle(100);
		ui.texture(nullptr);

		ui.separator();
		ui.separator(true);
		ui.label("Edit text");
		static char edit_value[256];
		bool edit_finished = false;
		ui.edit(edit_value, 256, &edit_finished);
		ui.separator(true);

		ui.label("Label");
		ui.value("Value");
		static float val = 1.0f;
		ui.slider("Slider", &val, 0.0f, 10.0f, 1.0f);

		ui.separator(true);
		ui.label("Progress bar");
		static float progress = 7.0f;
		ui.progress(progress, 0.0f, 10.0f, 1.0f);

		ui.row(3);
		ui.button("Item1");
		ui.button("Item2");
		ui.button("Item3");
		ui.end_row();

		static char str_property[100] = "Property Val";
		ui.property("Property", str_property, 100, NULL);
		ui.draw_text(5, 5, 0, "Draw item", 0xffffffff);

		ui.unindent();
	}
	ui.end_rollout();

	ui.begin_rollout(vert_rollout);

	char str[100];
	static int selected = -1;
	for (int i = 0; i < 100; ++i) {
		sprintf(str, "item %d", i);
		if (ui.item(str, i == selected))
			selected = i;
	}

	ui.end_rollout();

	ui.end_frame();

Alt text

FAQ

The license? BSD

Dependencies

STL, c-runtime.

Performance

Rendering - almost allocation-free (and I will try to make it allocation-free completely in the future)

Compatibility

Working on Windows (tested with Visual Studio 2013, 2015), MacOS and Linux.

The library is based on IMGUI implementation from Recast library by Mikko Mononen https://github.com/recastnavigation/recastnavigation

You might also like...
An integrated information center created with dear ImGui using modern C++ design / coding style.

ImGui info-center Introduction An integrated notification and information center created with dear ImGui. Interfaces and variables are designed under

ImGuiBase - A very good & simple external ImGui base

ImGuiBase Join CProject to learn about ImGui! https://discord.gg/dnkdDuUtQu Check out our website: https://cproject.xyz Check out the youtube tutorial

Addon widgets for GUI library Dear ImGui.
Addon widgets for GUI library Dear ImGui.

ImGui-Addons Addon widgets for GUI library Dear ImGui. File Dialog A simple cross-platform file dialog that uses dirent interface for reading director

This is a software renderer for Dear ImGui. I built it not out of a specific need, but because it was fun
This is a software renderer for Dear ImGui. I built it not out of a specific need, but because it was fun

Dear ImGui software renderer This is a software renderer for Dear ImGui. I built it not out of a specific need, but because it was fun. The goal was t

This is a collection of widgets and utilities for the immediate mode GUI (imgui) that I am developing for the critic2 GUI
This is a collection of widgets and utilities for the immediate mode GUI (imgui) that I am developing for the critic2 GUI

ImGui Goodies This is a collection of widgets and utilities for the immediate mode GUI (imgui) that I am developing for the critic2 GUI. Currently, th

Immediate mode 3D gizmo for scene editing and other controls based on Dear Imgui
Immediate mode 3D gizmo for scene editing and other controls based on Dear Imgui

ImGuizmo Latest stable tagged version is 1.83. Current master version is 1.84 WIP. What started with the gizmo is now a collection of dear imgui widge

This is a thin c-api wrapper programmatically generated for the excellent C++ immediate mode gui Dear ImGui.

cimgui This is a thin c-api wrapper programmatically generated for the excellent C++ immediate mode gui Dear ImGui. All imgui.h functions are programm

Nice things to use along dear imgui
Nice things to use along dear imgui

Mini hexadecimal editor! Right-click for option menu. Features: Keyboard controls. Read-only mode. Optional Ascii display. Optional HexII display. Goto address. Highlight range/function. Read/Write handlers.

Window and GUI system based on Dear ImGui from OCornut
Window and GUI system based on Dear ImGui from OCornut

ImWindow Window and GUI system based on ImGui from OCornut. Include docking/floating window, multi window and multi render support. Platform Actually

Releases(v0.1)
Owner
null
Simple ImGui external base. Uses ImGui DX9.

ImGui External Base ??️ What is this? ⚡ Hello all! I used to use noteffex's loader base for all my external ImGui projects. I got bored of using this

Alfie 11 Jun 29, 2022
An addon of imgui for supporting docks in the imgui's window

An addon of imgui for support dock in the window

BB 207 Nov 29, 2022
An implementation of node editor with ImGui-like API.

Node Editor in ImGui About An implementation of node editor with ImGui-like API. Project purpose is to serve as a basis for more complex solutions lik

Michał Cichoń 2.4k Jan 9, 2023
Dear ImGui: Bloat-free Graphical User interface for C++ with minimal dependencies

Dear ImGui (This library is available under a free and permissive license, but needs financial support to sustain its continued improvements. In addit

omar 44.5k Jan 7, 2023
Advanced 2D Plotting for Dear ImGui

ImPlot ImPlot is an immediate mode, GPU accelerated plotting library for Dear ImGui. It aims to provide a first-class API that ImGui fans will love. I

Evan Pezent 2.9k Jan 9, 2023
CMakeLists wrapper around imgui

ImGui Wrappings This is a trifold wrapper for the Dear ImGui library. Ease integration with CMake, Provide an RAII mechanism for ImGui scopes, Provide

Oliver Smith 39 Dec 8, 2022
super duper simple gui for C, wrapping imgui and stb

super duper simle gui for C, wrapping imgui and stb You can use it as a static library with cmake. See the example directory for a complete example. E

Rasmus 11 May 19, 2022
Real-time GUI layout creator/editor for Dear ImGui

ImStudio Real-time GUI layout creator/editor for Dear ImGui Inspired by Code-Building/ImGuiBuilder Features Drag edit Property edit Covers most of the

null 303 Jan 9, 2023
KeyAuth login form made with ImGui.

KeyAuth-ImGui-Example KeyAuth ImGui Example Download Repository Download the DirectX SDK

Lolys 23 Dec 16, 2022
Dear ImGui prototyping wrapper.

LabImGui Prototyping framework LabImGui wraps up creating a window, GL bindings, and a full screen docking set up with ImGui so that all of the boiler

Nick Porcino 1 Dec 5, 2022