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
|
#ifndef YAZE_APP_CORE_PLATFORM_APP_DELEGATE_H
|
||||||
#define YAZE_APP_CORE_PLATFORM_APP_DELEGATE_H
|
#define YAZE_APP_CORE_PLATFORM_APP_DELEGATE_H
|
||||||
|
|
||||||
|
#ifdef TARGET_OS_MAC
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
@@ -11,4 +13,6 @@ void InitializeCocoa();
|
|||||||
} // extern "C"
|
} // extern "C"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif // TARGET_OS_MAC
|
||||||
|
|
||||||
#endif // YAZE_APP_CORE_PLATFORM_APP_DELEGATE_H
|
#endif // YAZE_APP_CORE_PLATFORM_APP_DELEGATE_H
|
||||||
|
|||||||
@@ -1,12 +1,26 @@
|
|||||||
// AppDelegate.mm
|
// AppDelegate.mm
|
||||||
#import <Cocoa/Cocoa.h>
|
|
||||||
|
|
||||||
#import "app/core/controller.h"
|
|
||||||
#import "app/core/platform/app_delegate.h"
|
#import "app/core/platform/app_delegate.h"
|
||||||
|
#import "app/core/controller.h"
|
||||||
#import "app/core/platform/file_dialog.h"
|
#import "app/core/platform/file_dialog.h"
|
||||||
#import "app/editor/utils/editor.h"
|
#import "app/editor/utils/editor.h"
|
||||||
#import "app/rom.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>
|
@interface AppDelegate : NSObject <NSApplicationDelegate>
|
||||||
- (void)setupMenus;
|
- (void)setupMenus;
|
||||||
// - (void)changeApplicationIcon;
|
// - (void)changeApplicationIcon;
|
||||||
@@ -223,3 +237,7 @@ extern "C" void InitializeCocoa() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#ifdef TARGET_OS_MAC
|
||||||
#import <Cocoa/Cocoa.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
void CopyImageToClipboard(const std::vector<uint8_t>& pngData) {
|
void CopyImageToClipboard(const std::vector<uint8_t>& pngData) {
|
||||||
@@ -40,3 +41,5 @@ void GetImageFromClipboard(std::vector<uint8_t>& pixel_data, int& width, int& he
|
|||||||
CGContextDrawImage(context, CGRectMake(0, 0, width, height), cgImage);
|
CGContextDrawImage(context, CGRectMake(0, 0, width, height), cgImage);
|
||||||
CGContextRelease(context);
|
CGContextRelease(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
@@ -45,9 +45,14 @@ class FileDialogWrapper {
|
|||||||
|
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
|
|
||||||
|
#include "TargetConditionals.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#ifdef TARGET_OS_MAC
|
||||||
|
// Other kinds of Mac OS
|
||||||
|
|
||||||
class FileDialogWrapper {
|
class FileDialogWrapper {
|
||||||
public:
|
public:
|
||||||
static std::string ShowOpenFileDialog();
|
static std::string ShowOpenFileDialog();
|
||||||
@@ -58,6 +63,21 @@ class FileDialogWrapper {
|
|||||||
const std::string& folder_path);
|
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__)
|
#elif defined(__linux__)
|
||||||
|
|
||||||
class FileDialogWrapper {
|
class FileDialogWrapper {
|
||||||
|
|||||||
@@ -1,10 +1,26 @@
|
|||||||
#import <Cocoa/Cocoa.h>
|
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "app/core/platform/file_dialog.h"
|
#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() {
|
std::string FileDialogWrapper::ShowOpenFileDialog() {
|
||||||
NSOpenPanel* openPanel = [NSOpenPanel openPanel];
|
NSOpenPanel* openPanel = [NSOpenPanel openPanel];
|
||||||
[openPanel setCanChooseFiles:YES];
|
[openPanel setCanChooseFiles:YES];
|
||||||
@@ -70,3 +86,8 @@ std::vector<std::string> FileDialogWrapper::GetSubdirectoriesInFolder(const std:
|
|||||||
}
|
}
|
||||||
return subdirectories;
|
return subdirectories;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
// Unsupported platform
|
||||||
|
#endif // TARGET_OS_MAC
|
||||||
|
|
||||||
|
#endif // __APPLE__ && __MACH__
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include "app/core/platform/font_loader.h"
|
#include "app/core/platform/font_loader.h"
|
||||||
|
|
||||||
#include <imgui/imgui.h>
|
#include "imgui/imgui.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|||||||
@@ -2,14 +2,25 @@
|
|||||||
#ifndef FONTLOADER_H
|
#ifndef FONTLOADER_H
|
||||||
#define FONTLOADER_H
|
#define FONTLOADER_H
|
||||||
|
|
||||||
// Function declaration for loading system fonts into ImGui
|
#include "TargetConditionals.h"
|
||||||
void LoadSystemFonts();
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
// Windows specific function declaration for loading system fonts into ImGui
|
// Windows specific function declaration for loading system fonts into ImGui
|
||||||
int CALLBACK EnumFontFamExProc(const LOGFONT* lpelfe, const TEXTMETRIC* lpntme,
|
int CALLBACK EnumFontFamExProc(const LOGFONT* lpelfe, const TEXTMETRIC* lpntme,
|
||||||
DWORD FontType, LPARAM lParam);
|
DWORD FontType, LPARAM lParam);
|
||||||
|
#elif __APPLE__
|
||||||
|
|
||||||
|
#ifdef TARGET_OS_MAC
|
||||||
|
|
||||||
|
void LoadSystemFonts();
|
||||||
|
|
||||||
|
#elif TARGET_OS_IPHONE
|
||||||
|
|
||||||
|
void LoadSystemFonts();
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // FONTLOADER_H
|
#endif // FONTLOADER_H
|
||||||
|
|||||||
@@ -1,11 +1,28 @@
|
|||||||
// FontLoader.mm
|
// FontLoader.mm
|
||||||
#include "app/core/platform/font_loader.h"
|
#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"
|
#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() {
|
void LoadSystemFonts() {
|
||||||
// List of common macOS system fonts
|
// List of common macOS system fonts
|
||||||
NSArray *fontNames = @[ @"Helvetica", @"Times New Roman", @"Courier", @"Arial", @"Verdana" ];
|
NSArray *fontNames = @[ @"Helvetica", @"Times New Roman", @"Courier", @"Arial", @"Verdana" ];
|
||||||
@@ -48,3 +65,8 @@ void LoadSystemFonts() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
// Unsupported platform
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user