Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2016-05-03 13:38:21 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2016-05-03 13:38:21 +0300
commitcb6307162b4c12743cee0db6b05f6b3a68f5258e (patch)
treebef89fc17e10b72f0c11a2f04ce511b61dfcbc12 /source
parentb34f177a39ce9fdfac05f60d21f6b763833f00f2 (diff)
Cache whether current translation language supports IME or not
Solves the weak point mentionedi n previous commit.
Diffstat (limited to 'source')
-rw-r--r--source/blender/blentranslation/BLT_translation.h1
-rw-r--r--source/blender/blentranslation/CMakeLists.txt6
-rw-r--r--source/blender/blentranslation/intern/blt_lang.c36
-rw-r--r--source/blender/editors/interface/interface_handlers.c17
4 files changed, 45 insertions, 15 deletions
diff --git a/source/blender/blentranslation/BLT_translation.h b/source/blender/blentranslation/BLT_translation.h
index efd59c3fa94..3838e8c827c 100644
--- a/source/blender/blentranslation/BLT_translation.h
+++ b/source/blender/blentranslation/BLT_translation.h
@@ -54,6 +54,7 @@ const char *BLT_translate_do_iface(const char *msgctxt, const char *msgid);
const char *BLT_translate_do_tooltip(const char *msgctxt, const char *msgid);
const char *BLT_translate_do_new_dataname(const char *msgctxt, const char *msgid);
+bool BLT_lang_is_ime_supported(void);
/* The "translation-marker" macro. */
#define N_(msgid) msgid
diff --git a/source/blender/blentranslation/CMakeLists.txt b/source/blender/blentranslation/CMakeLists.txt
index 59bd7f0adfa..a3e85344027 100644
--- a/source/blender/blentranslation/CMakeLists.txt
+++ b/source/blender/blentranslation/CMakeLists.txt
@@ -53,4 +53,10 @@ if(WITH_PYTHON)
)
endif()
+if(WIN32)
+ if(WITH_INPUT_IME)
+ add_definitions(-DWITH_INPUT_IME)
+ endif()
+endif()
+
blender_add_lib(bf_blentranslation "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/blender/blentranslation/intern/blt_lang.c b/source/blender/blentranslation/intern/blt_lang.c
index 1ad62fa5869..40771b3315a 100644
--- a/source/blender/blentranslation/intern/blt_lang.c
+++ b/source/blender/blentranslation/intern/blt_lang.c
@@ -64,6 +64,12 @@ static int num_locales = 0;
static EnumPropertyItem *locales_menu = NULL;
static int num_locales_menu = 0;
+#ifdef WITH_INPUT_IME
+/* Cached IME support flags */
+static bool ime_is_lang_supported = false;
+static void blt_lang_check_ime_supported(void);
+#endif
+
static void free_locales(void)
{
if (locales) {
@@ -280,6 +286,7 @@ void BLT_lang_set(const char *str)
#else
(void)str;
#endif
+ blt_lang_check_ime_supported();
}
/* Get the current locale (short code, e.g. es_ES). */
@@ -355,3 +362,32 @@ void BLT_lang_locale_explode(
MEM_freeN(_t);
}
}
+
+/* Test if the translation context allows IME input - used to
+ * avoid weird character drawing if IME inputs non-ascii chars.
+ */
+static void blt_lang_check_ime_supported(void)
+{
+#ifdef WITH_INPUT_IME
+ const char *uilng = BLT_lang_get();
+ if (U.transopts & USER_DOTRANSLATE) {
+ ime_is_lang_supported = STREQ(uilng, "zh_CN") ||
+ STREQ(uilng, "zh_TW") ||
+ STREQ(uilng, "ja_JP");
+ }
+ else {
+ ime_is_lang_supported = false;
+ }
+#else
+ ime_is_lang_supported = false;
+#endif
+}
+
+bool BLT_lang_is_ime_supported(void)
+{
+#ifdef WITH_INPUT_IME
+ return ime_is_lang_supported;
+#else
+ return false;
+#endif
+}
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index c6cd03d7ac7..2840be02ef8 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -2945,19 +2945,6 @@ static bool ui_textedit_copypaste(uiBut *but, uiHandleButtonData *data, const in
}
#ifdef WITH_INPUT_IME
-/* test if the translation context allows IME input - used to
- * avoid weird character drawing if IME inputs non-ascii chars */
-static bool ui_ime_is_lang_supported(void)
-{
- const char *uilng = BLT_lang_get();
- if (U.transopts & USER_DOTRANSLATE) {
- return STREQ(uilng, "zh_CN") ||
- STREQ(uilng, "zh_TW") ||
- STREQ(uilng, "ja_JP");
- }
- return false;
-}
-
/* enable ime, and set up uibut ime data */
static void ui_textedit_ime_begin(wmWindow *win, uiBut *UNUSED(but))
{
@@ -3079,7 +3066,7 @@ static void ui_textedit_begin(bContext *C, uiBut *but, uiHandleButtonData *data)
WM_cursor_modal_set(win, BC_TEXTEDITCURSOR);
#ifdef WITH_INPUT_IME
- if (is_num_but == false && ui_ime_is_lang_supported()) {
+ if (is_num_but == false && BLT_lang_is_ime_supported()) {
ui_textedit_ime_begin(win, but);
}
#endif
@@ -3406,7 +3393,7 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle
#ifdef WITH_INPUT_IME
&&
!is_ime_composing &&
- (!WM_event_is_ime_switch(event) || !ui_ime_is_lang_supported())
+ (!WM_event_is_ime_switch(event) || !BLT_lang_is_ime_supported())
#endif
)
{