Fix drawing of output slots with utf-8 names. Also always show last letters in alread...
authorSv. Lockal <lockalsash@gmail.com>
Sun, 16 Sep 2012 19:06:17 +0000 (19:06 +0000)
committerSv. Lockal <lockalsash@gmail.com>
Sun, 16 Sep 2012 19:06:17 +0000 (19:06 +0000)
source/blender/editors/space_node/drawnode.c

index 5c3cbf40bbc89d2a11cd37c881b6dfa40966b32c..e2b7e09b2ae8c3cea2a3a568993a975cf98b9e33 100644 (file)
@@ -200,25 +200,22 @@ static void node_draw_output_default(const bContext *C, uiBlock *block,
                                      const char *name, int UNUSED(x), int UNUSED(y), int UNUSED(width))
 {
        SpaceNode *snode = CTX_wm_space_node(C);
-       float slen;
-       int ofs = 0;
        const char *ui_name = IFACE_(name);
-       int len = strlen(ui_name);
+       float slen;
+
        UI_ThemeColor(TH_TEXT);
        slen = (UI_GetStringWidth(ui_name) + NODE_MARGIN_X) * snode->aspect_sqrt;
-       while (slen > node->width && ofs < len) {
-               ofs++;
-               slen = (UI_GetStringWidth(ui_name + ofs) + NODE_MARGIN_X) * snode->aspect_sqrt;
+       while (slen > node->width && *ui_name) {
+               ui_name = BLI_str_find_next_char_utf8(ui_name, NULL);
+               slen = (UI_GetStringWidth(ui_name) + NODE_MARGIN_X) * snode->aspect_sqrt;
        }
-
-       if (ofs < len) {
-               uiDefBut(block, LABEL, 0, ui_name + ofs,
-                        (int)(sock->locx - slen), (int)(sock->locy - 9.0f),
-                        (short)(node->width - NODE_DY), (short)NODE_DY,
-                        NULL, 0, 0, 0, 0, "");
+       
+       if (*ui_name) {
+               uiDefBut(block, LABEL, 0, ui_name,
+                                (int)(sock->locx - slen), (int)(sock->locy - 9.0f),
+                                (short)slen, (short)NODE_DY,
+                                NULL, 0, 0, 0, 0, "");
        }
-
-       (void)snode;
 }
 
 /* ****************** BASE DRAW FUNCTIONS FOR NEW OPERATOR NODES ***************** */