diff --git a/src/app/core/platform/app_delegate.h b/src/app/core/platform/app_delegate.h index 10d60f86..aab3df42 100644 --- a/src/app/core/platform/app_delegate.h +++ b/src/app/core/platform/app_delegate.h @@ -1,6 +1,8 @@ #ifndef YAZE_APP_CORE_PLATFORM_APP_DELEGATE_H #define YAZE_APP_CORE_PLATFORM_APP_DELEGATE_H +#ifdef TARGET_OS_MAC + #ifdef __cplusplus extern "C" { #endif @@ -11,4 +13,6 @@ void InitializeCocoa(); } // extern "C" #endif +#endif // TARGET_OS_MAC + #endif // YAZE_APP_CORE_PLATFORM_APP_DELEGATE_H diff --git a/src/app/core/platform/app_delegate.mm b/src/app/core/platform/app_delegate.mm index 23163ac7..141df9e8 100644 --- a/src/app/core/platform/app_delegate.mm +++ b/src/app/core/platform/app_delegate.mm @@ -1,12 +1,26 @@ // AppDelegate.mm -#import - -#import "app/core/controller.h" #import "app/core/platform/app_delegate.h" +#import "app/core/controller.h" #import "app/core/platform/file_dialog.h" #import "app/editor/utils/editor.h" #import "app/rom.h" +#if defined(__APPLE__) && defined(__MACH__) +/* Apple OSX and iOS (Darwin). */ +#include + +#import + +#if TARGET_IPHONE_SIMULATOR == 1 +/* iOS in Xcode simulator */ + +#elif TARGET_OS_IPHONE == 1 +/* iOS */ + +#elif TARGET_OS_MAC == 1 +/* macOS */ +#import + @interface AppDelegate : NSObject - (void)setupMenus; // - (void)changeApplicationIcon; @@ -222,4 +236,8 @@ extern "C" void InitializeCocoa() { } } -@end \ No newline at end of file +@end + +#endif + +#endif diff --git a/src/app/core/platform/clipboard.mm b/src/app/core/platform/clipboard.mm index b3dc6f9c..bdaba4a7 100644 --- a/src/app/core/platform/clipboard.mm +++ b/src/app/core/platform/clipboard.mm @@ -3,6 +3,7 @@ #include #include +#ifdef TARGET_OS_MAC #import void CopyImageToClipboard(const std::vector& pngData) { @@ -39,4 +40,6 @@ void GetImageFromClipboard(std::vector& pixel_data, int& width, int& he kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big); CGContextDrawImage(context, CGRectMake(0, 0, width, height), cgImage); CGContextRelease(context); -} \ No newline at end of file +} + +#endif diff --git a/src/app/core/platform/file_dialog.h b/src/app/core/platform/file_dialog.h index 62dfbd4c..8d7257c2 100644 --- a/src/app/core/platform/file_dialog.h +++ b/src/app/core/platform/file_dialog.h @@ -45,9 +45,14 @@ class FileDialogWrapper { #elif defined(__APPLE__) +#include "TargetConditionals.h" + #include #include +#ifdef TARGET_OS_MAC +// Other kinds of Mac OS + class FileDialogWrapper { public: static std::string ShowOpenFileDialog(); @@ -58,6 +63,21 @@ class FileDialogWrapper { const std::string& folder_path); }; +#elif TARGET_OS_IPHONE + +// iOS +class FileDialogWrapper { + public: + static std::string ShowOpenFileDialog(); + static std::string ShowOpenFolderDialog(); + static std::vector GetSubdirectoriesInFolder( + const std::string& folder_path); + static std::vector GetFilesInFolder( + const std::string& folder_path); +}; + +#endif + #elif defined(__linux__) class FileDialogWrapper { @@ -73,4 +93,4 @@ class FileDialogWrapper { #error "Unsupported platform." #endif -#endif // YAZE_APP_CORE_PLATFORM_FILE_DIALOG_H \ No newline at end of file +#endif // YAZE_APP_CORE_PLATFORM_FILE_DIALOG_H diff --git a/src/app/core/platform/file_dialog.mm b/src/app/core/platform/file_dialog.mm index 21dca047..b5dc75bb 100644 --- a/src/app/core/platform/file_dialog.mm +++ b/src/app/core/platform/file_dialog.mm @@ -1,10 +1,26 @@ -#import #include #include #include "app/core/platform/file_dialog.h" +#if defined(__APPLE__) && defined(__MACH__) +/* Apple OSX and iOS (Darwin). */ +#include + +#import + +#if TARGET_IPHONE_SIMULATOR == 1 +/* iOS in Xcode simulator */ + +#elif TARGET_OS_IPHONE == 1 +/* iOS */ + +#elif TARGET_OS_MAC == 1 +/* macOS */ + +#import + std::string FileDialogWrapper::ShowOpenFileDialog() { NSOpenPanel* openPanel = [NSOpenPanel openPanel]; [openPanel setCanChooseFiles:YES]; @@ -69,4 +85,9 @@ std::vector FileDialogWrapper::GetSubdirectoriesInFolder(const std: } } return subdirectories; -} \ No newline at end of file +} +#else +// Unsupported platform +#endif // TARGET_OS_MAC + +#endif // __APPLE__ && __MACH__ diff --git a/src/app/core/platform/font_loader.cc b/src/app/core/platform/font_loader.cc index a166aa55..0c87a33b 100644 --- a/src/app/core/platform/font_loader.cc +++ b/src/app/core/platform/font_loader.cc @@ -1,6 +1,6 @@ #include "app/core/platform/font_loader.h" -#include +#include "imgui/imgui.h" #include #include diff --git a/src/app/core/platform/font_loader.h b/src/app/core/platform/font_loader.h index c4686055..a0752dda 100644 --- a/src/app/core/platform/font_loader.h +++ b/src/app/core/platform/font_loader.h @@ -2,14 +2,25 @@ #ifndef FONTLOADER_H #define FONTLOADER_H -// Function declaration for loading system fonts into ImGui -void LoadSystemFonts(); +#include "TargetConditionals.h" #ifdef _WIN32 #include // Windows specific function declaration for loading system fonts into ImGui int CALLBACK EnumFontFamExProc(const LOGFONT* lpelfe, const TEXTMETRIC* lpntme, DWORD FontType, LPARAM lParam); +#elif __APPLE__ + +#ifdef TARGET_OS_MAC + +void LoadSystemFonts(); + +#elif TARGET_OS_IPHONE + +void LoadSystemFonts(); + +#endif + #endif #endif // FONTLOADER_H diff --git a/src/app/core/platform/font_loader.mm b/src/app/core/platform/font_loader.mm index 9dede77b..332d4c3c 100644 --- a/src/app/core/platform/font_loader.mm +++ b/src/app/core/platform/font_loader.mm @@ -1,11 +1,28 @@ // FontLoader.mm #include "app/core/platform/font_loader.h" -#import -#import -#include + +#include "imgui/imgui.h" #include "app/gui/icons.h" +#if defined(__APPLE__) && defined(__MACH__) +/* Apple OSX and iOS (Darwin). */ +#include + +#import + +#if TARGET_IPHONE_SIMULATOR == 1 +/* iOS in Xcode simulator */ + +#elif TARGET_OS_IPHONE == 1 +/* iOS */ + +#elif TARGET_OS_MAC == 1 +/* macOS */ + +#import + +// MacOS Implementation void LoadSystemFonts() { // List of common macOS system fonts NSArray *fontNames = @[ @"Helvetica", @"Times New Roman", @"Courier", @"Arial", @"Verdana" ]; @@ -47,4 +64,9 @@ void LoadSystemFonts() { CFRelease(fontURL); } } -} \ No newline at end of file +} +#else +// Unsupported platform +#endif + +#endif