// Copyright (C) 2020 Daniel Mall
#include "CDemoImgui.h"

#include "sokol_app.h"
#include "sokol_gfx.h"
//#include "sokol_time.h"
//#include "sokol_glue.h"
#include "imgui.h"
#include "sokol_imgui.h"

CDemoImgui::CDemoImgui()
{
}

CDemoImgui::~CDemoImgui()
{
}

/// draw
void CDemoImgui::Frame()
{
	m_show_demo_window = true;
	m_show_debug_window = true;

	// 1. Show a simple window.
	// Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets automatically appears in a window called "Debug".
	if (m_show_debug_window)
	{
		static float f = 0.0f;
		static int counter = 0;
		ImGui::Text("Hello, world!");                           // Display some text (you can use a format string too)
		ImGui::SliderFloat("float", &f, 0.0f, 1.0f);            // Edit 1 float using a slider from 0.0f to 1.0f

#ifdef UNDEFINED
		ImGui::ColorEdit3("clear color", (float*)&global()->m_clear_color); // Edit 3 floats representing a color
#endif

		ImGui::Checkbox("Demo Window", &m_show_demo_window);      // Edit bools storing our windows open/close state
		ImGui::Checkbox("Another Window", &m_show_another_window);

		if (ImGui::Button("Button"))                            // Buttons return true when clicked (NB: most widgets return true when edited/activated)
			counter++;
		ImGui::SameLine();
		ImGui::Text("counter = %d", counter);

		ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
	}

	// 2. Show another simple window. In most cases you will use an explicit Begin/End pair to name your windows.
	if (m_show_another_window)
	{
		ImGui::Begin("Another Window", &m_show_another_window);
		ImGui::Text("Hello from another window!");
		if (ImGui::Button("Close Me"))
			m_show_another_window = false;
		ImGui::End();
	}

	// 3. Show the ImGui demo window. Most of the sample code is in ImGui::ShowDemoWindow(). Read its code to learn more about Dear ImGui!
	if (m_show_demo_window)
	{
		ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiCond_FirstUseEver); // Normally user code doesn't need/want to call this because positions are saved in .ini file anyway. Here we just want to make the demo initial state a bit more friendly!
		ImGui::ShowDemoWindow(&m_show_demo_window);
	}
}
