Mercurial > hg > svgui
comparison layer/SingleColourLayer.cpp @ 366:a55affd7ab6c
* Avoid setting a new colour on layer when adding the same layer more than
once
author | Chris Cannam |
---|---|
date | Mon, 11 Feb 2008 11:06:17 +0000 |
parents | c0b9eec70639 |
children | 06360ed99cd1 |
comparison
equal
deleted
inserted
replaced
365:26ce2fb7bcbf | 366:a55affd7ab6c |
---|---|
25 SingleColourLayer::ColourRefCount | 25 SingleColourLayer::ColourRefCount |
26 SingleColourLayer::m_colourRefCount; | 26 SingleColourLayer::m_colourRefCount; |
27 | 27 |
28 SingleColourLayer::SingleColourLayer() : | 28 SingleColourLayer::SingleColourLayer() : |
29 m_colour(0), | 29 m_colour(0), |
30 m_colourExplicitlySet(false) | 30 m_colourExplicitlySet(false), |
31 m_defaultColourSet(false) | |
31 { | 32 { |
32 setDefaultColourFor(0); | 33 setDefaultColourFor(0); |
33 } | 34 } |
34 | 35 |
35 QPixmap | 36 QPixmap |
123 } | 124 } |
124 | 125 |
125 void | 126 void |
126 SingleColourLayer::setDefaultColourFor(View *v) | 127 SingleColourLayer::setDefaultColourFor(View *v) |
127 { | 128 { |
128 if (m_colourExplicitlySet) return; | 129 std::cerr << "SingleColourLayer::setDefaultColourFor: m_colourExplicitlySet = " << m_colourExplicitlySet << ", m_defaultColourSet " << m_defaultColourSet << std::endl; |
130 | |
131 if (m_colourExplicitlySet || m_defaultColourSet) return; | |
129 | 132 |
130 bool dark = false; | 133 bool dark = false; |
131 if (v) { | 134 if (v) { |
132 dark = !v->hasLightBackground(); | 135 dark = !v->hasLightBackground(); |
133 } else { | 136 } else { |
153 // std::cerr << "(from ctor)" << std::endl; | 156 // std::cerr << "(from ctor)" << std::endl; |
154 } | 157 } |
155 | 158 |
156 if (hint >= 0 && impose) { | 159 if (hint >= 0 && impose) { |
157 setBaseColour(hint); | 160 setBaseColour(hint); |
161 m_defaultColourSet = true; | |
158 return; | 162 return; |
159 } | 163 } |
160 | 164 |
161 int bestCount = 0, bestColour = -1; | 165 int bestCount = 0, bestColour = -1; |
162 | 166 |
188 if (m_colourRefCount.find(m_colour) == m_colourRefCount.end()) { | 192 if (m_colourRefCount.find(m_colour) == m_colourRefCount.end()) { |
189 m_colourRefCount[m_colour] = 1; | 193 m_colourRefCount[m_colour] = 1; |
190 } else { | 194 } else { |
191 m_colourRefCount[m_colour]++; | 195 m_colourRefCount[m_colour]++; |
192 } | 196 } |
197 | |
198 m_defaultColourSet = true; | |
193 } | 199 } |
194 | 200 |
195 void | 201 void |
196 SingleColourLayer::setBaseColour(int colour) | 202 SingleColourLayer::setBaseColour(int colour) |
197 { | 203 { |