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
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2013-12-18 00:15:25 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-12-18 00:18:28 +0400
commitd41b2bb25f5caf88e8f41a1f37297cd555ae158c (patch)
tree4979b50173b58deceefd164b41ff2de81993a472 /source/blender/editors/interface
parenta80278a1912c129d6176743a1540d9c918a29f51 (diff)
Fix issue with right aligned number buttons overlapping the label
This also simplifies button clipping which was attempting to detect offsets that were applied afterwards, Now apply text clipping after adjusting the button rect margins.
Diffstat (limited to 'source/blender/editors/interface')
-rw-r--r--source/blender/editors/interface/interface_widgets.c67
1 files changed, 27 insertions, 40 deletions
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index 9382a3b3a20..af5520340d3 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -1046,8 +1046,8 @@ static void ui_text_clip_cursor(uiFontStyle *fstyle, uiBut *but, const rcti *rec
*/
static void ui_text_clip_right_label(uiFontStyle *fstyle, uiBut *but, const rcti *rect)
{
- int border = (but->drawflag & UI_BUT_ALIGN_RIGHT) ? 8 : 10;
- int okwidth = max_ii(BLI_rcti_size_x(rect) - border, 0);
+ const int border = 4;
+ const int okwidth = max_ii(BLI_rcti_size_x(rect) - border, 0);
char *cpoin = NULL;
int drawstr_len = strlen(but->drawstr);
char *cpend = but->drawstr + drawstr_len;
@@ -1256,7 +1256,7 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b
/* part text right aligned */
if (drawstr_right) {
fstyle->align = UI_STYLE_TEXT_RIGHT;
- rect->xmax -= ui_but_draw_menu_icon(but) ? UI_DPI_ICON_SIZE : 0.25f * U.widget_unit;
+ rect->xmax -= 0.25f * U.widget_unit / but->block->aspect;
uiStyleFontDraw(fstyle, rect, drawstr_right);
}
}
@@ -1272,29 +1272,11 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB
ui_button_text_password_hide(password_str, but, FALSE);
- /* clip but->drawstr to fit in available space */
- if (but->editstr && but->pos >= 0) {
- ui_text_clip_cursor(fstyle, but, rect);
- }
- else if (ELEM(but->type, NUM, NUMSLI)) {
- ui_text_clip_right_label(fstyle, but, rect);
- }
- else if (ELEM3(but->type, TEX, SEARCH_MENU, SEARCH_MENU_UNLINK)) {
- ui_text_clip_left(fstyle, but, rect);
- }
- else if ((but->block->flag & UI_BLOCK_LOOP) && (but->type == BUT)) {
- ui_text_clip_left(fstyle, but, rect);
- }
- else {
- but->ofs = 0;
- }
-
/* check for button text label */
if (but->type == MENU && (but->flag & UI_BUT_NODE_LINK)) {
- int tmp = rect->xmin;
- rect->xmin = rect->xmax - BLI_rcti_size_y(rect) - 1;
- widget_draw_icon(but, ICON_LAYER_USED, alpha, rect);
- rect->xmin = tmp;
+ rcti temp = *rect;
+ temp.xmin = rect->xmax - BLI_rcti_size_y(rect) - 1;
+ widget_draw_icon(but, ICON_LAYER_USED, alpha, &temp);
}
/* If there's an icon too (made with uiDefIconTextBut) then draw the icon
@@ -1302,23 +1284,11 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB
if (but->flag & UI_HAS_ICON) {
widget_draw_icon(but, but->icon + but->iconadd, alpha, rect);
-
- /* icons default draw 0.8f x height */
- rect->xmin += (int)(0.8f * BLI_rcti_size_y(rect));
-
- if (but->editstr || (but->drawflag & UI_BUT_TEXT_LEFT)) {
- if (but->editstr || but->ofs == 0) {
- rect->xmin += (UI_TEXT_MARGIN_X * U.widget_unit) / but->block->aspect;
- }
- }
- else if ((but->drawflag & UI_BUT_TEXT_RIGHT)) {
- rect->xmax -= (UI_TEXT_MARGIN_X * U.widget_unit) / but->block->aspect;
- }
+ rect->xmin += 0.8f * BLI_rcti_size_y(rect);
}
- else if ((but->drawflag & UI_BUT_TEXT_LEFT)) {
- if (but->ofs == 0) {
- rect->xmin += (UI_TEXT_MARGIN_X * U.widget_unit) / but->block->aspect;
- }
+
+ if (but->editstr || (but->drawflag & UI_BUT_TEXT_LEFT)) {
+ rect->xmin += (UI_TEXT_MARGIN_X * U.widget_unit) / but->block->aspect;
}
else if ((but->drawflag & UI_BUT_TEXT_RIGHT)) {
rect->xmax -= (UI_TEXT_MARGIN_X * U.widget_unit) / but->block->aspect;
@@ -1332,6 +1302,23 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB
widget_draw_icon(but, ICON_X, alpha, &temp);
}
+ /* clip but->drawstr to fit in available space */
+ if (but->editstr && but->pos >= 0) {
+ ui_text_clip_cursor(fstyle, but, rect);
+ }
+ else if (ELEM(but->type, NUM, NUMSLI)) {
+ ui_text_clip_right_label(fstyle, but, rect);
+ }
+ else if (ELEM3(but->type, TEX, SEARCH_MENU, SEARCH_MENU_UNLINK)) {
+ ui_text_clip_left(fstyle, but, rect);
+ }
+ else if ((but->block->flag & UI_BLOCK_LOOP) && (but->type == BUT)) {
+ ui_text_clip_left(fstyle, but, rect);
+ }
+ else {
+ but->ofs = 0;
+ }
+
/* always draw text for textbutton cursor */
widget_draw_text(fstyle, wcol, but, rect);