MCPcopy Create free account
hub / github.com/TankOs/SFGUI / GetValue

Method GetValue

src/SFGUI/Engine.cpp:256–305  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

254}
255
256const std::string* Engine::GetValue( const std::string& property, Widget::PtrConst widget ) const {
257 // Look for property.
258 PropertyMap::const_iterator prop_iter( m_properties.find( property ) );
259
260 const std::string* value = 0;
261 int score = -1;
262
263 if( prop_iter != m_properties.end() ) {
264 WidgetNameMap::const_iterator name_iter;
265
266 if( widget ) {
267 // Find widget-specific properties, first.
268 name_iter = prop_iter->second.find( widget->GetName() );
269
270 if( name_iter != prop_iter->second.end() ) {
271 // Check against selectors.
272 for( const auto& selector_value : name_iter->second ) {
273 if( selector_value.first->Matches( widget ) ) {
274 // Found, check if it is better than current best.
275 auto new_score = selector_value.first->GetScore();
276
277 if( new_score > score ) {
278 value = &selector_value.second;
279 score = new_score;
280 }
281 }
282 }
283 }
284 }
285
286 // Look for general properties now.
287 name_iter = prop_iter->second.find( "*" );
288
289 if( name_iter != prop_iter->second.end() ) {
290 for( const auto& selector_value : name_iter->second ) {
291 if( selector_value.first->Matches( widget ) ) {
292 // Found, check if it is better than current best.
293 auto new_score = selector_value.first->GetScore();
294
295 if( new_score > score ) {
296 value = &selector_value.second;
297 score = new_score;
298 }
299 }
300 }
301 }
302 }
303
304 return value;
305}
306
307ResourceManager& Engine::GetResourceManager() const {
308 return m_resource_manager;

Callers

nothing calls this directly

Calls 3

endMethod · 0.80
MatchesMethod · 0.80
GetScoreMethod · 0.80

Tested by

no test coverage detected