Mercurial > hg > svgui
changeset 61:d072a3b59a0d
* truncate layer name texts if they get too wide
author | Chris Cannam |
---|---|
date | Mon, 20 Mar 2006 18:42:42 +0000 |
parents | 4df1a479bf10 |
children | 50429a56680f |
files | widgets/Pane.cpp |
diffstat | 1 files changed, 15 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/widgets/Pane.cpp Mon Mar 20 18:18:30 2006 +0000 +++ b/widgets/Pane.cpp Mon Mar 20 18:42:42 2006 +0000 @@ -330,8 +330,22 @@ for (LayerList::iterator i = m_layers.begin(); i != m_layers.end(); ++i) { QString text = (*i)->getLayerPresentationName(); - texts.push_back(text); int tw = paint.fontMetrics().width(text); + bool reduced = false; + while (tw > width() / 3 && text.length() > 4) { + if (!reduced && text.length() > 8) { + text = text.left(text.length() - 4); + } else { + text = text.left(text.length() - 2); + } + reduced = true; + tw = paint.fontMetrics().width(text + "..."); + } + if (reduced) { + texts.push_back(text + "..."); + } else { + texts.push_back(text); + } if (tw > maxTextWidth) maxTextWidth = tw; }