# HG changeset patch # User Chris Cannam # Date 1142880162 0 # Node ID d072a3b59a0d93956a3ebd55a01c75a010ac0c5c # Parent 4df1a479bf10c9ed08b694f87344b3e14d1ca4f4 * truncate layer name texts if they get too wide diff -r 4df1a479bf10 -r d072a3b59a0d widgets/Pane.cpp --- 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; }