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:
authorBastien Montagne <montagne29@wanadoo.fr>2014-01-04 19:50:42 +0400
committerBastien Montagne <montagne29@wanadoo.fr>2014-01-04 19:50:42 +0400
commit0074eac1ed6a876a951f04b6a017fd7058041558 (patch)
tree56b4c989bc886cadb2083b78a19009a543eabae8 /source/blender/editors/interface
parent76d9244843457c8c5bc3be6085167d85e0a20232 (diff)
More tweaks to clip middle:
* Do not apply margins with MENU (i.e. dropdowns) either. * When middle clipping would remove only a few chars, rather clip right part!
Diffstat (limited to 'source/blender/editors/interface')
-rw-r--r--source/blender/editors/interface/interface_widgets.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index 5e91b5cd305..c6aabbc61ca 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -973,7 +973,7 @@ static void ui_text_clip_left(uiFontStyle *fstyle, uiBut *but, const rcti *rect)
static void ui_text_clip_middle(uiFontStyle *fstyle, uiBut *but, const rcti *rect)
{
/* No margin for labels! */
- const int border = (but->type == LABEL) ? 0 : (int)(UI_TEXT_CLIP_MARGIN + 0.5f);
+ const int border = ELEM(but->type, LABEL, MENU) ? 0 : (int)(UI_TEXT_CLIP_MARGIN + 0.5f);
const int okwidth = max_ii(BLI_rcti_size_x(rect) - border, 0);
float strwidth;
@@ -996,8 +996,10 @@ static void ui_text_clip_middle(uiFontStyle *fstyle, uiBut *but, const rcti *rec
const float sep_strwidth = BLF_width(fstyle->uifont_id, sep, sep_len + 1);
const float parts_strwidth = ((float)okwidth - sep_strwidth) / 2.0f;
- if (parts_strwidth < (float)(UI_DPI_ICON_SIZE) / but->block->aspect * 1.5) {
- /* If we really have no place, only show start of string. */
+ if (min_ff(parts_strwidth, strwidth - okwidth) < (float)(UI_DPI_ICON_SIZE) / but->block->aspect * 1.5) {
+ /* If we really have no place, or we would clip a very small piece of string in the middle,
+ * only show start of string.
+ */
l_end = BLF_width_to_strlen(fstyle->uifont_id, but->drawstr, max_len, okwidth, &strwidth);
but->drawstr[l_end] = '\0';
}