gosu 1.1.1.1 → 1.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (219) hide show
  1. checksums.yaml +4 -4
  2. data/dependencies/SDL/include/SDL.h +108 -14
  3. data/dependencies/SDL/include/SDL_assert.h +81 -50
  4. data/dependencies/SDL/include/SDL_atomic.h +135 -35
  5. data/dependencies/SDL/include/SDL_audio.h +960 -355
  6. data/dependencies/SDL/include/SDL_bits.h +11 -6
  7. data/dependencies/SDL/include/SDL_blendmode.h +91 -14
  8. data/dependencies/SDL/include/SDL_clipboard.h +30 -7
  9. data/dependencies/SDL/include/SDL_config.h +277 -27
  10. data/dependencies/SDL/include/SDL_config_android.h +13 -38
  11. data/dependencies/SDL/include/SDL_config_iphoneos.h +21 -62
  12. data/dependencies/SDL/include/SDL_config_macosx.h +23 -92
  13. data/dependencies/SDL/include/SDL_config_minimal.h +1 -4
  14. data/dependencies/SDL/include/SDL_config_pandora.h +15 -22
  15. data/dependencies/SDL/include/SDL_config_psp.h +16 -37
  16. data/dependencies/SDL/include/SDL_config_windows.h +28 -91
  17. data/dependencies/SDL/include/SDL_config_winrt.h +33 -61
  18. data/dependencies/SDL/include/SDL_config_wiz.h +28 -56
  19. data/dependencies/SDL/include/SDL_copying.h +1 -1
  20. data/dependencies/SDL/include/SDL_cpuinfo.h +331 -71
  21. data/dependencies/SDL/include/SDL_egl.h +906 -280
  22. data/dependencies/SDL/include/SDL_endian.h +101 -47
  23. data/dependencies/SDL/include/SDL_error.h +70 -19
  24. data/dependencies/SDL/include/SDL_events.h +387 -79
  25. data/dependencies/SDL/include/SDL_filesystem.h +73 -64
  26. data/dependencies/SDL/include/SDL_gamecontroller.h +585 -125
  27. data/dependencies/SDL/include/SDL_gesture.h +36 -6
  28. data/dependencies/SDL/include/SDL_haptic.h +304 -210
  29. data/dependencies/SDL/include/SDL_hidapi.h +451 -0
  30. data/dependencies/SDL/include/SDL_hints.h +1286 -897
  31. data/dependencies/SDL/include/SDL_joystick.h +577 -130
  32. data/dependencies/SDL/include/SDL_keyboard.h +162 -63
  33. data/dependencies/SDL/include/SDL_keycode.h +7 -5
  34. data/dependencies/SDL/include/SDL_loadso.h +42 -8
  35. data/dependencies/SDL/include/SDL_locale.h +34 -32
  36. data/dependencies/SDL/include/SDL_log.h +212 -19
  37. data/dependencies/SDL/include/SDL_main.h +72 -17
  38. data/dependencies/SDL/include/SDL_messagebox.h +70 -23
  39. data/dependencies/SDL/include/SDL_metal.h +27 -32
  40. data/dependencies/SDL/include/SDL_misc.h +19 -15
  41. data/dependencies/SDL/include/SDL_mouse.h +262 -110
  42. data/dependencies/SDL/include/SDL_mutex.h +286 -66
  43. data/dependencies/SDL/include/SDL_name.h +1 -1
  44. data/dependencies/SDL/include/SDL_opengl.h +1 -1
  45. data/dependencies/SDL/include/SDL_opengles.h +1 -1
  46. data/dependencies/SDL/include/SDL_opengles2.h +2 -2
  47. data/dependencies/SDL/include/SDL_pixels.h +199 -34
  48. data/dependencies/SDL/include/SDL_platform.h +39 -2
  49. data/dependencies/SDL/include/SDL_power.h +23 -10
  50. data/dependencies/SDL/include/SDL_quit.h +1 -1
  51. data/dependencies/SDL/include/SDL_rect.h +78 -28
  52. data/dependencies/SDL/include/SDL_render.h +1204 -472
  53. data/dependencies/SDL/include/SDL_revision.h +2 -2
  54. data/dependencies/SDL/include/SDL_rwops.h +605 -33
  55. data/dependencies/SDL/include/SDL_scancode.h +1 -1
  56. data/dependencies/SDL/include/SDL_sensor.h +76 -42
  57. data/dependencies/SDL/include/SDL_shape.h +38 -27
  58. data/dependencies/SDL/include/SDL_stdinc.h +96 -24
  59. data/dependencies/SDL/include/SDL_surface.h +571 -139
  60. data/dependencies/SDL/include/SDL_system.h +339 -101
  61. data/dependencies/SDL/include/SDL_syswm.h +50 -20
  62. data/dependencies/SDL/include/SDL_test.h +1 -1
  63. data/dependencies/SDL/include/SDL_test_assert.h +2 -2
  64. data/dependencies/SDL/include/SDL_test_common.h +23 -6
  65. data/dependencies/SDL/include/SDL_test_compare.h +1 -1
  66. data/dependencies/SDL/include/SDL_test_crc32.h +1 -1
  67. data/dependencies/SDL/include/SDL_test_font.h +3 -3
  68. data/dependencies/SDL/include/SDL_test_fuzzer.h +28 -26
  69. data/dependencies/SDL/include/SDL_test_harness.h +6 -6
  70. data/dependencies/SDL/include/SDL_test_images.h +1 -1
  71. data/dependencies/SDL/include/SDL_test_log.h +1 -1
  72. data/dependencies/SDL/include/SDL_test_md5.h +1 -1
  73. data/dependencies/SDL/include/SDL_test_memory.h +1 -1
  74. data/dependencies/SDL/include/SDL_test_random.h +2 -2
  75. data/dependencies/SDL/include/SDL_thread.h +226 -128
  76. data/dependencies/SDL/include/SDL_timer.h +129 -22
  77. data/dependencies/SDL/include/SDL_touch.h +48 -8
  78. data/dependencies/SDL/include/SDL_types.h +1 -1
  79. data/dependencies/SDL/include/SDL_version.h +72 -46
  80. data/dependencies/SDL/include/SDL_video.h +1266 -460
  81. data/dependencies/SDL/include/SDL_vulkan.h +100 -161
  82. data/dependencies/SDL/include/begin_code.h +22 -1
  83. data/dependencies/SDL/include/close_code.h +1 -1
  84. data/dependencies/SDL/lib/x64/libSDL2.dll.a +0 -0
  85. data/dependencies/SDL/lib/x86/libSDL2.dll.a +0 -0
  86. data/dependencies/SDL_sound/SDL_sound.c +83 -7
  87. data/dependencies/SDL_sound/SDL_sound.h +4 -4
  88. data/dependencies/SDL_sound/SDL_sound_aiff.c +9 -12
  89. data/dependencies/SDL_sound/SDL_sound_au.c +7 -7
  90. data/dependencies/SDL_sound/SDL_sound_coreaudio.c +3 -3
  91. data/dependencies/SDL_sound/SDL_sound_flac.c +1 -1
  92. data/dependencies/SDL_sound/SDL_sound_internal.h +17 -10
  93. data/dependencies/SDL_sound/SDL_sound_modplug.c +25 -27
  94. data/dependencies/SDL_sound/SDL_sound_mp3.c +5 -17
  95. data/dependencies/SDL_sound/SDL_sound_raw.c +11 -11
  96. data/dependencies/SDL_sound/SDL_sound_shn.c +8 -7
  97. data/dependencies/SDL_sound/SDL_sound_voc.c +6 -4
  98. data/dependencies/SDL_sound/SDL_sound_vorbis.c +6 -11
  99. data/dependencies/SDL_sound/SDL_sound_wav.c +35 -29
  100. data/dependencies/SDL_sound/dr_flac.h +618 -220
  101. data/dependencies/SDL_sound/dr_mp3.h +263 -94
  102. data/dependencies/SDL_sound/libmodplug/fastmix.c +58 -64
  103. data/dependencies/SDL_sound/libmodplug/libmodplug.h +25 -103
  104. data/dependencies/SDL_sound/libmodplug/load_669.c +14 -17
  105. data/dependencies/SDL_sound/libmodplug/load_amf.c +11 -7
  106. data/dependencies/SDL_sound/libmodplug/load_ams.c +65 -22
  107. data/dependencies/SDL_sound/libmodplug/load_dbm.c +8 -4
  108. data/dependencies/SDL_sound/libmodplug/load_dmf.c +55 -25
  109. data/dependencies/SDL_sound/libmodplug/load_far.c +9 -13
  110. data/dependencies/SDL_sound/libmodplug/load_gdm.c +448 -0
  111. data/dependencies/SDL_sound/libmodplug/load_it.c +45 -49
  112. data/dependencies/SDL_sound/libmodplug/load_mdl.c +80 -53
  113. data/dependencies/SDL_sound/libmodplug/load_med.c +20 -12
  114. data/dependencies/SDL_sound/libmodplug/load_mod.c +40 -15
  115. data/dependencies/SDL_sound/libmodplug/load_mt2.c +29 -17
  116. data/dependencies/SDL_sound/libmodplug/load_okt.c +12 -8
  117. data/dependencies/SDL_sound/libmodplug/load_psm.c +101 -78
  118. data/dependencies/SDL_sound/libmodplug/load_ptm.c +18 -17
  119. data/dependencies/SDL_sound/libmodplug/load_s3m.c +9 -7
  120. data/dependencies/SDL_sound/libmodplug/load_stm.c +3 -2
  121. data/dependencies/SDL_sound/libmodplug/load_ult.c +2 -2
  122. data/dependencies/SDL_sound/libmodplug/load_umx.c +315 -35
  123. data/dependencies/SDL_sound/libmodplug/load_xm.c +25 -21
  124. data/dependencies/SDL_sound/libmodplug/mmcmp.c +295 -149
  125. data/dependencies/SDL_sound/libmodplug/modplug.c +7 -123
  126. data/dependencies/SDL_sound/libmodplug/modplug.h +32 -29
  127. data/dependencies/SDL_sound/libmodplug/snd_dsp.c +0 -1
  128. data/dependencies/SDL_sound/libmodplug/snd_flt.c +2 -2
  129. data/dependencies/SDL_sound/libmodplug/snd_fx.c +24 -18
  130. data/dependencies/SDL_sound/libmodplug/sndfile.c +55 -156
  131. data/dependencies/SDL_sound/libmodplug/sndmix.c +7 -12
  132. data/dependencies/SDL_sound/libmodplug/tables.h +10 -15
  133. data/dependencies/SDL_sound/stb_vorbis.h +508 -325
  134. data/dependencies/{al_soft → mojoAL}/AL/al.h +38 -30
  135. data/dependencies/{al_soft → mojoAL}/AL/alc.h +27 -56
  136. data/dependencies/mojoAL/mojoal.c +4594 -0
  137. data/ext/gosu/extconf.rb +29 -30
  138. data/include/Gosu/Audio.hpp +70 -85
  139. data/include/Gosu/Color.hpp +63 -107
  140. data/include/Gosu/Font.hpp +44 -48
  141. data/include/Gosu/Fwd.hpp +1 -1
  142. data/include/Gosu/Graphics.hpp +64 -75
  143. data/include/Gosu/GraphicsBase.hpp +32 -39
  144. data/include/Gosu/Image.hpp +56 -62
  145. data/include/Gosu/ImageData.hpp +23 -27
  146. data/include/Gosu/Inspection.hpp +1 -4
  147. data/include/Gosu/Math.hpp +4 -16
  148. data/include/Gosu/Platform.hpp +1 -51
  149. data/include/Gosu/Text.hpp +37 -40
  150. data/include/Gosu/TextInput.hpp +34 -40
  151. data/include/Gosu/Utility.hpp +10 -8
  152. data/include/Gosu/Version.hpp +1 -1
  153. data/include/Gosu/Window.hpp +73 -70
  154. data/lib/SDL2.dll +0 -0
  155. data/lib/gosu/compat.rb +28 -37
  156. data/lib/gosu/swig_patches.rb +31 -3
  157. data/lib/gosu.rb +2 -2
  158. data/lib64/SDL2.dll +0 -0
  159. data/rdoc/gosu.rb +9 -1
  160. data/src/Audio.cpp +88 -86
  161. data/src/AudioFile.hpp +6 -6
  162. data/src/AudioFileAudioToolbox.cpp +1 -1
  163. data/src/AudioFileSDLSound.cpp +1 -1
  164. data/src/AudioImpl.hpp +5 -5
  165. data/src/Bitmap.cpp +13 -13
  166. data/src/BitmapIO.cpp +0 -20
  167. data/src/BlockAllocator.cpp +2 -1
  168. data/src/Channel.cpp +22 -20
  169. data/src/Color.cpp +62 -55
  170. data/src/EmptyImageData.hpp +16 -18
  171. data/src/FileUnix.cpp +1 -1
  172. data/src/FileWin.cpp +1 -1
  173. data/src/Font.cpp +52 -57
  174. data/src/GosuViewController.cpp +2 -0
  175. data/src/Graphics.cpp +135 -143
  176. data/src/Image.cpp +42 -42
  177. data/src/Input.cpp +1 -1
  178. data/src/InputUIKit.cpp +1 -1
  179. data/src/LargeImageData.cpp +120 -113
  180. data/src/LargeImageData.hpp +18 -16
  181. data/src/Log.hpp +6 -6
  182. data/src/Macro.cpp +35 -37
  183. data/src/Macro.hpp +11 -11
  184. data/src/Math.cpp +8 -1
  185. data/src/RenderState.hpp +5 -5
  186. data/src/Resolution.cpp +12 -7
  187. data/src/RubyGosu.cxx +471 -502
  188. data/src/RubyGosu.h +3 -2
  189. data/src/TexChunk.cpp +50 -41
  190. data/src/TexChunk.hpp +22 -22
  191. data/src/Text.cpp +58 -59
  192. data/src/TextBuilder.cpp +60 -57
  193. data/src/TextBuilder.hpp +20 -20
  194. data/src/TextInput.cpp +127 -135
  195. data/src/TrueTypeFont.cpp +108 -108
  196. data/src/TrueTypeFont.hpp +39 -38
  197. data/src/TrueTypeFontApple.cpp +27 -23
  198. data/src/TrueTypeFontUnix.cpp +21 -26
  199. data/src/TrueTypeFontWin.cpp +30 -30
  200. data/src/Utility.cpp +82 -23
  201. data/src/WinUtility.hpp +2 -1
  202. data/src/Window.cpp +103 -86
  203. data/src/WindowUIKit.cpp +48 -51
  204. metadata +8 -20
  205. data/dependencies/SDL/include/SDL_config_os2.h +0 -188
  206. data/dependencies/SDL_sound/libmodplug/load_abc.c +0 -4725
  207. data/dependencies/SDL_sound/libmodplug/load_mid.c +0 -1405
  208. data/dependencies/SDL_sound/libmodplug/load_pat.c +0 -1143
  209. data/dependencies/SDL_sound/libmodplug/load_pat.h +0 -25
  210. data/dependencies/al_soft/AL/alext.h +0 -585
  211. data/dependencies/al_soft/AL/efx-creative.h +0 -3
  212. data/dependencies/al_soft/AL/efx-presets.h +0 -402
  213. data/dependencies/al_soft/AL/efx.h +0 -762
  214. data/dependencies/al_soft/x64/libOpenAL32.dll.a +0 -0
  215. data/dependencies/al_soft/x86/libOpenAL32.dll.a +0 -0
  216. data/lib/OpenAL32.dll +0 -0
  217. data/lib64/OpenAL32.dll +0 -0
  218. data/src/UtilityApple.cpp +0 -16
  219. data/src/UtilityWin.cpp +0 -17
data/src/TextBuilder.hpp CHANGED
@@ -12,44 +12,44 @@ namespace Gosu
12
12
  bool is_whitespace;
13
13
  bool is_end_of_line;
14
14
  double width;
15
-
15
+
16
16
  WordInfo(const std::string& font_name, double font_height,
17
17
  std::vector<FormattedString> parts);
18
18
  };
19
-
19
+
20
20
  class TextBuilder
21
21
  {
22
22
  // Parameters.
23
- std::string font_name;
24
- double font_height;
25
- double line_spacing;
26
- Alignment align;
27
-
28
- enum EndOfLineReason {
23
+ std::string m_font_name;
24
+ double m_font_height;
25
+ double m_line_spacing;
26
+ Alignment m_align;
27
+
28
+ enum EndOfLineReason
29
+ {
29
30
  LINE_TOO_LONG,
30
31
  END_OF_PARAGRAPH,
31
32
  END_OF_TEXT
32
33
  };
33
-
34
+
34
35
  // Input.
35
- std::vector<WordInfo> current_line;
36
- int current_line_width = 0;
36
+ std::vector<WordInfo> m_current_line;
37
+ int m_current_line_width = 0;
37
38
  void flush_current_line(EndOfLineReason reason);
38
39
 
39
40
  // Output.
40
- Bitmap result;
41
- int used_lines = 0;
42
- int allocated_lines = 0;
41
+ Bitmap m_result;
42
+ int m_used_lines = 0;
43
+ int m_allocated_lines = 0;
43
44
  void allocate_next_line();
44
45
  void resize_to_allocated_lines();
45
-
46
+
46
47
  public:
47
- TextBuilder(const std::string& font_name, int font_height, int line_spacing,
48
- int width, Alignment align);
49
-
48
+ TextBuilder(const std::string& font_name, int font_height, int line_spacing, int width,
49
+ Alignment align);
50
+
50
51
  void feed_word(std::vector<FormattedString>&& word);
51
52
 
52
- Bitmap move_into_bitmap();
53
+ Bitmap move_into_bitmap() &&;
53
54
  };
54
55
  }
55
-
data/src/TextInput.cpp CHANGED
@@ -1,125 +1,120 @@
1
- #include <Gosu/TextInput.hpp>
2
1
  #include <Gosu/Input.hpp>
3
2
  #include <Gosu/Platform.hpp>
3
+ #include <Gosu/TextInput.hpp>
4
+ #include <cctype>
4
5
 
5
6
  #ifndef GOSU_IS_IPHONE
6
7
  #include <SDL.h>
7
- #include <cctype>
8
8
  #endif
9
9
 
10
- using namespace std;
11
-
12
- struct Gosu::TextInput::Impl
10
+ struct Gosu::TextInput::Impl : Gosu::Noncopyable
13
11
  {
14
- string text;
15
-
12
+ std::string text;
13
+
16
14
  // This is the current IME composition (not used on iOS).
17
15
  // http://wiki.libsdl.org/Tutorials/TextInput#CandidateList
18
- string composition;
19
-
16
+ std::string composition;
17
+
20
18
  // Indices into the UTF-8 encoded text.
21
19
  unsigned caret_pos = 0, selection_start = 0;
22
-
20
+
23
21
  // Skip continuation characters, see: https://en.wikipedia.org/wiki/UTF-8#Description
24
22
  // (0xc0 = 11'000000, 0x80 = 10'000000)
25
- bool should_skip(char ch)
26
- {
27
- return (static_cast<unsigned char>(ch) & 0xc0) == 0x80;
28
- }
29
-
30
- void insert_text(const string& new_text)
23
+ static bool should_skip(char ch) { return (static_cast<unsigned char>(ch) & 0xc0) == 0x80; }
24
+
25
+ void insert_text(const std::string& new_text)
31
26
  {
32
27
  // Stop IME composition.
33
28
  composition.clear();
34
29
 
35
30
  // Delete (overwrite) previous selection.
36
31
  if (caret_pos != selection_start) {
37
- unsigned from = min(caret_pos, selection_start);
38
- unsigned to = max(caret_pos, selection_start);
32
+ unsigned from = std::min(caret_pos, selection_start);
33
+ unsigned to = std::max(caret_pos, selection_start);
39
34
  text.erase(text.begin() + from, text.begin() + to);
40
35
  caret_pos = selection_start = from;
41
36
  }
42
-
37
+
43
38
  text.insert(text.begin() + caret_pos, new_text.begin(), new_text.end());
44
39
  caret_pos += new_text.size();
45
40
  selection_start = caret_pos;
46
41
  }
47
-
42
+
48
43
  void move_left(bool modify_selection)
49
44
  {
50
45
  if (caret_pos > 0) {
51
46
  caret_pos -= 1;
52
-
47
+
53
48
  // Skip UTF-8 continuation bytes.
54
49
  while (caret_pos > 0 && should_skip(text[caret_pos])) {
55
50
  caret_pos -= 1;
56
51
  }
57
52
  }
58
-
53
+
59
54
  if (modify_selection) {
60
55
  selection_start = caret_pos;
61
56
  }
62
57
  }
63
-
58
+
64
59
  void move_right(bool modify_selection)
65
60
  {
66
61
  if (caret_pos < text.length()) {
67
62
  caret_pos += 1;
68
-
63
+
69
64
  // Skip UTF-8 continuation bytes.
70
65
  while (caret_pos < text.length() && should_skip(text[caret_pos])) {
71
66
  caret_pos += 1;
72
67
  }
73
68
  }
74
-
69
+
75
70
  if (modify_selection) {
76
71
  selection_start = caret_pos;
77
72
  }
78
73
  }
79
-
74
+
80
75
  void move_word_left(bool modify_selection)
81
76
  {
82
- while (caret_pos > 0 && isspace(text[caret_pos - 1])) {
77
+ while (caret_pos > 0 && std::isspace(text[caret_pos - 1])) {
83
78
  move_left(modify_selection);
84
79
  }
85
- while (caret_pos > 0 && !isspace(text[caret_pos - 1])) {
80
+ while (caret_pos > 0 && !std::isspace(text[caret_pos - 1])) {
86
81
  move_left(modify_selection);
87
82
  }
88
83
  }
89
84
 
90
85
  void move_word_right(bool modify_selection)
91
86
  {
92
- while (caret_pos < text.length() && isspace(text.at(caret_pos))) {
87
+ while (caret_pos < text.length() && std::isspace(text.at(caret_pos))) {
93
88
  move_right(modify_selection);
94
89
  }
95
- while (caret_pos < text.length() && !isspace(text.at(caret_pos))) {
90
+ while (caret_pos < text.length() && !std::isspace(text.at(caret_pos))) {
96
91
  move_right(modify_selection);
97
92
  }
98
93
  }
99
-
94
+
100
95
  void move_to_beginning_of_line(bool modify_selection)
101
96
  {
102
97
  caret_pos = 0;
103
-
98
+
104
99
  if (modify_selection) {
105
100
  selection_start = caret_pos;
106
101
  }
107
102
  }
108
-
103
+
109
104
  void move_to_end_of_line(bool modify_selection)
110
105
  {
111
106
  caret_pos = static_cast<unsigned>(text.length());
112
-
107
+
113
108
  if (modify_selection) {
114
109
  selection_start = caret_pos;
115
110
  }
116
111
  }
117
-
112
+
118
113
  void delete_backward()
119
114
  {
120
115
  if (selection_start != caret_pos) {
121
- unsigned from = min(caret_pos, selection_start);
122
- unsigned to = max(caret_pos, selection_start);
116
+ unsigned from = std::min(caret_pos, selection_start);
117
+ unsigned to = std::max(caret_pos, selection_start);
123
118
  text.erase(text.begin() + from, text.begin() + to);
124
119
  selection_start = caret_pos = from;
125
120
  }
@@ -129,12 +124,12 @@ struct Gosu::TextInput::Impl
129
124
  selection_start = caret_pos;
130
125
  }
131
126
  }
132
-
127
+
133
128
  void delete_forward()
134
129
  {
135
130
  if (selection_start != caret_pos) {
136
- unsigned from = min(caret_pos, selection_start);
137
- unsigned to = max(caret_pos, selection_start);
131
+ unsigned from = std::min(caret_pos, selection_start);
132
+ unsigned to = std::max(caret_pos, selection_start);
138
133
  text.erase(text.begin() + from, text.begin() + to);
139
134
  selection_start = caret_pos = from;
140
135
  }
@@ -147,150 +142,147 @@ struct Gosu::TextInput::Impl
147
142
  };
148
143
 
149
144
  Gosu::TextInput::TextInput()
150
- : pimpl(new Impl)
145
+ : m_impl{new Impl}
151
146
  {
152
147
  }
153
148
 
154
- Gosu::TextInput::~TextInput()
155
- {
156
- // TODO: Unset Input::text_input to avoid stale pointers?
157
- }
149
+ Gosu::TextInput::~TextInput() = default;
158
150
 
159
- string Gosu::TextInput::text() const
151
+ std::string Gosu::TextInput::text() const
160
152
  {
161
- string composed_text = pimpl->text;
162
- if (!pimpl->composition.empty()) {
163
- composed_text.insert(pimpl->caret_pos, pimpl->composition);
153
+ std::string composed_text = m_impl->text;
154
+ if (!m_impl->composition.empty()) {
155
+ composed_text.insert(m_impl->caret_pos, m_impl->composition);
164
156
  }
165
157
  return composed_text;
166
158
  }
167
159
 
168
- void Gosu::TextInput::set_text(const string& text)
160
+ void Gosu::TextInput::set_text(const std::string& text)
169
161
  {
170
- pimpl->text = text;
171
- pimpl->composition.clear();
172
- pimpl->caret_pos = pimpl->selection_start = static_cast<unsigned>(pimpl->text.length());
162
+ m_impl->text = text;
163
+ m_impl->composition.clear();
164
+ m_impl->caret_pos = m_impl->selection_start = static_cast<unsigned>(m_impl->text.length());
173
165
  }
174
166
 
175
167
  unsigned Gosu::TextInput::caret_pos() const
176
168
  {
177
- return pimpl->caret_pos;
169
+ return m_impl->caret_pos;
178
170
  }
179
171
 
180
172
  void Gosu::TextInput::set_caret_pos(unsigned caret_pos)
181
173
  {
182
- pimpl->caret_pos = caret_pos;
174
+ m_impl->caret_pos = caret_pos;
183
175
  }
184
176
 
185
177
  unsigned Gosu::TextInput::selection_start() const
186
178
  {
187
- return pimpl->selection_start;
179
+ return m_impl->selection_start;
188
180
  }
189
181
 
190
182
  void Gosu::TextInput::set_selection_start(unsigned selection_start)
191
183
  {
192
- pimpl->selection_start = selection_start;
184
+ m_impl->selection_start = selection_start;
193
185
  }
194
186
 
195
187
  #ifndef GOSU_IS_IPHONE
196
188
  bool Gosu::TextInput::feed_sdl_event(void* event)
197
189
  {
198
190
  const SDL_Event* e = static_cast<SDL_Event*>(event);
199
-
191
+
200
192
  switch (e->type) {
201
- // Direct text input or completed IME composition.
202
- case SDL_TEXTINPUT: {
203
- pimpl->insert_text(filter(e->text.text));
204
- return true;
205
- }
206
- // IME composition in progress.
207
- case SDL_TEXTEDITING: {
208
- pimpl->composition = e->edit.text;
209
- return true;
210
- }
211
- // Emulate "standard" Windows/Linux keyboard behavior.
212
- case SDL_KEYDOWN: {
213
- // ...but not if the IME is currently compositing.
214
- if (!pimpl->composition.empty()) return false;
215
-
216
- #ifdef GOSU_IS_MAC
217
- bool words = (e->key.keysym.mod & (KMOD_LALT | KMOD_RALT));
218
- bool command_down = (e->key.keysym.mod & (KMOD_LGUI | KMOD_RGUI));
219
- #else
220
- bool words = (e->key.keysym.mod & (KMOD_LCTRL | KMOD_RCTRL));
221
- #endif
222
- bool shift_down = (e->key.keysym.mod & (KMOD_LSHIFT | KMOD_RSHIFT));
223
- SDL_Keycode key = e->key.keysym.sym;
224
-
225
- switch (key) {
226
- case SDLK_LEFT:
227
- #ifdef GOSU_IS_MAC
228
- if (command_down) {
229
- pimpl->move_to_beginning_of_line(!shift_down);
230
- return true;
231
- }
232
- #endif
233
- if (words) {
234
- pimpl->move_word_left(!shift_down);
235
- }
236
- else {
237
- pimpl->move_left(!shift_down);
238
- }
239
- return true;
240
- case SDLK_RIGHT:
241
- #ifdef GOSU_IS_MAC
242
- if (command_down) {
243
- pimpl->move_to_end_of_line(!shift_down);
244
- return true;
245
- }
246
- #endif
247
- if (words) {
248
- pimpl->move_word_right(!shift_down);
249
- }
250
- else {
251
- pimpl->move_right(!shift_down);
252
- }
253
- return true;
254
- #ifdef GOSU_IS_MAC
255
- case SDLK_UP:
256
- #endif
257
- case SDLK_HOME:
258
- pimpl->move_to_beginning_of_line(!shift_down);
259
- return true;
260
- #ifdef GOSU_IS_MAC
261
- case SDLK_DOWN:
262
- #endif
263
- case SDLK_END:
264
- pimpl->move_to_end_of_line(!shift_down);
193
+ // Direct text input or completed IME composition.
194
+ case SDL_TEXTINPUT: {
195
+ m_impl->insert_text(filter(e->text.text));
265
196
  return true;
266
- case SDLK_BACKSPACE:
267
- pimpl->delete_backward();
268
- return true;
269
- case SDLK_DELETE:
270
- pimpl->delete_forward();
197
+ }
198
+ // IME composition in progress.
199
+ case SDL_TEXTEDITING: {
200
+ m_impl->composition = e->edit.text;
271
201
  return true;
272
202
  }
273
- break;
274
- }
203
+ // Emulate "standard" Windows/Linux keyboard behavior.
204
+ case SDL_KEYDOWN: {
205
+ // ...but not if the IME is currently compositing.
206
+ if (!m_impl->composition.empty()) return false;
275
207
 
276
- // TODO: Handle copy & paste.
208
+ #ifdef GOSU_IS_MAC
209
+ bool words = (e->key.keysym.mod & (KMOD_LALT | KMOD_RALT));
210
+ bool command_down = (e->key.keysym.mod & (KMOD_LGUI | KMOD_RGUI));
211
+ #else
212
+ bool words = (e->key.keysym.mod & (KMOD_LCTRL | KMOD_RCTRL));
213
+ #endif
214
+ bool shift_down = (e->key.keysym.mod & (KMOD_LSHIFT | KMOD_RSHIFT));
215
+ SDL_Keycode key = e->key.keysym.sym;
216
+
217
+ switch (key) {
218
+ case SDLK_LEFT:
219
+ #ifdef GOSU_IS_MAC
220
+ if (command_down) {
221
+ m_impl->move_to_beginning_of_line(!shift_down);
222
+ return true;
223
+ }
224
+ #endif
225
+ if (words) {
226
+ m_impl->move_word_left(!shift_down);
227
+ }
228
+ else {
229
+ m_impl->move_left(!shift_down);
230
+ }
231
+ return true;
232
+ case SDLK_RIGHT:
233
+ #ifdef GOSU_IS_MAC
234
+ if (command_down) {
235
+ m_impl->move_to_end_of_line(!shift_down);
236
+ return true;
237
+ }
238
+ #endif
239
+ if (words) {
240
+ m_impl->move_word_right(!shift_down);
241
+ }
242
+ else {
243
+ m_impl->move_right(!shift_down);
244
+ }
245
+ return true;
246
+ #ifdef GOSU_IS_MAC
247
+ case SDLK_UP:
248
+ #endif
249
+ case SDLK_HOME:
250
+ m_impl->move_to_beginning_of_line(!shift_down);
251
+ return true;
252
+ #ifdef GOSU_IS_MAC
253
+ case SDLK_DOWN:
254
+ #endif
255
+ case SDLK_END:
256
+ m_impl->move_to_end_of_line(!shift_down);
257
+ return true;
258
+ case SDLK_BACKSPACE:
259
+ m_impl->delete_backward();
260
+ return true;
261
+ case SDLK_DELETE:
262
+ m_impl->delete_forward();
263
+ return true;
264
+ }
265
+ break;
266
+ }
267
+
268
+ // TODO: Handle copy & paste.
277
269
  }
278
-
270
+
279
271
  return false;
280
272
  }
281
273
  #endif
282
274
 
283
- void Gosu::TextInput::insert_text(string text)
275
+ void Gosu::TextInput::insert_text(std::string text)
284
276
  {
285
- pimpl->insert_text(text);
277
+ m_impl->insert_text(text);
286
278
  }
287
279
 
288
280
  void Gosu::TextInput::delete_forward()
289
281
  {
290
- pimpl->delete_forward();
282
+ m_impl->delete_forward();
291
283
  }
292
284
 
293
285
  void Gosu::TextInput::delete_backward()
294
286
  {
295
- pimpl->delete_backward();
287
+ m_impl->delete_backward();
296
288
  }