diff options
Diffstat (limited to 'source/blender/editors/interface/interface.c')
-rw-r--r-- | source/blender/editors/interface/interface.c | 59 |
1 files changed, 43 insertions, 16 deletions
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index abc668d72dd..2ff77d255c6 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -55,6 +55,7 @@ #include "BIF_gl.h" #include "BLF_api.h" +#include "BLF_translation.h" #include "UI_interface.h" @@ -93,19 +94,46 @@ static void ui_free_but(const bContext *C, uiBut *but); /* ************* translation ************** */ -int ui_translate_buttons(void) +int UI_translate_iface(void) { - return (U.transopts & USER_TR_BUTTONS); +#ifdef INTERNATIONAL + return (U.transopts & USER_DOTRANSLATE) && (U.transopts & USER_TR_IFACE); +#else + return 0; +#endif } -int ui_translate_menus(void) +int UI_translate_tooltips(void) { - return (U.transopts & USER_TR_MENUS); +#ifdef INTERNATIONAL + return (U.transopts & USER_DOTRANSLATE) && (U.transopts & USER_TR_TOOLTIPS); +#else + return 0; +#endif } -int ui_translate_tooltips(void) +const char *UI_translate_do_iface(const char *msgid) { - return (U.transopts & USER_TR_TOOLTIPS); +#ifdef INTERNATIONAL + if(UI_translate_iface()) + return BLF_gettext(msgid); + else + return msgid; +#else + return msgid; +#endif +} + +const char *UI_translate_do_tooltip(const char *msgid) +{ +#ifdef INTERNATIONAL + if(UI_translate_tooltips()) + return BLF_gettext(msgid); + else + return msgid; +#else + return msgid; +#endif } /* ************* window matrix ************** */ @@ -229,7 +257,7 @@ void ui_block_translate(uiBlock *block, int x, int y) static void ui_text_bounds_block(uiBlock *block, float offset) { - uiStyle *style= U.uistyles.first; // XXX pass on as arg + uiStyle *style=UI_GetStyle(); uiBut *bt; int i = 0, j, x1addval= offset, nextcol; int lastcol= 0, col= 0; @@ -238,9 +266,6 @@ static void ui_text_bounds_block(uiBlock *block, float offset) for(bt= block->buttons.first; bt; bt= bt->next) { if(bt->type!=SEPR) { - //int transopts= ui_translate_buttons(); - //if(bt->type==TEX || bt->type==IDPOIN) transopts= 0; - j= BLF_width(style->widget.uifont_id, bt->drawstr); if(j > i) i = j; @@ -930,7 +955,7 @@ static void ui_but_to_pixelrect(rcti *rect, const ARegion *ar, uiBlock *block, u /* uses local copy of style, to scale things down, and allow widgets to change stuff */ void uiDrawBlock(const bContext *C, uiBlock *block) { - uiStyle style= *((uiStyle *)U.uistyles.first); // XXX pass on as arg + uiStyle style= *UI_GetStyle(); // XXX pass on as arg ARegion *ar; uiBut *but; rcti rect; @@ -2033,12 +2058,9 @@ void ui_check_but(uiBut *but) /* if something changed in the button */ double value= UI_BUT_VALUE_UNSET; // float okwidth; // UNUSED -// int transopts= ui_translate_buttons(); ui_is_but_sel(but, &value); -// if(but->type==TEX || but->type==IDPOIN) transopts= 0; - /* only update soft range while not editing */ if(but->rnaprop && !(but->editval || but->editstr || but->editvec)) { UI_GET_BUT_VALUE_INIT(but, value) @@ -2547,7 +2569,7 @@ static uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, const char *s DynStr *dynstr; int i, totitem, value, free; - RNA_property_enum_items(block->evil_C, ptr, prop, &item, &totitem, &free); + RNA_property_enum_items_gettexted(block->evil_C, ptr, prop, &item, &totitem, &free); value= RNA_property_enum_get(ptr, prop); dynstr= BLI_dynstr_new(); @@ -2582,7 +2604,7 @@ static uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, const char *s EnumPropertyItem *item; int i, totitem, free; - RNA_property_enum_items(block->evil_C, ptr, prop, &item, &totitem, &free); + RNA_property_enum_items_gettexted(block->evil_C, ptr, prop, &item, &totitem, &free); for(i=0; i<totitem; i++) { if(item[i].identifier[0] && item[i].value == (int)max) { str= item[i].name; @@ -2710,6 +2732,11 @@ static uiBut *ui_def_but_operator(uiBlock *block, int type, const char *opname, if ((!tip || tip[0]=='\0') && ot && ot->description) { tip= ot->description; + +#ifdef INTERNATIONAL + if(UI_translate_tooltips()) + tip= BLF_gettext(tip); +#endif } but= ui_def_but(block, type, -1, str, x1, y1, x2, y2, NULL, 0, 0, 0, 0, tip); |