split apple platforms by mac, ios, and simulator
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -1,12 +1,26 @@
|
||||
// AppDelegate.mm
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
#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 <TargetConditionals.h>
|
||||
|
||||
#import <CoreText/CoreText.h>
|
||||
|
||||
#if TARGET_IPHONE_SIMULATOR == 1
|
||||
/* iOS in Xcode simulator */
|
||||
|
||||
#elif TARGET_OS_IPHONE == 1
|
||||
/* iOS */
|
||||
|
||||
#elif TARGET_OS_MAC == 1
|
||||
/* macOS */
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
@interface AppDelegate : NSObject <NSApplicationDelegate>
|
||||
- (void)setupMenus;
|
||||
// - (void)changeApplicationIcon;
|
||||
@@ -222,4 +236,8 @@ extern "C" void InitializeCocoa() {
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
@end
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
#ifdef TARGET_OS_MAC
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
void CopyImageToClipboard(const std::vector<uint8_t>& pngData) {
|
||||
@@ -39,4 +40,6 @@ void GetImageFromClipboard(std::vector<uint8_t>& pixel_data, int& width, int& he
|
||||
kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big);
|
||||
CGContextDrawImage(context, CGRectMake(0, 0, width, height), cgImage);
|
||||
CGContextRelease(context);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -45,9 +45,14 @@ class FileDialogWrapper {
|
||||
|
||||
#elif defined(__APPLE__)
|
||||
|
||||
#include "TargetConditionals.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#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<std::string> GetSubdirectoriesInFolder(
|
||||
const std::string& folder_path);
|
||||
static std::vector<std::string> 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
|
||||
#endif // YAZE_APP_CORE_PLATFORM_FILE_DIALOG_H
|
||||
|
||||
@@ -1,10 +1,26 @@
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "app/core/platform/file_dialog.h"
|
||||
|
||||
#if defined(__APPLE__) && defined(__MACH__)
|
||||
/* Apple OSX and iOS (Darwin). */
|
||||
#include <TargetConditionals.h>
|
||||
|
||||
#import <CoreText/CoreText.h>
|
||||
|
||||
#if TARGET_IPHONE_SIMULATOR == 1
|
||||
/* iOS in Xcode simulator */
|
||||
|
||||
#elif TARGET_OS_IPHONE == 1
|
||||
/* iOS */
|
||||
|
||||
#elif TARGET_OS_MAC == 1
|
||||
/* macOS */
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
std::string FileDialogWrapper::ShowOpenFileDialog() {
|
||||
NSOpenPanel* openPanel = [NSOpenPanel openPanel];
|
||||
[openPanel setCanChooseFiles:YES];
|
||||
@@ -69,4 +85,9 @@ std::vector<std::string> FileDialogWrapper::GetSubdirectoriesInFolder(const std:
|
||||
}
|
||||
}
|
||||
return subdirectories;
|
||||
}
|
||||
}
|
||||
#else
|
||||
// Unsupported platform
|
||||
#endif // TARGET_OS_MAC
|
||||
|
||||
#endif // __APPLE__ && __MACH__
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "app/core/platform/font_loader.h"
|
||||
|
||||
#include <imgui/imgui.h>
|
||||
#include "imgui/imgui.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@@ -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.h>
|
||||
// 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
|
||||
|
||||
@@ -1,11 +1,28 @@
|
||||
// FontLoader.mm
|
||||
#include "app/core/platform/font_loader.h"
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import <CoreText/CoreText.h>
|
||||
#include <imgui/imgui.h>
|
||||
|
||||
#include "imgui/imgui.h"
|
||||
|
||||
#include "app/gui/icons.h"
|
||||
|
||||
#if defined(__APPLE__) && defined(__MACH__)
|
||||
/* Apple OSX and iOS (Darwin). */
|
||||
#include <TargetConditionals.h>
|
||||
|
||||
#import <CoreText/CoreText.h>
|
||||
|
||||
#if TARGET_IPHONE_SIMULATOR == 1
|
||||
/* iOS in Xcode simulator */
|
||||
|
||||
#elif TARGET_OS_IPHONE == 1
|
||||
/* iOS */
|
||||
|
||||
#elif TARGET_OS_MAC == 1
|
||||
/* macOS */
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
// Unsupported platform
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user