
#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

type overview_static
    /* window flags */
    show_menu as integer
    titlebar as integer
    border as integer
    resize as integer
    movable as integer
    no_scrollbar as integer
    scale_left as integer
    window_flags as integer
    minimizable as integer

    /* popups */
    header_align as integer
    show_app_about as integer

    /* menubar*/
	mprog as integer
	mslider as integer
	mcheck as integer

	/* menu #1 */
	prog as integer //= 40
    slider as integer // = 10
	check as integer //= nk_true

	/* menu #2 */
	menu_state as integer
	state as integer

endtype
global _so as overview_static
_so.show_menu = nk_true
_so.titlebar = nk_true
_so.border = nk_true
_so.resize = nk_true
_so.movable = nk_true
_so.no_scrollbar = nk_false
_so.scale_left = nk_false
_so.window_flags = 0
_so.minimizable = nk_true
_so.mprog = 60
_so.mslider = 10
_so.mcheck = nk_true
_so.prog = 40
_so.slider = 10
_so.check = nk_true
_so.menu_state = MENU_NONE
_so.state = NK_MINIMIZED

global int_slider as integer = 5
global float_slider as float = 2.5
global prog_value as integer = 40
global property_float as float
global property_int as integer = 10
global property_neg as integer = 10

global range_float_min as float = 0
global range_float_max as float = 100
global range_float_value as float = 50
global range_int_min as integer = 0
global range_int_value as integer = 2048
global range_int_max as integer = 4096
global ratio as float[1] = [120, 150]

global inactive as integer = 1

global selected4 as integer[4] = [nk_false, nk_false, nk_true, nk_false]
global selected16 as integer[16] = [1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1]

global test_color as integer = 0xff7fff7f
global current_weapon as integer = 0
global combo_color as nk_color
global combo_color2 as nk_colorf
global col_mode as integer = COL_RGB
global prog_a =  20
global prog_b = 40
global prog_c = 10
global prog_d = 90
global check_values as integer[5]
global position as float[3]
global chart_selection as float = 8.0
combo_color2 = nkRGBAf(0.509, 0.705, 0.2, 1.0)
combo_color = nkRGBA(130, 50, 50, 255)

global text as string[9]
global field_buffer as string
global box_buffer as String

global col_index as integer = -1
global line_index as integer = -1

global prog_context as integer = 40
global slider_context as integer = 10
global select_ as integer[4]
global popup_active as integer
global color as nk_color //= {255,0,0, 255};
color = nkRGBA(255,0,0,255)

global group_titlebar as integer = nk_false
global groupBorder as integer = nk_True
global group_noScrollbar as integer = nk_false
global group_width as float = 320
global group_height as float = 200
global selected as integer [32]
global rootSelected as integer = 0
global sel_nodes as integer [4]

global a as float = 100
global b as float = 100
global c as float = 100

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'/>")

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'/>")

function overview()

	// window flags
	_so.window_flags = win_flag||NK_WINDOW_CLOSABLE
    if _so.titlebar then _so.window_flags = _so.window_flags||NK_WINDOW_TITLE
    if _so.border then _so.window_flags = _so.window_flags||NK_WINDOW_BORDER
    if _so.resize then _so.window_flags = _so.window_flags||NK_WINDOW_SCALABLE
    if _so.movable then _so.window_flags = _so.window_flags||NK_WINDOW_MOVABLE
    if _so.no_scrollbar then _so.window_flags = _so.window_flags||NK_WINDOW_NO_SCROLLBAR
    if _so.scale_left then _so.window_flags = _so.window_flags||NK_WINDOW_SCALE_LEFT
    if _so.minimizable then _so.window_flags = _so.window_flags||NK_WINDOW_MINIMIZABLE

	// main window
	if(nk.WindowBegin("Overview", 10, 10, 600, 600, _so.window_flags))
		if(_so.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 _so.show_menu = nk_false
				if(nk.MenuItemLabel("About", NK_TEXT_LEFT)) then _so.show_app_about = nk_true
				_so.prog = nk.Progress(_so.prog, 100, NK_MODIFIABLE)
				_so.slider = nk.SliderInteger(0, _so.slider, 16, 1)
				_so.check = nk.CheckboxLabel("check", _so.check)
				nk.MenuEnd()
			endif

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

				if(_so.menu_state = MENU_FILE) then state = NK_MAXIMIZED else state = NK_MINIMIZED
                if(nk.TreeStatePush(NK_TREE_TAB, "FILE", state))
                    _so.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(_so.menu_state = MENU_FILE) then _so.menu_state = MENU_NONE
				endif

				if(_so.menu_state = MENU_EDIT) then state = NK_MAXIMIZED else state = NK_MINIMIZED
                if (nk.TreeStatePush(NK_TREE_TAB, "EDIT", state))
                    _so.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(_so.menu_state = MENU_EDIT) then _so.menu_state = MENU_NONE
				endif

				if(_so.menu_state = MENU_VIEW) then state = NK_MAXIMIZED else state = NK_MINIMIZED
                if (nk.TreeStatePush(NK_TREE_TAB, "VIEW", state))
                    _so.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(_so.menu_state = MENU_VIEW) then _so.menu_state = MENU_NONE
				endif

				if(_so.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]
                    _so.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(_so.menu_state = MENU_CHART) then _so.menu_state = MENU_NONE
				endif
                nk.MenuEnd()
            endif

			/* menu widgets */
			nk.LayoutRowPush(100)
			_so.mprog= nk.Progress(_so.mprog, 100, NK_MODIFIABLE)
			nk.LayoutRowPush(200)
			_so.mslider = nk.SliderInteger(0, _so.mslider, 16, 1)
			nk.LayoutRowPush(70)
			_so.mcheck = nk.CheckboxLabel("check", _so.mcheck)

			nk.MenubarEnd()
		endif

		/* about box */
		if (_so.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
				_so.show_app_about = nk_false
			endif
		endif

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

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

            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

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

                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

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

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

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

                nkLayoutRow(NK_STATIC, 30, ratio)
                nk.Label("Slider int", NK_TEXT_LEFT)
                int_slider = nk.SliderInteger(0, int_slider, 10, 1)

                nk.Label("Slider float", NK_TEXT_LEFT)
                float_slider = nk.SliderFloat(0, float_slider, 5.0, 0.5)
                nk.Label("Progressbar: " + str(prog_value), NK_TEXT_LEFT)
                prog_value = nk.Progress(prog_value, 100, NK_MODIFIABLE)

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

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

                range_int_min = nk.PropertyInteger("#min:", -2147483647, range_int_min, range_int_max, 1, 10)
                range_int_value = nk.PropertyInteger("#neg:", range_int_min, range_int_value, range_int_max, 1, 10)
                range_int_max = nk.PropertyInteger("#max:", range_int_min, range_int_max, 2147483647, 1, 10)

                nk.TreePop()
            endif

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

                nk.LayoutRowStatic(30, 80, 1)
                if (inactive = 1)
					nk.ButtonLabelStyled("btn_inactive", "button")
                elseif (nk.ButtonLabel("button"))
                    print("button pressed\n")
                endif

                nk.TreePop()
            endif


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

            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.
                 */
                weapons as string = "Fist,Pistol,Shotgun,Plasma,BFG"
                weapon2 as string[4] =["Fist","Pistol","Shotgun","Plasma","BFG"]

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

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

                /* slider color combobox */
                if (nk.ComboBeginColor(combo_color.r, combo_color.g, combo_color.b, combo_color.a, 200,200))
                    ratios as float[1] = [0.15, 0.85]
                    nkLayoutRow(NK_DYNAMIC, 30, ratios)
                    nk.Label("R:", NK_TEXT_LEFT)
                    combo_color.r = nk.SliderInteger(0, combo_color.r, 255, 5)
                    nk.Label("G:", NK_TEXT_LEFT)
                    combo_color.g = nk.SliderInteger(0, combo_color.g, 255, 5)
                    nk.Label("B:", NK_TEXT_LEFT)
                    combo_color.b = nk.SliderInteger(0, combo_color.b, 255, 5)
                    nk.Label("A:", NK_TEXT_LEFT)
                    combo_color.a = nk.SliderInteger(0, combo_color.a , 255, 5)
                    nk.ComboEnd()
                endif
                /* complex color combobox */
                if (nk.ComboBeginColor(nkColorFToInt(combo_color2), 200,400))
                    nk.LayoutRowDynamic(120, 1)
                    combo_color2 = nkColorFFromInt(nk.ColorPicker(combo_color2.r, combo_color2.g, combo_color2.b, combo_color2.a, NK_RGBA))

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

                    nk.LayoutRowDynamic(25, 1)
                    if (col_mode = COL_RGB)
                        combo_color2.r = nk.PropertyFloat("#R:", 0, combo_color2.r, 1.0, 0.01,0.005)
                        combo_color2.g = nk.propertyFloat("#G:", 0, combo_color2.g, 1.0, 0.01,0.005)
                        combo_color2.b = nk.propertyFloat("#B:", 0, combo_color2.b, 1.0, 0.01,0.005)
                        combo_color2.a = nk.propertyFloat("#A:", 0, combo_color2.a, 1.0, 0.01,0.005)
                    else
                        hsva as float[3]
                        hsva = nkHSVAFromColorf(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)
                        combo_color2 = nkHSVAToColorf(hsva[0], hsva[1], hsva[2], hsva[3])
                    endif
                    nk.ComboEnd()
                endif
                /* progressbar combobox */
                sum as integer
                buffer$ as String
                sum = prog_a + prog_b + prog_c + prog_d
                buffer$ = str(sum)
                if (nk.ComboBeginLabel(buffer$, 200,200))
                    nk.LayoutRowDynamic(30, 1)
                    prog_a = nk.Progress(prog_a, 100, NK_MODIFIABLE)
                    prog_b = nk.Progress(prog_b, 100, NK_MODIFIABLE)
                    prog_c = nk.Progress(prog_c, 100, NK_MODIFIABLE)
                    prog_d = nk.Progress(prog_d, 100, NK_MODIFIABLE)
                    nk.ComboEnd()
                endif

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

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

                /* chart combobox */
                buffer$ = str(chart_selection)
                if (nk.ComboBeginLabel(buffer$, 200,250))
                    i = 0
                    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]
                    nk.LayoutRowDynamic(150, 1)
                    nk.ChartBegin(NK_CHART_COLUMN, values2.length, 0, 50)
                    for i = 0 to values2.length
                        res as integer
                        res = nk.ChartPush(values2[i])
                        if (res && NK_CHART_CLICKED)
                            chart_selection = values2[i]
                            nk.ComboClose()
                        endif
                    next
                    nk.ChartEnd()
                    nk.ComboEnd()
                endif

                //~ {
                    //~ if (system_date.sel_yy = 0)
						//~ system_date.sel_yy = val(GetStringToken(system_date.cur_date,"-",1))
						//~ system_date.sel_mo = val(GetStringToken(system_date.cur_date,"-",2))
						//~ system_date.sel_dd = val(GetStringToken(system_date.cur_date,"-",3))
						//~ system_date.sel_hh = val(GetStringToken(system_date.cur_time,":",1))
						//~ system_date.sel_mm = val(GetStringToken(system_date.cur_time,":",2))
						//~ system_date.sel_ss = val(GetStringToken(system_date.cur_time,":",3))
                    //~ endif

                    /* time combobox */
                    //~ sprintf(buffer, "%02d:%02d:%02d", sel_time.tm_hour, sel_time.tm_min, sel_time.tm_sec);
                    //~ if (nk.ComboBeginLabel(system_date.cur_time, 200,250))
                        //~ nk.LayoutRowDynamic(25, 1)
                        //~ system_date.sel_ss = nk.PropertyInteger("#S:", 0, system_date.sel_ss, 60, 1, 1)
                        //~ system_date.sel_mm = nk.PropertyInteger("#M:", 0, system_date.sel_mm, 60, 1, 1)
                        //~ system_date.sel_hh = nk.PropertyInteger("#H:", 0, system_date.sel_hh, 23, 1, 1)
                        //~ nk.ComboEnd()
                        //~ system_date.cur_time = str(system_date.sel_hh)+":"+str(system_date.sel_mm)+":"+str(system_date.sel_ss)
                    //~ endif

                    /* date combobox */
                    //~ sprintf(buffer, "%02d-%02d-%02d", sel_date.tm_mday, sel_date.tm_mon+1, sel_date.tm_year+1900);
                    //~ if (nk.ComboBeginLabel(system_date.cur_date, 350,400))
                    //~ {
                        //~ int i = 0;
                        //~ month as string[11] = ["January", "February", "March","April", "May", "June", "July", "August", "September","October", "November", "December"]
                        //~ week_days as string[6] = ["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"]
                        //~ month_days as integer[11] = [31,28,31,30,31,30,31,31,30,31,30,31]
                        //~ year = system_date.sel_yy
                        //~ leap_year = (NOT mod(year, 4) AND (mod(year, 100))) OR NOT mod(year, 400)
                        //~ days as integer
                        //~ if (sel_date.tm_mon = 1) ?
                            //~ month_days[sel_date.tm_mon] + leap_year:
                            //~ month_days[sel_date.tm_mon];
//~
                        //~ /* header with month and year */
                        //~ date_selected = 1;
                        //~ nk_layout_row_begin(ctx, NK_DYNAMIC, 20, 3);
                        //~ nk_layout_row_push(ctx, 0.05f);
                        //~ if (nk_button_symbol(ctx, NK_SYMBOL_TRIANGLE_LEFT)) {
                            //~ if (sel_date.tm_mon == 0) {
                                //~ sel_date.tm_mon = 11;
                                //~ sel_date.tm_year = NK_MAX(0, sel_date.tm_year-1);
                            //~ } else sel_date.tm_mon--;
                        //~ }
                        //~ nk_layout_row_push(ctx, 0.9f);
                        //~ sprintf(buffer, "%s %d", month[sel_date.tm_mon], year);
                        //~ nk_label(ctx, buffer, NK_TEXT_CENTERED);
                        //~ nk_layout_row_push(ctx, 0.05f);
                        //~ if (nk_button_symbol(ctx, NK_SYMBOL_TRIANGLE_RIGHT)) {
                            //~ if (sel_date.tm_mon == 11) {
                                //~ sel_date.tm_mon = 0;
                                //~ sel_date.tm_year++;
                            //~ } else sel_date.tm_mon++;
                        //~ }
                        //~ nk_layout_row_end(ctx);
//~
                        //~ /* good old week day formula (double because precision) */
                        //~ {int year_n = (sel_date.tm_mon < 2) ? year-1: year;
                        //~ int y = year_n % 100;
                        //~ int c = year_n / 100;
                        //~ int y4 = (int)((float)y / 4);
                        //~ int c4 = (int)((float)c / 4);
                        //~ int m = (int)(2.6 * (double)(((sel_date.tm_mon + 10) % 12) + 1) - 0.2);
                        //~ int week_day = (((1 + m + y + y4 + c4 - 2 * c) % 7) + 7) % 7;
//~
                        //~ /* weekdays  */
                        //~ nk_layout_row_dynamic(ctx, 35, 7);
                        //~ for (i = 0; i < (int)NK_LEN(week_days); ++i)
                            //~ nk_label(ctx, week_days[i], NK_TEXT_CENTERED);
//~
                        //~ /* days  */
                        //~ if (week_day > 0) nk_spacing(ctx, week_day);
                        //~ for (i = 1; i <= days; ++i) {
                            //~ sprintf(buffer, "%d", i);
                            //~ if (nk_button_label(ctx, buffer)) {
                                //~ sel_date.tm_mday = i;
                                //~ nk_combo_close(ctx);
                            //~ }
                        //~ }}
                        //~ nk_combo_end(ctx);
                    //~ }
                nk.TreePop()
            endif

            if (nk.TreePush(NK_TREE_NODE, "Input", NK_MINIMIZED))
                ratio = [120, 150]

                nkLayoutRow(NK_STATIC, 25, ratio)
                nk.Label("Default:", NK_TEXT_LEFT)
                text[0] = nk.EditString(NK_EDIT_SIMPLE, text[0], 64, NK_FILTER_DEFAULT)

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

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

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

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

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

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

            nk.TreePop()
        endif

        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. */
            id as float = 0
            step_ as float = 0.196349540

            //~ int i;
            //~ int index = -1;
            //~ struct nk_rect bounds;

            /* line chart */
            index as integer
            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 line_index = i
                    inc id, step_
                next
                nk.ChartEnd()
            endif

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

            /* column chart */
            nk.LayoutRowDynamic(100, 1)
            //~ bounds = nk.widget_bounds(ctx);
            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 col_index = i
                    inc id, step_
                next
                nk.ChartEnd()
            endif
            if (index <> -1) then nk.Tooltip("Value: " +str(abs(SinRad(step_ * index)), 2))
            if (col_index <> -1)
                nk.LayoutRowDynamic(20, 1)
                nk.Label("Selected value: " +str(abs(SinRad(step_ * col_index)), 2),NK_TEXT_LEFT)
            endif

            /* mixed chart */
            nk.LayoutRowDynamic(100, 1)
            //~ bounds = nk.WidgetBounds(ctx);
            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)
            //~ bounds = nk.widget_bounds(ctx);
            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

        if (nk.TreePush(NK_TREE_TAB, "Popup", NK_MINIMIZED))
            //~ const struct nk.input *in = &ctx->input;
            bounds as nk_rect

            /* 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))
                selection$ as string
                nk.LayoutRowDynamic(25, 1)
                _so.show_menu = nk.CheckBoxLabel("Menu", _so.show_menu)
                prog_context = nk.Progress(prog_context, 100, NK_MODIFIABLE)
                slider_context = nk.SliderInteger(0, slider_context, 16, 1)
                if nk.ContextualItemLabel( "About", NK_TEXT_CENTERED ) <> 0 then _so.show_app_about = nk_true
                if select_[0] = 1 then selection$="Select" else selection$="Unselect"
                select_[0] = nk.SelectableLabel(selection$, NK_TEXT_LEFT, select_[0])
                if select_[1] = 1 then selection$="Select" else selection$="Unselect"
                select_[1] = nk.SelectableLabel(selection$, NK_TEXT_LEFT, select_[1])
                if select_[2] = 1 then selection$="Select" else selection$="Unselect"
                select_[2] = nk.SelectableLabel(selection$, NK_TEXT_LEFT, select_[2])
                if select_[3] = 1 then selection$="Select" else selection$="Unselect"
                select_[3] = nk.SelectableLabel(selection$, NK_TEXT_LEFT, 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(color)
            nk.LayoutRowEnd()

            if (nkContextualBegin(0, 350, 60, bounds))
                nk.LayoutRowDynamic(30, 4)
                color.r = nk.PropertyInteger("#r", 0, color.r, 255, 1, 1)
                color.g = nk.PropertyInteger("#g", 0, color.g, 255, 1, 1)
                color.b = nk.Propertyinteger("#b", 0, color.b, 255, 1, 1)
                color.a = nk.PropertyInteger("#a", 0, 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 popup_active = nk_true
            nk.LayoutRowEnd()

            if (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"))
                        popup_active = nk_false
                        nk.PopupClose()
                    endif
                    if (nk.ButtonLabel("Cancel"))
                        popup_active = nk_false
                        nk.PopupClose()
                    endif
                    nk.PopupEnd()
                else
					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

        if (nk.TreePush(NK_TREE_TAB, "Layout", NK_MINIMIZED))
            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

            if (nk.TreePush(NK_TREE_NODE, "Group", NK_MINIMIZED))
                groupFlags as integer = 0
                if (groupBorder) then groupFlags = groupFlags||NK_WINDOW_BORDER
                if (group_noScrollbar) then groupFlags = groupFlags||NK_WINDOW_NO_SCROLLBAR
                if (group_titlebar) then groupFlags = groupFlags||NK_WINDOW_TITLE

                nk.LayoutRowDynamic(30, 3)
                group_titlebar = nk.CheckboxLabel("Titlebar", group_titlebar)
                groupBorder = nk.CheckboxLabel("Border", groupBorder)
                group_noScrollbar = nk.CheckboxLabel("No Scrollbar", group_noScrollbar)

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

                nk.LayoutRowStatic(group_height, group_width, 2)
                if (nk.GroupBegin("Group", groupFlags))
                    nk.LayoutRowStatic(18, 100, 1)
                    for i = 0 to 16
                        selected$ as string
						if selected[i] then selected$="Selected" else selected$="Unselected"
                        selected[i] = nk.SelectableLabel(selected$, NK_TEXT_CENTERED, selected[i])
                    next
                    nk.GroupEnd()
                endif
                nk.TreePop()
            endif

            if (nk.TreePush(NK_TREE_NODE, "Tree", NK_MINIMIZED))
                sel as integer
                sel = rootSelected
                if (nk.TreeElementPushID(NK_TREE_NODE, "Root", NK_MINIMIZED, sel,0))
                    nodeselect as integer
					sel = nk.TreeGetLastElementValue()
                    //~ static int selected[8]
                    nodeSelect = selected[0]
                    if (sel <> rootSelected)
                        rootSelected = sel
                        for i = 0 to 7
                            selected[i] = sel
                        next
                    endif
                    if (nk.TreeElementPushID(NK_TREE_NODE, "Node", NK_MINIMIZED, nodeSelect,1))
                        node_select as integer
                        node_select = nk.TreeGetLastElementValue()
                        if (nodeSelect <> selected[0])
                            selected[0] = nodeSelect
                            for i = 0 to 3
                                sel_nodes[i] = nodeSelect
                            next
                        endif
                        nk.LayoutRowStatic(18, 100, 1)
                        j as integer
                        for j = 0 to 3
							if sel_nodes[j] then selected$="Selected" else selected$="Unselected"
                            sel_nodes[j] = nk.SelectableSymbolLabel(NK_SYMBOL_CIRCLE_SOLID, selected$, NK_TEXT_RIGHT, sel_nodes[j])
                        next
                        nk.TreeElementPop()
                    endif
                    nk.LayoutRowStatic(18, 100, 1)
                    for i=1 to 7
						if selected[i] then selected$="Selected" else selected$="Unselected"
                        selected[i] = nk.SelectableSymbolLabel(NK_SYMBOL_CIRCLE_SOLID, selected$, NK_TEXT_RIGHT, selected[i])
                    next
                    nk.TreeElementPop()
                endif
                nk.TreePop()
            endif

            if (nk.TreePush(NK_TREE_NODE, "Notebook", NK_MINIMIZED))
				tabs as string[2] = ["Lines", "Columns", "Mixed"]
				step_ = 0.196349540
				global tab_sel as integer

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

				nk.StylePop()


                /* Body */
                nk.LayoutRowDynamic(140, 1)
                if (nk.GroupBegin("Notebook", NK_WINDOW_BORDER))
                    nk.StylePop()
                    select (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

            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

            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 selected[i] then selected$="Selected" else selected$="Unselected"
                        selected[i] = nk.SelectableLabel(selected$, NK_TEXT_CENTERED, selected[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 selected[i] then selected$="Selected" else selected$="Unselected"
                        selected[i] = nk.SelectableLabel(selected$, NK_TEXT_CENTERED, selected[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 selected[i] then selected$="Selected" else selected$="Unselected"
                        selected[i] = nk.SelectableLabel(selected$, NK_TEXT_CENTERED, selected[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 selected[i] then selected$="Selected" else selected$="Unselected"
                        selected[i] = nk.SelectableLabel(selected$, NK_TEXT_CENTERED, selected[i])
                    next
                    nk.GroupEnd()
                endif
                nk.LayoutSpaceEnd()
                nk.TreePop()
            endif

            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 as float[5]
                    rowLayout[0] = a
                    rowLayout[1] = 8
                    rowLayout[2] = b
                    rowLayout[3] = 8
                    rowLayout[4] = c

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

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

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

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

                    /* left space */
                    if (nk.GroupBegin("left", NK_WINDOW_NO_SCROLLBAR||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 */
                    delta# as float
                    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()
                        a = rowLayout[0] + delta#
                        b = 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()
                        b = (rowLayout[2] + delta#)
                        c = (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)
                    a = nk.SliderFloat(10.0, a, 200.0, 10.0)

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

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

                    /* top space */
                    nk.LayoutRowDynamic(a, 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()
						a = a + delta#
						b = b - delta#
                    endif

                    /* middle space */
                    nk.LayoutRowDynamic(b, 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()
						b = b + delta#
						c = c - delta#
					endif

                    /* bottom space */
                    nk.LayoutRowDynamic(c, 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
            nk.TreePop()
        endif

	endif
	nk.WindowEnd()
endfunction
