2.5 filebrowser

- some cleanup of ugly conditional.
This commit is contained in:
Andrea Weikert
2009-05-26 21:34:20 +00:00
parent 3159f4a243
commit b89fb7d8fd

View File

@@ -182,12 +182,17 @@ static float shorten_string(char* string, float w, int flag)
float sw = 0;
float pad = 0;
if (w <= 0) {
*string = '\0';
return 0.0;
}
sw = file_string_width(string);
if (flag == FILE_SHORTEN_FRONT) {
char *s = string;
BLI_strncpy(temp, "...", 4);
pad = file_string_width(temp);
while (s && *s && (w > 0) && (sw+pad>w)) {
while ((*s) && (sw+pad>w)) {
s++;
sw = file_string_width(s);
shortened = 1;
@@ -200,14 +205,13 @@ static float shorten_string(char* string, float w, int flag)
}
} else {
char *s = string;
if (w>0) {
while (sw>w) {
int slen = strlen(string);
string[slen-1] = '\0';
sw = file_string_width(s);
shortened = 1;
}
while (sw>w) {
int slen = strlen(string);
string[slen-1] = '\0';
sw = file_string_width(s);
shortened = 1;
}
if (shortened) {
int slen = strlen(string);
if (slen > 3) {