• Stars
    star
    315
  • Rank 132,208 (Top 3 %)
  • Language Haxe
  • License
    zlib License
  • Created about 9 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Immediate Mode User Interface

zui

Portable immediate mode UI library designed for tools and debug interfaces. Written in Haxe and Kha, used in ArmorPaint.

Getting started

  • Clone into your_kha_project/Libraries
  • Add project.addLibrary('zui'); into khafile.js
	// In init()
	var ui = new Zui({ font: myFont });

	// In render()
	public function render(frames: Array<Framebuffer>) {
		var g = frames[0].g2;
		g.begin();
		// Draw your stuff...
		g.end();

		ui.begin(g);
		if (ui.window(Id.handle(), x, y, w, h, drag)) {
			if (ui.button("Hello")) {
				trace("World");
			}
		}
		ui.end();

		// Draw more stuff...
	}

Elements

function tab(handle: Handle, text: String, vertical = false): Bool;
function panel(handle: Handle, text: String, isTree = false): Bool;
function image(image: Image, tint = 0xffffffff): State;
function text(text: String, align = Left, bg = 0x00000000);
function textInput(handle: Handle, label = "", align = Left): String;
function button(text: String, align = Center, label = ""): Bool;
function check(handle: Handle, text: String): Bool;
function radio(groupId: Handle, pos: Int, text: String): Bool;
function combo(handle: Handle, texts: Array<String>, label = ""): Int;
function slider(handle: Handle, text: String, from: Float, to: Float, filled = false, precision = 100, displayValue = true): Float;
function tooltip(text: String);
function tooltipImage(image: Image);

// Formatting
function row(ratios: Array<Float>);
function separator(h = 4, fill = true);
function indent();
function unindent();

Id.hx - simple macros to generate handles

var state = ui.check(Id.handle(), "Check Box");

Ext.hx - prebuilt elements:

function colorWheel(...); // See examples
function fileBrowser(...);
function inlineRadio(handle: Handle, texts: Array<String>): Int;
function textArea(handle: Handle, align = Left): String;

Nodes.hx - drawing node systems

nodes.nodeCanvas(...); // See examples

Examples

Check out examples/ folder. To run specific example, simply drop it's folder into KodeStudio and hit run. If you are having trouble compiling, clone latest Kha repository into your example folder (alongside the khafile.js). This will let KodeStudio pick up the most recent Kha.

Theming

Themes can be defined using TTheme typedef. Check zui.Themes class for example. Set ZuiOptions.theme when creating new Zui instance to overwrite default theme.

Snippets

Check element for changes

var hcombo = Id.handle();
ui.combo(hcombo, ["Item 1", "item 2"]);
if (hcombo.changed) {
	trace("Combo value changed this frame");
}

Force redrawing zui window on demand

function render(..) {
    // Get window handle
    var hwin = Id.handle();
    // Force redraw - set each frame or whenever desired
    hwin.redraws = 1;
    if (ui.window(hwin, x, y, w, h)) { ... }
}

Using render targets - prevent nested begin/end calls

g2.begin();
..
g2.end();

renderTarget.g2.begin();
..
renderTarget.g2.end();

zui.begin(); // Zui also draws to texture..
..
zui.end();

g2.begin();
..
g2.end();

Using Id.handle() in a for loop

// Id.handle() works at compile time
// Call .nest() to get unique handle per iteration
for (i in 0...3) Id.handle().nest(i);
// Or use new zui.Handle() directly

Set initial Id.handle() state

var h1 = Id.handle({selected: true});
var h2 = Id.handle({position: 0});
var h3 = Id.handle({value: 1.0});
var h4 = Id.handle({text: "Text"});

Custom integration

Using the powerful render target system of Kha, it is possible to easily integrate the library into any scenario. Set ZuiOptions.autoNotifyInput to false when creating a new Zui instance. You can then manually process the input and render the resulting texture in any way you may need.

zui.onMouseDown(button:Int, x: Int, y: Int)
zui.onMouseUp(button:Int, x: Int, y: Int)
zui.onMouseMove(x: Int, y: Int, movementX: Int, movementY: Int)
zui.onMouseWheel(delta: Int)

Inspired by imgui.

More Repositories

1

armortools

3D Content Creation Tools
C++
3,210
star
2

armory

3D Engine with Blender Integration
Python
3,047
star
3

iron

3D Engine Core
Haxe
257
star
4

armorlab

Moved to https://github.com/armory3d/armortools/tree/main/armorlab
Haxe
166
star
5

sdfgen

GPU-based SDF generator
Haxe
149
star
6

armorcore

3D Engine Core for C with JS scripting
C
117
star
7

haxebullet

Bullet 3D Physics for Haxe
C++
95
star
8

armory2d

2D Editor
Haxe
83
star
9

armory_examples

Armory Examples
Haxe
60
star
10

armory_templates

Starter Scenes
Haxe
52
star
11

armory_docs

Moved to Armory Wiki
HTML
46
star
12

armorpaint_unreal

Unreal Engine plugin for ArmorPaint
C++
45
star
13

armsdk

Single-clone Armory SDK
Python
37
star
14

armory_tutorials

Armory Tutorials
Haxe
32
star
15

armorpaint_unity

Unity plugin for ArmorPaint
C#
22
star
16

logic_pack

Community-made logic nodes
Python
19
star
17

iron_examples

Iron Examples
Haxe
16
star
18

armorai

ML models for ArmorLab
Python
13
star
19

armorpaint_docs

Moved to https://github.com/armory3d/armorpaint_web/tree/main/manual.md.
CSS
12
star
20

armorpaint_godot

Godot plugin for ArmorPaint
GDScript
11
star
21

v8_bin

C++
11
star
22

voxel_world

Voxel worlds for Armory
Haxe
10
star
23

armory_web

Armory Website
HTML
10
star
24

armorpaint_samples

Use 'Browser - Cloud' in ArmorPaint instead.
10
star
25

gamecenter_kha

Game Center library for Haxe Kha
Java
9
star
26

iap_kha

In-App-Purchases Support for Haxe Kha
Objective-C++
9
star
27

kha_tensorflow

GPU-accelerated machine learning for Kha powered by tensorflow
Haxe
8
star
28

haxerecast_old

Recast & Detour for Haxe
JavaScript
8
star
29

armory_examples_browser

Armory3D Examples Browser
Haxe
7
star
30

blender_externs

Python
7
star
31

driver_celshade

Celshade/toon rendering driver
Python
6
star
32

armorpaint_lib

Deprecated in favor of the ArmorPaint cloud.
6
star
33

armory_houdini

Armory + Houdini
6
star
34

armorlogic

Embed Logic Nodes on the Web
Haxe
6
star
35

armory_tools

JavaScript
6
star
36

tensorflow_example

Using tensorflow in armory
Haxe
5
star
37

archviz_templates

Test scenes
5
star
38

material_vault

4
star
39

driver_celshade_example

Celshade/toon rendering example
Haxe
4
star
40

armorbase

Moved to https://github.com/armory3d/armortools
Haxe
4
star
41

armorpaint_web

ArmorPaint Website
HTML
4
star
42

oimo_module

Oimo physics engine for Armory
Haxe
4
star
43

glsl_to_spirv

Mini-krafix for compiling glsl to sprirv at runtime.
C++
3
star
44

voxelgen

GPU-based triangle mesh voxelizer with light injection
Haxe
3
star
45

armory_gh_actions

Build armory projects in github workflows
TypeScript
2
star
46

armory_calibration

Match Armory lighting to Eevee
2
star
47

haxeui_example

CSS
2
star
48

shader_pack

Custom shaders usable in Armory
GLSL
2
star
49

dungeons_example

Haxe
1
star
50

armorbench1

Space corridor benchmark
Haxe
1
star
51

armory_api

Moved to https://github.com/armory3d/armsdk/tree/gh-pages
HTML
1
star
52

castledb_example

Haxe
1
star
53

krom_tensorflow

GPU-accelerated machine learning for Krom powered by tensorflow
JavaScript
1
star
54

hermes_bin

Static Hermes binaries.
C++
1
star
55

island_demo

Old island demo
1
star
56

armorlab_plugins

Moved to https://github.com/armory3d/armortools
C++
1
star
57

armorlab_web

ArmorLab Website
HTML
1
star