Mercurial > hg > svgui
comparison widgets/Pane.cpp @ 61:d072a3b59a0d
* truncate layer name texts if they get too wide
author | Chris Cannam |
---|---|
date | Mon, 20 Mar 2006 18:42:42 +0000 |
parents | 705f05ab42e3 |
children | c4fff27cd651 |
comparison
equal
deleted
inserted
replaced
60:4df1a479bf10 | 61:d072a3b59a0d |
---|---|
328 int maxTextWidth = 0; | 328 int maxTextWidth = 0; |
329 | 329 |
330 for (LayerList::iterator i = m_layers.begin(); i != m_layers.end(); ++i) { | 330 for (LayerList::iterator i = m_layers.begin(); i != m_layers.end(); ++i) { |
331 | 331 |
332 QString text = (*i)->getLayerPresentationName(); | 332 QString text = (*i)->getLayerPresentationName(); |
333 texts.push_back(text); | |
334 int tw = paint.fontMetrics().width(text); | 333 int tw = paint.fontMetrics().width(text); |
334 bool reduced = false; | |
335 while (tw > width() / 3 && text.length() > 4) { | |
336 if (!reduced && text.length() > 8) { | |
337 text = text.left(text.length() - 4); | |
338 } else { | |
339 text = text.left(text.length() - 2); | |
340 } | |
341 reduced = true; | |
342 tw = paint.fontMetrics().width(text + "..."); | |
343 } | |
344 if (reduced) { | |
345 texts.push_back(text + "..."); | |
346 } else { | |
347 texts.push_back(text); | |
348 } | |
335 if (tw > maxTextWidth) maxTextWidth = tw; | 349 if (tw > maxTextWidth) maxTextWidth = tw; |
336 } | 350 } |
337 | 351 |
338 int lly = height() - 6; | 352 int lly = height() - 6; |
339 | 353 |