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

Method Attach

src/SFGUI/Table.cpp:33–67  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31}
32
33void Table::Attach( Widget::Ptr widget, const sf::Rect<std::uint32_t>& rect, int x_options, int y_options, const sf::Vector2f& padding ) {
34 assert( rect.size.x > 0 );
35 assert( rect.size.y > 0 );
36
37 // Store widget in a table cell object.
38 priv::TableCell cell( widget, rect, x_options, y_options, padding );
39 m_cells.push_back( cell );
40
41 // Check if we need to enlarge rows/columns.
42 if( rect.position.x + rect.size.x >= m_columns.size() ) {
43 std::size_t old_size( m_columns.size() );
44 m_columns.resize( rect.position.x + rect.size.x );
45
46 // Set default spacings.
47 for( std::size_t col_index = old_size; col_index < m_columns.size(); ++col_index ) {
48 m_columns[col_index].spacing = m_general_spacings.x;
49 }
50 }
51
52 if( rect.position.y + rect.size.y >= m_rows.size() ) {
53 std::size_t old_size( m_rows.size() );
54 m_rows.resize( rect.position.y + rect.size.y );
55
56 // Set default spacings.
57 for( std::size_t row_index = old_size; row_index < m_rows.size(); ++row_index ) {
58 m_rows[row_index].spacing = m_general_spacings.y;
59 }
60 }
61
62 // Add widget to container.
63 Add( widget );
64
65 // Request new size.
66 RequestResize();
67}
68
69
70void Table::HandleSizeChange() {

Callers 5

mainFunction · 0.80
RunMethod · 0.80
mainFunction · 0.80
mainFunction · 0.80
mainFunction · 0.80

Calls 1

sizeMethod · 0.80

Tested by 1

RunMethod · 0.64