| 187 | } |
| 188 | |
| 189 | void Desktop::BringToFront( std::shared_ptr<const Widget> child ) { |
| 190 | WidgetsList::iterator iter( std::find( m_children.begin(), m_children.end(), child ) ); |
| 191 | |
| 192 | if( iter == m_children.end() || iter == m_children.begin() ) { |
| 193 | return; |
| 194 | } |
| 195 | |
| 196 | if( child->GetAllocation().contains( sf::Vector2f( m_last_mouse_pos ) ) ) { |
| 197 | SendFakeMouseMoveEvent( m_children.front() ); |
| 198 | } |
| 199 | |
| 200 | Widget::Ptr ptr( *iter ); |
| 201 | m_children.erase( iter ); |
| 202 | m_children.push_front( ptr ); |
| 203 | |
| 204 | RecalculateWidgetLevels(); |
| 205 | |
| 206 | if( child->GetAllocation().contains( sf::Vector2f( m_last_mouse_pos ) ) ) { |
| 207 | SendFakeMouseMoveEvent( ptr, m_last_mouse_pos.x, m_last_mouse_pos.y ); |
| 208 | } |
| 209 | } |
| 210 | |
| 211 | void Desktop::SendFakeMouseMoveEvent( std::shared_ptr<Widget> widget, int x, int y ) const { |
| 212 | widget->HandleEvent( sf::Event::MouseMoved{ { x, y } } ); |