Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/interface_widgets.c
| Context not available. | |||||
| int drawstr_left_len = UI_MAX_DRAW_STR; | int drawstr_left_len = UI_MAX_DRAW_STR; | ||||
| char *drawstr_right = NULL; | char *drawstr_right = NULL; | ||||
| bool use_right_only = false; | bool use_right_only = false; | ||||
| char *drawstr = but->drawstr; | |||||
| uiStyleFontSet(fstyle); | uiStyleFontSet(fstyle); | ||||
| Context not available. | |||||
| if (fstyle->kerning == 1) /* for BLF_width */ | if (fstyle->kerning == 1) /* for BLF_width */ | ||||
| BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT); | BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT); | ||||
| /* Special case: when we're entering text for multiple buttons, | |||||
| * don't draw the text for any of the multi-editing buttons */ | |||||
| if (UNLIKELY(but->flag & UI_BUT_DRAG_MULTI)) { | |||||
| uiBut *but_iter; | |||||
| for (but_iter = but->block->buttons.first; but_iter; but_iter = but_iter->next) { | |||||
| if (but_iter->editstr) { | |||||
| drawstr = but_iter->editstr; | |||||
| fstyle->align = UI_STYLE_TEXT_LEFT; | |||||
| break; | |||||
| } | |||||
| } | |||||
| } | |||||
| /* text button selection and cursor */ | /* text button selection and cursor */ | ||||
| if (but->editstr && but->pos != -1) { | if (but->editstr && but->pos != -1) { | ||||
| short t = 0, pos = 0; | short t = 0, pos = 0; | ||||
| Context not available. | |||||
| selsta_tmp = but->selsta; | selsta_tmp = but->selsta; | ||||
| selend_tmp = but->selend; | selend_tmp = but->selend; | ||||
| if (but->drawstr[0] != 0) { | if (drawstr[0] != 0) { | ||||
| if (but->selsta >= but->ofs) { | if (but->selsta >= but->ofs) { | ||||
| selsta_draw = BLF_width(fstyle->uifont_id, but->drawstr + but->ofs, selsta_tmp - but->ofs); | selsta_draw = BLF_width(fstyle->uifont_id, drawstr + but->ofs, selsta_tmp - but->ofs); | ||||
| } | } | ||||
| else { | else { | ||||
| selsta_draw = 0; | selsta_draw = 0; | ||||
| } | } | ||||
| selwidth_draw = BLF_width(fstyle->uifont_id, but->drawstr + but->ofs, selend_tmp - but->ofs); | selwidth_draw = BLF_width(fstyle->uifont_id, drawstr + but->ofs, selend_tmp - but->ofs); | ||||
| glColor4ubv((unsigned char *)wcol->item); | glColor4ubv((unsigned char *)wcol->item); | ||||
| glRects(rect->xmin + selsta_draw, rect->ymin + 2, rect->xmin + selwidth_draw, rect->ymax - 2); | glRects(rect->xmin + selsta_draw, rect->ymin + 2, rect->xmin + selwidth_draw, rect->ymax - 2); | ||||
| Context not available. | |||||
| /* text cursor */ | /* text cursor */ | ||||
| pos = but->pos; | pos = but->pos; | ||||
| if (pos >= but->ofs) { | if (pos >= but->ofs) { | ||||
| if (but->drawstr[0] != 0) { | if (drawstr[0] != 0) { | ||||
| t = BLF_width(fstyle->uifont_id, but->drawstr + but->ofs, pos - but->ofs) / but->aspect; | t = BLF_width(fstyle->uifont_id, drawstr + but->ofs, pos - but->ofs) / but->aspect; | ||||
| } | } | ||||
| glColor3f(0.20, 0.6, 0.9); | glColor3f(0.20, 0.6, 0.9); | ||||
| Context not available. | |||||
| /* cut string in 2 parts - only for menu entries */ | /* cut string in 2 parts - only for menu entries */ | ||||
| if ((but->block->flag & UI_BLOCK_LOOP)) { | if ((but->block->flag & UI_BLOCK_LOOP)) { | ||||
| if (ELEM3(but->type, NUM, TEX, NUMSLI) == 0) { | if (ELEM3(but->type, NUM, TEX, NUMSLI) == 0) { | ||||
| drawstr_right = strchr(but->drawstr, UI_SEP_CHAR); | drawstr_right = strchr(drawstr, UI_SEP_CHAR); | ||||
| if (drawstr_right) { | if (drawstr_right) { | ||||
| drawstr_left_len = (drawstr_right - but->drawstr); | drawstr_left_len = (drawstr_right - drawstr); | ||||
| drawstr_right++; | drawstr_right++; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| #ifdef USE_NUMBUTS_LR_ALIGN | #ifdef USE_NUMBUTS_LR_ALIGN | ||||
| if (!drawstr_right && ELEM(but->type, NUM, NUMSLI) && (but->editstr == NULL)) { | if (!drawstr_right && ELEM(but->type, NUM, NUMSLI) && (but->editstr == NULL) && (drawstr == but->drawstr)) { | ||||
| drawstr_right = strchr(but->drawstr + but->ofs, ':'); | drawstr_right = strchr(drawstr + but->ofs, ':'); | ||||
| if (drawstr_right) { | if (drawstr_right) { | ||||
| drawstr_right++; | drawstr_right++; | ||||
| drawstr_left_len = (drawstr_right - but->drawstr); | drawstr_left_len = (drawstr_right - drawstr); | ||||
| while (*drawstr_right == ' ') { | while (*drawstr_right == ' ') { | ||||
| drawstr_right++; | drawstr_right++; | ||||
| Context not available. | |||||
| } | } | ||||
| else { | else { | ||||
| /* no prefix, even so use only cpoin */ | /* no prefix, even so use only cpoin */ | ||||
| drawstr_right = but->drawstr + but->ofs; | drawstr_right = drawstr + but->ofs; | ||||
| use_right_only = true; | use_right_only = true; | ||||
| } | } | ||||
| } | } | ||||
| Context not available. | |||||
| /* for underline drawing */ | /* for underline drawing */ | ||||
| float font_xofs, font_yofs; | float font_xofs, font_yofs; | ||||
| uiStyleFontDrawExt(fstyle, rect, but->drawstr + but->ofs, | uiStyleFontDrawExt(fstyle, rect, drawstr + but->ofs, | ||||
| drawstr_left_len - but->ofs, &font_xofs, &font_yofs); | drawstr_left_len - but->ofs, &font_xofs, &font_yofs); | ||||
| if (but->menu_key != '\0') { | if (but->menu_key != '\0') { | ||||
| char fixedbuf[128]; | char fixedbuf[128]; | ||||
| char *str; | char *str; | ||||
| BLI_strncpy(fixedbuf, but->drawstr + but->ofs, min_ii(sizeof(fixedbuf), drawstr_left_len)); | BLI_strncpy(fixedbuf, drawstr + but->ofs, min_ii(sizeof(fixedbuf), drawstr_left_len)); | ||||
| str = strchr(fixedbuf, but->menu_key - 32); /* upper case */ | str = strchr(fixedbuf, but->menu_key - 32); /* upper case */ | ||||
| if (str == NULL) | if (str == NULL) | ||||
| Context not available. | |||||
| char red[4] = {255, 0, 0}; | char red[4] = {255, 0, 0}; | ||||
| widget_state_blend(wt->wcol.inner, red, 0.4f); | widget_state_blend(wt->wcol.inner, red, 0.4f); | ||||
| } | } | ||||
| if (state & UI_BUT_DRAG_MULTI) { | |||||
| /* XXX - should use theme color, | |||||
| * this happens to make the button look pressed with the default theme */ | |||||
| char col[4] = {0, 0, 0}; | |||||
| widget_state_blend(wt->wcol.inner, col, 0.12f); | |||||
| } | |||||
| if (state & UI_BUT_NODE_ACTIVE) { | if (state & UI_BUT_NODE_ACTIVE) { | ||||
| char blue[4] = {86, 128, 194}; | char blue[4] = {86, 128, 194}; | ||||
| widget_state_blend(wt->wcol.inner, blue, 0.3f); | widget_state_blend(wt->wcol.inner, blue, 0.3f); | ||||
| Context not available. | |||||