| 212 | } |
| 213 | |
| 214 | void ComboBox::HandleMouseMoveEvent( int x, int y ) { |
| 215 | if( ( x == std::numeric_limits<int>::min() ) || ( y == std::numeric_limits<int>::min() ) ) { |
| 216 | return; |
| 217 | } |
| 218 | |
| 219 | if( GetState() == State::ACTIVE ) { |
| 220 | if( m_scrollbar ) { |
| 221 | sf::Event::MouseMoved event; |
| 222 | |
| 223 | event.position.x = x - static_cast<int>( GetAllocation().position.x ); |
| 224 | event.position.y = y - static_cast<int>( GetAllocation().position.y ); |
| 225 | |
| 226 | ReleaseModal(); |
| 227 | m_scrollbar->SetActiveWidget(); |
| 228 | m_scrollbar->HandleEvent( event ); |
| 229 | SetActiveWidget(); |
| 230 | GrabModal(); |
| 231 | |
| 232 | auto scrollbar_allocation = m_scrollbar->GetAllocation(); |
| 233 | scrollbar_allocation.position += GetAllocation().position; |
| 234 | |
| 235 | if( scrollbar_allocation.contains( sf::Vector2f( sf::Vector2( x, y ) ) ) ) { |
| 236 | m_highlighted_item = NONE; |
| 237 | Invalidate(); |
| 238 | |
| 239 | return; |
| 240 | } |
| 241 | } |
| 242 | |
| 243 | if( ( x > GetAllocation().position.x ) && ( x < GetAllocation().position.x + GetAllocation().size.x ) ) { |
| 244 | float padding( Context::Get().GetEngine().GetProperty<float>( "ItemPadding", shared_from_this() ) ); |
| 245 | const std::string& font_name( Context::Get().GetEngine().GetProperty<std::string>( "FontName", shared_from_this() ) ); |
| 246 | unsigned int font_size( Context::Get().GetEngine().GetProperty<unsigned int>( "FontSize", shared_from_this() ) ); |
| 247 | const sf::Font& font( *Context::Get().GetEngine().GetResourceManager().GetFont( font_name ) ); |
| 248 | |
| 249 | auto line_y = y; |
| 250 | line_y -= static_cast<int>( GetAllocation().position.y + GetAllocation().size.y + padding ); |
| 251 | line_y /= static_cast<int>( Context::Get().GetEngine().GetFontLineHeight( font, font_size ) + 2 * padding ); |
| 252 | |
| 253 | if( ( line_y < static_cast<int>( GetItemCount() ) ) && ( line_y >= 0 ) ) { |
| 254 | if( line_y != static_cast<int>( m_highlighted_item ) ) { |
| 255 | Invalidate(); |
| 256 | m_highlighted_item = line_y + GetDisplayedItemStart(); |
| 257 | } |
| 258 | } |
| 259 | else { |
| 260 | if( m_highlighted_item != NONE ) { |
| 261 | m_highlighted_item = NONE; |
| 262 | Invalidate(); |
| 263 | } |
| 264 | } |
| 265 | } |
| 266 | else { |
| 267 | if( m_highlighted_item != NONE ) { |
| 268 | m_highlighted_item = NONE; |
| 269 | Invalidate(); |
| 270 | } |
| 271 | } |
nothing calls this directly
no test coverage detected