Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/platform/macos/display_server_macos_base.h
10277 views
1
/**************************************************************************/
2
/* display_server_macos_base.h */
3
/**************************************************************************/
4
/* This file is part of: */
5
/* GODOT ENGINE */
6
/* https://godotengine.org */
7
/**************************************************************************/
8
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10
/* */
11
/* Permission is hereby granted, free of charge, to any person obtaining */
12
/* a copy of this software and associated documentation files (the */
13
/* "Software"), to deal in the Software without restriction, including */
14
/* without limitation the rights to use, copy, modify, merge, publish, */
15
/* distribute, sublicense, and/or sell copies of the Software, and to */
16
/* permit persons to whom the Software is furnished to do so, subject to */
17
/* the following conditions: */
18
/* */
19
/* The above copyright notice and this permission notice shall be */
20
/* included in all copies or substantial portions of the Software. */
21
/* */
22
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
29
/**************************************************************************/
30
31
#pragma once
32
33
#include "core/input/input.h"
34
#include "servers/display_server.h"
35
36
#define FontVariation __FontVariation
37
38
#import <AppKit/AppKit.h>
39
40
#undef FontVariation
41
42
class DisplayServerMacOSBase : public DisplayServer {
43
GDSOFTCLASS(DisplayServerMacOSBase, DisplayServer)
44
45
id tts = nullptr;
46
47
struct LayoutInfo {
48
String name;
49
String code;
50
};
51
mutable Vector<LayoutInfo> kbd_layouts;
52
mutable int current_layout = 0;
53
mutable bool keyboard_layout_dirty = true;
54
55
protected:
56
_THREAD_SAFE_CLASS_
57
58
void initialize_tts() const;
59
60
void _update_keyboard_layouts() const;
61
static void _keyboard_layout_changed(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef user_info);
62
63
public:
64
virtual void clipboard_set(const String &p_text) override;
65
virtual String clipboard_get() const override;
66
virtual Ref<Image> clipboard_get_image() const override;
67
virtual bool clipboard_has() const override;
68
virtual bool clipboard_has_image() const override;
69
70
virtual int keyboard_get_layout_count() const override;
71
virtual int keyboard_get_current_layout() const override;
72
virtual void keyboard_set_current_layout(int p_index) override;
73
virtual String keyboard_get_layout_language(int p_index) const override;
74
virtual String keyboard_get_layout_name(int p_index) const override;
75
virtual Key keyboard_get_keycode_from_physical(Key p_keycode) const override;
76
virtual Key keyboard_get_label_from_physical(Key p_keycode) const override;
77
virtual void show_emoji_and_symbol_picker() const override;
78
79
virtual bool tts_is_speaking() const override;
80
virtual bool tts_is_paused() const override;
81
virtual TypedArray<Dictionary> tts_get_voices() const override;
82
83
virtual void tts_speak(const String &p_text, const String &p_voice, int p_volume = 50, float p_pitch = 1.f, float p_rate = 1.f, int p_utterance_id = 0, bool p_interrupt = false) override;
84
virtual void tts_pause() override;
85
virtual void tts_resume() override;
86
virtual void tts_stop() override;
87
88
DisplayServerMacOSBase();
89
~DisplayServerMacOSBase();
90
};
91
92