diff --git a/projects/kiwano.vcxproj b/projects/kiwano.vcxproj
index 149e7855..2b4e6407 100644
--- a/projects/kiwano.vcxproj
+++ b/projects/kiwano.vcxproj
@@ -18,8 +18,7 @@
-
-
+
@@ -92,8 +91,7 @@
-
-
+
diff --git a/projects/kiwano.vcxproj.filters b/projects/kiwano.vcxproj.filters
index 237be06a..6415693e 100644
--- a/projects/kiwano.vcxproj.filters
+++ b/projects/kiwano.vcxproj.filters
@@ -36,133 +36,373 @@
-
-
-
+
+ ui
+
+
+ ui
+
+
+ 2d
+
+
+ 2d
+
+
+ 2d
+
+
+ 2d
+
+
+ 2d
+
+
+ 2d
+
+
+ 2d
+
+
+ 2d
+
+
+ 2d
+
+
+ 2d
+
+
+ 2d
+
+
+ 2d
+
+
+ 2d
+
+
+ 2d
+
+
+ 2d
+
+
+ 2d
+
+
+ 2d
+
+
+ 2d
+
+
+ 2d
+
+
+ 2d
+
+
+ 2d
+
+
+ common
+
+
+ common
+
+
+ common
+
+
+ common
+
+
+ common
+
+
+ base
+
+
+ base
+
+
+ base
+
+
+ base
+
+
+ base
+
+
+ base
+
+
+ base
+
+
+ base
+
+
+ base
+
+
+ renderer
+
+
+ renderer
+
+
+ renderer
+
+
+ renderer
+
+
+ renderer
+
+
+ renderer
+
+
+ math
+
+
+ math
+
+
+ math
+
+
+ math
+
+
+ math
+
+
+ math
+
+
+ platform
+
+
+ platform
+
+
+ utils
+
+
+ utils
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+ math
+
+
+ math
+
+
+ base
+
+
+ base
+
+
+ base
+
+
+ base
+
+
+
+ utils
+
+
+ base
+
+
+ base
+
+
+ base
+
+
+ 2d
+
+
+ third-party\StackWalker
+
+
+ utils
+
+
+ renderer
+
+
+ base
+
+
+ 2d
+
+
+ common
+
+
+ common
+
+
+ common
+
+
+ common
+
+
+ common
+
+
+ third-party\tinyxml2
+
+
+ 2d
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+ ui
+
+
+ ui
+
+
+ 2d
+
+
+ 2d
+
+
+ 2d
+
+
+ 2d
+
+
+ 2d
+
+
+ 2d
+
+
+ 2d
+
+
+ 2d
+
+
+ 2d
+
+
+ 2d
+
+
+ 2d
+
+
+ 2d
+
+
+ 2d
+
+
+ 2d
+
+
+ 2d
+
+
+ 2d
+
+
+ base
+
+
+ base
+
+
+ base
+
+
+ base
+
+
+ base
+
+
+ renderer
+
+
+ renderer
+
+
+ renderer
+
+
+ renderer
+
+
+ renderer
+
+
+ platform
+
+
+ platform
+
+
+ utils
+
+
+ utils
+
+
+ base
+
+
+ base
+
+
+ base
+
+
+ utils
+
+
+ base
+
+
+ base
+
+
+ base
+
+
+ 2d
+
+
+ third-party\StackWalker
+
+
+ utils
+
+
+ 2d
+
+
+ third-party\tinyxml2
+
+
+ 2d
+
\ No newline at end of file
diff --git a/samples/Box2DSample/Board.h b/samples/Box2DSample/Board.h
deleted file mode 100644
index 403807b2..00000000
--- a/samples/Box2DSample/Board.h
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright (C) 2019 Nomango
-
-#pragma once
-
-#include "common.h"
-
-// ̶ľ
-KGE_DECLARE_SMART_PTR(Board);
-class Board
- : public GeometryNode
-{
-public:
- Board(b2World* world, const Size& size, const Point& pos)
- {
- GeometryPtr geo = new RectangleGeometry(Point(), size);
- SetGeometry(geo);
- SetStrokeColor(Color::White);
- SetFillColor(Color(0, 0, 0, 0));
-
- SetSize(size);
- SetAnchor(0.5f, 0.5f);
- SetRotation(10);
- SetPosition(pos);
-
- b2BodyDef groundBodyDef;
- groundBodyDef.position = Vec2Convert(GetPosition());
- groundBodyDef.angle = 10 * math::constants::PI_F / 180.f;
-
- b2Body* groundBody = world->CreateBody(&groundBodyDef);
-
- b2PolygonShape groundBox;
- b2Vec2 sz = Vec2Convert(Point{ size.x / 2, size.y / 2 });
- groundBox.SetAsBox(sz.x, sz.y);
- groundBody->CreateFixture(&groundBox, 0.0f);
- }
-};
diff --git a/samples/Box2DSample/Box2DSample.filters b/samples/Box2DSample/Box2DSample.filters
deleted file mode 100644
index 4327830c..00000000
--- a/samples/Box2DSample/Box2DSample.filters
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/samples/Box2DSample/Box2DSample.vcxproj b/samples/Box2DSample/Box2DSample.vcxproj
deleted file mode 100644
index 9dca4003..00000000
--- a/samples/Box2DSample/Box2DSample.vcxproj
+++ /dev/null
@@ -1,109 +0,0 @@
-
-
-
-
- Debug
- Win32
-
-
- Release
- Win32
-
-
-
- {324CFF47-4EB2-499A-BE5F-53A82E3BA14B}
- Box2DSample
-
-
-
- Application
- true
- Unicode
- $(DefaultPlatformToolset)
-
-
- Application
- false
- false
- Unicode
- $(DefaultPlatformToolset)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- $(SolutionDir)\output\$(PlatformToolset)\$(Platform)\$(Configuration)\
- $(SolutionDir)\build\$(PlatformToolset)\$(Platform)\$(Configuration)\$(ProjectName)\
- true
-
-
- $(SolutionDir)\output\$(PlatformToolset)\$(Platform)\$(Configuration)\
- $(SolutionDir)\build\$(PlatformToolset)\$(Platform)\$(Configuration)\$(ProjectName)\
- false
-
-
-
- Level3
- Disabled
- true
- ../../src;
-
-
- true
- Windows
-
-
-
-
- Level3
- MaxSpeed
- true
- true
- true
- ../../src;
-
-
- true
- true
- true
- Windows
-
-
-
-
-
-
-
- {ff7f943d-a89c-4e6c-97cf-84f7d8ff8edf}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。
-
-
-
-
\ No newline at end of file
diff --git a/samples/Box2DSample/Circle.h b/samples/Box2DSample/Circle.h
deleted file mode 100644
index f0c389e1..00000000
--- a/samples/Box2DSample/Circle.h
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright (C) 2019 Nomango
-
-#pragma once
-
-#include "common.h"
-
-// Բ
-KGE_DECLARE_SMART_PTR(Circle);
-class Circle
- : public Sprite
-{
-public:
- Circle(b2World* world, const Point& pos)
- {
- Load(L"circle.png");
- SetAnchor(0.5f, 0.5f);
- SetScale(0.7f);
-
- b2BodyDef bodyDef;
- bodyDef.type = b2_dynamicBody;
- bodyDef.position = Vec2Convert(pos);
-
- b2Body* body = world->CreateBody(&bodyDef);
-
- SetUserData(body);
-
- b2CircleShape shape;
- shape.m_radius = GetWidth() / GLOBAL_SCALE / 2 * 0.7f;
-
- b2FixtureDef fixtureDef;
- fixtureDef.shape = &shape;
- fixtureDef.density = 1.0f;
- fixtureDef.friction = 0.3f;
-
- body->CreateFixture(&fixtureDef);
- body->SetUserData(this);
- }
-};
diff --git a/samples/Box2DSample/MainScene.h b/samples/Box2DSample/MainScene.h
deleted file mode 100644
index 1aac08f6..00000000
--- a/samples/Box2DSample/MainScene.h
+++ /dev/null
@@ -1,84 +0,0 @@
-// Copyright (C) 2019 Nomango
-
-#pragma once
-
-#include "Circle.h"
-#include "Rect.h"
-#include "Board.h"
-
-KGE_DECLARE_SMART_PTR(MainScene);
-class MainScene
- : public Scene
-{
- b2World* world_;
-
-public:
- MainScene()
- {
- // ÿӦ״̬, ʹԽյ Click Ϣ
- SetResponsible(true);
-
- // Ϣ
- AddListener(Event::Click, MakeClosure(this, &MainScene::Click));
-
- //
- world_ = new b2World(b2Vec2(0, 10));
-
- BoardPtr board = new Board(world_, Size(GetWidth() - 100, 20), Point(GetWidth() / 2, GetHeight() - 50));
- AddChild(board);
-
- CirclePtr circle = new Circle(world_, Point(320, 240));
- AddChild(circle);
- }
-
- ~MainScene()
- {
- if (world_)
- delete world_;
- }
-
- void OnUpdate(Duration dt) override
- {
- // Box2D
- world_->Step(dt.Seconds(), 6, 2);
-
- // ÿһλúתǶ
- b2Body* body = world_->GetBodyList();
- while (body)
- {
- Node* node = (Node*)body->GetUserData();
- b2Body* next = body->GetNext();
- if (node)
- {
- const b2Vec2& pos = body->GetPosition();
- node->SetPosition(Vec2Convert(pos));
- node->SetRotation(body->GetAngle() * 180.f / math::constants::PI_F);
-
- // Ƴ䵽
- if (node->GetPosition().y > GetHeight() + 50)
- {
- body->SetUserData(0);
- world_->DestroyBody(body);
-
- node->RemoveFromParent();
- }
- }
-
- body = next;
- }
- }
-
- void Click(Event const& evt)
- {
- if (evt.mouse.button == MouseButton::Left)
- {
- CirclePtr circle = new Circle(world_, Point{ evt.mouse.x, evt.mouse.y });
- AddChild(circle);
- }
- else if (evt.mouse.button == MouseButton::Right)
- {
- SquarePtr rect = new Square(world_, Point{ evt.mouse.x, evt.mouse.y });
- AddChild(rect);
- }
- }
-};
diff --git a/samples/Box2DSample/Rect.h b/samples/Box2DSample/Rect.h
deleted file mode 100644
index 773d2b8c..00000000
--- a/samples/Box2DSample/Rect.h
+++ /dev/null
@@ -1,39 +0,0 @@
-// Copyright (C) 2019 Nomango
-
-#pragma once
-
-#include "common.h"
-
-//
-KGE_DECLARE_SMART_PTR(Square);
-class Square
- : public Sprite
-{
-public:
- Square(b2World* world, const Point& pos)
- {
- Load(L"square.png");
- SetAnchor(0.5f, 0.5f);
- SetScale(0.7f);
-
- b2BodyDef bodyDef;
- bodyDef.type = b2_dynamicBody;
- bodyDef.position = Vec2Convert(pos);
-
- b2Body* body = world->CreateBody(&bodyDef);
-
- SetUserData(body);
-
- b2PolygonShape shape;
- b2Vec2 sz = Vec2Convert(GetSize() / 2 * 0.7f);
- shape.SetAsBox(sz.x, sz.y);
-
- b2FixtureDef fixtureDef;
- fixtureDef.shape = &shape;
- fixtureDef.density = 1.0f;
- fixtureDef.friction = 0.3f;
-
- body->CreateFixture(&fixtureDef);
- body->SetUserData(this);
- }
-};
diff --git a/samples/Box2DSample/circle.png b/samples/Box2DSample/circle.png
deleted file mode 100644
index c122a7ae..00000000
Binary files a/samples/Box2DSample/circle.png and /dev/null differ
diff --git a/samples/Box2DSample/common.h b/samples/Box2DSample/common.h
deleted file mode 100644
index 8c0cf9d6..00000000
--- a/samples/Box2DSample/common.h
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright (C) 2019 Nomango
-
-#pragma once
-
-#include "kiwano/kiwano.h"
-#include
-
-using namespace kiwano;
-
-//
-// Box2D dzõӦ /ǧ/ ĵλ,
-// Ϊλм.
-// ƽ Box2D Kiwano Ķʱ, Ҫ
-// һЩת.
-//
-namespace
-{
- const float GLOBAL_SCALE = 100.0f;
-
- b2Vec2 Vec2Convert(const Point& pos)
- {
- return b2Vec2(pos.x / GLOBAL_SCALE, pos.y / GLOBAL_SCALE);
- }
-
- Point Vec2Convert(const b2Vec2& pos)
- {
- return Point(pos.x * GLOBAL_SCALE, pos.y * GLOBAL_SCALE);
- }
-}
diff --git a/samples/Box2DSample/main.cpp b/samples/Box2DSample/main.cpp
deleted file mode 100644
index 608e923d..00000000
--- a/samples/Box2DSample/main.cpp
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright (C) 2019 Nomango
-
-#include "MainScene.h"
-
-int WINAPI wWinMain(_In_ HINSTANCE, _In_opt_ HINSTANCE, _In_ PWSTR, _In_ int)
-{
- try
- {
- Application app;
-
- Options options(L"Box2D Demo");
- app.Init(options);
-
- MainScenePtr scene = new MainScene;
- app.EnterScene(scene);
- app.Run();
- }
- catch (std::exception& e)
- {
- ::MessageBoxA(nullptr, e.what(), "An exception has occurred!", MB_ICONERROR | MB_OK);
- }
- return 0;
-}
diff --git a/samples/Box2DSample/packages.config b/samples/Box2DSample/packages.config
deleted file mode 100644
index 96076339..00000000
--- a/samples/Box2DSample/packages.config
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/samples/Box2DSample/square.png b/samples/Box2DSample/square.png
deleted file mode 100644
index 3f711318..00000000
Binary files a/samples/Box2DSample/square.png and /dev/null differ
diff --git a/samples/HelloWorld/HelloWorld.vcxproj b/samples/HelloWorld/HelloWorld.vcxproj
deleted file mode 100644
index 7b1b9e15..00000000
--- a/samples/HelloWorld/HelloWorld.vcxproj
+++ /dev/null
@@ -1,94 +0,0 @@
-
-
-
-
- Debug
- Win32
-
-
- Release
- Win32
-
-
-
- {3561A359-F9FD-48AB-A977-34E7E568BC8E}
- HelloWorld
-
-
-
- Application
- true
- Unicode
- $(DefaultPlatformToolset)
-
-
- Application
- false
- false
- Unicode
- $(DefaultPlatformToolset)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- $(SolutionDir)\output\$(PlatformToolset)\$(Platform)\$(Configuration)\
- $(SolutionDir)\build\$(PlatformToolset)\$(Platform)\$(Configuration)\$(ProjectName)\
- true
-
-
- $(SolutionDir)\output\$(PlatformToolset)\$(Platform)\$(Configuration)\
- $(SolutionDir)\build\$(PlatformToolset)\$(Platform)\$(Configuration)\$(ProjectName)\
- false
-
-
-
- Level3
- Disabled
- true
- true
- ../../src;
-
-
- true
- Windows
-
-
-
-
- Level3
- MaxSpeed
- true
- true
- true
- true
- ../../src;
-
-
- true
- true
- true
- Windows
-
-
-
-
-
-
-
- {ff7f943d-a89c-4e6c-97cf-84f7d8ff8edf}
-
-
-
-
-
-
\ No newline at end of file
diff --git a/samples/HelloWorld/HelloWorld.vcxproj.filters b/samples/HelloWorld/HelloWorld.vcxproj.filters
deleted file mode 100644
index 4327830c..00000000
--- a/samples/HelloWorld/HelloWorld.vcxproj.filters
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/samples/HelloWorld/main.cpp b/samples/HelloWorld/main.cpp
deleted file mode 100644
index 6f90bad6..00000000
--- a/samples/HelloWorld/main.cpp
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright (C) 2019 Nomango
-
-#include "kiwano/kiwano.h"
-
-using namespace kiwano;
-
-class MainScene
- : public Scene
-{
-public:
- MainScene()
- {
- TextPtr text = new Text(L"Hello Kiwano!"); // ֽڵ
- text->SetSize(text->GetLayoutSize()); // ýڵСΪֲִС
- text->SetPosition(640 / 2, 480 / 2); // Ľڵλ, ʹڵĻϾ
- text->SetAnchor(0.5, 0.5); // Ľڵê, ʹĶĻ
- this->AddChild(text); // ӵ
- }
-};
-
-int WINAPI wWinMain(_In_ HINSTANCE, _In_opt_ HINSTANCE, _In_ PWSTR, _In_ int)
-{
- // Kiwano ʵ
- Application app;
-
- // ڳʼѡôڿ
- Options options;
- options.width = 640;
- options.height = 480;
-
- // ʼ app
- app.Init(options);
-
- //
- ScenePtr scene = new MainScene;
- app.EnterScene(scene);
-
- //
- app.Run();
- return 0;
-}
diff --git a/samples/ImGuiSample/.gitignore b/samples/ImGuiSample/.gitignore
deleted file mode 100644
index 56a9edce..00000000
--- a/samples/ImGuiSample/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-# ImGui Configuration
-imgui.ini
\ No newline at end of file
diff --git a/samples/ImGuiSample/ImGuiSample.vcxproj b/samples/ImGuiSample/ImGuiSample.vcxproj
deleted file mode 100644
index f6245f56..00000000
--- a/samples/ImGuiSample/ImGuiSample.vcxproj
+++ /dev/null
@@ -1,98 +0,0 @@
-
-
-
-
- Debug
- Win32
-
-
- Release
- Win32
-
-
-
- {6152D36C-EA40-4968-A696-244B6CA58395}
- ImGuiSample
-
-
-
- Application
- true
- Unicode
- $(DefaultPlatformToolset)
-
-
- Application
- false
- false
- Unicode
- $(DefaultPlatformToolset)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- $(SolutionDir)\output\$(PlatformToolset)\$(Platform)\$(Configuration)\
- $(SolutionDir)\build\$(PlatformToolset)\$(Platform)\$(Configuration)\$(ProjectName)\
- true
-
-
- $(SolutionDir)\output\$(PlatformToolset)\$(Platform)\$(Configuration)\
- $(SolutionDir)\build\$(PlatformToolset)\$(Platform)\$(Configuration)\$(ProjectName)\
- false
-
-
-
- Level3
- Disabled
- true
- ../../src;
-
-
- true
- Windows
-
-
-
-
- Level3
- MaxSpeed
- true
- true
- true
- ../../src;
-
-
- true
- true
- true
- Windows
-
-
-
-
-
-
-
- {a7062ed8-8910-48a5-a3bc-c1612672571f}
-
-
- {ff7f943d-a89c-4e6c-97cf-84f7d8ff8edf}
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/samples/ImGuiSample/ImGuiSample.vcxproj.filters b/samples/ImGuiSample/ImGuiSample.vcxproj.filters
deleted file mode 100644
index f3f6c7df..00000000
--- a/samples/ImGuiSample/ImGuiSample.vcxproj.filters
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/samples/ImGuiSample/MainScene.h b/samples/ImGuiSample/MainScene.h
deleted file mode 100644
index c2e96205..00000000
--- a/samples/ImGuiSample/MainScene.h
+++ /dev/null
@@ -1,76 +0,0 @@
-// Copyright (C) 2019 Nomango
-
-#pragma once
-
-#include "kiwano/kiwano.h"
-#include "kiwano-imgui/kiwano-imgui.h"
-
-using namespace kiwano;
-using namespace kiwano::imgui;
-
-KGE_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()
- {
- // ImGui ͼ
- ImGuiLayerPtr layer = new ImGuiLayer;
- AddChild(layer);
-
- // ImGui ṩ Demo
- layer->AddItem([=]() {
- if (show_demo_window)
- ImGui::ShowDemoWindow(&show_demo_window);
- }, L"DemoWindow");
-
- // һ
- layer->AddItem(MakeClosure(this, &MainScene::SimpleWindow), L"SimpleWindow");
-
- // һ
- layer->AddItem(MakeClosure(this, &MainScene::AnotherWindow), L"AnotherWindow");
- }
-
- 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();
-
- // Ĵڱɫ
- 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();
- }
- }
-};
diff --git a/samples/ImGuiSample/main.cpp b/samples/ImGuiSample/main.cpp
deleted file mode 100644
index 1d235d7f..00000000
--- a/samples/ImGuiSample/main.cpp
+++ /dev/null
@@ -1,40 +0,0 @@
-// Copyright (C) 2019 Nomango
-
-#include "MainScene.h"
-
-using namespace kiwano;
-
-class ImGuiApp
- : public Application
-{
-public:
- ImGuiApp()
- {
- // ImGui
- Use(ImGuiModule::Instance());
-
- // ʼ
- Options options(L"ImGui Demo", 1280, 800);
- Init(options);
- }
-
- void OnStart() override
- {
- MainScenePtr scene = new MainScene;
- EnterScene(scene);
- }
-};
-
-int WINAPI wWinMain(_In_ HINSTANCE, _In_opt_ HINSTANCE, _In_ PWSTR, _In_ int)
-{
- try
- {
- ImGuiApp app;
- app.Run();
- }
- catch (std::exception& e)
- {
- ::MessageBoxA(nullptr, e.what(), "An exception has occurred!", MB_ICONERROR | MB_OK);
- }
- return 0;
-}
diff --git a/samples/Samples.sln b/samples/Samples.sln
deleted file mode 100644
index d3cda943..00000000
--- a/samples/Samples.sln
+++ /dev/null
@@ -1,75 +0,0 @@
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio Version 16
-VisualStudioVersion = 16.0.28729.10
-MinimumVisualStudioVersion = 10.0.40219.1
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HelloWorld", "HelloWorld\HelloWorld.vcxproj", "{3561A359-F9FD-48AB-A977-34E7E568BC8E}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Samples", "Samples\Samples.vcxproj", "{45F5738D-CDF2-4024-974D-25B64F9043DE}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ImGuiSample", "ImGuiSample\ImGuiSample.vcxproj", "{6152D36C-EA40-4968-A696-244B6CA58395}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Box2DSample", "Box2DSample\Box2DSample.vcxproj", "{324CFF47-4EB2-499A-BE5F-53A82E3BA14B}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "kiwano", "..\projects\kiwano.vcxproj", "{FF7F943D-A89C-4E6C-97CF-84F7D8FF8EDF}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "kiwano-audio", "..\projects\kiwano-audio.vcxproj", "{1B97937D-8184-426C-BE71-29A163DC76C9}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "kiwano-network", "..\projects\kiwano-network.vcxproj", "{69DFBE92-C06F-4CF8-9495-CA9BF2E3BAF2}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "kiwano-imgui", "..\projects\kiwano-imgui.vcxproj", "{A7062ED8-8910-48A5-A3BC-C1612672571F}"
-EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Libraries", "Libraries", "{44D7EDE1-8C27-4608-8018-F891280A77B2}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Win32 = Debug|Win32
- Release|Win32 = Release|Win32
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {3561A359-F9FD-48AB-A977-34E7E568BC8E}.Debug|Win32.ActiveCfg = Debug|Win32
- {3561A359-F9FD-48AB-A977-34E7E568BC8E}.Debug|Win32.Build.0 = Debug|Win32
- {3561A359-F9FD-48AB-A977-34E7E568BC8E}.Release|Win32.ActiveCfg = Release|Win32
- {3561A359-F9FD-48AB-A977-34E7E568BC8E}.Release|Win32.Build.0 = Release|Win32
- {FF7F943D-A89C-4E6C-97CF-84F7D8FF8EDF}.Debug|Win32.ActiveCfg = Debug|Win32
- {FF7F943D-A89C-4E6C-97CF-84F7D8FF8EDF}.Debug|Win32.Build.0 = Debug|Win32
- {FF7F943D-A89C-4E6C-97CF-84F7D8FF8EDF}.Debug|Win32.Deploy.0 = Debug|Win32
- {FF7F943D-A89C-4E6C-97CF-84F7D8FF8EDF}.Release|Win32.ActiveCfg = Release|Win32
- {FF7F943D-A89C-4E6C-97CF-84F7D8FF8EDF}.Release|Win32.Build.0 = Release|Win32
- {45F5738D-CDF2-4024-974D-25B64F9043DE}.Debug|Win32.ActiveCfg = Debug|Win32
- {45F5738D-CDF2-4024-974D-25B64F9043DE}.Debug|Win32.Build.0 = Debug|Win32
- {45F5738D-CDF2-4024-974D-25B64F9043DE}.Release|Win32.ActiveCfg = Release|Win32
- {45F5738D-CDF2-4024-974D-25B64F9043DE}.Release|Win32.Build.0 = Release|Win32
- {6152D36C-EA40-4968-A696-244B6CA58395}.Debug|Win32.ActiveCfg = Debug|Win32
- {6152D36C-EA40-4968-A696-244B6CA58395}.Debug|Win32.Build.0 = Debug|Win32
- {6152D36C-EA40-4968-A696-244B6CA58395}.Release|Win32.ActiveCfg = Release|Win32
- {6152D36C-EA40-4968-A696-244B6CA58395}.Release|Win32.Build.0 = Release|Win32
- {324CFF47-4EB2-499A-BE5F-53A82E3BA14B}.Debug|Win32.ActiveCfg = Debug|Win32
- {324CFF47-4EB2-499A-BE5F-53A82E3BA14B}.Debug|Win32.Build.0 = Debug|Win32
- {324CFF47-4EB2-499A-BE5F-53A82E3BA14B}.Release|Win32.ActiveCfg = Release|Win32
- {324CFF47-4EB2-499A-BE5F-53A82E3BA14B}.Release|Win32.Build.0 = Release|Win32
- {1B97937D-8184-426C-BE71-29A163DC76C9}.Debug|Win32.ActiveCfg = Debug|Win32
- {1B97937D-8184-426C-BE71-29A163DC76C9}.Debug|Win32.Build.0 = Debug|Win32
- {1B97937D-8184-426C-BE71-29A163DC76C9}.Release|Win32.ActiveCfg = Release|Win32
- {1B97937D-8184-426C-BE71-29A163DC76C9}.Release|Win32.Build.0 = Release|Win32
- {69DFBE92-C06F-4CF8-9495-CA9BF2E3BAF2}.Debug|Win32.ActiveCfg = Debug|Win32
- {69DFBE92-C06F-4CF8-9495-CA9BF2E3BAF2}.Debug|Win32.Build.0 = Debug|Win32
- {69DFBE92-C06F-4CF8-9495-CA9BF2E3BAF2}.Release|Win32.ActiveCfg = Release|Win32
- {69DFBE92-C06F-4CF8-9495-CA9BF2E3BAF2}.Release|Win32.Build.0 = Release|Win32
- {A7062ED8-8910-48A5-A3BC-C1612672571F}.Debug|Win32.ActiveCfg = Debug|Win32
- {A7062ED8-8910-48A5-A3BC-C1612672571F}.Debug|Win32.Build.0 = Debug|Win32
- {A7062ED8-8910-48A5-A3BC-C1612672571F}.Release|Win32.ActiveCfg = Release|Win32
- {A7062ED8-8910-48A5-A3BC-C1612672571F}.Release|Win32.Build.0 = Release|Win32
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
- GlobalSection(NestedProjects) = preSolution
- {FF7F943D-A89C-4E6C-97CF-84F7D8FF8EDF} = {44D7EDE1-8C27-4608-8018-F891280A77B2}
- {1B97937D-8184-426C-BE71-29A163DC76C9} = {44D7EDE1-8C27-4608-8018-F891280A77B2}
- {69DFBE92-C06F-4CF8-9495-CA9BF2E3BAF2} = {44D7EDE1-8C27-4608-8018-F891280A77B2}
- {A7062ED8-8910-48A5-A3BC-C1612672571F} = {44D7EDE1-8C27-4608-8018-F891280A77B2}
- EndGlobalSection
- GlobalSection(ExtensibilityGlobals) = postSolution
- SolutionGuid = {FAC2BE2F-19AF-477A-8DC6-4645E66868A4}
- EndGlobalSection
-EndGlobal
diff --git a/samples/Samples/Demo1.h b/samples/Samples/Demo1.h
deleted file mode 100644
index 4bc7472d..00000000
--- a/samples/Samples/Demo1.h
+++ /dev/null
@@ -1,55 +0,0 @@
-// Copyright (C) 2019 Nomango
-
-#pragma once
-#include "common.h"
-
-class Demo1
- : public Scene
-{
-public:
- static ScenePtr Create()
- {
- return new Demo1;
- }
-
- Demo1()
- {
- // ȡͼƬ
- ImagePtr man_image = g_Loader.GetImage(L"man");
-
- //
- auto ease_functions = {
- Ease::Linear, // Ա仯
- Ease::EaseInOut, // 仯л
- Ease::ExpoInOut, // ڿʼͽηdz̷dz
- Ease::BounceInOut, // ڿʼͽξ赯
- Ease::BackInOut // ʼͽξһݵķ˶
- };
-
- float height = 100.f;
- for (auto& func : ease_functions)
- {
- SpritePtr man = new Sprite(man_image);
- man->SetPosition(100, height);
- man->SetScale(0.5f, 0.3f);
- this->AddChild(man);
-
- // λú
- auto reset_pos = [ptr = man.Get()]() { ptr->Move(-350, 0); };
-
- // ִж
- man->AddAction(
- Tween::Group({ // Tween::Group ϶
- Tween::MoveBy(Point{ 350, 0 }) // Tween::MoveBy λ 350
- .SetDuration(4000) // λʱΪ 4
- .SetEaseFunc(func), // û
- Tween::Delay(1000) // Tween::Delay ӳ 1
- })
- .SetLoops(-1) // ѭִ
- .SetLoopDoneCallback(reset_pos) // ÿѭλ
- );
-
- height += 60.f;
- }
- }
-};
diff --git a/samples/Samples/Demo2.h b/samples/Samples/Demo2.h
deleted file mode 100644
index 1cc1832e..00000000
--- a/samples/Samples/Demo2.h
+++ /dev/null
@@ -1,96 +0,0 @@
-// Copyright (C) 2019 Nomango
-
-#pragma once
-#include "common.h"
-
-// ɫ
-KGE_DECLARE_SMART_PTR(Hero);
-class Hero
- : public GifSprite
-{
-public:
- Hero(GifImagePtr image)
- {
- // ͼƬ
- Load(image);
- // GIF ͼѭ
- SetLoopCount(-1);
- }
-
- // ÿ֡Ⱦǰִ OnUpdate
- void OnUpdate(Duration dt) override
- {
- // ȡ豸
- auto input = Input::Instance();
-
- // Ҽ
- if (input->IsDown(KeyCode::Left))
- {
- this->Move(-2, 0);
- }
- else if (input->IsDown(KeyCode::Right))
- {
- this->Move(2, 0);
- }
-
- // ¼
- if (input->IsDown(KeyCode::Up))
- {
- this->Move(0, -2);
- }
- else if (input->IsDown(KeyCode::Down))
- {
- this->Move(0, 2);
- }
-
- // ˳ʱתɫ
- if (input->IsDown(MouseButton::Left))
- {
- // ȡǰתǶ
- float rotation = this->GetRotation();
- // ýǶֵ+2
- this->SetRotation(rotation + 2);
- }
-
- // Ҽػʾɫ
- if (input->WasPressed(MouseButton::Right))
- {
- // ȡǰʾ״̬
- bool visible = this->IsVisible();
- // ෴ʾ״̬
- this->SetVisible(!visible);
- }
- }
-};
-
-class Demo2
- : public Scene
-{
-public:
- static ScenePtr Create()
- {
- return new Demo2;
- }
-
- Demo2()
- {
- // ɫ
- HeroPtr hero = new Hero(g_Loader.GetGifImage(L"Kusanagi"));
- // ĻϾʾ
- hero->SetAnchor(0.5f, 0.5f);
- hero->SetPosition(WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2);
-
- // ˵
- TextPtr text = new Text(L"Ҽƶ\nת\nҼ");
- // ýڵСΪֲִС
- text->SetSize(text->GetLayoutSize());
- // λ
- text->SetAnchor(0.5f, 0.5f);
- text->SetPosition(WINDOW_WIDTH / 2, WINDOW_HEIGHT - 50);
- text->SetAlignment(TextAlign::Center);
-
- // ӵ
- this->AddChild(hero);
- this->AddChild(text);
- }
-};
diff --git a/samples/Samples/Demo3.h b/samples/Samples/Demo3.h
deleted file mode 100644
index 2ea0073f..00000000
--- a/samples/Samples/Demo3.h
+++ /dev/null
@@ -1,84 +0,0 @@
-// Copyright (C) 2019 Nomango
-
-#pragma once
-#include "common.h"
-
-class Demo3
- : public Scene
-{
- SoundPtr bgmusic; // ֶ
- TextPtr volume_text; //
- TextPtr state_text; // ״̬
-
-public:
- static ScenePtr Create()
- {
- return new Demo3;
- }
-
- Demo3()
- {
- //
- bgmusic = new Sound;
- if (!bgmusic->Load(L"res/splash.mp3"))
- {
- bgmusic = nullptr;
-
- TextPtr err = new Text(L"Ƶļʧ");
- this->AddChild(err);
- }
-
- // ֣òѭ-1 ʾѭţ
- bgmusic->Play(-1);
-
- // ˵
- TextPtr intro_text = new Text(L"¼\nոͣ");
- intro_text->SetPosition(WINDOW_WIDTH / 2 - 80, WINDOW_HEIGHT / 2 - 50);
-
- //
- volume_text = new Text(L"ǰ");
- volume_text->SetPosition(WINDOW_WIDTH / 2 - 80, WINDOW_HEIGHT / 2 + 30);
-
- // ״̬
- state_text = new Text(L"ǰ״̬");
- state_text->SetPosition(WINDOW_WIDTH / 2 - 80, WINDOW_HEIGHT / 2 + 60);
-
- // ӵ
- this->AddChild(intro_text);
- this->AddChild(volume_text);
- this->AddChild(state_text);
- }
-
- void OnUpdate(Duration dt) override
- {
- if (bgmusic == nullptr)
- return;
-
- // ȡͲ״̬
- float volume = bgmusic->GetVolume();
- bool playing = bgmusic->IsPlaying();
-
- // ı
- volume_text->SetText(L"ǰ" + std::to_wstring(volume));
- state_text->SetText(playing ? L"ǰ״̬ڲ" : L"ǰ״ֹ̬ͣ");
-
- // ȡ豸
- auto input = Input::Instance();
-
- // ոͣ
- if (input->WasPressed(KeyCode::Space))
- {
- bgmusic->IsPlaying() ? bgmusic->Pause() : bgmusic->Resume();
- }
-
- // ¼
- if (input->WasPressed(KeyCode::Up))
- {
- bgmusic->SetVolume(volume + 0.1f);
- }
- else if (input->WasPressed(KeyCode::Down))
- {
- bgmusic->SetVolume(volume - 0.1f);
- }
- }
-};
diff --git a/samples/Samples/Demo4.h b/samples/Samples/Demo4.h
deleted file mode 100644
index 132e09fc..00000000
--- a/samples/Samples/Demo4.h
+++ /dev/null
@@ -1,178 +0,0 @@
-// Copyright (C) 2019 Nomango
-
-#pragma once
-#include "common.h"
-
-// ϻ
-KGE_DECLARE_SMART_PTR(Tiger);
-class Tiger
- : public Sprite
-{
- FramesPtr run_frames; // ܲ֡
- FramesPtr stand_frames; // վ֡
- bool facing_left; // 泯泯
- bool running; // Ƿܲ
- Direction running_direction; // ܲ
-
-public:
- Tiger()
- {
- // ֡
- run_frames = g_Loader.GetFrames(L"tiger_running");
- stand_frames = g_Loader.GetFrames(L"tiger_standing");
-
- // ִж
- AddAction(
- Tween::Animation(stand_frames)
- .SetDuration(1000)
- .SetLoops(-1)
- );
-
- // Ӱ
- AddListener(Event::KeyDown, MakeClosure(this, &Tiger::OnKeyDown));
- AddListener(Event::KeyUp, MakeClosure(this, &Tiger::OnKeyUp));
-
- // ĬϷΪ Left
- facing_left = true;
- running = false;
-
- // ê
- SetAnchor(0.5f, 0.5f);
- }
-
- void OnKeyDown(Event const& e)
- {
- if (e.key.code == KeyCode::Left)
- Run(Direction::Left);
- else if (e.key.code == KeyCode::Right)
- Run(Direction::Right);
- else if (e.key.code == KeyCode::Up)
- Run(Direction::Up);
- else if (e.key.code == KeyCode::Down)
- Run(Direction::Down);
- }
-
- void OnKeyUp(Event const& e)
- {
- switch (e.key.code)
- {
- case KeyCode::Left:
- case KeyCode::Right:
- case KeyCode::Up:
- case KeyCode::Down:
- StopRun();
- break;
- }
- }
-
- void Run(Direction d)
- {
- if (!running)
- {
- running = true;
- StopAllActions();
-
- // ִܲ
- AddAction(
- Tween::Animation(run_frames)
- .SetDuration(500)
- .SetLoops(-1)
- );
- }
-
- running_direction = d;
- if (running_direction == Direction::Left)
- {
- facing_left = true;
- }
- else if (running_direction == Direction::Right)
- {
- facing_left = false;
- }
-
- // ſԵͼƬʾ
- // -1 ͼƬᷴת
- SetScaleX(facing_left ? 1.0f : -1.0f);
- }
-
- void StopRun()
- {
- if (running)
- {
- running = false;
- StopAllActions();
-
- // ִվ
- AddAction(
- Tween::Animation(stand_frames)
- .SetDuration(1000)
- .SetLoops(-1)
- );
- }
- }
-
- void OnUpdate(Duration dt)
- {
- if (running)
- {
- // ƶ
- // OnUpdate һȶִеĺ, ʵȶ
- // ÿƶ 150 , Ӧ dt ƶ
- const float moving_per_sec = 150;
- const float distance = moving_per_sec * dt.Seconds();
-
- switch (running_direction)
- {
- case Direction::Up:
- Move(0, -distance);
- break;
- case Direction::Down:
- Move(0, distance);
- break;
- case Direction::Left:
- Move(-distance, 0);
- break;
- case Direction::Right:
- Move(distance, 0);
- break;
- }
- }
- }
-};
-
-class Demo4
- : public Scene
-{
-public:
- static ScenePtr Create()
- {
- return new Demo4;
- }
-
- Demo4()
- {
- //
- SpritePtr bg = new Sprite(L"res/spring_forest.jpg");
- bg->SetSize(GetSize());
-
- // ϻ
- TigerPtr tiger = new Tiger;
- // ĻϾʾ
- tiger->SetAnchor(0.5f, 0.5f);
- tiger->SetPosition(WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2);
-
- // ˵
- TextPtr text = new Text(L"Ҽƶ");
- // ýڵСΪֲִС
- text->SetSize(text->GetLayoutSize());
- // λ
- text->SetAnchor(0.5f, 0.5f);
- text->SetPosition(WINDOW_WIDTH / 2, WINDOW_HEIGHT - 80);
- text->SetAlignment(TextAlign::Center);
-
- // ӵ
- this->AddChild(bg);
- this->AddChild(tiger);
- this->AddChild(text);
- }
-};
diff --git a/samples/Samples/Demo5.h b/samples/Samples/Demo5.h
deleted file mode 100644
index 2fbd918e..00000000
--- a/samples/Samples/Demo5.h
+++ /dev/null
@@ -1,176 +0,0 @@
-// Copyright (C) 2019 Nomango
-
-#pragma once
-#include "common.h"
-#include
-
-class Demo5
- : public Scene
-{
-public:
- static ScenePtr Create()
- {
- return new Demo5;
- }
-
- Demo5()
- {
- // Ӱ
- AddListener(Event::KeyDown, MakeClosure(this, &Demo5::OnKeyDown));
-
- // ˵
- TextPtr text = new Text(L"GGET\nPPOST\nUPUT\nDDELETE");
- // ýڵСΪֲִС
- text->SetSize(text->GetLayoutSize());
- // λ
- text->SetAnchor(0.5f, 0.5f);
- text->SetPosition(WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2);
-
- // ӵ
- this->AddChild(text);
- }
-
- void OnEnter() override
- {
- // 볡ʱ̨
- Logger::Instance()->ShowConsole(true);
- }
-
- void OnExit() override
- {
- // ˳ʱرտ̨
- Logger::Instance()->ShowConsole(false);
- }
-
- void OnKeyDown(Event const& e)
- {
- // ͬͲͬ
- if (e.key.code == KeyCode::G)
- {
- SendGetRequest();
- }
- else if (e.key.code == KeyCode::P)
- {
- SendPostRequest();
- }
- else if (e.key.code == KeyCode::U)
- {
- SendPutRequest();
- }
- else if (e.key.code == KeyCode::D)
- {
- SendDeleteRequest();
- }
- }
-
- void SendGetRequest()
- {
- // GET
- Logger::Instance()->Println(L"Start to send GET request...");
-
- HttpRequestPtr request = new HttpRequest;
- // URL
- request->SetUrl(L"http://httpbin.org/get");
- // Ϊ GET
- request->SetType(HttpRequest::Type::Get);
- // ɺĻص
- request->SetResponseCallback(MakeClosure(this, &Demo5::Complete));
-
- // HTTP
- HttpClient::Instance()->Send(request);
- }
-
- void SendPostRequest()
- {
- // POST
- Logger::Instance()->Println(L"Start to send POST request...");
-
- // JSON ʽ POST
- Json request_data = {
- { L"string", L"test" },
- { L"boolean", true },
- { L"integer", 12 },
- { L"float", 3.125 },
- { L"array", { 1, 2, 3, 4, 4.5 } },
- { L"object", { L"key", L"value" } },
- };
-
- HttpRequestPtr request = new HttpRequest;
- request->SetUrl(L"http://httpbin.org/post");
- request->SetType(HttpRequest::Type::Post);
- // POST
- request->SetJsonData(request_data);
- request->SetResponseCallback(MakeClosure(this, &Demo5::Complete));
-
- HttpClient::Instance()->Send(request);
- }
-
- void SendPutRequest()
- {
- // PUT
- Logger::Instance()->Println(L"Start to send PUT request...");
-
- // JSON ʽ PUT
- Json request_data = Json::array({ 1, 2, 3 });
-
- HttpRequestPtr request = new HttpRequest;
- request->SetUrl(L"http://httpbin.org/put");
- request->SetType(HttpRequest::Type::Put);
- // PUT
- request->SetJsonData(request_data);
- request->SetResponseCallback(MakeClosure(this, &Demo5::Complete));
-
- HttpClient::Instance()->Send(request);
- }
-
- void SendDeleteRequest()
- {
- // DELETE
- Logger::Instance()->Println(L"Start to send DELETE request...");
-
- HttpRequestPtr request = new HttpRequest;
- request->SetUrl(L"http://httpbin.org/delete");
- request->SetType(HttpRequest::Type::Delete);
- request->SetResponseCallback(MakeClosure(this, &Demo5::Complete));
-
- HttpClient::Instance()->Send(request);
- }
-
- void Complete(HttpRequestPtr request, HttpResponsePtr response)
- {
- // жǷɹ
- if (response->IsSucceed())
- {
- try
- {
- // ȡݽ JSON ʽ
- Json response_data = Json::parse(response->GetData());
- Json result = {
- {L"HttpCode", response->GetResponseCode()},
- {L"Data", response_data},
- };
-
- std::wcout << L"Response: " << std::endl << result.dump(4) << std::endl;
- }
- catch (json_exception& e)
- {
- std::wcout << L"Parse JSON failed: " << e.what() << std::endl;
- }
- }
- else
- {
- // ʧʱӡϢ
- OutputError(response);
- }
- }
-
- void OutputError(HttpResponsePtr response)
- {
- // ӡ HTTP Ӧ״̬ʹϢ
- Json result = {
- {L"HttpCode", response->GetResponseCode()},
- {L"Error", response->GetError()},
- };
- std::wcout << L"Response: " << std::endl << result.dump(4) << std::endl;
- }
-};
diff --git a/samples/Samples/Samples.rc b/samples/Samples/Samples.rc
deleted file mode 100644
index ede40d6b..00000000
Binary files a/samples/Samples/Samples.rc and /dev/null differ
diff --git a/samples/Samples/Samples.vcxproj b/samples/Samples/Samples.vcxproj
deleted file mode 100644
index 03a89aa4..00000000
--- a/samples/Samples/Samples.vcxproj
+++ /dev/null
@@ -1,133 +0,0 @@
-
-
-
-
- Debug
- Win32
-
-
- Release
- Win32
-
-
-
- {45F5738D-CDF2-4024-974D-25B64F9043DE}
- Samples
-
-
-
- Application
- true
- Unicode
- $(DefaultPlatformToolset)
-
-
- Application
- false
- false
- Unicode
- $(DefaultPlatformToolset)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- $(SolutionDir)\output\$(PlatformToolset)\$(Platform)\$(Configuration)\
- $(SolutionDir)\build\$(PlatformToolset)\$(Platform)\$(Configuration)\$(ProjectName)\
- true
-
-
- $(SolutionDir)\output\$(PlatformToolset)\$(Platform)\$(Configuration)\
- $(SolutionDir)\build\$(PlatformToolset)\$(Platform)\$(Configuration)\$(ProjectName)\
- false
-
-
-
- Level3
- Disabled
- true
- ../../src;
-
-
- true
- Windows
-
-
-
- xcopy "$(ProjectDir)\res" "$(OutDir)\res\" /D /E /I /F /Y
- xcopy "$(ProjectDir)..\..\src\kiwano-network\dlls\*.dll" "$(OutDir)" /D /Y
-
- Copy files
-
-
-
-
- Level3
- MaxSpeed
- true
- true
- true
- ../../src;
-
-
- true
- true
- true
- Windows
-
-
-
- xcopy "$(ProjectDir)\res" "$(OutDir)\res\" /D /E /I /F /Y
- xcopy "$(ProjectDir)..\..\src\kiwano-network\dlls\*.dll" "$(OutDir)" /D /Y
-
- Copy files
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {1b97937d-8184-426c-be71-29a163dc76c9}
-
-
- {69dfbe92-c06f-4cf8-9495-ca9bf2e3baf2}
-
-
- {ff7f943d-a89c-4e6c-97cf-84f7d8ff8edf}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/samples/Samples/Samples.vcxproj.filters b/samples/Samples/Samples.vcxproj.filters
deleted file mode 100644
index 744661bb..00000000
--- a/samples/Samples/Samples.vcxproj.filters
+++ /dev/null
@@ -1,57 +0,0 @@
-
-
-
-
-
-
-
- src
-
-
- src
-
-
- src
-
-
- src
-
-
- src
-
-
- src
-
-
- resources
-
-
-
-
- {4460eeec-9e2f-46b6-909a-5ff4443075ce}
-
-
- {04b65e7e-f0ce-4b83-a73e-501913daf790}
-
-
-
-
- resources
-
-
-
-
- resources
-
-
-
-
- resources
-
-
-
-
- resources
-
-
-
\ No newline at end of file
diff --git a/samples/Samples/common.h b/samples/Samples/common.h
deleted file mode 100644
index 93c3750a..00000000
--- a/samples/Samples/common.h
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright (C) 2019 Nomango
-
-#pragma once
-#include "kiwano/kiwano.h"
-#include "kiwano-audio/kiwano-audio.h"
-#include "kiwano-network/kiwano-network.h"
-
-using namespace kiwano;
-using namespace kiwano::audio;
-using namespace kiwano::network;
-
-const int WINDOW_WIDTH = 640;
-const int WINDOW_HEIGHT = 480;
-
-// Դع
-extern ResLoader g_Loader;
diff --git a/samples/Samples/main.cpp b/samples/Samples/main.cpp
deleted file mode 100644
index 071b1955..00000000
--- a/samples/Samples/main.cpp
+++ /dev/null
@@ -1,115 +0,0 @@
-// Copyright (C) 2019 Nomango
-
-#include "Demo1.h"
-#include "Demo2.h"
-#include "Demo3.h"
-#include "Demo4.h"
-#include "Demo5.h"
-#include "resource.h"
-
-namespace
-{
- struct Demo
- {
- String title;
- ScenePtr(*Create)();
- };
-
- Demo s_Demos[] = {
- { L"ʾ", Demo1::Create },
- { L"ʾ", Demo2::Create },
- { L"Ƶʾ", Demo3::Create },
- { L"֡ʾ", Demo4::Create },
- { L"ʾ", Demo5::Create },
- };
- int s_CurrIndex = -1;
- int s_DemoNum = sizeof(s_Demos) / sizeof(Demo);
-}
-
-// Դع
-ResLoader g_Loader;
-
-class DemoApp
- : public Application
-{
-public:
- DemoApp()
- {
- // ʹ Audio
- Use(Audio::Instance());
-
- // ʹ HttpClient
- Use(HttpClient::Instance());
-
- Options options(L"Kiwanoʾ", WINDOW_WIDTH, WINDOW_HEIGHT, MAKEINTRESOURCE(IDI_ICON1));
- Init(options);
- }
-
- void OnStart() override
- {
- // JSON ļжȡԴϢ
- //g_Loader.LoadFromJsonFile(L"res/index.json");
-
- // XML ļжȡԴϢ
- g_Loader.LoadFromXmlFile(L"res/index.xml");
-
- // лһ
- ChangeDemoScene(0);
- }
-
- void OnDestroy() override
- {
- // ˳ϷʱԴ
- g_Loader.Destroy();
- }
-
- void ChangeDemoScene(int index)
- {
- if (s_CurrIndex != index)
- {
- s_CurrIndex = index;
-
- String title = s_Demos[index].title;
- Window::Instance()->SetTitle(L"Kiwanoʾ - " + title);
-
- ScenePtr scene = s_Demos[index].Create();
- EnterScene(scene);
-
- // Ӱ
- scene->AddListener(Event::KeyUp, MakeClosure(this, &DemoApp::KeyPressed));
-
- // ʾʾ
- String intro_str = String::format(L" 1~%d лʾ\n", s_DemoNum);
- TextPtr intro = new Text(intro_str + title);
- intro->SetFontSize(16.f);
- intro->SetPosition(10, 10);
- scene->AddChild(intro);
- }
- }
-
- void KeyPressed(Event const& evt)
- {
- KGE_ASSERT(evt.type == Event::KeyUp);
-
- if (evt.key.code > KeyCode::Num0 &&
- evt.key.code <= (KeyCode::Num0 + s_DemoNum))
- {
- int index = evt.key.code - KeyCode::Num1;
- ChangeDemoScene(index);
- }
- }
-};
-
-int WINAPI wWinMain(_In_ HINSTANCE, _In_opt_ HINSTANCE, _In_ PWSTR, _In_ int)
-{
- try
- {
- DemoApp app;
- app.Run();
- }
- catch (std::exception& e)
- {
- ::MessageBoxA(nullptr, e.what(), "An exception has occurred!", MB_ICONERROR | MB_OK);
- }
- return 0;
-}
diff --git a/samples/Samples/res/Kusanagi.gif b/samples/Samples/res/Kusanagi.gif
deleted file mode 100644
index a412cf1a..00000000
Binary files a/samples/Samples/res/Kusanagi.gif and /dev/null differ
diff --git a/samples/Samples/res/akushu.png b/samples/Samples/res/akushu.png
deleted file mode 100644
index 916e43b7..00000000
Binary files a/samples/Samples/res/akushu.png and /dev/null differ
diff --git a/samples/Samples/res/index.json b/samples/Samples/res/index.json
deleted file mode 100644
index 4a581a09..00000000
--- a/samples/Samples/res/index.json
+++ /dev/null
@@ -1,40 +0,0 @@
-{
- "version": "0.1",
- "path": "./res/",
- "images": [
- {
- "id": "man",
- "file": "man.png"
- },
- {
- "id": "monster",
- "file": "akushu.png"
- },
- {
- "id": "forest_bg",
- "file": "spring_forest.jpg"
- },
- {
- "id": "tiger_running",
- "files": [
- "tiger/run/run01.png",
- "tiger/run/run02.png",
- "tiger/run/run03.png",
- "tiger/run/run04.png",
- "tiger/run/run05.png",
- "tiger/run/run06.png"
- ]
- },
- {
- "id": "tiger_standing",
- "file": "tiger/stand.png",
- "rows": 2,
- "cols": 3
- },
- {
- "id": "Kusanagi",
- "file": "Kusanagi.gif",
- "type": "gif"
- }
- ]
-}
\ No newline at end of file
diff --git a/samples/Samples/res/index.xml b/samples/Samples/res/index.xml
deleted file mode 100644
index 256b5813..00000000
--- a/samples/Samples/res/index.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
- 0.1
- ./res/
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/samples/Samples/res/man.png b/samples/Samples/res/man.png
deleted file mode 100644
index 71ecf69c..00000000
Binary files a/samples/Samples/res/man.png and /dev/null differ
diff --git a/samples/Samples/res/splash.mp3 b/samples/Samples/res/splash.mp3
deleted file mode 100644
index 1f084890..00000000
Binary files a/samples/Samples/res/splash.mp3 and /dev/null differ
diff --git a/samples/Samples/res/spring_forest.jpg b/samples/Samples/res/spring_forest.jpg
deleted file mode 100644
index 72268be5..00000000
Binary files a/samples/Samples/res/spring_forest.jpg and /dev/null differ
diff --git a/samples/Samples/res/tiger/run/run01.png b/samples/Samples/res/tiger/run/run01.png
deleted file mode 100644
index c9edf27e..00000000
Binary files a/samples/Samples/res/tiger/run/run01.png and /dev/null differ
diff --git a/samples/Samples/res/tiger/run/run02.png b/samples/Samples/res/tiger/run/run02.png
deleted file mode 100644
index b4be56bb..00000000
Binary files a/samples/Samples/res/tiger/run/run02.png and /dev/null differ
diff --git a/samples/Samples/res/tiger/run/run03.png b/samples/Samples/res/tiger/run/run03.png
deleted file mode 100644
index a6ec3549..00000000
Binary files a/samples/Samples/res/tiger/run/run03.png and /dev/null differ
diff --git a/samples/Samples/res/tiger/run/run04.png b/samples/Samples/res/tiger/run/run04.png
deleted file mode 100644
index 005680c4..00000000
Binary files a/samples/Samples/res/tiger/run/run04.png and /dev/null differ
diff --git a/samples/Samples/res/tiger/run/run05.png b/samples/Samples/res/tiger/run/run05.png
deleted file mode 100644
index e0c71b7a..00000000
Binary files a/samples/Samples/res/tiger/run/run05.png and /dev/null differ
diff --git a/samples/Samples/res/tiger/run/run06.png b/samples/Samples/res/tiger/run/run06.png
deleted file mode 100644
index af3c5546..00000000
Binary files a/samples/Samples/res/tiger/run/run06.png and /dev/null differ
diff --git a/samples/Samples/res/tiger/shock.png b/samples/Samples/res/tiger/shock.png
deleted file mode 100644
index 41809eb8..00000000
Binary files a/samples/Samples/res/tiger/shock.png and /dev/null differ
diff --git a/samples/Samples/res/tiger/stand.png b/samples/Samples/res/tiger/stand.png
deleted file mode 100644
index 1c6868eb..00000000
Binary files a/samples/Samples/res/tiger/stand.png and /dev/null differ
diff --git a/samples/Samples/res/tiger/stand/stand01.png b/samples/Samples/res/tiger/stand/stand01.png
deleted file mode 100644
index 864dcb95..00000000
Binary files a/samples/Samples/res/tiger/stand/stand01.png and /dev/null differ
diff --git a/samples/Samples/res/tiger/stand/stand02.png b/samples/Samples/res/tiger/stand/stand02.png
deleted file mode 100644
index 503f7c23..00000000
Binary files a/samples/Samples/res/tiger/stand/stand02.png and /dev/null differ
diff --git a/samples/Samples/res/tiger/stand/stand03.png b/samples/Samples/res/tiger/stand/stand03.png
deleted file mode 100644
index a1d7cf9a..00000000
Binary files a/samples/Samples/res/tiger/stand/stand03.png and /dev/null differ
diff --git a/samples/Samples/res/tiger/stand/stand04.png b/samples/Samples/res/tiger/stand/stand04.png
deleted file mode 100644
index d8c6b8c1..00000000
Binary files a/samples/Samples/res/tiger/stand/stand04.png and /dev/null differ
diff --git a/samples/Samples/res/tiger/stand/stand05.png b/samples/Samples/res/tiger/stand/stand05.png
deleted file mode 100644
index e4756cd4..00000000
Binary files a/samples/Samples/res/tiger/stand/stand05.png and /dev/null differ
diff --git a/samples/Samples/res/tiger/stand/stand06.png b/samples/Samples/res/tiger/stand/stand06.png
deleted file mode 100644
index b5337f8d..00000000
Binary files a/samples/Samples/res/tiger/stand/stand06.png and /dev/null differ
diff --git a/samples/Samples/resource.h b/samples/Samples/resource.h
deleted file mode 100644
index 05ca7137..00000000
--- a/samples/Samples/resource.h
+++ /dev/null
@@ -1,16 +0,0 @@
-//{{NO_DEPENDENCIES}}
-// Microsoft Visual C++ ɵİļ
-// Samples.rc ʹ
-//
-#define IDI_ICON1 101
-
-// Next default values for new objects
-//
-#ifdef APSTUDIO_INVOKED
-#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 102
-#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1001
-#define _APS_NEXT_SYMED_VALUE 101
-#endif
-#endif
diff --git a/src/kiwano/2d/ActionGroup.h b/src/kiwano/2d/ActionGroup.h
index d3286225..7615f177 100644
--- a/src/kiwano/2d/ActionGroup.h
+++ b/src/kiwano/2d/ActionGroup.h
@@ -72,6 +72,9 @@ namespace kiwano
};
+#pragma warning(push)
+#pragma warning(disable : 4996)
+
// ˳
class KGE_API ActionSequence
: public ActionGroup
@@ -100,4 +103,7 @@ namespace kiwano
virtual ~ActionSpawn() {}
};
+
+#pragma warning(pop)
+
}
diff --git a/src/kiwano/2d/ActionTween.cpp b/src/kiwano/2d/ActionTween.cpp
index 21f6ddef..437ea893 100644
--- a/src/kiwano/2d/ActionTween.cpp
+++ b/src/kiwano/2d/ActionTween.cpp
@@ -424,36 +424,84 @@ namespace kiwano
// ActionPath
//-------------------------------------------------------
- ActionPath::ActionPath(Duration duration, GeometryPtr geo, bool rotating, float start, float end, EaseFunc func)
+ ActionPath::ActionPath(Duration duration, bool rotating, float start, float end, EaseFunc func)
: ActionTween(duration, func)
, start_(start)
, end_(end)
- , geo_(geo)
, rotating_(rotating)
+ , path_beginning_(false)
+ , geo_(nullptr)
+ , geo_sink_(nullptr)
{
}
ActionPtr ActionPath::Clone() const
{
- return new ActionPath(dur_, geo_, rotating_, start_, end_, ease_func_);
+ ActionPathPtr clone = new ActionPath(dur_, rotating_, start_, end_, ease_func_);
+ if (clone)
+ {
+ clone->SetGeometry(geo_);
+ }
+ return clone;
}
ActionPtr ActionPath::Reverse() const
{
- return new ActionPath(dur_, geo_, rotating_, end_, start_, ease_func_);
+ ActionPathPtr reverse = new ActionPath(dur_, rotating_, end_, start_, ease_func_);
+ if (reverse)
+ {
+ reverse->SetGeometry(geo_);
+ }
+ return reverse;
+ }
+
+ float ActionPath::GetPathLength() const
+ {
+ float length = 0.f;
+ if (geo_)
+ {
+ // no matter it failed or not
+ geo_->ComputeLength(D2D1::Matrix3x2F::Identity(), &length);
+ }
+ return length;
+ }
+
+ bool ActionPath::ComputePointAtLength(float length, Point* point, Vec2* tangent) const
+ {
+ if (geo_)
+ {
+ HRESULT hr = geo_->ComputePointAtLength(
+ length,
+ D2D1::Matrix3x2F::Identity(),
+ DX::ConvertToPoint2F(point),
+ DX::ConvertToPoint2F(tangent)
+ );
+ return SUCCEEDED(hr);
+ }
+ return false;
}
void ActionPath::Init(NodePtr target)
{
start_pos_ = target->GetPosition();
+
+ if (path_beginning_)
+ {
+ EndPath();
+ }
+
+ if (!geo_)
+ {
+ Complete(target);
+ }
}
void ActionPath::UpdateTween(NodePtr target, float percent)
{
- float length = geo_->GetLength() * std::min(std::max((end_ - start_) * percent + start_, 0.f), 1.f);
+ float length = GetPathLength() * std::min(std::max((end_ - start_) * percent + start_, 0.f), 1.f);
Point point, tangent;
- if (geo_->ComputePointAt(length, &point, &tangent))
+ if (ComputePointAtLength(length, &point, &tangent))
{
target->SetPosition(start_pos_ + point);
@@ -466,6 +514,123 @@ namespace kiwano
}
}
+ void ActionPath::BeginPath()
+ {
+ if (path_beginning_) return;
+ path_beginning_ = true;
+
+ geo_ = nullptr;
+ geo_sink_ = nullptr;
+
+ auto factory = Renderer::Instance()->GetD2DDeviceResources()->GetFactory();
+
+ ThrowIfFailed(
+ factory->CreatePathGeometry(&geo_)
+ );
+
+ ThrowIfFailed(
+ geo_->Open(&geo_sink_)
+ );
+
+ geo_sink_->BeginFigure(DX::ConvertToPoint2F(Point{ 0, 0 }), D2D1_FIGURE_BEGIN_FILLED);
+ }
+
+ void ActionPath::EndPath(bool closed)
+ {
+ if (!path_beginning_) return;
+ path_beginning_ = false;
+
+ if (geo_sink_)
+ {
+ geo_sink_->EndFigure(closed ? D2D1_FIGURE_END_CLOSED : D2D1_FIGURE_END_OPEN);
+ ThrowIfFailed(
+ geo_sink_->Close()
+ );
+
+ // Clear geometry sink
+ geo_sink_ = nullptr;
+ }
+ }
+
+ void ActionPath::AddLine(Point const& point)
+ {
+ if (!path_beginning_)
+ {
+ BeginPath();
+ }
+
+ if (geo_sink_)
+ {
+ geo_sink_->AddLine(DX::ConvertToPoint2F(point));
+ }
+ }
+
+ void ActionPath::AddLines(Array const& points)
+ {
+ if (!path_beginning_)
+ {
+ BeginPath();
+ }
+
+ if (geo_sink_ && !points.empty())
+ {
+ geo_sink_->AddLines(
+ reinterpret_cast(&points[0]),
+ static_cast(points.size())
+ );
+ }
+ }
+
+ void ActionPath::AddBezier(Point const& point1, Point const& point2, Point const& point3)
+ {
+ if (!path_beginning_)
+ {
+ BeginPath();
+ }
+
+ if (geo_sink_)
+ {
+ geo_sink_->AddBezier(
+ D2D1::BezierSegment(
+ DX::ConvertToPoint2F(point1),
+ DX::ConvertToPoint2F(point2),
+ DX::ConvertToPoint2F(point3)
+ )
+ );
+ }
+ }
+
+ void ActionPath::AddArc(Point const& point, Size const& radius, float rotation, bool clockwise, bool is_small)
+ {
+ if (!path_beginning_)
+ {
+ BeginPath();
+ }
+
+ if (geo_sink_)
+ {
+ geo_sink_->AddArc(
+ D2D1::ArcSegment(
+ DX::ConvertToPoint2F(point),
+ DX::ConvertToSizeF(radius),
+ rotation,
+ clockwise ? D2D1_SWEEP_DIRECTION_CLOCKWISE : D2D1_SWEEP_DIRECTION_COUNTER_CLOCKWISE,
+ is_small ? D2D1_ARC_SIZE_SMALL : D2D1_ARC_SIZE_LARGE
+ )
+ );
+ }
+ }
+
+ void ActionPath::ClearPath()
+ {
+ if (path_beginning_)
+ {
+ EndPath();
+ }
+
+ geo_sink_ = nullptr;
+ geo_ = nullptr;
+ }
//-------------------------------------------------------
// ActionCustom
diff --git a/src/kiwano/2d/ActionTween.h b/src/kiwano/2d/ActionTween.h
index 272de038..598db22b 100644
--- a/src/kiwano/2d/ActionTween.h
+++ b/src/kiwano/2d/ActionTween.h
@@ -20,8 +20,8 @@
#pragma once
#include "Action.h"
-#include "Geometry.h" // ActionPath
#include "../base/logs.h"
+#include "../renderer/render.h" // ID2D1PathGeometry, ID2D1GeometrySink
namespace kiwano
{
@@ -419,7 +419,6 @@ namespace kiwano
public:
ActionPath(
Duration duration, /* ʱ */
- GeometryPtr geo, /* ͼ */
bool rotating = false, /* ·߷ת */
float start = 0.f, /* */
float end = 1.f, /* յ */
@@ -432,17 +431,69 @@ namespace kiwano
// ȡöĵת
ActionPtr Reverse() const override;
+ // ʼ·
+ void BeginPath();
+
+ // ·
+ void EndPath(
+ bool closed = false /* ·Ƿպ */
+ );
+
+ // һ߶
+ void AddLine(
+ Point const& point /* ˵ */
+ );
+
+ // Ӷ߶
+ void AddLines(
+ Array const& points
+ );
+
+ // һη
+ void AddBezier(
+ Point const& point1, /* ߵĵһƵ */
+ Point const& point2, /* ߵĵڶƵ */
+ Point const& point3 /* ߵյ */
+ );
+
+ // ӻ
+ void AddArc(
+ Point const& point, /* յ */
+ Size const& radius, /* Բ뾶 */
+ float rotation, /* ԲתǶ */
+ bool clockwise = true, /* ˳ʱ or ʱ */
+ bool is_small = true /* ǷȡС 180 Ļ */
+ );
+
+ // ·
+ void ClearPath();
+
+ // ȡ·
+ float GetPathLength() const;
+
+ // 㵱ǰ·ָ
+ bool ComputePointAtLength(float length, Point* point, Vec2* tangent) const;
+
+ // ȡ·
+ inline ComPtr GetGeometry() const { return geo_; }
+
+ // ü·
+ inline void SetGeometry(ComPtr geo) { geo_ = geo; }
+
protected:
void Init(NodePtr target) override;
void UpdateTween(NodePtr target, float percent) override;
protected:
- bool rotating_;
- float start_;
- float end_;
- Point start_pos_;
- GeometryPtr geo_;
+ bool path_beginning_;
+ bool rotating_;
+ float start_;
+ float end_;
+ Point start_pos_;
+
+ ComPtr geo_;
+ ComPtr geo_sink_;
};
diff --git a/src/kiwano/2d/Canvas.cpp b/src/kiwano/2d/Canvas.cpp
index 378c2bab..be985f0d 100644
--- a/src/kiwano/2d/Canvas.cpp
+++ b/src/kiwano/2d/Canvas.cpp
@@ -20,7 +20,6 @@
#include "Canvas.h"
#include "Image.h"
-#include "Geometry.h"
#include "../base/logs.h"
#include "../renderer/render.h"
@@ -298,20 +297,6 @@ namespace kiwano
);
}
- void Canvas::DrawGeometry(GeometryPtr geo)
- {
- if (geo && geo->geo_)
- {
- render_target_->DrawGeometry(
- geo->geo_.Get(),
- stroke_brush_.Get(),
- stroke_width_,
- outline_join_style_.Get()
- );
- cache_expired_ = true;
- }
- }
-
void Canvas::FillCircle(const Point & center, float radius)
{
render_target_->FillEllipse(
@@ -376,18 +361,6 @@ namespace kiwano
cache_expired_ = true;
}
- void Canvas::FillGeometry(GeometryPtr geo)
- {
- if (geo && geo->geo_)
- {
- render_target_->FillGeometry(
- geo->geo_.Get(),
- fill_brush_.Get()
- );
- cache_expired_ = true;
- }
- }
-
void Canvas::BeginPath(Point const& begin_pos)
{
current_geometry_ = nullptr;
@@ -508,4 +481,4 @@ namespace kiwano
return bitmap_cached_;
}
-}
\ No newline at end of file
+}
diff --git a/src/kiwano/2d/Canvas.h b/src/kiwano/2d/Canvas.h
index 436284aa..310db944 100644
--- a/src/kiwano/2d/Canvas.h
+++ b/src/kiwano/2d/Canvas.h
@@ -95,11 +95,6 @@ namespace kiwano
Point const& point /* λ */
);
- // ͼα߿
- void DrawGeometry(
- GeometryPtr geo
- );
-
// Բ
void FillCircle(
const Point& center,
@@ -125,11 +120,6 @@ namespace kiwano
float radius_y
);
- // 伸ͼ
- void FillGeometry(
- GeometryPtr geo
- );
-
// ʼ·
void BeginPath(
Point const& begin_pos /* ·ʼ */
@@ -240,4 +230,4 @@ namespace kiwano
mutable bool cache_expired_;
mutable ComPtr bitmap_cached_;
};
-}
\ No newline at end of file
+}
diff --git a/src/kiwano/2d/GeometryNode.cpp b/src/kiwano/2d/GeometryNode.cpp
deleted file mode 100644
index 8f29e7c1..00000000
--- a/src/kiwano/2d/GeometryNode.cpp
+++ /dev/null
@@ -1,87 +0,0 @@
-// Copyright (c) 2016-2018 Kiwano - Nomango
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-#include "GeometryNode.h"
-#include "../renderer/render.h"
-
-namespace kiwano
-{
- GeometryNode::GeometryNode()
- : fill_color_(Color::White)
- , stroke_color_(Color(Color::Black, 0))
- , stroke_width_(1.f)
- , outline_join_(StrokeStyle::Miter)
- {
- }
-
- GeometryNode::GeometryNode(GeometryPtr geometry)
- : GeometryNode()
- {
- SetGeometry(geometry);
- }
-
- GeometryNode::~GeometryNode()
- {
- }
-
- void GeometryNode::SetGeometry(GeometryPtr geometry)
- {
- geometry_ = geometry;
- }
-
- void GeometryNode::SetFillColor(const Color & color)
- {
- fill_color_ = color;
- }
-
- void GeometryNode::SetStrokeColor(const Color & color)
- {
- stroke_color_ = color;
- }
-
- void GeometryNode::SetStrokeWidth(float width)
- {
- stroke_width_ = std::max(width, 0.f);
- }
-
- void GeometryNode::SetOutlineJoinStyle(StrokeStyle outline_join)
- {
- outline_join_ = outline_join;
- }
-
- void GeometryNode::OnRender()
- {
- if (geometry_ && geometry_->geo_)
- {
- Renderer::Instance()->FillGeometry(
- geometry_->geo_.Get(),
- fill_color_
- );
-
- Renderer::Instance()->DrawGeometry(
- geometry_->geo_,
- stroke_color_,
- stroke_width_,
- outline_join_
- );
- }
- }
-
-}
diff --git a/src/kiwano/2d/GeometryNode.h b/src/kiwano/2d/GeometryNode.h
deleted file mode 100644
index 7228933b..00000000
--- a/src/kiwano/2d/GeometryNode.h
+++ /dev/null
@@ -1,89 +0,0 @@
-// Copyright (c) 2016-2018 Kiwano - Nomango
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-#pragma once
-#include "Geometry.h"
-#include "Node.h"
-
-namespace kiwano
-{
- // ͼ
- class KGE_API GeometryNode
- : public VisualNode
- {
- public:
- GeometryNode();
-
- GeometryNode(
- GeometryPtr geometry
- );
-
- virtual ~GeometryNode();
-
- // ״
- void SetGeometry(
- GeometryPtr geometry
- );
-
- // ɫ
- void SetFillColor(
- const Color& color
- );
-
- // ɫ
- void SetStrokeColor(
- const Color& color
- );
-
- //
- void SetStrokeWidth(
- float width
- );
-
- // ཻʽ
- void SetOutlineJoinStyle(
- StrokeStyle outline_join
- );
-
- // ȡ״
- GeometryPtr GetGeometry() const { return geometry_; }
-
- // ȡɫ
- Color GetFillColor() const { return fill_color_; }
-
- // ȡɫ
- Color GetStrokeColor() const { return stroke_color_; }
-
- // ȡ
- float GetStrokeWidth() const { return stroke_width_; }
-
- // ȡཻʽ
- StrokeStyle SetOutlineJoinStyle() const { return outline_join_; }
-
- void OnRender() override;
-
- protected:
- Color fill_color_;
- Color stroke_color_;
- float stroke_width_;
- StrokeStyle outline_join_;
- GeometryPtr geometry_;
- };
-}
diff --git a/src/kiwano/2d/Geometry.cpp b/src/kiwano/2d/ShapeNode.cpp
similarity index 68%
rename from src/kiwano/2d/Geometry.cpp
rename to src/kiwano/2d/ShapeNode.cpp
index 5c2cfe63..d3bc288f 100644
--- a/src/kiwano/2d/Geometry.cpp
+++ b/src/kiwano/2d/ShapeNode.cpp
@@ -18,25 +18,30 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-#include "Geometry.h"
-#include "../renderer/render.h"
+#include "ShapeNode.h"
#include "../base/logs.h"
namespace kiwano
{
- //-------------------------------------------------------
- // Geometry
- //-------------------------------------------------------
-
- Geometry::Geometry()
+ ShapeNode::ShapeNode()
+ : fill_color_(Color::White)
+ , stroke_color_(Color(Color::Black, 0))
+ , stroke_width_(1.f)
+ , outline_join_(StrokeStyle::Miter)
{
}
- Geometry::~Geometry()
+ ShapeNode::ShapeNode(ComPtr geometry)
+ : ShapeNode()
+ {
+ SetGeometry(geometry);
+ }
+
+ ShapeNode::~ShapeNode()
{
}
- Rect Geometry::GetBoundingBox()
+ Rect ShapeNode::GetBoundingBox()
{
if (!geo_)
return Rect{};
@@ -47,7 +52,7 @@ namespace kiwano
return Rect{ rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top };
}
- float Geometry::GetLength()
+ float ShapeNode::GetLength()
{
float length = 0.f;
if (geo_)
@@ -58,28 +63,23 @@ namespace kiwano
return length;
}
- bool Geometry::ComputePointAt(float length, Point* point, Point* tangent)
+ bool ShapeNode::ComputePointAtLength(float length, Point& point, Vec2& tangent)
{
if (geo_)
{
- D2D1_POINT_2F point_tmp, tangent_tmp;
if (SUCCEEDED(geo_->ComputePointAtLength(
length,
D2D1::Matrix3x2F::Identity(),
- &point_tmp,
- &tangent_tmp)))
+ DX::ConvertToPoint2F(&point),
+ DX::ConvertToPoint2F(&tangent))))
{
- (*point).x = point_tmp.x;
- (*point).y = point_tmp.y;
- (*tangent).x = tangent_tmp.x;
- (*tangent).y = tangent_tmp.y;
return true;
}
}
return false;
}
- float Geometry::ComputeArea()
+ float ShapeNode::ComputeArea()
{
if (!geo_)
return 0.f;
@@ -90,7 +90,7 @@ namespace kiwano
return area;
}
- bool Geometry::ContainsPoint(Point const & point)
+ bool ShapeNode::ContainsPoint(Point const& point)
{
if (!geo_)
return false;
@@ -105,25 +105,62 @@ namespace kiwano
return !!ret;
}
+ void ShapeNode::SetFillColor(const Color & color)
+ {
+ fill_color_ = color;
+ }
+
+ void ShapeNode::SetStrokeColor(const Color & color)
+ {
+ stroke_color_ = color;
+ }
+
+ void ShapeNode::SetStrokeWidth(float width)
+ {
+ stroke_width_ = std::max(width, 0.f);
+ }
+
+ void ShapeNode::SetOutlineJoinStyle(StrokeStyle outline_join)
+ {
+ outline_join_ = outline_join;
+ }
+
+ void ShapeNode::OnRender()
+ {
+ if (geo_)
+ {
+ Renderer::Instance()->FillGeometry(
+ geo_,
+ fill_color_
+ );
+
+ Renderer::Instance()->DrawGeometry(
+ geo_,
+ stroke_color_,
+ stroke_width_,
+ outline_join_
+ );
+ }
+ }
//-------------------------------------------------------
- // LineGeometry
+ // LineNode
//-------------------------------------------------------
- LineGeometry::LineGeometry()
+ LineNode::LineNode()
{
}
- LineGeometry::LineGeometry(Point const & begin, Point const & end)
+ LineNode::LineNode(Point const& begin, Point const& end)
{
SetLine(begin, end);
}
- LineGeometry::~LineGeometry()
+ LineNode::~LineNode()
{
}
- void LineGeometry::SetLine(Point const & begin, Point const & end)
+ void LineNode::SetLine(Point const& begin, Point const& end)
{
ComPtr path_geo;
ComPtr path_sink;
@@ -149,40 +186,40 @@ namespace kiwano
}
}
- void LineGeometry::SetBegin(Point const & begin)
+ void LineNode::SetBegin(Point const& begin)
{
SetLine(begin, end_);
}
- void LineGeometry::SetEnd(Point const & end)
+ void LineNode::SetEnd(Point const& end)
{
SetLine(begin_, end);
}
//-------------------------------------------------------
- // RectangleGeometry
+ // RectNode
//-------------------------------------------------------
- RectangleGeometry::RectangleGeometry()
+ RectNode::RectNode()
{
}
- RectangleGeometry::RectangleGeometry(Rect const & rect)
+ RectNode::RectNode(Rect const& rect)
{
SetRect(rect);
}
- RectangleGeometry::RectangleGeometry(Point const & left_top, Size const & size)
+ RectNode::RectNode(Point const& left_top, Size const& size)
{
SetRect(Rect{ left_top, size });
}
- RectangleGeometry::~RectangleGeometry()
+ RectNode::~RectNode()
{
}
- void RectangleGeometry::SetRect(Rect const & rect)
+ void RectNode::SetRect(Rect const& rect)
{
ComPtr geo;
auto factory = Renderer::Instance()->GetD2DDeviceResources()->GetFactory();
@@ -196,230 +233,35 @@ namespace kiwano
//-------------------------------------------------------
- // CircleGeometry
+ // RoundedRectNode
//-------------------------------------------------------
- CircleGeometry::CircleGeometry()
- : radius_(0.f)
- {
- }
-
- CircleGeometry::CircleGeometry(Point const & center, float radius)
- {
- SetCircle(center, radius);
- }
-
- CircleGeometry::~CircleGeometry()
- {
- }
-
- void CircleGeometry::SetRadius(float radius)
- {
- SetCircle(center_, radius);
- }
-
- void CircleGeometry::SetCenter(Point const & center)
- {
- SetCircle(center, radius_);
- }
-
- void CircleGeometry::SetCircle(Point const & center, float radius)
- {
- ComPtr geo;
- auto factory = Renderer::Instance()->GetD2DDeviceResources()->GetFactory();
-
- if (SUCCEEDED(factory->CreateEllipseGeometry(
- D2D1::Ellipse(
- DX::ConvertToPoint2F(center),
- radius,
- radius),
- &geo)))
- {
- geo_ = geo;
- center_ = center;
- radius_ = radius;
- }
- }
-
-
- //-------------------------------------------------------
- // EllipseGeometry
- //-------------------------------------------------------
-
- EllipseGeometry::EllipseGeometry()
+ RoundedRectNode::RoundedRectNode()
: radius_x_(0.f)
, radius_y_(0.f)
{
}
- EllipseGeometry::EllipseGeometry(Point const & center, float radius_x, float radius_y)
- {
- SetEllipse(center, radius_x, radius_y);
- }
-
- EllipseGeometry::~EllipseGeometry()
- {
- }
-
- void EllipseGeometry::SetRadius(float radius_x, float radius_y)
- {
- SetEllipse(center_, radius_x, radius_y);
- }
-
- void EllipseGeometry::SetCenter(Point const & center)
- {
- SetEllipse(center, radius_x_, radius_y_);
- }
-
- void EllipseGeometry::SetEllipse(Point const & center, float radius_x, float radius_y)
- {
- ComPtr geo;
- auto factory = Renderer::Instance()->GetD2DDeviceResources()->GetFactory();
-
- if (SUCCEEDED(factory->CreateEllipseGeometry(
- D2D1::Ellipse(
- DX::ConvertToPoint2F(center),
- radius_x,
- radius_y),
- &geo)))
- {
- geo_ = geo;
- radius_x_ = radius_x;
- radius_y_ = radius_y;
- }
- }
-
-
- //-------------------------------------------------------
- // PathGeometry
- //-------------------------------------------------------
-
- PathGeometry::PathGeometry()
- {
- }
-
- PathGeometry::~PathGeometry()
- {
- }
-
- void PathGeometry::BeginPath(Point const& begin_pos)
- {
- current_geometry_ = nullptr;
-
- auto factory = Renderer::Instance()->GetD2DDeviceResources()->GetFactory();
-
- ThrowIfFailed(
- factory->CreatePathGeometry(¤t_geometry_)
- );
-
- ThrowIfFailed(
- current_geometry_->Open(¤t_sink_)
- );
-
- current_sink_->BeginFigure(DX::ConvertToPoint2F(begin_pos), D2D1_FIGURE_BEGIN_FILLED);
- }
-
- void PathGeometry::EndPath(bool closed)
- {
- if (current_sink_)
- {
- current_sink_->EndFigure(closed ? D2D1_FIGURE_END_CLOSED : D2D1_FIGURE_END_OPEN);
- ThrowIfFailed(
- current_sink_->Close()
- );
-
- geo_ = current_geometry_;
-
- current_sink_ = nullptr;
- current_geometry_ = nullptr;
- }
- }
-
- void PathGeometry::AddLine(Point const & point)
- {
- if (current_sink_)
- current_sink_->AddLine(DX::ConvertToPoint2F(point));
- }
-
- void PathGeometry::AddLines(Array const& points)
- {
- if (current_sink_ && !points.empty())
- {
- current_sink_->AddLines(
- reinterpret_cast(&points[0]),
- static_cast(points.size())
- );
- }
- }
-
- void PathGeometry::AddBezier(Point const & point1, Point const & point2, Point const & point3)
- {
- if (current_sink_)
- {
- current_sink_->AddBezier(
- D2D1::BezierSegment(
- DX::ConvertToPoint2F(point1),
- DX::ConvertToPoint2F(point2),
- DX::ConvertToPoint2F(point3)
- )
- );
- }
- }
-
- void PathGeometry::AddArc(Point const & point, Size const & radius, float rotation, bool clockwise, bool is_small)
- {
- if (current_sink_)
- {
- current_sink_->AddArc(
- D2D1::ArcSegment(
- DX::ConvertToPoint2F(point),
- DX::ConvertToSizeF(radius),
- rotation,
- clockwise ? D2D1_SWEEP_DIRECTION_CLOCKWISE : D2D1_SWEEP_DIRECTION_COUNTER_CLOCKWISE,
- is_small ? D2D1_ARC_SIZE_SMALL : D2D1_ARC_SIZE_LARGE
- )
- );
- }
- }
-
- void PathGeometry::ClearPath()
- {
- geo_ = nullptr;
- current_sink_ = nullptr;
- current_geometry_ = nullptr;
- }
-
-
- //-------------------------------------------------------
- // RoundedRectGeometry
- //-------------------------------------------------------
-
- RoundedRectGeometry::RoundedRectGeometry()
- : radius_x_(0.f)
- , radius_y_(0.f)
- {
- }
-
- RoundedRectGeometry::RoundedRectGeometry(Rect const & rect, float radius_x, float radius_y)
+ RoundedRectNode::RoundedRectNode(Rect const& rect, float radius_x, float radius_y)
{
SetRoundedRect(rect, radius_x, radius_y);
}
- RoundedRectGeometry::~RoundedRectGeometry()
+ RoundedRectNode::~RoundedRectNode()
{
}
- void RoundedRectGeometry::SetRadius(float radius_x, float radius_y)
+ void RoundedRectNode::SetRadius(float radius_x, float radius_y)
{
SetRoundedRect(rect_, radius_x, radius_y);
}
- void RoundedRectGeometry::SetRect(Rect const & rect)
+ void RoundedRectNode::SetRect(Rect const& rect)
{
SetRoundedRect(rect, radius_x_, radius_y_);
}
- void RoundedRectGeometry::SetRoundedRect(Rect const & rect, float radius_x, float radius_y)
+ void RoundedRectNode::SetRoundedRect(Rect const& rect, float radius_x, float radius_y)
{
ComPtr geo;
auto factory = Renderer::Instance()->GetD2DDeviceResources()->GetFactory();
@@ -439,4 +281,199 @@ namespace kiwano
}
}
-}
\ No newline at end of file
+
+ //-------------------------------------------------------
+ // CircleNode
+ //-------------------------------------------------------
+
+ CircleNode::CircleNode()
+ : radius_(0.f)
+ {
+ }
+
+ CircleNode::CircleNode(Point const& center, float radius)
+ {
+ SetCircle(center, radius);
+ }
+
+ CircleNode::~CircleNode()
+ {
+ }
+
+ void CircleNode::SetRadius(float radius)
+ {
+ SetCircle(center_, radius);
+ }
+
+ void CircleNode::SetCenter(Point const& center)
+ {
+ SetCircle(center, radius_);
+ }
+
+ void CircleNode::SetCircle(Point const& center, float radius)
+ {
+ ComPtr geo;
+ auto factory = Renderer::Instance()->GetD2DDeviceResources()->GetFactory();
+
+ if (SUCCEEDED(factory->CreateEllipseGeometry(
+ D2D1::Ellipse(
+ DX::ConvertToPoint2F(center),
+ radius,
+ radius),
+ &geo)))
+ {
+ geo_ = geo;
+ center_ = center;
+ radius_ = radius;
+ }
+ }
+
+
+ //-------------------------------------------------------
+ // EllipseNode
+ //-------------------------------------------------------
+
+ EllipseNode::EllipseNode()
+ : radius_x_(0.f)
+ , radius_y_(0.f)
+ {
+ }
+
+ EllipseNode::EllipseNode(Point const& center, float radius_x, float radius_y)
+ {
+ SetEllipse(center, radius_x, radius_y);
+ }
+
+ EllipseNode::~EllipseNode()
+ {
+ }
+
+ void EllipseNode::SetRadius(float radius_x, float radius_y)
+ {
+ SetEllipse(center_, radius_x, radius_y);
+ }
+
+ void EllipseNode::SetCenter(Point const& center)
+ {
+ SetEllipse(center, radius_x_, radius_y_);
+ }
+
+ void EllipseNode::SetEllipse(Point const& center, float radius_x, float radius_y)
+ {
+ ComPtr geo;
+ auto factory = Renderer::Instance()->GetD2DDeviceResources()->GetFactory();
+
+ if (SUCCEEDED(factory->CreateEllipseGeometry(
+ D2D1::Ellipse(
+ DX::ConvertToPoint2F(center),
+ radius_x,
+ radius_y),
+ &geo)))
+ {
+ geo_ = geo;
+ radius_x_ = radius_x;
+ radius_y_ = radius_y;
+ }
+ }
+
+
+ //-------------------------------------------------------
+ // PathNode
+ //-------------------------------------------------------
+
+ PathNode::PathNode()
+ {
+ }
+
+ PathNode::~PathNode()
+ {
+ }
+
+ void PathNode::BeginPath(Point const& begin_pos)
+ {
+ current_geometry_ = nullptr;
+
+ auto factory = Renderer::Instance()->GetD2DDeviceResources()->GetFactory();
+
+ ThrowIfFailed(
+ factory->CreatePathGeometry(¤t_geometry_)
+ );
+
+ ThrowIfFailed(
+ current_geometry_->Open(¤t_sink_)
+ );
+
+ current_sink_->BeginFigure(DX::ConvertToPoint2F(begin_pos), D2D1_FIGURE_BEGIN_FILLED);
+ }
+
+ void PathNode::EndPath(bool closed)
+ {
+ if (current_sink_)
+ {
+ current_sink_->EndFigure(closed ? D2D1_FIGURE_END_CLOSED : D2D1_FIGURE_END_OPEN);
+ ThrowIfFailed(
+ current_sink_->Close()
+ );
+
+ geo_ = current_geometry_;
+
+ current_sink_ = nullptr;
+ current_geometry_ = nullptr;
+ }
+ }
+
+ void PathNode::AddLine(Point const& point)
+ {
+ if (current_sink_)
+ current_sink_->AddLine(DX::ConvertToPoint2F(point));
+ }
+
+ void PathNode::AddLines(Array const& points)
+ {
+ if (current_sink_ && !points.empty())
+ {
+ current_sink_->AddLines(
+ reinterpret_cast(&points[0]),
+ static_cast(points.size())
+ );
+ }
+ }
+
+ void PathNode::AddBezier(Point const& point1, Point const& point2, Point const& point3)
+ {
+ if (current_sink_)
+ {
+ current_sink_->AddBezier(
+ D2D1::BezierSegment(
+ DX::ConvertToPoint2F(point1),
+ DX::ConvertToPoint2F(point2),
+ DX::ConvertToPoint2F(point3)
+ )
+ );
+ }
+ }
+
+ void PathNode::AddArc(Point const& point, Size const& radius, float rotation, bool clockwise, bool is_small)
+ {
+ if (current_sink_)
+ {
+ current_sink_->AddArc(
+ D2D1::ArcSegment(
+ DX::ConvertToPoint2F(point),
+ DX::ConvertToSizeF(radius),
+ rotation,
+ clockwise ? D2D1_SWEEP_DIRECTION_CLOCKWISE : D2D1_SWEEP_DIRECTION_COUNTER_CLOCKWISE,
+ is_small ? D2D1_ARC_SIZE_SMALL : D2D1_ARC_SIZE_LARGE
+ )
+ );
+ }
+ }
+
+ void PathNode::ClearPath()
+ {
+ geo_ = nullptr;
+ current_sink_ = nullptr;
+ current_geometry_ = nullptr;
+ }
+
+}
diff --git a/src/kiwano/2d/Geometry.h b/src/kiwano/2d/ShapeNode.h
similarity index 69%
rename from src/kiwano/2d/Geometry.h
rename to src/kiwano/2d/ShapeNode.h
index 6f54a492..75d40318 100644
--- a/src/kiwano/2d/Geometry.h
+++ b/src/kiwano/2d/ShapeNode.h
@@ -19,22 +19,35 @@
// THE SOFTWARE.
#pragma once
-#include "include-forwards.h"
-#include
+#include "Node.h"
+#include "../renderer/render.h" // ID2D1Geometry
namespace kiwano
{
- // γ
- class KGE_API Geometry
- : public Object
+ // άͼνڵ
+ class KGE_API ShapeNode
+ : public VisualNode
{
- friend class Canvas;
- friend class GeometryNode;
-
public:
- Geometry();
+ ShapeNode();
- virtual ~Geometry();
+ ShapeNode(
+ ComPtr geometry
+ );
+
+ virtual ~ShapeNode();
+
+ // ȡɫ
+ Color GetFillColor() const { return fill_color_; }
+
+ // ȡɫ
+ Color GetStrokeColor() const { return stroke_color_; }
+
+ // ȡ
+ float GetStrokeWidth() const { return stroke_width_; }
+
+ // ȡཻʽ
+ StrokeStyle SetOutlineJoinStyle() const { return outline_join_; }
// ȡаΧ
Rect GetBoundingBox();
@@ -47,34 +60,66 @@ namespace kiwano
// ȡͼչһֱߵij
float GetLength();
- // ͼ·ϵλú
- bool ComputePointAt(
- float length,
- Point* point,
- Point* tangent
- );
-
//
float ComputeArea();
+ // ͼ·ϵλú
+ bool ComputePointAtLength(
+ float length,
+ Point& point,
+ Vec2& tangent
+ );
+
+ // ɫ
+ void SetFillColor(
+ const Color& color
+ );
+
+ // ɫ
+ void SetStrokeColor(
+ const Color& color
+ );
+
+ //
+ void SetStrokeWidth(
+ float width
+ );
+
+ // ཻʽ
+ void SetOutlineJoinStyle(
+ StrokeStyle outline_join
+ );
+
+ // ״
+ inline void SetGeometry(ComPtr geometry) { geo_ = geometry; }
+
+ // ȡ״
+ inline ComPtr GetGeometry() const { return geo_; }
+
+ void OnRender() override;
+
protected:
- ComPtr geo_;
+ Color fill_color_;
+ Color stroke_color_;
+ float stroke_width_;
+ StrokeStyle outline_join_;
+ ComPtr geo_;
};
// ֱ
- class KGE_API LineGeometry
- : public Geometry
+ class KGE_API LineNode
+ : public ShapeNode
{
public:
- LineGeometry();
+ LineNode();
- LineGeometry(
+ LineNode(
Point const& begin,
Point const& end
);
- virtual ~LineGeometry();
+ virtual ~LineNode();
Point const& GetBegin() const { return begin_; }
@@ -99,23 +144,23 @@ namespace kiwano
};
- // ξ
- class KGE_API RectangleGeometry
- : public Geometry
+ // νڵ
+ class KGE_API RectNode
+ : public ShapeNode
{
public:
- RectangleGeometry();
+ RectNode();
- RectangleGeometry(
+ RectNode(
Rect const& rect
);
- RectangleGeometry(
+ RectNode(
Point const& left_top,
Size const& size
);
- virtual ~RectangleGeometry();
+ virtual ~RectNode();
Rect const& GetRect() const { return rect_; }
@@ -126,19 +171,62 @@ namespace kiwano
};
- // Բ
- class KGE_API CircleGeometry
- : public Geometry
+ // ԲǾνڵ
+ class KGE_API RoundedRectNode
+ : public ShapeNode
{
public:
- CircleGeometry();
+ RoundedRectNode();
- CircleGeometry(
+ RoundedRectNode(
+ Rect const& rect,
+ float radius_x,
+ float radius_y
+ );
+
+ virtual ~RoundedRectNode();
+
+ float GetRadiusX() const { return radius_x_; }
+
+ float GetRadiusY() const { return radius_y_; }
+
+ void SetRadius(
+ float radius_x,
+ float radius_y
+ );
+
+ Rect const& GetRect() const { return rect_; }
+
+ void SetRect(
+ Rect const& rect
+ );
+
+ void SetRoundedRect(
+ Rect const& rect,
+ float radius_x,
+ float radius_y
+ );
+
+ protected:
+ Rect rect_;
+ float radius_x_;
+ float radius_y_;
+ };
+
+
+ // Բνڵ
+ class KGE_API CircleNode
+ : public ShapeNode
+ {
+ public:
+ CircleNode();
+
+ CircleNode(
Point const& center,
float radius
);
- virtual ~CircleGeometry();
+ virtual ~CircleNode();
float GetRadius() const { return radius_; }
@@ -163,20 +251,20 @@ namespace kiwano
};
- // Բ
- class KGE_API EllipseGeometry
- : public Geometry
+ // Բڵ
+ class KGE_API EllipseNode
+ : public ShapeNode
{
public:
- EllipseGeometry();
+ EllipseNode();
- EllipseGeometry(
+ EllipseNode(
Point const& center,
float radius_x,
float radius_y
);
- virtual ~EllipseGeometry();
+ virtual ~EllipseNode();
float GetRadiusX() const { return radius_x_; }
@@ -206,14 +294,14 @@ namespace kiwano
};
- // ·
- class KGE_API PathGeometry
- : public Geometry
+ // ·ڵ
+ class KGE_API PathNode
+ : public ShapeNode
{
public:
- PathGeometry();
+ PathNode();
- virtual ~PathGeometry();
+ virtual ~PathNode();
// ʼ·
void BeginPath(
@@ -259,46 +347,4 @@ namespace kiwano
ComPtr current_sink_;
};
-
- // ԲǾ
- class KGE_API RoundedRectGeometry
- : public Geometry
- {
- public:
- RoundedRectGeometry();
-
- RoundedRectGeometry(
- Rect const& rect,
- float radius_x,
- float radius_y
- );
-
- virtual ~RoundedRectGeometry();
-
- float GetRadiusX() const { return radius_x_; }
-
- float GetRadiusY() const { return radius_y_; }
-
- void SetRadius(
- float radius_x,
- float radius_y
- );
-
- Rect const& GetRect() const { return rect_; }
-
- void SetRect(
- Rect const& rect
- );
-
- void SetRoundedRect(
- Rect const& rect,
- float radius_x,
- float radius_y
- );
-
- protected:
- Rect rect_;
- float radius_x_;
- float radius_y_;
- };
}
diff --git a/src/kiwano/2d/include-forwards.h b/src/kiwano/2d/include-forwards.h
index 16607b34..620fb3da 100644
--- a/src/kiwano/2d/include-forwards.h
+++ b/src/kiwano/2d/include-forwards.h
@@ -38,14 +38,6 @@ namespace kiwano
KGE_DECLARE_SMART_PTR(GifImage);
KGE_DECLARE_SMART_PTR(Frames);
- KGE_DECLARE_SMART_PTR(Geometry);
- KGE_DECLARE_SMART_PTR(LineGeometry);
- KGE_DECLARE_SMART_PTR(RectangleGeometry);
- KGE_DECLARE_SMART_PTR(RoundedRectGeometry);
- KGE_DECLARE_SMART_PTR(CircleGeometry);
- KGE_DECLARE_SMART_PTR(EllipseGeometry);
- KGE_DECLARE_SMART_PTR(PathGeometry);
-
KGE_DECLARE_SMART_PTR(Node);
KGE_DECLARE_SMART_PTR(Scene);
KGE_DECLARE_SMART_PTR(Layer);
@@ -53,7 +45,13 @@ namespace kiwano
KGE_DECLARE_SMART_PTR(GifSprite);
KGE_DECLARE_SMART_PTR(Text);
KGE_DECLARE_SMART_PTR(Canvas);
- KGE_DECLARE_SMART_PTR(GeometryNode);
+ KGE_DECLARE_SMART_PTR(ShapeNode);
+ KGE_DECLARE_SMART_PTR(LineNode);
+ KGE_DECLARE_SMART_PTR(RectNode);
+ KGE_DECLARE_SMART_PTR(RoundedRectNode);
+ KGE_DECLARE_SMART_PTR(CircleNode);
+ KGE_DECLARE_SMART_PTR(EllipseNode);
+ KGE_DECLARE_SMART_PTR(PathNode);
KGE_DECLARE_SMART_PTR(Action);
KGE_DECLARE_SMART_PTR(ActionTween);
diff --git a/src/kiwano/kiwano.h b/src/kiwano/kiwano.h
index 85f7450f..30489ed3 100644
--- a/src/kiwano/kiwano.h
+++ b/src/kiwano/kiwano.h
@@ -85,7 +85,6 @@
#include "2d/Image.h"
#include "2d/GifImage.h"
#include "2d/Frames.h"
-#include "2d/Geometry.h"
#include "2d/Action.h"
#include "2d/ActionGroup.h"
#include "2d/ActionTween.h"
@@ -101,7 +100,7 @@
#include "2d/GifSprite.h"
#include "2d/Text.h"
#include "2d/Canvas.h"
-#include "2d/GeometryNode.h"
+#include "2d/ShapeNode.h"
#include "2d/DebugNode.h"
diff --git a/src/kiwano/renderer/helper.hpp b/src/kiwano/renderer/helper.hpp
index 47098a76..ec536fdf 100644
--- a/src/kiwano/renderer/helper.hpp
+++ b/src/kiwano/renderer/helper.hpp
@@ -38,36 +38,110 @@ namespace kiwano
}
}
- inline D2D1_POINT_2F const& ConvertToPoint2F(Vec2 const& point)
+ //
+ // Point2F
+ //
+
+ inline D2D1_POINT_2F const& ConvertToPoint2F(Vec2 const& vec2)
{
- return reinterpret_cast(point);
+ return reinterpret_cast(vec2);
}
- inline D2D1_SIZE_F const& ConvertToSizeF(Vec2 const& size)
+ inline D2D1_POINT_2F& ConvertToPoint2F(Vec2& vec2)
{
- return reinterpret_cast(size);
+ return reinterpret_cast(vec2);
}
+ inline const D2D1_POINT_2F* ConvertToPoint2F(const Vec2* vec2)
+ {
+ return reinterpret_cast(vec2);
+ }
+
+ inline D2D1_POINT_2F* ConvertToPoint2F(Vec2* vec2)
+ {
+ return reinterpret_cast(vec2);
+ }
+
+ //
+ // SizeF
+ //
+
+ inline D2D1_SIZE_F const& ConvertToSizeF(Vec2 const& vec2)
+ {
+ return reinterpret_cast(vec2);
+ }
+
+ inline D2D1_SIZE_F& ConvertToSizeF(Vec2& vec2)
+ {
+ return reinterpret_cast(vec2);
+ }
+
+ inline const D2D1_SIZE_F* ConvertToSizeF(const Vec2* vec2)
+ {
+ return reinterpret_cast(vec2);
+ }
+
+ inline D2D1_SIZE_F* ConvertToSizeF(Vec2* vec2)
+ {
+ return reinterpret_cast(vec2);
+ }
+
+ //
+ // SizeF
+ //
+
inline D2D1_RECT_F ConvertToRectF(Rect const& rect)
{
return D2D1_RECT_F{ rect.origin.x, rect.origin.y, rect.origin.x + rect.size.x, rect.origin.y + rect.size.y };
}
+ //
+ // SizeF
+ //
inline D2D1_COLOR_F const& ConvertToColorF(Color const& color)
{
return reinterpret_cast(color);
}
+ inline D2D1_COLOR_F& ConvertToColorF(Color& color)
+ {
+ return reinterpret_cast(color);
+ }
+
+ inline const D2D1_COLOR_F* ConvertToColorF(const Color* color)
+ {
+ return reinterpret_cast(color);
+ }
+
+ inline D2D1_COLOR_F* ConvertToColorF(Color* color)
+ {
+ return reinterpret_cast(color);
+ }
+
+ //
+ // SizeF
+ //
+
inline D2D1_MATRIX_3X2_F const& ConvertToMatrix3x2F(Matrix const& matrix)
{
return reinterpret_cast(matrix);
}
+ inline D2D1_MATRIX_3X2_F& ConvertToMatrix3x2F(Matrix& matrix)
+ {
+ return reinterpret_cast(matrix);
+ }
+
inline const D2D1_MATRIX_3X2_F* ConvertToMatrix3x2F(const Matrix* matrix)
{
return reinterpret_cast(matrix);
}
+ inline D2D1_MATRIX_3X2_F* ConvertToMatrix3x2F(Matrix* matrix)
+ {
+ return reinterpret_cast(matrix);
+ }
+
// Converts a length in device-independent pixels (DIPs) to a length in physical pixels.
inline float ConvertDipsToPixels(float dips, float dpi)
{
diff --git a/src/kiwano/renderer/render.cpp b/src/kiwano/renderer/render.cpp
index d2f7f493..a447b760 100644
--- a/src/kiwano/renderer/render.cpp
+++ b/src/kiwano/renderer/render.cpp
@@ -179,7 +179,10 @@ namespace kiwano
device_context_->SaveDrawingState(drawing_state_block_.Get());
device_context_->BeginDraw();
- return S_OK;
+
+ HRESULT hr = d3d_res_->ClearRenderTarget(clear_color_);
+
+ return hr;
}
HRESULT Renderer::EndDraw()
@@ -196,11 +199,6 @@ namespace kiwano
hr = d3d_res_->Present(vsync_);
}
- if (SUCCEEDED(hr))
- {
- hr = d3d_res_->ClearRenderTarget(clear_color_);
- }
-
if (hr == DXGI_ERROR_DEVICE_REMOVED || hr == DXGI_ERROR_DEVICE_RESET)
{
// Direct3D 豸ִйʧǰ豸Դ