Kaynağa Gözat

Support for imgui/SDL text input IME

Thomas Buck 9 yıl önce
ebeveyn
işleme
6cf1b1923b

+ 1
- 0
ChangeLog.md Dosyayı Görüntüle

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

+ 2
- 0
include/system/Window.h Dosyayı Görüntüle

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

+ 2
- 0
include/system/WindowGLFW.h Dosyayı Görüntüle

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

+ 2
- 0
include/system/WindowSDL.h Dosyayı Görüntüle

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

+ 1
- 0
src/UI.cpp Dosyayı Görüntüle

80
     io.RenderDrawListsFn = UI::renderImGui;
80
     io.RenderDrawListsFn = UI::renderImGui;
81
     io.GetClipboardTextFn = Window::getClipboard;
81
     io.GetClipboardTextFn = Window::getClipboard;
82
     io.SetClipboardTextFn = Window::setClipboard;
82
     io.SetClipboardTextFn = Window::setClipboard;
83
+    io.ImeSetInputScreenPosFn = Window::inputPositionCallback;
83
 
84
 
84
     // Load font texture
85
     // Load font texture
85
     //! \TODO allow loading other TTF fonts
86
     //! \TODO allow loading other TTF fonts

+ 8
- 0
src/system/Window.cpp Dosyayı Görüntüle

168
     return ret;
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 Dosyayı Görüntüle

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

+ 9
- 0
src/system/WindowSDL.cpp Dosyayı Görüntüle

560
     return nullptr;
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…
İptal
Kaydet