#import_plugin Nuklear as nk

// show all errors
SetErrorMode(2)

// set window properties
SetWindowTitle( "First Nuklear Window" )
SetWindowSize( 1280, 720, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window

// set display properties
SetVirtualResolution( 1280, 720 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 0, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts

#insert "../Nuklear.agc"

// basic nuklear initialization
nkInit()

// set default values.
default_style as nk_style_button
current_style as nk_style_button
default_style = nk_ctx.button
current_style = nk_ctx.button

do
	// pass agk inputs to nuklear
    nk.HandleInput()

	if nk.WindowBegin("Manipulate Context Style Part 1", 30, 50, 1220, 240, NK_WINDOW_BORDER||NK_WINDOW_MOVABLE||NK_WINDOW_TITLE)
		change as integer = nk_false
		
		// layout for three buttons (reset, set color, set alignment
		nk.LayoutRowDynamic(30, 3)
		
		// the reset button
		if nk.ButtonLabel("Reset")
			// copy button default style to current button style
			current_style = default_style
			
			change = nk_true
		endif
		
		if nk.ButtonLabel("Set Color")
			// change back color of current style
			current_style.normal.color = nkRGB(32,32,64)
			current_style.hover.color = nkRGB(32,64,32)
			current_style.active.color = nkRGB(64,64,32)

			// change text color of current style
			current_style.text_normal = nkRGB(192,192,192)
			current_style.text_hover = nkRGB(255,255,255)
			current_style.text_active = nkRGB(255,255,255)

			change = nk_true
		endif
		
		if nk.ButtonLabel("Set Alignment")
			// set current style text alignment to left
			current_style.text_alignment = NK_TEXT_LEFT
			
			change = nk_true
		endif
		
		if change
			// write the values from UDT current_style to then context memblock
			nkStyleSetButtonToMemblock(current_style, nk_ctx.memblocks[NK_WIDGETTYPE_BUTTON], 0)
			
			// write the memblock to nuklear engines context.
			nk.StyleSetFromMemblock(NK_WIDGETTYPE_BUTTON, nk_ctx.memblocks[NK_WIDGETTYPE_BUTTON])
		endif
	endif
	nk.WindowEnd()
	
    nkSync()
loop
