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

Method AddWithViewport

src/SFGUI/ScrolledWindow.cpp:306–334  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

304}
305
306void ScrolledWindow::AddWithViewport( Widget::Ptr widget ) {
307 float border_width( Context::Get().GetEngine().GetProperty<float>( "BorderWidth", shared_from_this() ) );
308
309 if( GetChildren().size() > 2 ) {
310
311#if defined( SFGUI_DEBUG )
312 std::cerr << "SFGUI warning: Only one widget can be added to a ScrolledWindow.\n";
313#endif
314
315 return;
316 }
317
318 m_viewport = Viewport::Create();
319
320 m_viewport->SetHorizontalAdjustment( m_horizontal_scrollbar->GetAdjustment() );
321 m_viewport->SetVerticalAdjustment( m_vertical_scrollbar->GetAdjustment() );
322
323 m_viewport->Add( widget );
324
325 Container::Add( m_viewport );
326
327 // Make sure the viewport is offset by the border width.
328 sf::FloatRect allocation( m_viewport->GetAllocation() );
329
330 allocation.position.x += border_width;
331 allocation.position.y += border_width;
332
333 m_viewport->SetAllocation( allocation );
334}
335
336void ScrolledWindow::Add( Widget::Ptr /*widget*/ ) {
337#if defined( SFGUI_DEBUG )

Callers 2

mainFunction · 0.80
RunMethod · 0.80

Calls 6

sizeMethod · 0.80
SetAllocationMethod · 0.80
GetAdjustmentMethod · 0.45
SetVerticalAdjustmentMethod · 0.45
AddMethod · 0.45

Tested by 1

RunMethod · 0.64