* take the precision into account while trying to add an optional character
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27298 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1233,6 +1233,16 @@ write_ellipsis(char* dst)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static bool
|
||||||
|
optional_char_fits(float escapement, float fontSize, float gap)
|
||||||
|
{
|
||||||
|
const float size = escapement * fontSize;
|
||||||
|
if (size <= gap || fabs(size - gap) <= 0.0001)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
truncate_end(const char* source, char* dest, uint32 numChars,
|
truncate_end(const char* source, char* dest, uint32 numChars,
|
||||||
const float* escapementArray, float width, float ellipsisWidth, float size)
|
const float* escapementArray, float width, float ellipsisWidth, float size)
|
||||||
@@ -1358,16 +1368,16 @@ truncate_middle(const char* source, char* dest, uint32 numChars,
|
|||||||
float gap = width - (leftWidth + ellipsisWidth + rightWidth);
|
float gap = width - (leftWidth + ellipsisWidth + rightWidth);
|
||||||
if (left > numChars - right) {
|
if (left > numChars - right) {
|
||||||
// try right letter first
|
// try right letter first
|
||||||
if (escapementArray[right - 1] * size <= gap) {
|
if (optional_char_fits(escapementArray[right - 1], size, gap)) {
|
||||||
right--;
|
right--;
|
||||||
} else if (escapementArray[left] * size <= gap) {
|
} else if (optional_char_fits(escapementArray[left], size, gap)) {
|
||||||
left++;
|
left++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// try left letter first
|
// try left letter first
|
||||||
if (escapementArray[left] * size <= gap) {
|
if (optional_char_fits(escapementArray[left], size, gap)) {
|
||||||
left++;
|
left++;
|
||||||
} else if (escapementArray[right - 1] * size <= gap) {
|
} else if (optional_char_fits(escapementArray[right - 1], size, gap)) {
|
||||||
right--;
|
right--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user