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

Method Add

src/SFGUI/Desktop.cpp:105–133  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

103}
104
105void 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
135void Desktop::Remove( std::shared_ptr<Widget> widget ) {
136 WidgetsList::iterator iter( std::find( m_children.begin(), m_children.end(), widget ));

Callers 15

CreateTextMethod · 0.45
InvalidateImplMethod · 0.45
CreateBorderMethod · 0.45
CreateSliderMethod · 0.45
CreateStepperMethod · 0.45
CreateLabelDrawableMethod · 0.45
CreateButtonDrawableMethod · 0.45

Calls 3

endMethod · 0.80
sizeMethod · 0.80
RefreshMethod · 0.45

Tested by 1

RunMethod · 0.36