#include "cru/osx/gui/Cursor.hpp" #include "CursorPrivate.h" #include "cru/osx/Exception.hpp" #include "cru/osx/gui/Resource.hpp" #include "cru/platform/gui/Cursor.hpp" #include "cru/platform/gui/UiApplication.hpp" #include namespace cru::platform::gui::osx { namespace details { OsxCursorPrivate::OsxCursorPrivate(OsxCursor* cursor, SystemCursorType cursor_type) { cursor_ = cursor; switch (cursor_type) { case SystemCursorType::Arrow: ns_cursor_ = [NSCursor arrowCursor]; break; case SystemCursorType::Hand: ns_cursor_ = [NSCursor pointingHandCursor]; break; case SystemCursorType::IBeam: ns_cursor_ = [NSCursor IBeamCursor]; break; default: throw Exception(u"Unknown system cursor type."); } } OsxCursorPrivate::~OsxCursorPrivate() {} } OsxCursor::OsxCursor(IUiApplication* ui_application, SystemCursorType cursor_type) : OsxGuiResource(ui_application) { p_ = std::make_unique(this, cursor_type); } OsxCursor::~OsxCursor() {} namespace details { class OsxCursorManagerPrivate { friend OsxCursorManager; public: explicit OsxCursorManagerPrivate(OsxCursorManager* cursor_manager); CRU_DELETE_COPY(OsxCursorManagerPrivate) CRU_DELETE_MOVE(OsxCursorManagerPrivate) ~OsxCursorManagerPrivate(); private: OsxCursorManager* cursor_manager_; std::shared_ptr arrow_cursor_; std::shared_ptr hand_cursor_; std::shared_ptr ibeam_cursor_; }; OsxCursorManagerPrivate::OsxCursorManagerPrivate(OsxCursorManager* cursor_manager) { cursor_manager_ = cursor_manager; arrow_cursor_ = std::make_shared(cursor_manager->GetUiApplication(), SystemCursorType::Arrow); hand_cursor_ = std::make_shared(cursor_manager->GetUiApplication(), SystemCursorType::Hand); ibeam_cursor_ = std::make_shared(cursor_manager->GetUiApplication(), SystemCursorType::IBeam); } OsxCursorManagerPrivate::~OsxCursorManagerPrivate() {} } OsxCursorManager::OsxCursorManager(IUiApplication* ui_application) : OsxGuiResource(ui_application) { p_ = std::make_unique(this); } OsxCursorManager::~OsxCursorManager() {} std::shared_ptr OsxCursorManager::GetSystemCursor(SystemCursorType type) { switch (type) { case SystemCursorType::Arrow: return p_->arrow_cursor_; case SystemCursorType::Hand: return p_->hand_cursor_; case SystemCursorType::IBeam: return p_->ibeam_cursor_; default: throw Exception(u"Unknown system cursor type."); } } }