mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-10 19:13:29 +00:00
Add support for native OS X clipboard
This commit is contained in:
parent
0350ac4bbe
commit
4421f4cb10
@ -90,7 +90,9 @@ endif()
|
||||
|
||||
if(APPLE)
|
||||
list(APPEND SHE_SOURCES
|
||||
osx/logger.mm)
|
||||
osx/clipboard.mm
|
||||
osx/logger.mm
|
||||
osx/native_dialogs.mm)
|
||||
endif()
|
||||
|
||||
add_library(she ${SHE_SOURCES})
|
||||
|
@ -7,6 +7,9 @@
|
||||
#ifdef _WIN32
|
||||
#include "she/win/clipboard.h"
|
||||
#include "she/win/native_dialogs.h"
|
||||
#elif defined(__APPLE__)
|
||||
#include "she/osx/clipboard.h"
|
||||
#include "she/osx/native_dialogs.h"
|
||||
#else
|
||||
#include "she/clipboard_simple.h"
|
||||
#endif
|
||||
@ -43,6 +46,9 @@ public:
|
||||
#ifdef _WIN32
|
||||
if (!m_nativeDialogs)
|
||||
m_nativeDialogs = new NativeDialogsWin32();
|
||||
#elif defined(__APPLE__)
|
||||
if (!m_nativeDialogs)
|
||||
m_nativeDialogs = new NativeDialogsOSX();
|
||||
#endif
|
||||
return m_nativeDialogs;
|
||||
}
|
||||
@ -50,6 +56,8 @@ public:
|
||||
Clipboard* createClipboard() override {
|
||||
#ifdef _WIN32
|
||||
return new ClipboardWin32();
|
||||
#elif defined(__APPLE__)
|
||||
return new ClipboardOSX();
|
||||
#else
|
||||
return new ClipboardImpl();
|
||||
#endif
|
||||
|
28
src/she/osx/clipboard.h
Normal file
28
src/she/osx/clipboard.h
Normal file
@ -0,0 +1,28 @@
|
||||
// SHE library
|
||||
// Copyright (C) 2012-2015 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
// Read LICENSE.txt for more information.
|
||||
|
||||
#ifndef SHE_OSX_CLIPBOARD_H_INCLUDED
|
||||
#define SHE_OSX_CLIPBOARD_H_INCLUDED
|
||||
#pragma once
|
||||
|
||||
#include "base/string.h"
|
||||
#include "she/clipboard.h"
|
||||
|
||||
namespace she {
|
||||
|
||||
class ClipboardOSX : public Clipboard {
|
||||
public:
|
||||
void dispose() override;
|
||||
std::string getText(DisplayHandle display) override;
|
||||
void setText(DisplayHandle display, const std::string& text) override;
|
||||
|
||||
private:
|
||||
std::string m_text;
|
||||
};
|
||||
|
||||
} // namespace she
|
||||
|
||||
#endif
|
38
src/she/osx/clipboard.mm
Normal file
38
src/she/osx/clipboard.mm
Normal file
@ -0,0 +1,38 @@
|
||||
// SHE library
|
||||
// Copyright (C) 2012-2015 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
// Read LICENSE.txt for more information.
|
||||
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
#include <Foundation/Foundation.h>
|
||||
#include <AppKit/AppKit.h>
|
||||
|
||||
#include "she/osx/clipboard.h"
|
||||
|
||||
namespace she {
|
||||
|
||||
void ClipboardOSX::dispose()
|
||||
{
|
||||
delete this;
|
||||
}
|
||||
|
||||
std::string ClipboardOSX::getText(DisplayHandle display)
|
||||
{
|
||||
NSPasteboard* pasteboard = [NSPasteboard generalPasteboard];
|
||||
NSString* string = [pasteboard stringForType:NSStringPboardType];
|
||||
if (string)
|
||||
return std::string([string UTF8String]);
|
||||
else
|
||||
return std::string();
|
||||
}
|
||||
|
||||
void ClipboardOSX::setText(DisplayHandle display, const std::string& text)
|
||||
{
|
||||
NSPasteboard* pasteboard = [NSPasteboard generalPasteboard];
|
||||
[pasteboard clearContents];
|
||||
[pasteboard setString:[NSString stringWithUTF8String:text.c_str()]
|
||||
forType:NSStringPboardType];
|
||||
}
|
||||
|
||||
} // namespace she
|
23
src/she/osx/native_dialogs.h
Normal file
23
src/she/osx/native_dialogs.h
Normal file
@ -0,0 +1,23 @@
|
||||
// SHE library
|
||||
// Copyright (C) 2015 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
// Read LICENSE.txt for more information.
|
||||
|
||||
#ifndef SHE_OSX_NATIVE_DIALOGS_H_INCLUDED
|
||||
#define SHE_OSX_NATIVE_DIALOGS_H_INCLUDED
|
||||
#pragma once
|
||||
|
||||
#include "she/native_dialogs.h"
|
||||
|
||||
namespace she {
|
||||
|
||||
class NativeDialogsOSX : public NativeDialogs {
|
||||
public:
|
||||
NativeDialogsOSX();
|
||||
FileDialog* createFileDialog() override;
|
||||
};
|
||||
|
||||
} // namespace she
|
||||
|
||||
#endif
|
23
src/she/osx/native_dialogs.mm
Normal file
23
src/she/osx/native_dialogs.mm
Normal file
@ -0,0 +1,23 @@
|
||||
// SHE library
|
||||
// Copyright (C) 2012-2015 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
// Read LICENSE.txt for more information.
|
||||
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
#include <Foundation/Foundation.h>
|
||||
|
||||
#include "she/osx/native_dialogs.h"
|
||||
|
||||
namespace she {
|
||||
|
||||
NativeDialogsOSX::NativeDialogsOSX()
|
||||
{
|
||||
}
|
||||
|
||||
FileDialog* NativeDialogsOSX::createFileDialog()
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
} // namespace she
|
Loading…
x
Reference in New Issue
Block a user