| 17 | } |
| 18 | |
| 19 | Drawable* UIIcon::getSize( const int& size ) const { |
| 20 | auto it = mSizes.find( size ); |
| 21 | if ( it != mSizes.end() ) |
| 22 | return it->second; |
| 23 | int distance = UINT32_MAX; |
| 24 | Drawable* closest = nullptr; |
| 25 | for ( const auto& sit : mSizes ) { |
| 26 | int diff = abs( sit.first - size ); |
| 27 | if ( diff < distance ) { |
| 28 | distance = diff; |
| 29 | closest = sit.second; |
| 30 | } |
| 31 | } |
| 32 | return closest; |
| 33 | } |
| 34 | |
| 35 | void UIIcon::setSize( const int& size, Drawable* drawable ) { |
| 36 | mSizes[size] = drawable; |
nothing calls this directly
no test coverage detected