| 103 | } |
| 104 | |
| 105 | void Desktop::Add( std::shared_ptr<Widget> widget ) { |
| 106 | if( std::find( m_children.begin(), m_children.end(), widget ) != m_children.end() ) { |
| 107 | return; |
| 108 | } |
| 109 | |
| 110 | // Get old focused widget out of State::PRELIGHT state if mouse is inside the new |
| 111 | // widget. |
| 112 | if( m_children.size() ) { |
| 113 | if( widget->GetAllocation().contains( sf::Vector2f( m_last_mouse_pos ) ) ) { |
| 114 | SendFakeMouseMoveEvent( m_children.front() ); |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | m_children.push_front( widget ); |
| 119 | |
| 120 | RecalculateWidgetLevels(); |
| 121 | |
| 122 | if( widget->GetAllocation().contains( sf::Vector2f (m_last_mouse_pos ) ) ) { |
| 123 | SendFakeMouseMoveEvent( widget, m_last_mouse_pos.x, m_last_mouse_pos.y ); |
| 124 | } |
| 125 | |
| 126 | // Activate context. |
| 127 | Context::Activate( m_context ); |
| 128 | |
| 129 | widget->Refresh(); |
| 130 | |
| 131 | // Restore previous context. |
| 132 | Context::Deactivate(); |
| 133 | } |
| 134 | |
| 135 | void Desktop::Remove( std::shared_ptr<Widget> widget ) { |
| 136 | WidgetsList::iterator iter( std::find( m_children.begin(), m_children.end(), widget )); |