aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/cru/common/Base.hpp2
-rw-r--r--include/cru/common/Logger.hpp14
-rw-r--r--include/cru/common/String.hpp2
-rw-r--r--include/cru/osx/graphics/quartz/Font.hpp2
-rw-r--r--include/cru/osx/graphics/quartz/Resource.hpp2
-rw-r--r--include/cru/ui/helper/ShortcutHub.hpp4
-rw-r--r--include/cru/ui/render/BorderRenderObject.hpp2
-rw-r--r--src/common/Logger.cpp4
-rw-r--r--src/osx/CMakeLists.txt5
-rw-r--r--src/osx/graphics/quartz/Factory.cpp21
-rw-r--r--src/osx/graphics/quartz/Font.cpp2
-rw-r--r--src/osx/graphics/quartz/TextLayout.cpp2
-rw-r--r--src/osx/gui/CMakeLists.txt4
-rw-r--r--src/ui/Helper.cpp2
14 files changed, 51 insertions, 17 deletions
diff --git a/include/cru/common/Base.hpp b/include/cru/common/Base.hpp
index 2f76385e..174ac037 100644
--- a/include/cru/common/Base.hpp
+++ b/include/cru/common/Base.hpp
@@ -96,5 +96,5 @@ inline void hash_combine(std::size_t& s, const T& v) {
#define CRU_DEFINE_CLASS_LOG_TAG(tag) \
private: \
- constexpr static std::u16string_view log_tag = tag;
+ constexpr static StringView log_tag = tag;
} // namespace cru
diff --git a/include/cru/common/Logger.hpp b/include/cru/common/Logger.hpp
index 5aea5126..3dabeb91 100644
--- a/include/cru/common/Logger.hpp
+++ b/include/cru/common/Logger.hpp
@@ -13,7 +13,7 @@ enum class LogLevel { Debug, Info, Warn, Error };
struct CRU_BASE_API ILogSource : virtual Interface {
// Write the string s. LogLevel is just a helper. It has no effect on the
// content to write.
- virtual void Write(LogLevel level, const String& s) = 0;
+ virtual void Write(LogLevel level, StringView s) = 0;
};
class CRU_BASE_API Logger : public Object {
@@ -33,8 +33,8 @@ class CRU_BASE_API Logger : public Object {
void RemoveSource(ILogSource* source);
public:
- void Log(LogLevel level, const String& message);
- void Log(LogLevel level, const String& tag, const String& message);
+ void Log(LogLevel level, StringView message);
+ void Log(LogLevel level, StringView tag, StringView message);
private:
std::list<std::unique_ptr<ILogSource>> sources_;
@@ -69,7 +69,7 @@ void Error(TArgs&&... args) {
// TODO: Remove argument evaluation in Debug.
template <typename... TArgs>
-void TagDebug([[maybe_unused]] std::u16string_view tag,
+void TagDebug([[maybe_unused]] StringView tag,
[[maybe_unused]] TArgs&&... args) {
#ifdef CRU_DEBUG
Logger::GetInstance()->Log(LogLevel::Debug, tag,
@@ -78,19 +78,19 @@ void TagDebug([[maybe_unused]] std::u16string_view tag,
}
template <typename... TArgs>
-void TagInfo(std::u16string_view tag, TArgs&&... args) {
+void TagInfo(StringView tag, TArgs&&... args) {
Logger::GetInstance()->Log(LogLevel::Info, tag,
Format(std::forward<TArgs>(args)...));
}
template <typename... TArgs>
-void TagWarn(std::u16string_view tag, TArgs&&... args) {
+void TagWarn(StringView tag, TArgs&&... args) {
Logger::GetInstance()->Log(LogLevel::Warn, tag,
Format(std::forward<TArgs>(args)...));
}
template <typename... TArgs>
-void TagError(std::u16string_view tag, TArgs&&... args) {
+void TagError(StringView tag, TArgs&&... args) {
Logger::GetInstance()->Log(LogLevel::Error, tag,
Format(std::forward<TArgs>(args)...));
}
diff --git a/include/cru/common/String.hpp b/include/cru/common/String.hpp
index f407cb60..58abc517 100644
--- a/include/cru/common/String.hpp
+++ b/include/cru/common/String.hpp
@@ -372,6 +372,8 @@ inline void String::append(StringView str) {
}
inline String String::From(StringView str) { return str.ToString(); }
+
+inline String ToString(StringView value) { return value.ToString(); }
} // namespace cru
template <>
diff --git a/include/cru/osx/graphics/quartz/Font.hpp b/include/cru/osx/graphics/quartz/Font.hpp
index 75eeff60..1ea2b891 100644
--- a/include/cru/osx/graphics/quartz/Font.hpp
+++ b/include/cru/osx/graphics/quartz/Font.hpp
@@ -17,6 +17,8 @@ class OsxCTFont : public OsxQuartzResource, public virtual IFont {
CTFontRef GetCTFont() const { return ct_font_; }
+ float GetFontSize() override;
+
private:
CTFontRef ct_font_;
};
diff --git a/include/cru/osx/graphics/quartz/Resource.hpp b/include/cru/osx/graphics/quartz/Resource.hpp
index d7038274..8b8f8bbc 100644
--- a/include/cru/osx/graphics/quartz/Resource.hpp
+++ b/include/cru/osx/graphics/quartz/Resource.hpp
@@ -17,7 +17,7 @@ class OsxQuartzResource : public platform::osx::OsxResource,
public:
String GetPlatformId() const override { return u"OSX Quartz"; }
- IGraphicsFactory* GetGraphicsFactory() override;
+ IGraphicsFactory* GetGraphicsFactory() override { return graphics_factory_; }
private:
IGraphicsFactory* graphics_factory_;
diff --git a/include/cru/ui/helper/ShortcutHub.hpp b/include/cru/ui/helper/ShortcutHub.hpp
index fe3414fe..7f098a6d 100644
--- a/include/cru/ui/helper/ShortcutHub.hpp
+++ b/include/cru/ui/helper/ShortcutHub.hpp
@@ -45,8 +45,8 @@ class ShortcutKeyBind {
return !this->operator==(other);
}
- std::u16string ToString() {
- std::u16string result = u"(";
+ String ToString() {
+ String result = u"(";
result += platform::gui::ToString(modifier_);
result += u")";
result += platform::gui::ToString(key_);
diff --git a/include/cru/ui/render/BorderRenderObject.hpp b/include/cru/ui/render/BorderRenderObject.hpp
index 34ad71d6..5bed3cb0 100644
--- a/include/cru/ui/render/BorderRenderObject.hpp
+++ b/include/cru/ui/render/BorderRenderObject.hpp
@@ -2,7 +2,7 @@
#include <string_view>
#include "../style/ApplyBorderStyleInfo.hpp"
#include "RenderObject.hpp"
-#include "cru/platform/GraphBase.hpp"
+#include "cru/platform/GraphicsBase.hpp"
#include "cru/ui/Base.hpp"
namespace cru::ui::render {
diff --git a/src/common/Logger.cpp b/src/common/Logger.cpp
index e77e8a85..6ba5d578 100644
--- a/src/common/Logger.cpp
+++ b/src/common/Logger.cpp
@@ -53,7 +53,7 @@ String GetLogTime() {
}
} // namespace
-void Logger::Log(LogLevel level, const String &message) {
+void Logger::Log(LogLevel level, StringView message) {
#ifndef CRU_DEBUG
if (level == LogLevel::Debug) {
return;
@@ -65,7 +65,7 @@ void Logger::Log(LogLevel level, const String &message) {
}
}
-void Logger::Log(LogLevel level, const String &tag, const String &message) {
+void Logger::Log(LogLevel level, StringView tag, StringView message) {
#ifndef CRU_DEBUG
if (level == LogLevel::Debug) {
return;
diff --git a/src/osx/CMakeLists.txt b/src/osx/CMakeLists.txt
index cb6c2b1a..5d20c2ec 100644
--- a/src/osx/CMakeLists.txt
+++ b/src/osx/CMakeLists.txt
@@ -10,7 +10,10 @@ target_sources(cru_osx_base PUBLIC
${CRU_OSX_BASE_INCLUDE_DIR}/Resource.hpp
)
-target_link_libraries(cru_osx_base PUBLIC cru_platform_base)
+find_library(FOUNDATION Foundation REQUIRED)
+find_library(CORE_FOUNDATION CoreFoundation REQUIRED)
+
+target_link_libraries(cru_osx_base PUBLIC cru_platform_base ${FOUNDATION} ${CORE_FOUNDATION})
add_subdirectory(graphics)
add_subdirectory(gui)
diff --git a/src/osx/graphics/quartz/Factory.cpp b/src/osx/graphics/quartz/Factory.cpp
index 72dd96c7..7aef9d7e 100644
--- a/src/osx/graphics/quartz/Factory.cpp
+++ b/src/osx/graphics/quartz/Factory.cpp
@@ -1,6 +1,10 @@
#include "cru/osx/graphics/quartz/Factory.hpp"
#include "cru/osx/graphics/quartz/Brush.hpp"
+#include "cru/osx/graphics/quartz/Font.hpp"
+#include "cru/osx/graphics/quartz/Geometry.hpp"
+#include "cru/osx/graphics/quartz/TextLayout.hpp"
+#include "cru/platform/Check.hpp"
#include <memory>
@@ -9,4 +13,21 @@ std::unique_ptr<ISolidColorBrush>
QuartzGraphicsFactory::CreateSolidColorBrush() {
return std::make_unique<QuartzSolidColorBrush>(this, colors::black);
}
+
+std::unique_ptr<IGeometryBuilder>
+QuartzGraphicsFactory::CreateGeometryBuilder() {
+ return std::make_unique<QuartzGeometryBuilder>(this);
+}
+
+std::unique_ptr<IFont> QuartzGraphicsFactory::CreateFont(String font_family,
+ float font_size) {
+ return std::make_unique<OsxCTFont>(this, font_family, font_size);
+}
+
+std::unique_ptr<ITextLayout> QuartzGraphicsFactory::CreateTextLayout(
+ std::shared_ptr<IFont> font, String text) {
+ auto f = CheckPlatform<OsxCTFont>(font, GetPlatformId());
+ return std::make_unique<OsxCTTextLayout>(this, f, text);
+}
+
} // namespace cru::platform::graphics::osx::quartz
diff --git a/src/osx/graphics/quartz/Font.cpp b/src/osx/graphics/quartz/Font.cpp
index c35f53fa..600f8309 100644
--- a/src/osx/graphics/quartz/Font.cpp
+++ b/src/osx/graphics/quartz/Font.cpp
@@ -15,4 +15,6 @@ OsxCTFont::OsxCTFont(IGraphicsFactory* graphics_factory, const String& name,
}
OsxCTFont::~OsxCTFont() { CFRelease(ct_font_); }
+
+float OsxCTFont::GetFontSize() { return CTFontGetSize(ct_font_); }
} // namespace cru::platform::graphics::osx::quartz
diff --git a/src/osx/graphics/quartz/TextLayout.cpp b/src/osx/graphics/quartz/TextLayout.cpp
index d6a19264..577eba58 100644
--- a/src/osx/graphics/quartz/TextLayout.cpp
+++ b/src/osx/graphics/quartz/TextLayout.cpp
@@ -20,6 +20,8 @@ OsxCTTextLayout::OsxCTTextLayout(IGraphicsFactory* graphics_factory,
RecreateFrame();
}
+OsxCTTextLayout::~OsxCTTextLayout() {}
+
void OsxCTTextLayout::SetFont(std::shared_ptr<IFont> font) {
font_ = CheckPlatform<OsxCTFont>(font, GetPlatformId());
CFRelease(ct_framesetter_);
diff --git a/src/osx/gui/CMakeLists.txt b/src/osx/gui/CMakeLists.txt
index 06ab92db..f3b93bfe 100644
--- a/src/osx/gui/CMakeLists.txt
+++ b/src/osx/gui/CMakeLists.txt
@@ -14,4 +14,6 @@ target_sources(cru_osx_gui PUBLIC
${CRU_OSX_GUI_INCLUDE_DIR}/Window.hpp
)
-target_link_libraries(cru_osx_gui PUBLIC cru_platform_gui cru_osx_graphics_quartz)
+find_library(APPKIT AppKit REQUIRED)
+
+target_link_libraries(cru_osx_gui PUBLIC cru_platform_gui cru_osx_graphics_quartz ${APPKIT})
diff --git a/src/ui/Helper.cpp b/src/ui/Helper.cpp
index 90b384c4..fd54c05b 100644
--- a/src/ui/Helper.cpp
+++ b/src/ui/Helper.cpp
@@ -8,7 +8,7 @@ using cru::platform::graphics::IGraphicsFactory;
using cru::platform::gui::IUiApplication;
IGraphicsFactory* GetGraphFactory() {
- return IUiApplication::GetInstance()->GetGraphFactory();
+ return IUiApplication::GetInstance()->GetGraphicsFactory();
}
IUiApplication* GetUiApplication() { return IUiApplication::GetInstance(); }