• R/O
  • HTTP
  • SSH
  • HTTPS

コミット

タグ
未設定

よく使われているワード(クリックで追加)

javaandroidc++linuxc#objective-ccocoa誰得qtrubybathyscaphegamepythonphpguiwindowsc翻訳omegattwitterframeworkbtronarduinovb.net計画中(planning stage)directxpreviewertestゲームエンジンdom

Simple C++ UI framework and more...


コミットメタ情報

リビジョンd154cfb461897095525dec78d30625d328b3354c (tree)
日時2018-06-10 16:05:24
作者Starg <starg@user...>
コミッターStarg

ログメッセージ

PCH and unity build support

変更サマリ

差分

--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -5,11 +5,18 @@ cmake_minimum_required(VERSION 3.9)
55
66 project(sirius)
77
8+# ====
9+
810 set(SIRIUS_LIBRARY_TYPE "SHARED" CACHE STRING "Library kind")
911 set_property(CACHE SIRIUS_LIBRARY_TYPE PROPERTY STRINGS SHARED STATIC OBJECT)
1012
1113 set(SIRIUS_USE_AVX2 "OFF" CACHE BOOL "Enable use of Intel AVX2 enhanced instructions")
1214
15+set(SIRIUS_UNITY_BUILD "OFF" CACHE BOOL "Do unity build")
16+set(SIRIUS_USE_PCH "OFF" CACHE BOOL "Use precompiled headers")
17+
18+# ====
19+
1320 if("${SIRIUS_USE_AVX2}")
1421 add_definitions(-DSIRIUS_X86_SIMD_LEVEL=SIRIUS_X86_SIMD_LEVEL_AVX2)
1522 else()
@@ -43,7 +50,7 @@ else()
4350 add_compile_options(-msse4.2)
4451 endif()
4552
46- add_compile_options(-Wall -Wextra -ffast-math -msse4.2)
53+ add_compile_options(-Wall -Wextra -ffast-math)
4754
4855 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
4956 set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -flto")
--- /dev/null
+++ b/include/sirius.hpp
@@ -0,0 +1,15 @@
1+// Copyright 2018 Starg
2+// Distributed under the 3-Clause BSD License.
3+
4+#pragma once
5+
6+#include "sirius/animation.hpp"
7+#include "sirius/array_view.hpp"
8+#include "sirius/event.hpp"
9+#include "sirius/intrinsics.hpp"
10+#include "sirius/platform_window.hpp"
11+#include "sirius/platform_window_factory.hpp"
12+#include "sirius/renderer.hpp"
13+#include "sirius/simpletypes.hpp"
14+#include "sirius/uimanager.hpp"
15+#include "sirius/widget.hpp"
--- /dev/null
+++ b/include/sirius/platform_window.hpp
@@ -0,0 +1,51 @@
1+// Copyright 2018 Starg
2+// Distributed under the 3-Clause BSD License.
3+
4+#pragma once
5+
6+#include <memory>
7+#include <utility>
8+
9+#include "sirius/event.hpp"
10+#include "sirius/widget.hpp"
11+
12+namespace Sirius
13+{
14+
15+class UIManager;
16+class PlatformWindow;
17+
18+class SIRIUS_DLLEXPORT PlatformWindowBackEnd
19+{
20+public:
21+ PlatformWindowBackEnd() = default;
22+ PlatformWindowBackEnd(const PlatformWindowBackEnd&) = delete;
23+ PlatformWindowBackEnd& operator=(const PlatformWindowBackEnd&) = delete;
24+ virtual ~PlatformWindowBackEnd() = default;
25+
26+ virtual void Initialize(PlatformWindow* pPlatformWindow);
27+
28+ PlatformWindow& GetPlatformWindow() const
29+ {
30+ return *m_pPlatformWindow;
31+ }
32+
33+private:
34+ PlatformWindow* m_pPlatformWindow = nullptr;
35+};
36+
37+class SIRIUS_DLLEXPORT PlatformWindow : public Widget
38+{
39+public:
40+ explicit PlatformWindow(UIManager& uiManager);
41+ PlatformWindow(const PlatformWindow&) = delete;
42+ PlatformWindow& operator=(const PlatformWindow&) = delete;
43+ virtual ~PlatformWindow() = default;
44+
45+ virtual void OnEvent(EventID id, EventArgs* pArgs) override;
46+
47+private:
48+ std::unique_ptr<PlatformWindowBackEnd> m_pBackEnd;
49+};
50+
51+} // namespace Sirius
--- /dev/null
+++ b/include/sirius/platform_window_factory.hpp
@@ -0,0 +1,24 @@
1+// Copyright 2018 Starg
2+// Distributed under the 3-Clause BSD License.
3+
4+#pragma once
5+
6+#include <memory>
7+
8+namespace Sirius
9+{
10+
11+class PlatformWindowBackEnd;
12+
13+class SIRIUS_DLLEXPORT PlatformWindowFactory
14+{
15+public:
16+ PlatformWindowFactory() = default;
17+ PlatformWindowFactory(const PlatformWindowFactory&) = delete;
18+ PlatformWindowFactory& operator=(const PlatformWindowFactory&) = delete;
19+ virtual ~PlatformWindowFactory() = default;
20+
21+ virtual std::unique_ptr<PlatformWindowBackEnd> CreateBackEnd() = 0;
22+};
23+
24+} // namespace Sirius
--- a/include/sirius/uimanager.hpp
+++ b/include/sirius/uimanager.hpp
@@ -4,32 +4,31 @@
44 #pragma once
55
66 #include <memory>
7-#include <vector>
8-
9-#include "sirius/animation.hpp"
10-#include "sirius/event.hpp"
117
128 namespace Sirius
139 {
1410
11+class EventManager;
12+class AnimationManager;
1513 class Widget;
14+class PlatformWindowFactory;
1615
1716 class SIRIUS_DLLEXPORT UIManager
1817 {
1918 public:
20- UIManager() = default;
19+ UIManager();
2120 UIManager(const UIManager&) = delete;
2221 UIManager& operator=(const UIManager&) = delete;
23- ~UIManager() = default;
22+ ~UIManager();
2423
2524 EventManager& GetEventManager()
2625 {
27- return m_EventManager;
26+ return *m_pEventManager;
2827 }
2928
3029 AnimationManager& GetAnimationManager()
3130 {
32- return m_AnimationManager;
31+ return *m_pAnimationManager;
3332 }
3433
3534 std::weak_ptr<Widget> GetFocusedWidget() const
@@ -52,12 +51,21 @@ public:
5251 m_pCapturedWidget = p;
5352 }
5453
54+ PlatformWindowFactory& GetPlatformWindowFactory() const
55+ {
56+ return *m_pPlatformWindowFactory;
57+ }
58+
59+ void SetPlatformWindowFactory(std::unique_ptr<PlatformWindowFactory> p);
60+
5561 private:
56- EventManager m_EventManager;
57- AnimationManager m_AnimationManager;
62+ std::unique_ptr<EventManager> m_pEventManager;
63+ std::unique_ptr<AnimationManager> m_pAnimationManager;
5864
5965 std::weak_ptr<Widget> m_pFocusedWidget;
6066 std::weak_ptr<Widget> m_pCapturedWidget;
67+
68+ std::unique_ptr<PlatformWindowFactory> m_pPlatformWindowFactory;
6169 };
6270
6371 } // namespace Sirius
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,23 +1,75 @@
11 # Copyright 2018 Starg
22 # Distributed under the 3-Clause BSD License.
33
4-add_library(
5- sirius ${SIRIUS_LIBRARY_TYPE}
4+set(
5+ SIRIUS_HEADERS
66
7+ ../include/sirius.hpp
78 ../include/sirius/animation.hpp
89 ../include/sirius/array_view.hpp
910 ../include/sirius/event.hpp
1011 ../include/sirius/intrinsics.hpp
12+ ../include/sirius/platform_window.hpp
13+ ../include/sirius/platform_window_factory.hpp
1114 ../include/sirius/renderer.hpp
1215 ../include/sirius/simpletypes.hpp
1316 ../include/sirius/uimanager.hpp
1417 ../include/sirius/widget.hpp
18+)
19+
20+set(
21+ SIRIUS_INDIVIDUAL_BUILD_SOURCES
1522
1623 animation.cpp
1724 event.cpp
25+ platform_window.cpp
26+ uimanager.cpp
1827 widget.cpp
1928 )
2029
30+set(SIRIUS_UNITY_BUILD_SOURCES all.cpp)
31+
32+set(SIRIUS_SOURCES ${SIRIUS_INDIVIDUAL_BUILD_SOURCES} ${SIRIUS_UNITY_BUILD_SOURCES})
33+
34+set(SIRIUS_PCH_HEADER_NAME "${CMAKE_CURRENT_SOURCE_DIR}/pch.hpp")
35+set(SIRIUS_PCH_SOURCE_NAME pch.cpp)
36+set(SIRIUS_PCH_PCH_NAME "${CMAKE_CURRENT_BINARY_DIR}/pch.pch")
37+
38+if("${SIRIUS_UNITY_BUILD}")
39+ set_source_files_properties(${SIRIUS_INDIVIDUAL_BUILD_SOURCES} PROPERTIES HEADER_FILE_ONLY TRUE)
40+else()
41+ set_source_files_properties(${SIRIUS_UNITY_BUILD_SOURCES} PROPERTIES HEADER_FILE_ONLY TRUE)
42+endif()
43+
44+if("${SIRIUS_USE_PCH}")
45+ if(MSVC)
46+ set_source_files_properties(
47+ ${SIRIUS_PCH_SOURCE_NAME}
48+ PROPERTIES
49+ COMPILE_FLAGS "/FI\"${SIRIUS_PCH_HEADER_NAME}\" /Fp\"${SIRIUS_PCH_PCH_NAME}\" /Yc\"${SIRIUS_PCH_HEADER_NAME}\""
50+ OBJECT_OUTPUTS "${SIRIUS_PCH_PCH_NAME}"
51+ )
52+
53+ set_source_files_properties(
54+ ${SIRIUS_SOURCES}
55+ PROPERTIES
56+ COMPILE_FLAGS "/FI\"${SIRIUS_PCH_HEADER_NAME}\" /Fp\"${SIRIUS_PCH_PCH_NAME}\" /Yu\"${SIRIUS_PCH_HEADER_NAME}\""
57+ OBJECT_DEPENDS "${SIRIUS_PCH_PCH_NAME}"
58+ )
59+
60+ list(APPEND SIRIUS_SOURCES ${SIRIUS_PCH_SOURCE_NAME})
61+ else()
62+ message(WARNING "PCH support is not implemented for this target")
63+ endif()
64+endif()
65+
66+add_library(
67+ sirius ${SIRIUS_LIBRARY_TYPE}
68+
69+ ${SIRIUS_HEADERS}
70+ ${SIRIUS_SOURCES}
71+)
72+
2173 if(WIN32 AND ("${SIRIUS_LIBRARY_TYPE}" STREQUAL "SHARED"))
2274 target_compile_definitions(
2375 sirius
--- /dev/null
+++ b/src/all.cpp
@@ -0,0 +1,10 @@
1+// Copyright 2018 Starg
2+// Distributed under the 3-Clause BSD License.
3+
4+// source file for "unity build"
5+
6+#include "animation.cpp"
7+#include "event.cpp"
8+#include "platform_window.cpp"
9+#include "uimanager.cpp"
10+#include "widget.cpp"
--- a/src/animation.cpp
+++ b/src/animation.cpp
@@ -1,8 +1,6 @@
11 // Copyright 2018 Starg
22 // Distributed under the 3-Clause BSD License.
33
4-#include "sirius/animation.hpp"
5-
64 #include <cassert>
75 #include <cmath>
86
@@ -10,6 +8,8 @@
108 #include <iterator>
119 #include <stdexcept>
1210
11+#include "sirius/animation.hpp"
12+
1313 namespace Sirius
1414 {
1515
--- /dev/null
+++ b/src/pch.cpp
@@ -0,0 +1,2 @@
1+// Copyright 2018 Starg
2+// Distributed under the 3-Clause BSD License.
--- /dev/null
+++ b/src/pch.hpp
@@ -0,0 +1,32 @@
1+// Copyright 2018 Starg
2+// Distributed under the 3-Clause BSD License.
3+
4+#pragma once
5+
6+#include <cassert>
7+#include <cstddef>
8+#include <cstdint>
9+
10+#include <algorithm>
11+#include <atomic>
12+#include <chrono>
13+#include <functional>
14+#include <future>
15+#include <iterator>
16+#include <limits>
17+#include <memory>
18+#include <mutex>
19+#include <optional>
20+#include <stdexcept>
21+#include <string>
22+#include <string_view>
23+#include <type_traits>
24+#include <utility>
25+#include <variant>
26+#include <vector>
27+
28+#ifdef _MSC_VER
29+#include <intrin.h>
30+#elif defined(_M_IX86) || defined(__i386__) || defined(_M_X64) || defined(__x86_64__)
31+#include <x86intrin.h>
32+#endif
--- /dev/null
+++ b/src/platform_window.cpp
@@ -0,0 +1,27 @@
1+// Copyright 2018 Starg
2+// Distributed under the 3-Clause BSD License.
3+
4+#include "sirius/platform_window.hpp"
5+#include "sirius/platform_window_factory.hpp"
6+#include "sirius/uimanager.hpp"
7+
8+namespace Sirius
9+{
10+
11+void PlatformWindowBackEnd::Initialize(PlatformWindow* pPlatformWindow)
12+{
13+ m_pPlatformWindow = pPlatformWindow;
14+}
15+
16+PlatformWindow::PlatformWindow(UIManager& uiManager)
17+ : Widget(uiManager), m_pBackEnd(uiManager.GetPlatformWindowFactory().CreateBackEnd())
18+{
19+ m_pBackEnd->Initialize(this);
20+}
21+
22+void PlatformWindow::OnEvent(EventID id, EventArgs* pArgs)
23+{
24+ Widget::OnEvent(id, pArgs);
25+}
26+
27+} // namespace Sirius
--- /dev/null
+++ b/src/uimanager.cpp
@@ -0,0 +1,28 @@
1+// Copyright 2018 Starg
2+// Distributed under the 3-Clause BSD License.
3+
4+#include <memory>
5+#include <utility>
6+
7+#include "sirius/animation.hpp"
8+#include "sirius/event.hpp"
9+#include "sirius/platform_window_factory.hpp"
10+#include "sirius/uimanager.hpp"
11+
12+namespace Sirius
13+{
14+
15+UIManager::UIManager()
16+ : m_pEventManager(std::make_unique<EventManager>()),
17+ m_pAnimationManager(std::make_unique<AnimationManager>())
18+{
19+}
20+
21+UIManager::~UIManager() = default;
22+
23+void UIManager::SetPlatformWindowFactory(std::unique_ptr<PlatformWindowFactory> p)
24+{
25+ m_pPlatformWindowFactory = std::move(p);
26+}
27+
28+} // namespace Sirius