2019-03-14 17:55:06 +08:00
|
|
|
|
// Copyright (C) 2019 Nomango
|
|
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
|
|
#include "easy2d.h"
|
|
|
|
|
|
#include "easy2d-imgui.h"
|
|
|
|
|
|
|
|
|
|
|
|
using namespace easy2d;
|
|
|
|
|
|
|
|
|
|
|
|
E2D_DECLARE_SMART_PTR(MainScene);
|
|
|
|
|
|
class MainScene
|
|
|
|
|
|
: public Scene
|
|
|
|
|
|
{
|
|
|
|
|
|
bool show_demo_window = true;
|
|
|
|
|
|
bool show_another_window = false;
|
|
|
|
|
|
Color clear_color = Color(0.45f, 0.55f, 0.6f, 1.f);
|
|
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
MainScene()
|
|
|
|
|
|
{
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD> ImGui ͼ<><CDBC>
|
2019-04-05 16:06:32 +08:00
|
|
|
|
ImGuiLayerPtr layer = ImGuiView::Instance().CreateLayer(this);
|
2019-03-14 17:55:06 +08:00
|
|
|
|
AddChild(layer);
|
|
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD> ImGui <20>ṩ<EFBFBD><E1B9A9> Demo <20><><EFBFBD><EFBFBD>
|
|
|
|
|
|
layer->AddItem([=]() {
|
|
|
|
|
|
if (show_demo_window)
|
|
|
|
|
|
ImGui::ShowDemoWindow(&show_demo_window);
|
|
|
|
|
|
}, L"DemoWindow");
|
|
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><F2B5A5B4><EFBFBD>
|
2019-04-08 14:15:27 +08:00
|
|
|
|
layer->AddItem(MakeClosure(this, &MainScene::SimpleWindow), L"SimpleWindow");
|
2019-03-14 17:55:06 +08:00
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2019-04-08 14:15:27 +08:00
|
|
|
|
layer->AddItem(MakeClosure(this, &MainScene::AnotherWindow), L"AnotherWindow");
|
2019-03-14 17:55:06 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SimpleWindow()
|
|
|
|
|
|
{
|
|
|
|
|
|
static float f = 0.0f;
|
|
|
|
|
|
static int counter = 0;
|
|
|
|
|
|
|
|
|
|
|
|
ImGui::Begin("Hello, world!");
|
|
|
|
|
|
|
|
|
|
|
|
ImGui::Text("This is some useful text.");
|
|
|
|
|
|
ImGui::Checkbox("Demo Window", &show_demo_window);
|
|
|
|
|
|
ImGui::Checkbox("Another Window", &show_another_window);
|
|
|
|
|
|
|
|
|
|
|
|
ImGui::SliderFloat("float", &f, 0.0f, 1.0f);
|
|
|
|
|
|
ImGui::ColorEdit3("clear color", (float*)&clear_color);
|
|
|
|
|
|
|
|
|
|
|
|
if (ImGui::Button("Button"))
|
|
|
|
|
|
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);
|
|
|
|
|
|
ImGui::End();
|
|
|
|
|
|
|
|
|
|
|
|
// <20>Ĵ<DEB8><C4B4>ڱ<EFBFBD><DAB1><EFBFBD>ɫ
|
|
|
|
|
|
Renderer::Instance().SetClearColor(clear_color);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void AnotherWindow()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (show_another_window)
|
|
|
|
|
|
{
|
|
|
|
|
|
ImGui::Begin("Another Window", &show_another_window);
|
|
|
|
|
|
ImGui::Text("Hello from another window!");
|
|
|
|
|
|
if (ImGui::Button("Close Me"))
|
|
|
|
|
|
show_another_window = false;
|
|
|
|
|
|
ImGui::End();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|