Mercurial > hg > svgui
changeset 299:5c59c433b358
* Show colour swatch next to layer name in pane (if available)
* Fix for incorrect layer name prefix handling (was making some layers appear
to have the same model name in cases where the model names differed by the
final character only)
| author | Chris Cannam |
|---|---|
| date | Wed, 05 Sep 2007 15:17:15 +0000 |
| parents | 226cb289bdf4 |
| children | 0824a754a8eb |
| files | layer/Layer.h layer/SingleColourLayer.cpp layer/SingleColourLayer.h view/Pane.cpp |
| diffstat | 4 files changed, 23 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/layer/Layer.h Thu Aug 16 16:47:07 2007 +0000 +++ b/layer/Layer.h Wed Sep 05 15:17:15 2007 +0000 @@ -24,6 +24,7 @@ #include <QRect> #include <QXmlAttributes> #include <QMutex> +#include <QPixmap> #include <map> #include <set> @@ -95,6 +96,7 @@ } virtual QString getLayerPresentationName() const; + virtual QPixmap getLayerPresentationPixmap(QSize) const { return QPixmap(); } virtual int getVerticalScaleWidth(View *, QPainter &) const { return 0; } virtual void paintVerticalScale(View *, QPainter &, QRect) const { }
--- a/layer/SingleColourLayer.cpp Thu Aug 16 16:47:07 2007 +0000 +++ b/layer/SingleColourLayer.cpp Wed Sep 05 15:17:15 2007 +0000 @@ -31,6 +31,12 @@ setDefaultColourFor(0); } +QPixmap +SingleColourLayer::getLayerPresentationPixmap(QSize size) const +{ + return ColourDatabase::getInstance()->getExamplePixmap(m_colour, size); +} + bool SingleColourLayer::hasLightBackground() const {
--- a/layer/SingleColourLayer.h Thu Aug 16 16:47:07 2007 +0000 +++ b/layer/SingleColourLayer.h Wed Sep 05 15:17:15 2007 +0000 @@ -33,6 +33,8 @@ return ColourDistinguishes; } + virtual QPixmap getLayerPresentationPixmap(QSize size) const; + virtual PropertyList getProperties() const; virtual QString getPropertyLabel(const PropertyName &) const; virtual PropertyType getPropertyType(const PropertyName &) const;
--- a/view/Pane.cpp Thu Aug 16 16:47:07 2007 +0000 +++ b/view/Pane.cpp Wed Sep 05 15:17:15 2007 +0000 @@ -716,8 +716,13 @@ } QStringList texts; + std::vector<QPixmap> pixmaps; for (LayerList::iterator i = m_layers.begin(); i != m_layers.end(); ++i) { texts.push_back((*i)->getLayerPresentationName()); +// std::cerr << "Pane " << this << ": Layer presentation name for " << *i << ": " +// << texts[texts.size()-1].toStdString() << std::endl; + pixmaps.push_back((*i)->getLayerPresentationPixmap + (QSize(fontAscent, fontAscent))); } int maxTextWidth = width() / 3; @@ -734,6 +739,8 @@ if (r.x() + r.width() >= llx) { for (size_t i = 0; i < texts.size(); ++i) { + +// std::cerr << "Pane "<< this << ": text " << i << ": " << texts[i].toStdString() << std::endl; if (i + 1 == texts.size()) { paint.setPen(getForeground()); @@ -742,6 +749,12 @@ drawVisibleText(paint, llx, lly - fontHeight + fontAscent, texts[i], OutlinedText); + + if (!pixmaps[i].isNull()) { + paint.drawPixmap(llx - fontAscent - 3, + lly - fontHeight + (fontHeight-fontAscent)/2, + pixmaps[i]); + } lly -= fontHeight; }
