//~
//~ #constant MENU_DEFAULT					0
//~ #constant MENU_WINDOWS					1

#constant MENU_NONE						0
#constant MENU_FILE						1
#constant MENU_EDIT						2
#constant MENU_VIEW						3
#constant MENU_CHART					4

#constant COL_RGB						0
#constant COL_HSV						1

#constant CHART_LINE					0
#constant CHART_HISTO					1
#constant CHART_MIXED					2

function overview()
	global init_overview as integer

	global titlebar		as integer
	global show_menu  	as integer
	global border  		as integer
	global resize  		as integer
	global movable		as integer
	global no_scrollbar	as integer
	global minimizable 	as integer
	global scale_left 	as integer

	if init_overview = NK_FALSE then overview_init()

	window_flags as integer
	window_flags = (titlebar*NK_WINDOW_TITLE)
	window_flags = window_flags||(border*NK_WINDOW_BORDER)
	window_flags = window_flags||(resize*NK_WINDOW_SCALABLE)
	window_flags = window_flags||(movable*NK_WINDOW_MOVABLE)
	window_flags = window_flags||(no_scrollbar*NK_WINDOW_NO_SCROLLBAR)
	window_flags = window_flags||(minimizable*NK_WINDOW_MINIMIZABLE)
	window_flags = window_flags||(scale_left*NK_WINDOW_SCALE_LEFT)

	if (nk.WindowBegin("Overview", 10, 10, 600, 600, window_flags))
		do_about_box()

		do_menu()

		do_tree_window_flags()
		do_tree_widgets()
		do_tree_chart()
		do_tree_popup()
		do_tree_layout()

	endif
	nk.WindowEnd()
endfunction

function overview_init()
	// preset for global variables - main window
	titlebar		= NK_TRUE
	movable			= NK_TRUE

	// preset for global variables - menu bar
	mb_prog			= 40
    mb_slider		= 10
	mb_check		= NK_TRUE
	mb_mprog		= 60
	mb_mslider		= 10
	mb_mcheck		= NK_TRUE

	// preset for global variables - widget selection
	ws_selected16[0]	= NK_TRUE
	ws_selected16[5]	= NK_TRUE
	ws_selected16[10]	= NK_TRUE
	ws_selected16[15]	= NK_TRUE

	// preset for global variables - widget combo
	wc_combo_color		= nkRGBA(130, 50, 50, 255)
	wc_combo_color2 	= nkRGBAf(0.509, 0.705, 0.2, 1.0)
	wc_prog_a 				=  20
	wc_prog_b 				= 40
	wc_prog_c 				= 10
	wc_prog_d 				= 90

	// preset for global variables - widget inactive
	nk.StyleMakeItem("<styleitem name='darkgrey' color='40,40,40'/>")
	nk.StyleMakeItem("<styleitem name='grey' color='60,60,60'/>")
	nk.StyleMake("btn_inactive", "<button normal='darkgrey' hover='darkgrey' active='darkgrey' border_color='grey' text_background='grey' text_normal='grey' text_hover='grey' text_active='grey'/>")

	// TODO: wx_button = nkStyleCreateButton()
	//~ wx_button_memblock	= nk.StyleCreateMemblock(NK_WIDGETTYPE_BUTTON]
	//~ nkStyleSetFromMemblock(wx_button, wx_button_memblock, 0)
//~
	//~ wx_button.normal.typ	= NK_ITEMTYPE_COLOR
	//~ wx_button.normal.color	= nk_color(40,40,40,255)
	//~ wx_button.hover			= wx_button.normal
	//~ wx_button.active		= wx_button.normal
	//~ wx_button.border_color	= nk_color(60,60,60,255)
	//~ wx_button.text_background = wx_button.border_color
	//~ wx_button.text_normal	= wx_button.border_color
	//~ wx_button.text_hover	= wx_button.border_color
	//~ wx_button.text_active	= wx_button.border_color

	// TODO: nkStyleSetButton(wx_button)

	// preset for global variables - chart
	ch_line_index			= -1
	ch_col_index			= -1

	// preset for global variables - popup
	pop_prog_context 		= 40
	pop_slider_context		= 10
	pop_color				= nkRGBA(255,0,0,255)

	// preset for global variables - layout
	lay_group_titlebar		= NK_FALSE
	lay_group_border		= NK_TRUE
	lay_group_noScrollbar	= NK_FALSE
	lay_group_width			= 320
	lay_group_height		= 200
	lay_root_selected		= 0
	lay_va					= 100.0
	lay_vb					= 100.0
	lay_vc					= 100.0
	lay_ha					= 100.0
	lay_hb					= 100.0
	lay_hc					= 100.0

	nk.StyleMake("tab_window", "<window spacing_vec2='0,0'/>")
	nk.StyleMake("tab_button_active", "<button normal='grey' hover='grey' active='grey' rounding='0'/>")
	nk.StyleMake("tab_button_normal", "<button rounding='0'/>")

	init_overview 	= NK_TRUE
endfunction

function do_about_box()
	/* about box */
	if mb_show_app_about
		/* about popup */
		if nk.PopupBegin(NK_POPUP_STATIC, "About", NK_WINDOW_CLOSABLE, 20, 100, 400,150)
			nk.LayoutRowDynamic(20, 1)
			nk.Label("Nuklear", NK_TEXT_LEFT)
			nk.Label("By Micha Mettke", NK_TEXT_LEFT)
			nk.Label("nuklear is licensed under the public domain License.",  NK_TEXT_LEFT)
			nk.PopupEnd()
		else
			mb_show_app_about = NK_FALSE
		endif
	endif
endfunction

function do_menu()
	global mb_show_app_about as integer
	global mb_prog as integer
	global mb_slider as integer
	global mb_check as integer
	global mb_menu_state as integer
	global mb_mprog as integer
	global mb_mslider as integer
	global mb_mcheck as integer

	if show_menu
		// menubar
		nk.MenubarBegin()

		// menu #1
		nk.LayoutRowBegin(NK_STATIC, 25, 5)
		nk.LayoutRowPush(45)
		if(nk.MenuBeginLabel("MENU", NK_TEXT_CENTERED, 120, 200))
			nk.LayoutRowDynamic(25, 1)
			if(nk.MenuItemLabel("Hide", NK_TEXT_LEFT)) then show_menu = NK_FALSE
			if(nk.MenuItemLabel("About", NK_TEXT_LEFT)) then mb_show_app_about = NK_TRUE
			mb_prog = nk.Progress(mb_prog, 100, NK_MODIFIABLE)
			mb_slider = nk.SliderInteger(0, mb_slider, 16, 1)
			mb_check = nk.CheckboxLabel("check", mb_check)
			nk.MenuEnd()
		endif

		// menu #2
		nk.LayoutRowPush(60)
		if nk.MenuBeginLabel("ADVANCED", NK_TEXT_CENTERED, 200, 600)
			state as integer = NK_MINIMIZED

			if mb_menu_state = MENU_FILE  then state = NK_MAXIMIZED else state = NK_MINIMIZED
			if nk.TreeStatePush(NK_TREE_TAB, "FILE", state)
				mb_menu_state = MENU_FILE
				nk.MenuItemLabel("New", NK_TEXT_LEFT)
				nk.MenuItemLabel("Open", NK_TEXT_LEFT)
				nk.MenuItemLabel("Save", NK_TEXT_LEFT)
				nk.MenuItemLabel("Close", NK_TEXT_LEFT)
				nk.MenuItemLabel("Exit", NK_TEXT_LEFT)
				nk.TreePop()
			else
				if mb_menu_state = MENU_FILE then mb_menu_state = MENU_NONE
			endif

			if mb_menu_state = MENU_EDIT then state = NK_MAXIMIZED else state = NK_MINIMIZED
			if nk.TreeStatePush(NK_TREE_TAB, "EDIT", state)
				mb_menu_state = MENU_EDIT
				nk.MenuItemLabel("Copy", NK_TEXT_LEFT)
				nk.MenuItemLabel("Delete", NK_TEXT_LEFT)
				nk.MenuItemLabel("Cut", NK_TEXT_LEFT)
				nk.MenuItemLabel("Paste", NK_TEXT_LEFT)
				nk.TreePop()
			else
				if mb_menu_state = MENU_EDIT then mb_menu_state = MENU_NONE
			endif

			if mb_menu_state = MENU_VIEW then state = NK_MAXIMIZED else state = NK_MINIMIZED
			if nk.TreeStatePush(NK_TREE_TAB, "VIEW", state)
				mb_menu_state = MENU_VIEW
				nk.MenuItemLabel("About", NK_TEXT_LEFT)
				nk.MenuItemLabel("Options", NK_TEXT_LEFT)
				nk.MenuItemLabel("Customize", NK_TEXT_LEFT)
				nk.TreePop()
			else
				if mb_menu_state = MENU_VIEW then mb_menu_state = MENU_NONE
			endif

			if mb_menu_state = MENU_CHART then state = NK_MAXIMIZED else state = NK_MINIMIZED
			if nk.TreeStatePush(NK_TREE_TAB, "CHART", state)
				i as integer = 0
				values as float[11] = [26.0,13.0,30.0,15.0,25.0,10.0,20.0,40.0,12.0,8.0,22.0,28.0]
				mb_menu_state = MENU_CHART

				nk.LayoutRowDynamic(150, 1)
				nk.ChartBegin(NK_CHART_COLUMN, values.length+1, 0, 50)
				for i = 0 to values.length
					nk.ChartPush(values[i])
				next
				nk.ChartEnd()

				nk.TreePop()
			else
				if mb_menu_state = MENU_CHART then mb_menu_state = MENU_NONE
			endif
			nk.MenuEnd()
		endif

		/* menu widgets */
		nk.LayoutRowPush(100)
		mb_mprog= nk.Progress(mb_mprog, 100, NK_MODIFIABLE)
		nk.LayoutRowPush(200)
		mb_mslider = nk.SliderInteger(0, mb_mslider, 16, 1)
		nk.LayoutRowPush(70)
		mb_mcheck = nk.CheckboxLabel("check", mb_mcheck)

		nk.MenubarEnd()
	endif
endfunction

function do_tree_window_flags()
	/* window flags */
	if (nk.TreePush(NK_TREE_TAB, "Window", NK_MINIMIZED))
		nk.LayoutRowDynamic(30, 2)
		titlebar	= nk.CheckboxLabel("Titlebar", titlebar)
		show_menu	= nk.CheckboxLabel("Menu", show_menu)
		border		= nk.CheckboxLabel("Border", border)
		resize		= nk.CheckboxLabel("Resizable", resize)
		movable		= nk.CheckboxLabel("Movable", movable)
		no_scrollbar= nk.CheckboxLabel("No Scrollbar", no_scrollbar)
		minimizable	= nk.CheckboxLabel("Minimizable", minimizable)
		scale_left	= nk.CheckboxLabel("Scale Left", scale_left)
		nk.TreePop()
	endif
endfunction

function do_node_text()
	if nk.TreePush(NK_TREE_NODE, "Text", NK_MINIMIZED)
		/* Text Widgets */
		nk.LayoutRowDynamic(20, 1)
		nk.Label("Label aligned left", NK_TEXT_LEFT)
		nk.Label("Label aligned centered", NK_TEXT_CENTERED)
		nk.Label("Label aligned right", NK_TEXT_RIGHT)
		nk.LabelColored("Blue text", NK_TEXT_LEFT, MakeColor(0,0,255))
		nk.LabelColored("Yellow text", NK_TEXT_LEFT, MakeColor(255,255,0))
		nk.Text("Text without "+chr(0), 15, NK_TEXT_RIGHT)

		nk.LayoutRowStatic(100, 200, 1)
		nk.LabelWrap("This is a very long line to hopefully get this text to be wrapped into multiple lines to show line wrapping")
		nk.LayoutRowDynamic(100, 1)
		nk.LabelWrap("This is another long text to show dynamic window changes on multiline text")
		nk.TreePop()
	endif
endfunction

function do_node_button()
	label as String

	if nk.TreePush(NK_TREE_NODE, "Button", NK_MINIMIZED)
		/* Buttons Widgets */
		nk.LayoutRowStatic(30, 100, 4)
		if (nk.ButtonLabel("Button")) then label = "Button pressed!"
		nk.ButtonSetBehavior(NK_BUTTON_REPEATER)
		if (nk.ButtonLabel("Repeater")) then label = "Repeater is being pressed!"
		nk.ButtonSetBehavior(NK_BUTTON_DEFAULT)
		nk.ButtonColor(MakeColor(0,0,255))
		nk.Label(label, NK_TEXT_CENTERED)

		nk.LayoutRowStatic(25, 25, 8)
		nk.ButtonSymbol(NK_SYMBOL_CIRCLE_SOLID)
		nk.ButtonSymbol(NK_SYMBOL_CIRCLE_OUTLINE)
		nk.ButtonSymbol(NK_SYMBOL_RECT_SOLID)
		nk.ButtonSymbol(NK_SYMBOL_RECT_OUTLINE)
		nk.ButtonSymbol(NK_SYMBOL_TRIANGLE_UP)
		nk.ButtonSymbol(NK_SYMBOL_TRIANGLE_DOWN)
		nk.ButtonSymbol(NK_SYMBOL_TRIANGLE_LEFT)
		nk.ButtonSymbol(NK_SYMBOL_TRIANGLE_RIGHT)

		nk.LayoutRowStatic(30, 100, 2)
		nk.ButtonSymbolLabel(NK_SYMBOL_TRIANGLE_LEFT, "prev", NK_TEXT_RIGHT)
		nk.ButtonSymbolLabel(NK_SYMBOL_TRIANGLE_RIGHT, "next", NK_TEXT_LEFT)
		nk.TreePop()
	endif
endfunction

function do_node_basic()
	global wb_checkbox as integer
	global wb_option as integer
	global wb_int_slider as integer
	global wb_float_slider as float
	global wb_prog_value as integer
	global wb_prop_float as float
	global wb_prop_int as integer
	global wb_prop_neg as integer
	global wb_range_int_min as integer
	global wb_range_int_max as integer
	global wb_range_int_value as integer
	global wb_range_float_min as float
	global wb_range_float_max as float
	global wb_range_float_value as float

	ratio as float[1] = [120, 150]

	if nk.TreePush(NK_TREE_NODE, "Basic", NK_MINIMIZED)
		/* Basic widgets */

		nk.LayoutRowStatic(30, 100, 1)
		wb_checkbox = nk.CheckboxLabel("Checkbox", wb_checkbox)

		nk.LayoutRowStatic(30, 80, 3)
		if(nk.OptionLabel("optionA", wb_option = 1)) then wb_option = 1
		if(nk.OptionLabel("optionB", wb_option = 2)) then wb_option = 2
		if(nk.OptionLabel("optionC", wb_option = 3)) then wb_option = 3

		nkLayoutRow(NK_STATIC, 30, ratio)
		nk.Label("Slider int", NK_TEXT_LEFT)
		wb_int_slider = nk.SliderInteger(0, wb_int_slider, 10, 1)
		nk.Label("Slider float", NK_TEXT_LEFT)
		wb_float_slider = nk.SliderFloat(0, wb_float_slider, 5.0, 0.5)
		
		nk.Label("Progressbar: " + str(wb_prog_value), NK_TEXT_LEFT)
		wb_prog_value = nk.Progress(wb_prog_value, 100, NK_MODIFIABLE)

		nkLayoutRow(NK_STATIC, 25, ratio)
		nk.Label("Property float:", NK_TEXT_LEFT)
		wb_prop_float = nk.PropertyFloat("Float:", 0, wb_prop_float, 64.0, 0.1, 0.2)
		nk.Label("Property int:", NK_TEXT_LEFT)
		wb_prop_int = nk.PropertyInteger("Int:", 0, wb_prop_int, 100.0, 1, 1)
		nk.Label("Property neg:", NK_TEXT_LEFT)
		wb_prop_neg = nk.PropertyInteger("Neg:", -10, wb_prop_neg, 10, 1, 1)

		nk.LayoutRowDynamic(25, 1)
		nk.Label("Range:", NK_TEXT_LEFT)
		nk.LayoutRowDynamic(25, 3)
		wb_range_float_min = nk.PropertyFloat("#min:", 0, wb_range_float_min, wb_range_float_max, 1.0, 0.2)
		wb_range_float_value = nk.PropertyFloat("#float:", wb_range_float_min, wb_range_float_value, wb_range_float_max, 1.0, 0.2)
		wb_range_float_max = nk.PropertyFloat("#max:", wb_range_float_min, wb_range_float_max, 100, 1.0, 0.2)

		wb_range_int_min = nk.PropertyInteger("#min:", -2147483647, wb_range_int_min, wb_range_int_max, 1, 10)
		wb_range_int_value = nk.PropertyInteger("#neg:", wb_range_int_min, wb_range_int_value, wb_range_int_max, 1, 10)
		wb_range_int_max = nk.PropertyInteger("#max:", wb_range_int_min, wb_range_int_max, 2147483647, 1, 10)

		nk.TreePop()
	endif
endfunction

function do_node_inactive()
	global wx_inactive as integer
	global wx_button_memblock as integer
	global wx_button as nk_style_button

	label as String

	if nk.TreePush(NK_TREE_NODE, "Inactive", NK_MINIMIZED)
		nk.LayoutRowDynamic(30, 1)
		print(wx_inactive)
		wx_inactive = nk.CheckboxLabel("Inactive", wx_inactive)

		nk.LayoutRowStatic(30, 80, 2)
		if (wx_inactive = 1)
			// TODO: nkButtonLabelStyled(wx_button, "button")
			nk.ButtonLabelStyled("btn_inactive", "button")
		elseif (nk.ButtonLabel("button"))
			label = "button pressed"
		endif
		nk.Label(label, NK_TEXT_CENTERED)

		nk.TreePop()
	endif
endfunction

function do_node_selectable()
	global ws_selected4 as integer[3]
	global ws_selected16 as integer[15]

	if nk.TreePush(NK_TREE_NODE, "Selectable", NK_MINIMIZED)
		if nk.TreePush(NK_TREE_NODE, "List", NK_MINIMIZED)
			nk.LayoutRowStatic(18, 100, 1)
			ws_selected4[0] = nk.SelectableLabel("Selectable", NK_TEXT_LEFT, ws_selected4[0])
			ws_selected4[1] = nk.SelectableLabel("Selectable", NK_TEXT_LEFT, ws_selected4[1])
			nk.Label("Not Selectable", NK_TEXT_LEFT)
			ws_selected4[2] = nk.SelectableLabel("Selectable", NK_TEXT_LEFT, ws_selected4[2])
			ws_selected4[3] = nk.SelectableLabel("Selectable", NK_TEXT_LEFT, ws_selected4[3])
			nk.TreePop()
		endif
		if nk.TreePush(NK_TREE_NODE, "Grid", NK_MINIMIZED)
			nk.LayoutRowStatic(50, 50, 4)
			i as integer
			for i = 0 to 15
				v as integer
				v = nk.SelectableLabel("Z", NK_TEXT_CENTERED, ws_selected16[i])
				if v <> ws_selected16[i]
					x as integer
					y as integer
					ws_selected16[i] = v
					x = mod(i, 4)
					y = trunc(i / 4)
					if (x > 0) then ws_selected16[i - 1] = ws_selected16[i - 1] ~~ 1
					if (x < 3) then ws_selected16[i + 1] = ws_selected16[i + 1] ~~ 1
					if (y > 0) then ws_selected16[i - 4] = ws_selected16[i - 4] ~~ 1
					if (y < 3) then ws_selected16[i + 4] = ws_selected16[i + 4] ~~ 1
				endif
			next
			nk.TreePop()
		endif
		nk.TreePop()
	endif
endfunction

function do_node_combo()
	global wc_current_weapon as integer
	global wc_combo_color as nk_color
	global wc_combo_color2 as nk_colorf
	global wc_prog_a as integer
	global wc_prog_b as integer
	global wc_prog_c as integer
	global wc_prog_d as integer
	global wc_check_values as integer[4]
	global wc_position as float[2]
	global wc_chart_selection as integer
	global wc_col_mode as integer

	values2 as float[13]=[26.0,13.0,30.0,15.0,25.0,10.0,20.0,40.0, 12.0, 8.0, 22.0, 28.0, 5.0]
	weapons as string = "Fist,Pistol,Shotgun,Plasma,BFG"
	weapon2 as string[4] =["Fist","Pistol","Shotgun","Plasma","BFG"]
	ratiof as float[1]
	sum as integer
	buffer as String

	if nk.TreePush(NK_TREE_NODE, "Combo", NK_MINIMIZED)
		/* Combobox Widgets
		 * In this library comboboxes are not limited to being a popup
		 * list of selectable text. Instead it is a abstract concept of
		 * having something that is *selected* or displayed, a popup window
		 * which opens if something needs to be modified and the content
		 * of the popup which causes the *selected* or displayed value to
		 * change or if wanted close the combobox.
		 *
		 * While strange at first handling comboboxes in a abstract way
		 * solves the problem of overloaded window content. For example
		 * changing a color value requires 4 value modifier (slider, property,...)
		 * for RGBA then you need a label and ways to display the current color.
		 * If you want to go fancy you even add rgb and hsv ratio boxes.
		 * While fine for one color if you have a lot of them it because
		 * tedious to look at and quite wasteful in space. You could add
		 * a popup which modifies the color but this does not solve the
		 * fact that it still requires a lot of cluttered space to do.
		 *
		 * In these kind of instance abstract comboboxes are quite handy. All
		 * value modifiers are hidden inside the combobox popup and only
		 * the color is shown if not open. This combines the clarity of the
		 * popup with the ease of use of just using the space for modifiers.
		 *
		 * Other instances are for example time and especially date picker,
		 * which only show the currently activated time/data and hide the
		 * selection logic inside the combobox popup.
		 */

		//~ char buffer[64];
		//~ size_t sum = 0;

		/* default combobox */
		nk.LayoutRowStatic(25, 200, 1)
		wc_current_weapon = nk.ComboSeparator(weapons, asc(","), wc_current_weapon, 5, 25, 200, 200)

		/* slider color combobox */
		if nk.ComboBeginColor(wc_combo_color.r, wc_combo_color.g, wc_combo_color.b, wc_combo_color.a, 200,200)
			ratiof = [0.15, 0.85]
			nkLayoutRow(NK_DYNAMIC, 30, ratiof)
			nk.Label("R:", NK_TEXT_LEFT)
			wc_combo_color.r = nk.SliderInteger(0, wc_combo_color.r, 255, 5)
			nk.Label("G:", NK_TEXT_LEFT)
			wc_combo_color.g = nk.SliderInteger(0, wc_combo_color.g, 255, 5)
			nk.Label("B:", NK_TEXT_LEFT)
			wc_combo_color.b = nk.SliderInteger(0, wc_combo_color.b, 255, 5)
			nk.Label("A:", NK_TEXT_LEFT)
			wc_combo_color.a = nk.SliderInteger(0, wc_combo_color.a , 255, 5)
			nk.ComboEnd()
		endif

		/* complex color combobox */
		if nk.ComboBeginColor(nkColorFToInt(wc_combo_color2), 200,400)
			nk.LayoutRowDynamic(120, 1)
			wc_combo_color2 = nkColorFFromInt(nk.ColorPicker(wc_combo_color2.r, wc_combo_color2.g, wc_combo_color2.b, wc_combo_color2.a, NK_RGBA))

			nk.LayoutRowDynamic(25, 2)
			if nk.OptionLabel("RGB", wc_col_mode = COL_RGB) then wc_col_mode = COL_RGB
			if nk.OptionLabel("HSV", wc_col_mode = COL_HSV) then wc_col_mode = COL_HSV

			nk.LayoutRowDynamic(25, 1)
			if wc_col_mode = COL_RGB
				wc_combo_color2.r = nk.PropertyFloat("#R:", 0, wc_combo_color2.r, 1.0, 0.01,0.005)
				wc_combo_color2.g = nk.propertyFloat("#G:", 0, wc_combo_color2.g, 1.0, 0.01,0.005)
				wc_combo_color2.b = nk.propertyFloat("#B:", 0, wc_combo_color2.b, 1.0, 0.01,0.005)
				wc_combo_color2.a = nk.propertyFloat("#A:", 0, wc_combo_color2.a, 1.0, 0.01,0.005)
			else
				hsva as float[3]
				hsva = nkHSVAFromColorf(wc_combo_color2)
				hsva[0] = nk.PropertyFloat("#H:", 0, hsva[0], 1.0, 0.01,0.05)
				hsva[1] = nk.PropertyFloat("#S:", 0, hsva[1], 1.0, 0.01,0.05)
				hsva[2] = nk.PropertyFloat("#V:", 0, hsva[2], 1.0, 0.01,0.05)
				hsva[3] = nk.PropertyFloat("#A:", 0, hsva[3], 1.0, 0.01,0.05)
				wc_combo_color2 = nkHSVAToColorf(hsva[0], hsva[1], hsva[2], hsva[3])
			endif
			nk.ComboEnd()
		endif

		/* progressbar combobox */
		sum = wc_prog_a + wc_prog_b + wc_prog_c + wc_prog_d
		buffer = str(sum)
		if nk.ComboBeginLabel(buffer, 200,200)
			nk.LayoutRowDynamic(30, 1)
			wc_prog_a = nk.Progress(wc_prog_a, 100, NK_MODIFIABLE)
			wc_prog_b = nk.Progress(wc_prog_b, 100, NK_MODIFIABLE)
			wc_prog_c = nk.Progress(wc_prog_c, 100, NK_MODIFIABLE)
			wc_prog_d = nk.Progress(wc_prog_d, 100, NK_MODIFIABLE)
			nk.ComboEnd()
		endif

		/* checkbox combobox */
		sum = (wc_check_values[0] + wc_check_values[1] + wc_check_values[2] + wc_check_values[3] + wc_check_values[4])
		buffer = str(sum)
		if nk.ComboBeginLabel(buffer, 200,200)
			nk.LayoutRowDynamic(30, 1)
			wc_check_values[0] = nk.CheckboxLabel(weapon2[0], wc_check_values[0])
			wc_check_values[1] = nk.CheckboxLabel(weapon2[1], wc_check_values[1])
			wc_check_values[2] = nk.CheckboxLabel(weapon2[2], wc_check_values[2])
			wc_check_values[3] = nk.CheckboxLabel(weapon2[3], wc_check_values[3])
			nk.ComboEnd()
		endif

		/* complex text combobox */
		buffer = str(wc_position[0])+", "+str(wc_position[1])+", "+str(wc_position[2])
		if nk.ComboBeginLabel(buffer, 200,200)
			nk.LayoutRowDynamic(25, 1)
			wc_position[0] = nk.PropertyFloat("#X:", -1024.0, wc_position[0], 1024.0, 1,0.5)
			wc_position[1] = nk.PropertyFloat("#Y:", -1024.0, wc_position[1], 1024.0, 1,0.5)
			wc_position[2] = nk.PropertyFloat("#Z:", -1024.0, wc_position[2], 1024.0, 1,0.5)
			nk.ComboEnd()
		endif

		/* chart combobox */
		buffer = str(wc_chart_selection)
		if (nk.ComboBeginLabel(buffer, 200,250))
			nk.LayoutRowDynamic(150, 1)
			nk.ChartBegin(NK_CHART_COLUMN, values2.length, 0, 50)
			i as integer
			res as integer
			for i = 0 to values2.length
				res = nk.ChartPush(values2[i])
				if (res && NK_CHART_CLICKED)
					wc_chart_selection = values2[i]
					nk.ComboClose()
				endif
			next
			nk.ChartEnd()
			nk.ComboEnd()
		endif

		nk.TreePop()
	endif
	//~ nk.TreePop()
endfunction

function do_node_input()
	global wi_text as string[7]
	global wi_field_buffer as String
	global wi_box_buffer as String

	buffer as String
	active as integer

	ratio as float[1] = [120, 150]
	if nk.TreePush(NK_TREE_NODE, "Input", NK_MINIMIZED)
		nkLayoutRow(NK_STATIC, 25, ratio)
		nk.Label("Default:", NK_TEXT_LEFT)
		wi_text[0] = nk.EditString(NK_EDIT_SIMPLE, wi_text[0], 64, NK_FILTER_DEFAULT)

		nk.Label("Int:", NK_TEXT_LEFT)
		wi_text[1] = nk.EditString(NK_EDIT_SIMPLE, wi_text[1], 64, NK_FILTER_DECIMAL)
		nk.Label("Float:", NK_TEXT_LEFT)
		wi_text[2] = nk.EditString(NK_EDIT_SIMPLE, wi_text[2], 64, NK_FILTER_FLOAT)
		nk.Label("Hex:", NK_TEXT_LEFT)
		wi_text[3] = nk.EditString(NK_EDIT_SIMPLE, wi_text[3], 64, NK_FILTER_HEX)
		nk.Label("Octal:", NK_TEXT_LEFT)
		wi_text[4] = nk.EditString(NK_EDIT_SIMPLE, wi_text[4], 64, NK_FILTER_OCT)
		nk.Label("Binary:", NK_TEXT_LEFT)
		wi_text[5] = nk.EditString(NK_EDIT_SIMPLE, wi_text[5], 64, NK_FILTER_BINARY)

		nk.Label("Password: "+wi_text[6], NK_TEXT_LEFT)
		buffer=""
		i as integer
		for i=1 to len(wi_text[6])
			buffer = buffer + "*"
		next i
		print(buffer)
		buffer = nk.EditString(NK_EDIT_FIELD, buffer, 64, NK_FILTER_DEFAULT)

		if len(buffer) < len(wi_text[6])
			wi_text[6] = left(wi_text[6], len(buffer))
		elseif len(buffer) > len(wi_text[6])
			wi_text[6] = wi_text[6] + right(buffer, 1)
		endif

		nk.Label("Field:", NK_TEXT_LEFT)
		wi_field_buffer = nk.EditString(NK_EDIT_FIELD, wi_field_buffer, 64, NK_FILTER_DEFAULT)

		nk.Label("Box:", NK_TEXT_LEFT)
		nk.LayoutRowStatic(180, 278, 1)
		wi_box_buffer = nk.EditString(NK_EDIT_BOX, wi_box_buffer, 512, NK_FILTER_DEFAULT)

		nkLayoutRow(NK_STATIC, 25, ratio)
		wi_text[7] = nk.EditString(NK_EDIT_FIELD||NK_EDIT_SIG_ENTER, wi_text[7], 64,  NK_FILTER_ASCII)
		active = nk.EditGetLastEvent()
		if nk.ButtonLabel("Submit") or (active && NK_EDIT_COMMITED)
			wi_box_buffer = wi_box_buffer + wi_text[7] + chr(10)
			wi_text[7] = ""
		endif
		nk.TreePop()
	endif
endfunction

function do_tree_widgets()
	global checkbox as integer
	global option as integer

	if nk.TreePush(NK_TREE_TAB, "Widgets", NK_MINIMIZED)
	//~ enum options {A,B,C};

		do_node_text()
		do_node_button()
		do_node_basic()
		do_node_inactive()
		do_node_selectable()
		do_node_combo()
		do_node_input()

		nk.TreePop()
	endif
endfunction

function do_tree_chart()
	global ch_line_index as integer
	global ch_col_index as integer

	id as float = 0.0
	step_ as float = 0.196349540
	index as integer = -1
	i as integer
	res as integer

	if nk.TreePush(NK_TREE_TAB, "Chart", NK_MINIMIZED)
		/* Chart Widgets
		 * This library has two different rather simple charts. The line and the
		 * column chart. Both provide a simple way of visualizing values and
		 * have a retained mode and immediate mode API version. For the retain
		 * mode version `nk.plot` and `nk.plot_function` you either provide
		 * an array or a callback to call to handle drawing the graph.
		 * For the immediate mode version you start by calling `nk.chart_begin`
		 * and need to provide min and max values for scaling on the Y-axis.
		 * and then call `nk.chart_push` to push values into the chart.
		 * Finally `nk.chart_end` needs to be called to end the process. */

		/* line chart */
		id = 0
		index = -1
		nk.LayoutRowDynamic(100, 1)
		//~ bounds = nk.WidgetBounds()
		if nk.ChartBegin(NK_CHART_LINES, 32, -1.0, 1.0)
			for i = 0 to 31
				res = nk.ChartPush(CosRad(id))
				if res && NK_CHART_HOVERING then index = i
				if res && NK_CHART_CLICKED then ch_line_index = i
				inc id, step_
			next
			nk.ChartEnd()
		endif

		if index <> -1 then nk.ToolTip("Value: " + str(CosRad(index*step_), 2))
		if ch_line_index <> -1
			nk.LayoutRowDynamic(20, 1)
			nk.Label("Selected value: " + str(CosRad(ch_line_index*step_), 2),NK_TEXT_LEFT)
		endif

		/* column chart */
		nk.LayoutRowDynamic(100, 1)
		if nk.ChartBegin(NK_CHART_COLUMN, 32, 0.0, 1.0)
			for i = 0 to 31
				res = nk.ChartPush(abs(SinRad(id)))
				if res && NK_CHART_HOVERING then index = i
				if res && NK_CHART_CLICKED then ch_col_index = i
				inc id, step_
			next
			nk.ChartEnd()
		endif
		if index <> -1 then nk.Tooltip("Value: " +str(abs(SinRad(step_ * index)), 2))
		if ch_col_index <> -1
			nk.LayoutRowDynamic(20, 1)
			nk.Label("Selected value: " +str(abs(SinRad(step_ * ch_col_index)), 2),NK_TEXT_LEFT)
		endif

		/* mixed chart */
		nk.LayoutRowDynamic(100, 1)
		if nk.ChartBegin(NK_CHART_COLUMN, 32, 0.0, 1.0)
			nk.ChartAddSlot(NK_CHART_LINES, 32, -1.0, 1.0)
			nk.ChartAddSlot(NK_CHART_LINES, 32, -1.0, 1.0)
			id = 0
			for i = 0 to 31
				nk.ChartPushSlot(abs(SinRad(id)), 0)
				nk.ChartPushSlot(CosRad(id), 1)
				nk.ChartPushSlot(SinRad(id), 2)
				inc id ,step_
			next
		endif
		nk.ChartEnd()

		/* mixed colored chart */
		nk.LayoutRowDynamic(100, 1)
		if nk.ChartBeginColored(NK_CHART_LINES, MakeColor(255,0,0), MakeColor(150,0,0), 32, 0.0, 1.0)
			nk.ChartAddSlotColored(NK_CHART_LINES, MakeColor(0,0,255), MakeColor(0,0,150),32, -1.0, 1.0)
			nk.ChartAddSlotColored(NK_CHART_LINES, MakeColor(0,255,0), MakeColor(0,150,0), 32, -1.0, 1.0)
			id=0
			for i=0 to 31
				nk.ChartPushSlot(abs(SinRad(id)), 0)
				nk.ChartPushSlot(CosRad(id), 1)
				nk.ChartPushSlot(SinRad(id), 2)
				inc id, step_
			next
		endif
		nk.ChartEnd()
		nk.TreePop()
	endif
endfunction

function do_tree_popup()
	global pop_prog_context as integer
	global pop_slider_context as integer
	global pop_select as integer[3]
	global pop_popup_active as integer
	global pop_color as nk_color

	bounds as nk_rect
	selection as String

	if nk.TreePush(NK_TREE_TAB, "Popup", NK_MINIMIZED)
		/* menu contextual */
		nk.LayoutRowStatic(30, 160, 1)
		bounds = nkWidgetBounds()
		nk.Label("Right click me for menu", NK_TEXT_LEFT)

		if nk.ContextualBegin(0, 100, 300, bounds.x, bounds.y, bounds.w, bounds.h)
			nk.LayoutRowDynamic(25, 1)
			show_menu = nk.CheckBoxLabel("Menu", show_menu)
			pop_prog_context = nk.Progress(pop_prog_context, 100, NK_MODIFIABLE)
			pop_slider_context = nk.SliderInteger(0, pop_slider_context, 16, 1)
			if nk.ContextualItemLabel( "About", NK_TEXT_CENTERED ) <> 0 then mb_show_app_about = NK_TRUE
			if pop_select[0] = 1 then selection="Select" else selection="Unselect"
			pop_select[0] = nk.SelectableLabel(selection, NK_TEXT_LEFT, pop_select[0])
			if pop_select[1] = 1 then selection="Select" else selection="Unselect"
			pop_select[1] = nk.SelectableLabel(selection, NK_TEXT_LEFT, pop_select[1])
			if pop_select[2] = 1 then selection="Select" else selection="Unselect"
			pop_select[2] = nk.SelectableLabel(selection, NK_TEXT_LEFT, pop_select[2])
			if pop_select[3] = 1 then selection="Select" else selection="Unselect"
			pop_select[3] = nk.SelectableLabel(selection, NK_TEXT_LEFT, pop_select[3])
			nk.ContextualEnd()
		endif

		/* color contextual */
		nk.LayoutRowBegin(NK_STATIC, 30, 2)
		nk.LayoutRowPush(100)
		nk.Label("Right Click here:", NK_TEXT_LEFT)
		nk.LayoutRowPush(50)
		bounds = nkWidgetBounds()
		nkButtonColor(pop_color)
		nk.LayoutRowEnd()

		if (nkContextualBegin(0, 350, 60, bounds))
			nk.LayoutRowDynamic(30, 4)
			pop_color.r = nk.PropertyInteger("#r", 0, pop_color.r, 255, 1, 1)
			pop_color.g = nk.PropertyInteger("#g", 0, pop_color.g, 255, 1, 1)
			pop_color.b = nk.Propertyinteger("#b", 0, pop_color.b, 255, 1, 1)
			pop_color.a = nk.PropertyInteger("#a", 0, pop_color.a, 255, 1, 1)
			nk.ContextualEnd()
		endif

		/* popup */
		nk.LayoutRowBegin(NK_STATIC, 30, 2)
		nk.LayoutRowPush(100)
		nk.Label("Popup:", NK_TEXT_LEFT)
		nk.LayoutRowPush(50)
		if (nk.ButtonLabel("Popup")) then pop_popup_active = NK_TRUE
		nk.LayoutRowEnd()

		if pop_popup_active
			s as nk_rect
			s = nk_rect(20, 100, 220, 90)
			if (nkPopupBegin(NK_POPUP_STATIC, "Error", 0, s))
				nk.LayoutRowDynamic(25, 1)
				nk.Label("A terrible error as occured", NK_TEXT_LEFT)
				nk.LayoutRowDynamic(25, 2)
				if (nk.ButtonLabel("OK"))
					pop_popup_active = NK_FALSE
					nk.PopupClose()
				endif
				if (nk.ButtonLabel("Cancel"))
					pop_popup_active = NK_FALSE
					nk.PopupClose()
				endif
				nk.PopupEnd()
			else
				pop_popup_active = NK_FALSE
			endif
		endif

		/* tooltip */
		nk.LayoutRowStatic(30, 150, 1)
		bounds = nkWidgetBounds()
		nk.Label("Hover me for tooltip", NK_TEXT_LEFT)
		if nk.InputIsMouseHoveringRect(bounds.x, bounds.y, bounds.w, bounds.h) then nk.Tooltip("This is a tooltip")

		nk.TreePop()
	endif
endfunction

function do_tree_layout()
	if (nk.TreePush(NK_TREE_TAB, "Layout", NK_MINIMIZED))
		do_node_widget()
		do_node_group()
		do_node_tree()
		do_node_notebook()
		do_node_simple()
		do_node_complex()
		do_node_splitter()

		nk.TreePop()
	endif
endfunction

function do_node_widget()
	if nk.TreePush(NK_TREE_NODE, "Widget", NK_MINIMIZED)
		ratio_two as float[2] = [0.2, 0.6, 0.2]
		width_two as float[2] = [100, 200, 50]

		nk.LayoutRowDynamic(30, 1)
		nk.Label("Dynamic fixed column layout with generated position and size:", NK_TEXT_LEFT)
		nk.LayoutRowDynamic(30, 3)
		nk.ButtonLabel("button")
		nk.ButtonLabel("button")
		nk.ButtonLabel("button")

		nk.LayoutRowDynamic(30, 1)
		nk.Label("static fixed column layout with generated position and size:", NK_TEXT_LEFT)
		nk.LayoutRowStatic(30, 100, 3)
		nk.ButtonLabel("button")
		nk.ButtonLabel("button")
		nk.ButtonLabel("button")

		nk.LayoutRowDynamic(30, 1)
		nk.Label("Dynamic array-based custom column layout with generated position and custom size:",NK_TEXT_LEFT)
		nkLayoutRow(NK_DYNAMIC, 30, ratio_two)
		nk.ButtonLabel("button")
		nk.ButtonLabel("button")
		nk.ButtonLabel("button")

		nk.LayoutRowDynamic(30, 1)
		nk.Label("Static array-based custom column layout with generated position and custom size:",NK_TEXT_LEFT )
		nkLayoutRow(NK_STATIC, 30, width_two)
		nk.ButtonLabel("button")
		nk.ButtonLabel("button")
		nk.ButtonLabel("button")

		nk.LayoutRowDynamic(30, 1)
		nk.Label("Dynamic immediate mode custom column layout with generated position and custom size:",NK_TEXT_LEFT)
		nk.LayoutRowBegin(NK_DYNAMIC, 30, 3)
		nk.LayoutRowPush(0.2)
		nk.ButtonLabel("button")
		nk.LayoutRowPush(0.6)
		nk.ButtonLabel("button")
		nk.LayoutRowPush(0.2)
		nk.ButtonLabel("button")
		nk.LayoutRowEnd()

		nk.LayoutRowDynamic(30, 1)
		nk.Label("Static immediate mode custom column layout with generated position and custom size:", NK_TEXT_LEFT)
		nk.LayoutRowBegin(NK_STATIC, 30, 3)
		nk.LayoutRowPush(100)
		nk.ButtonLabel("button")
		nk.LayoutRowPush(200)
		nk.ButtonLabel("button")
		nk.LayoutRowPush(50)
		nk.ButtonLabel("button")
		nk.LayoutRowEnd()

		nk.LayoutRowDynamic(30, 1)
		nk.Label("Static free space with custom position and custom size:", NK_TEXT_LEFT)
		nk.LayoutSpaceBegin(NK_STATIC, 60, 4)
		nk.LayoutSpacePush(100, 0, 100, 30)
		nk.ButtonLabel("button")
		nk.LayoutSpacePush(0, 15, 100, 30)
		nk.ButtonLabel("button")
		nk.LayoutSpacePush(200, 15, 100, 30)
		nk.ButtonLabel("button")
		nk.LayoutSpacePush(100, 30, 100, 30)
		nk.ButtonLabel("button")
		nk.LayoutSpaceEnd()

		nk.LayoutRowDynamic(30, 1)
		nk.Label("Row template:", NK_TEXT_LEFT)
		nk.LayoutRowTemplateBegin(30)
		nk.LayoutRowTemplatePushDynamic()
		nk.LayoutRowTemplatePushVariable(80)
		nk.LayoutRowTemplatePushStatic(80)
		nk.LayoutRowTemplateEnd()
		nk.ButtonLabel("button")
		nk.ButtonLabel("button")
		nk.ButtonLabel("button")

		nk.TreePop()
	endif
endfunction

function do_node_group()
	global lay_group_titlebar as integer
	global lay_group_border as integer
	global lay_group_noScrollbar as integer
	global lay_group_width as float
	global lay_group_height as float
	global lay_selected as integer [32]

	groupFlags as integer = 0
	selected as String
	i as integer

	if nk.TreePush(NK_TREE_NODE, "Group", NK_MINIMIZED)
		if lay_group_border then groupFlags = groupFlags||NK_WINDOW_BORDER
		if lay_group_noScrollbar then groupFlags = groupFlags||NK_WINDOW_NO_SCROLLBAR
		if lay_group_titlebar then groupFlags = groupFlags||NK_WINDOW_TITLE

		nk.LayoutRowDynamic(30, 3)
		lay_group_titlebar = nk.CheckboxLabel("Titlebar", lay_group_titlebar)
		lay_group_border = nk.CheckboxLabel("Border", lay_group_border)
		lay_group_noScrollbar = nk.CheckboxLabel("No Scrollbar", lay_group_noScrollbar)

		nk.LayoutRowBegin(NK_STATIC, 22, 3)
		nk.LayoutRowPush(50)
		nk.Label("size:", NK_TEXT_LEFT)
		nk.LayoutRowPush(130)
		lay_group_width = nk.PropertyInteger("#Width:", 100, lay_group_width, 500, 10, 1)
		nk.LayoutRowPush(130)
		lay_group_height = nk.PropertyInteger("#Height:", 100, lay_group_height, 500, 10, 1)
		nk.LayoutRowEnd()

		nk.LayoutRowStatic(lay_group_height, lay_group_width, 2)
		if nk.GroupBegin("Group", groupFlags)
			nk.LayoutRowStatic(18, 100, 1)
			for i = 0 to 16
				if lay_selected[i] then selected="Selected" else selected="Unselected"
				lay_selected[i] = nk.SelectableLabel(selected, NK_TEXT_CENTERED, lay_selected[i])
			next
			nk.GroupEnd()
		endif
		nk.TreePop()
	endif
endfunction

function do_node_tree()
	global lay_root_selected as integer
	global lay_selected8 as integer[7]
	global lay_sel_nodes as integer[3]

	i as integer
	j as integer
	sel as integer
	selected as String
	node_select as integer
	symbol as integer

	if nk.TreePush(NK_TREE_NODE, "Tree", NK_MINIMIZED)
		sel = lay_root_selected
		if nk.TreeElementPushID(NK_TREE_NODE, "Root", NK_MINIMIZED, sel, 0)
			sel = nk.TreeGetLastElementValue()
			node_select = lay_selected8[0]
			if (sel <> lay_root_selected)
				lay_root_selected = sel
				for i = 0 to 7
					lay_selected8[i] = sel
				next
			endif
			if nk.TreeElementPushID(NK_TREE_NODE, "Node", NK_MINIMIZED, node_select, 1)
				node_select = nk.TreeGetLastElementValue()
				if node_select <> lay_selected8[0]
					lay_selected8[0] = node_select
					for i = 0 to 3
						lay_sel_nodes[i] = node_select
					next
				endif
				nk.LayoutRowStatic(18, 100, 1)
				for j = 0 to 3
					if lay_sel_nodes[j]
						selected="Selected"
						symbol = NK_SYMBOL_CIRCLE_SOLID
					else 
						selected="Unselected"
						symbol = NK_SYMBOL_CIRCLE_OUTLINE
					endif
					lay_sel_nodes[j] = nk.SelectableSymbolLabel(symbol, selected, NK_TEXT_RIGHT, lay_sel_nodes[j])
				next
				nk.TreeElementPop()
			endif
			nk.LayoutRowStatic(18, 100, 1)
			for i=1 to 7
				if lay_selected8[i] then selected="Selected" else selected="Unselected"
				if lay_selected8[i]
					selected="Selected"
					symbol = NK_SYMBOL_CIRCLE_SOLID
				else 
					selected="Unselected"
					symbol = NK_SYMBOL_CIRCLE_OUTLINE
				endif
				lay_selected8[i] = nk.SelectableSymbolLabel(symbol, selected, NK_TEXT_RIGHT, lay_selected8[i])
			next
			nk.TreeElementPop()
		endif
		nk.TreePop()
	endif
endfunction

function do_node_notebook()
	global lay_tab_sel as integer

	tabs as string[2] = ["Lines", "Columns", "Mixed"]
	step_ as float = 0.196349540
	tab_width as float
	i as integer
	id as float

	if nk.TreePush(NK_TREE_NODE, "Notebook", NK_MINIMIZED)

		/* Header */
		nk.StylePush("tab_window")
		nk.StylePush("tab_button_normal")
		nk.LayoutRowBegin(NK_STATIC, 20, 3)
		for i=0 to 2
			tab_width = nk.FontGetLabelWidth(tabs[i])
			nk.LayoutRowPush(tab_width+8)
			if i = lay_tab_sel
				nk.ButtonLabelStyled("tab_button_active", tabs[i])
			else
				if nk.ButtonLabel(tabs[i]) then lay_tab_sel = i
			endif
		next

		nk.StylePop()


		/* Body */
		nk.LayoutRowDynamic(140, 1)
		if nk.GroupBegin("Notebook", NK_WINDOW_BORDER)
			nk.StylePop()
			select (lay_tab_sel)
				case CHART_LINE:
					nk.LayoutRowDynamic(100, 1)
					//~ bounds = nkWidgetBounds()
					if nk.ChartBeginColored(NK_CHART_LINES, MakeColor(255,0,0), MakeColor(150,0,0), 32, 0.0, 1.0)
						nk.ChartAddSlotColored(NK_CHART_LINES, MakeColor(0,0,255), MakeColor(0,0,150),32, -1.0, 1.0)
						for i=0 to 32
							nk.ChartPushSlot(abs(SinRad(id)), 0)
							nk.ChartPushSlot(CosRad(id), 1)
							inc id, step_
						next
					endif
					nk.ChartEnd()
					endcase
				case CHART_HISTO:
					nk.LayoutRowDynamic(100, 1)
					//~ bounds = nk.WidgetBounds()
					if nk.ChartBeginColored(NK_CHART_COLUMN, MakeColor(255,0,0), MakeColor(150,0,0), 32, 0.0, 1.0)
						for i=0 to 32
							nk.ChartPushSlot(abs(SinRad(id)), 0)
							inc id, step_
						next
					endif
					nk.ChartEnd()
					endcase
				case CHART_MIXED:
					nk.LayoutRowDynamic(100, 1)
					//~ bounds = nk.WidgetBounds()
					if nk.ChartBeginColored(NK_CHART_LINES, MakeColor(255,0,0), MakeColor(150,0,0), 32, 0.0, 1.0)
						nk.ChartAddSlotColored(NK_CHART_LINES, MakeColor(0,0,255), MakeColor(0,0,150),32, -1.0, 1.0)
						nk.ChartAddSlotColored(NK_CHART_COLUMN, MakeColor(0,255,0), MakeColor(0,150,0), 32, 0.0, 1.0)
						for i=0 to 32
							nk.ChartPushSlot(abs(SinRad(id)), 0)
							nk.ChartPushSlot(abs(CosRad(id)), 1)
							nk.ChartPushSlot(abs(SinRad(id)), 2)
							inc id, step_
						next
					endif
					nk.ChartEnd()
					endcase
			endselect
			nk.GroupEnd()
		else
			nk.StylePop()
		endif

		nk.TreePop()
	endif
endfunction

function do_node_simple()
	buffer as String
	i as integer

	if nk.TreePush(NK_TREE_NODE, "Simple", NK_MINIMIZED)
		nk.LayoutRowDynamic(300, 2)
		if nk.GroupBegin("Group_Without_Border", 0)
			nk.LayoutRowStatic(18, 150, 1)
			for i = 0 to 63
				buffer = "0x"+hex(i)+": scrollable region"
				nk.Label(buffer, NK_TEXT_LEFT)
			next
			nk.GroupEnd()
		endif
		if nk.GroupBegin("Group_With_Border", NK_WINDOW_BORDER)
			nk.LayoutRowDynamic(25, 2)
			for i = 0 to 63
				//~ sprintf(buffer, "%08d", ((((i%7)*10)^32))+(64+(i%2)*2))
				buffer = str(((mod(i,7)*10)~~32) + (64+mod(i, 2)*2))
				nk.ButtonLabel(buffer)
			next
			nk.GroupEnd()
		endif
		nk.TreePop()
	endif
endfunction

function do_node_complex()
	global lay_selected32 as integer[31]
	global lay_selected_top as integer[3]
	global lay_selected_center as integer[3]
	global lay_selected_bottom as integer[3]

	i as integer
	selected as String

	if nk.TreePush(NK_TREE_NODE, "Complex", NK_MINIMIZED)
		nk.LayoutSpaceBegin(NK_STATIC, 500, 64)
		nk.LayoutSpacePush(0,0,150,500)
		if nk.GroupBegin("GroupLeft", NK_WINDOW_BORDER)
			nk.LayoutRowStatic(18, 100, 1)
			for i=0 to 31
				if lay_selected32[i] then selected="Selected" else selected="Unselected"
				lay_selected32[i] = nk.SelectableLabel(selected, NK_TEXT_CENTERED, lay_selected32[i])
			next
			nk.GroupEnd()
		endif

		nk.LayoutSpacePush(160,0,150,240)
		if (nk.GroupBegin("Group_top", NK_WINDOW_BORDER))
			nk.LayoutRowDynamic(25, 1)
			nk.ButtonLabel("#FFAA")
			nk.ButtonLabel("#FFBB")
			nk.ButtonLabel("#FFCC")
			nk.ButtonLabel("#FFDD")
			nk.ButtonLabel("#FFEE")
			nk.ButtonLabel("#FFFF")
			nk.GroupEnd()
		endif

		nk.LayoutSpacePush(160,250,150,250)
		if (nk.GroupBegin("GroupButtom", NK_WINDOW_BORDER))
			nk.LayoutRowDynamic(25, 1)
			nk.ButtonLabel("#FFAA")
			nk.ButtonLabel("#FFBB")
			nk.ButtonLabel("#FFCC")
			nk.ButtonLabel("#FFDD")
			nk.ButtonLabel("#FFEE")
			nk.ButtonLabel("#FFFF")
			nk.GroupEnd()
		endif

		nk.LayoutSpacePush(320,0,150,150)
		if (nk.GroupBegin("GroupRight_top", NK_WINDOW_BORDER))
			nk.LayoutRowStatic(18, 100, 1)
			for i=0 to 3
				if lay_selected_top[i] then selected="Selected" else selected="Unselected"
				lay_selected_top[i] = nk.SelectableLabel(selected, NK_TEXT_CENTERED, lay_selected_top[i])
			next
			nk.GroupEnd()
		endif

		nk.LayoutSpacePush(320,160,150,150)
		if (nk.GroupBegin("GroupRight_center", NK_WINDOW_BORDER))
			nk.LayoutRowStatic(18, 100, 1)
			for i=0 to 3
				if lay_selected_center[i] then selected="Selected" else selected="Unselected"
				lay_selected_center[i] = nk.SelectableLabel(selected, NK_TEXT_CENTERED, lay_selected_center[i])
			next
			nk.GroupEnd()
		endif

		nk.LayoutSpacePush(320,320,150,150)
		if (nk.GroupBegin("GroupRightBottom", NK_WINDOW_BORDER))
			nk.LayoutRowStatic(18, 100, 1)
			for i=0 to 3
				if lay_selected_bottom[i] then selected="Selected" else selected="Unselected"
				lay_selected_bottom[i] = nk.SelectableLabel(selected, NK_TEXT_CENTERED, lay_selected_bottom[i])
			next
			nk.GroupEnd()
		endif
		nk.LayoutSpaceEnd()
		nk.TreePop()
	endif
endfunction

function do_node_splitter()
	global lay_va as float
	global lay_vb as float
	global lay_vc as float
	global lay_ha as float
	global lay_hb as float
	global lay_hc as float

	rowLayout as float[5]
	delta as float
	bounds as nk_rect

	if nk.TreePush(NK_TREE_NODE, "Splitter", NK_MINIMIZED)
		//~ const struct nk.Input *in = &ctx->input
		nk.LayoutRowStatic(20, 320, 1)
		nk.Label("Use slider and spinner to change tile size", NK_TEXT_LEFT)
		nk.Label("Drag the space between tiles to change tile ratio", NK_TEXT_LEFT)

		if nk.TreePush(NK_TREE_NODE, "Vertical", NK_MINIMIZED)
			rowLayout[0] = lay_va
			rowLayout[1] = 8
			rowLayout[2] = lay_vb
			rowLayout[3] = 8
			rowLayout[4] = lay_vc

			/* header */
			nk.LayoutRowStatic(30, 100, 2)
			nk.Label("left:", NK_TEXT_LEFT)
			lay_va = nk.SliderFloat(10.0, lay_va, 200.0, 10.0)

			nk.Label("middle:", NK_TEXT_LEFT)
			lay_vb = nk.SliderFloat(10.0, lay_vb, 200.0, 10.0)

			nk.Label("right:", NK_TEXT_LEFT)
			lay_vc = nk.SliderFloat(10.0, lay_vc, 200.0, 10.0)

			/* tiles */
			nkLayoutRow(NK_STATIC, 200, rowLayout)

			/* left space */
			if nk.GroupBegin("left", NK_WINDOW_BORDER||NK_WINDOW_NO_SCROLLBAR)
				nk.LayoutRowDynamic(25, 1)
				nk.ButtonLabel("#FFAA")
				nk.ButtonLabel("#FFBB")
				nk.ButtonLabel("#FFCC")
				nk.ButtonLabel("#FFDD")
				nk.ButtonLabel("#FFEE")
				nk.ButtonLabel("#FFFF")
				nk.GroupEnd()
			endif

			/* scaler */
			bounds = nkWidgetBounds()
			nk.Spacing(1)
			if (nk.InputIsMouseHoveringRect(bounds.x,bounds.y,bounds.w,bounds.h) or nk.InputIsMousePrevHoveringRect(bounds.x,bounds.y,bounds.w,bounds.h)) and nk.InputIsMouseDown(NK_BUTTON_LEFT)
				delta = nk.InputGetMouseDeltaX()
				lay_va = rowLayout[0] + delta
				lay_vb = rowLayout[2] - delta
			endif

			/* middle space */
			if (nk.GroupBegin("center", NK_WINDOW_BORDER||NK_WINDOW_NO_SCROLLBAR))
				nk.LayoutRowDynamic(25, 1)
				nk.ButtonLabel("#FFAA")
				nk.ButtonLabel("#FFBB")
				nk.ButtonLabel("#FFCC")
				nk.ButtonLabel("#FFDD")
				nk.ButtonLabel("#FFEE")
				nk.ButtonLabel("#FFFF")
				nk.GroupEnd()
			endif

			/* scaler */
			bounds = nkWidgetBounds()
			nk.Spacing(1)
			if (nk.InputIsMouseHoveringRect(bounds.x,bounds.y,bounds.w,bounds.h) or nk.InputIsMousePrevHoveringRect(bounds.x,bounds.y,bounds.w,bounds.h)) and nk.InputIsMouseDown(NK_BUTTON_LEFT)
				delta = nk.InputGetMouseDeltaX()
				lay_vb = (rowLayout[2] + delta)
				lay_vc = (rowLayout[4] - delta)
			endif

			/* right space */
			if nk.GroupBegin("right", NK_WINDOW_BORDER||NK_WINDOW_NO_SCROLLBAR)
				nk.LayoutRowDynamic(25, 1)
				nk.ButtonLabel("#FFAA")
				nk.ButtonLabel("#FFBB")
				nk.ButtonLabel("#FFCC")
				nk.ButtonLabel("#FFDD")
				nk.ButtonLabel("#FFEE")
				nk.ButtonLabel("#FFFF")
				nk.GroupEnd()
			endif

			nk.TreePop()
		endif

		if nk.TreePush(NK_TREE_NODE, "Horizontal", NK_MINIMIZED)
			/* header */
			nk.LayoutRowStatic(30, 100, 2)
			nk.Label("top:", NK_TEXT_LEFT)
			lay_ha = nk.SliderFloat(10.0, lay_ha, 200.0, 10.0)

			nk.Label("middle:", NK_TEXT_LEFT)
			lay_hb = nk.SliderFloat(10.0, lay_hb, 200.0, 10.0)

			nk.Label("bottom:", NK_TEXT_LEFT)
			lay_hc = nk.SliderFloat(10.0, lay_hc, 200.0, 10.0)

			/* top space */
			nk.LayoutRowDynamic(lay_ha, 1)
			if (nk.GroupBegin("top", NK_WINDOW_NO_SCROLLBAR||NK_WINDOW_BORDER))
				nk.LayoutRowDynamic(25, 3)
				nk.ButtonLabel("#FFAA")
				nk.ButtonLabel("#FFBB")
				nk.ButtonLabel("#FFCC")
				nk.ButtonLabel("#FFDD")
				nk.ButtonLabel("#FFEE")
				nk.ButtonLabel("#FFFF")
				nk.GroupEnd()
			endif

			/* scaler */
			nk.LayoutRowDynamic(8, 1)
			bounds = nkWidgetBounds()
			nk.Spacing(1)
			if ((nk.InputIsMouseHoveringRect(bounds.x,bounds.y,bounds.w,bounds.h) or nk.InputIsMousePrevHoveringRect(bounds.x,bounds.y,bounds.w,bounds.h)) and nk.InputIsMouseDown(NK_BUTTON_LEFT))
				delta = nk.InputGetMouseDeltaY()
				lay_ha = lay_ha + delta
				lay_hb = lay_hb - delta
			endif

			/* middle space */
			nk.LayoutRowDynamic(lay_hb, 1)
			if (nk.GroupBegin("middle", NK_WINDOW_NO_SCROLLBAR||NK_WINDOW_BORDER))
				nk.LayoutRowDynamic(25, 3)
				nk.ButtonLabel("#FFAA")
				nk.ButtonLabel("#FFBB")
				nk.ButtonLabel("#FFCC")
				nk.ButtonLabel("#FFDD")
				nk.ButtonLabel("#FFEE")
				nk.ButtonLabel("#FFFF")
				nk.GroupEnd()
			endif

			/* scaler */
			nk.LayoutRowDynamic(8, 1)
			bounds = nkWidgetBounds()
			if ((nk.InputIsMouseHoveringRect(bounds.x,bounds.y,bounds.w,bounds.h) or nk.InputIsMousePrevHoveringRect(bounds.x,bounds.y,bounds.w,bounds.h)) and nk.InputIsMouseDown(NK_BUTTON_LEFT))
				delta = nk.InputGetMouseDeltaY()
				lay_hb = lay_hb + delta
				lay_hc = lay_hc - delta
			endif

			/* bottom space */
			nk.LayoutRowDynamic(lay_hc, 1)
			if (nk.GroupBegin("bottom", NK_WINDOW_NO_SCROLLBAR||NK_WINDOW_BORDER))
				nk.LayoutRowDynamic(25, 3)
				nk.ButtonLabel("#FFAA")
				nk.ButtonLabel("#FFBB")
				nk.ButtonLabel("#FFCC")
				nk.ButtonLabel("#FFDD")
				nk.ButtonLabel("#FFEE")
				nk.ButtonLabel("#FFFF")
				nk.GroupEnd()
			endif
			nk.TreePop()
		endif
		nk.TreePop()
	endif
endfunction
