Browse Source

Support for imgui/SDL text input IME

Thomas Buck 9 years ago
parent
commit
6cf1b1923b

+ 1
- 0
ChangeLog.md View File

@@ -6,6 +6,7 @@
6 6
     * Added ability to visualize font _outline_.
7 7
     * Updated imgui to newest version, now with its own TTF support.
8 8
     * Fixed drawing of camera view frustum.
9
+    * Added support for imgui/SDLs IME text input rectangle.
9 10
 
10 11
     [ 20140117 ]
11 12
     * Updated imgui, fix for Logging to Clipboard included.

+ 2
- 0
include/system/Window.h View File

@@ -31,6 +31,8 @@ class Window {
31 31
 
32 32
     static void setClipboard(const char* s);
33 33
     static const char* getClipboard();
34
+
35
+    static void inputPositionCallback(int x, int y);
34 36
 };
35 37
 
36 38
 #endif

+ 2
- 0
include/system/WindowGLFW.h View File

@@ -34,6 +34,8 @@ class WindowGLFW {
34 34
     static void setClipboard(const char* s);
35 35
     static const char* getClipboard();
36 36
 
37
+    static void inputPositionCallback(int x, int y);
38
+
37 39
   private:
38 40
     static void errorCallback(int error, const char* desc);
39 41
     static void sizeCallback(GLFWwindow* w, int width, int height);

+ 2
- 0
include/system/WindowSDL.h View File

@@ -34,6 +34,8 @@ class WindowSDL {
34 34
     static void setClipboard(const char* s);
35 35
     static const char* getClipboard();
36 36
 
37
+    static void inputPositionCallback(int x, int y);
38
+
37 39
   private:
38 40
     static glm::i32vec2 size;
39 41
     static bool fullscreen;

+ 1
- 0
src/UI.cpp View File

@@ -80,6 +80,7 @@ int UI::initialize() {
80 80
     io.RenderDrawListsFn = UI::renderImGui;
81 81
     io.GetClipboardTextFn = Window::getClipboard;
82 82
     io.SetClipboardTextFn = Window::setClipboard;
83
+    io.ImeSetInputScreenPosFn = Window::inputPositionCallback;
83 84
 
84 85
     // Load font texture
85 86
     //! \TODO allow loading other TTF fonts

+ 8
- 0
src/system/Window.cpp View File

@@ -168,3 +168,11 @@ const char* Window::getClipboard() {
168 168
     return ret;
169 169
 }
170 170
 
171
+void Window::inputPositionCallback(int x, int y) {
172
+#ifdef USING_SDL
173
+    WindowSDL::inputPositionCallback(x, y);
174
+#elif defined(USING_GLFW)
175
+    WindowGLFW::inputPositionCallback(x, y);
176
+#endif
177
+}
178
+

+ 4
- 0
src/system/WindowGLFW.cpp View File

@@ -123,6 +123,10 @@ const char* WindowGLFW::getClipboard() {
123 123
     return nullptr;
124 124
 }
125 125
 
126
+void WindowGLFW::inputPositionCallback(int x, int y) {
127
+
128
+}
129
+
126 130
 void WindowGLFW::errorCallback(int error, const char* desc) {
127 131
     Log::get(LOG_ERROR) << "GLFW Error (" << error << "): " << desc << Log::endl;
128 132
 }

+ 9
- 0
src/system/WindowSDL.cpp View File

@@ -560,3 +560,12 @@ const char* WindowSDL::getClipboard() {
560 560
     return nullptr;
561 561
 }
562 562
 
563
+void WindowSDL::inputPositionCallback(int x, int y) {
564
+    SDL_Rect rect;
565
+    rect.x = x;
566
+    rect.y = y;
567
+    rect.w = 50;
568
+    rect.h = 25;
569
+    SDL_SetTextInputRect(&rect);
570
+}
571
+

Loading…
Cancel
Save