comparison layer/SingleColourLayer.cpp @ 296:ea37c229a578

* Fix #1757772 tempo, dynamic related plug-ins bug -- make auto-align only auto-align if there is a unit involved * Fix #1755366 text layer bug in retrieved session * Fix input model selection in plugin parameter dialog (was being ignored) * Use lighter background than the standard widget one for panes (assuming the widget background is light but not white) -- similarly darker if dark * Fix colour reference counting in loaded session in SingleColourLayer * Reset overview pane colour when switching dark background on or off
author Chris Cannam
date Tue, 14 Aug 2007 13:58:53 +0000
parents 919740b20cc9
children 860f9ada4327
comparison
equal deleted inserted replaced
295:5804703450d8 296:ea37c229a578
139 } 139 }
140 // We don't want to call this if !v because that probably 140 // We don't want to call this if !v because that probably
141 // means we're being called from the constructor, and this is 141 // means we're being called from the constructor, and this is
142 // a virtual function 142 // a virtual function
143 hint = getDefaultColourHint(dark, impose); 143 hint = getDefaultColourHint(dark, impose);
144 // std::cerr << "hint = " << hint << ", impose = " << impose << std::endl; 144 std::cerr << "hint = " << hint << ", impose = " << impose << std::endl;
145 } else { 145 } else {
146 // std::cerr << "(from ctor)" << std::endl; 146 std::cerr << "(from ctor)" << std::endl;
147 } 147 }
148 148
149 if (hint >= 0 && impose) { 149 if (hint >= 0 && impose) {
150 setBaseColour(hint); 150 setBaseColour(hint);
151 return; 151 return;
162 int count = 0; 162 int count = 0;
163 if (m_colourRefCount.find(index) != m_colourRefCount.end()) { 163 if (m_colourRefCount.find(index) != m_colourRefCount.end()) {
164 count = m_colourRefCount[index]; 164 count = m_colourRefCount[index];
165 } 165 }
166 166
167 // std::cerr << "index = " << index << ", count = " << count; 167 std::cerr << "index = " << index << ", count = " << count;
168 168
169 if (bestColour < 0 || count < bestCount) { 169 if (bestColour < 0 || count < bestCount) {
170 bestColour = index; 170 bestColour = index;
171 bestCount = count; 171 bestCount = count;
172 // std::cerr << " *"; 172 std::cerr << " *";
173 } 173 }
174 174
175 // std::cerr << std::endl; 175 std::cerr << std::endl;
176 } 176 }
177 177
178 if (bestColour < 0) m_colour = 0; 178 if (bestColour < 0) m_colour = 0;
179 else m_colour = bestColour; 179 else m_colour = bestColour;
180 180
271 SingleColourLayer::setProperties(const QXmlAttributes &attributes) 271 SingleColourLayer::setProperties(const QXmlAttributes &attributes)
272 { 272 {
273 QString colourName = attributes.value("colourName"); 273 QString colourName = attributes.value("colourName");
274 QString colourSpec = attributes.value("colour"); 274 QString colourSpec = attributes.value("colour");
275 QString darkbg = attributes.value("darkBackground"); 275 QString darkbg = attributes.value("darkBackground");
276 m_colour = ColourDatabase::getInstance()->putStringValues 276
277 int colour = ColourDatabase::getInstance()->putStringValues
277 (colourName, colourSpec, darkbg); 278 (colourName, colourSpec, darkbg);
278 if (m_colourRefCount.find(m_colour) == m_colourRefCount.end()) { 279
279 m_colourRefCount[m_colour] = 1;
280 } else {
281 m_colourRefCount[m_colour]++;
282 }
283 m_colourExplicitlySet = true; 280 m_colourExplicitlySet = true;
284 flagBaseColourChanged(); 281
285 } 282 if (m_colour != colour) {
286 283
284 std::cerr << "SingleColourLayer::setProperties: changing colour from " << m_colour << " to " << colour << std::endl;
285
286 if (m_colourRefCount.find(m_colour) != m_colourRefCount.end() &&
287 m_colourRefCount[m_colour] > 0) {
288 m_colourRefCount[m_colour]--;
289 }
290
291 m_colour = colour;
292
293 if (m_colourRefCount.find(m_colour) == m_colourRefCount.end()) {
294 m_colourRefCount[m_colour] = 1;
295 } else {
296 m_colourRefCount[m_colour]++;
297 }
298
299 flagBaseColourChanged();
300 }
301 }
302