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

Method GetDisplayedItemCount

src/SFGUI/ComboBox.cpp:454–474  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

452}
453
454ComboBox::IndexType ComboBox::GetDisplayedItemCount() const {
455 float border_width( Context::Get().GetEngine().GetProperty<float>( "BorderWidth", shared_from_this() ) );
456 float padding( Context::Get().GetEngine().GetProperty<float>( "ItemPadding", shared_from_this() ) );
457 const std::string& font_name( Context::Get().GetEngine().GetProperty<std::string>( "FontName", shared_from_this() ) );
458 unsigned int font_size( Context::Get().GetEngine().GetProperty<unsigned int>( "FontSize", shared_from_this() ) );
459 const sf::Font& font( *Context::Get().GetEngine().GetResourceManager().GetFont( font_name ) );
460 const float line_height( Context::Get().GetEngine().GetFontLineHeight( font, font_size ) );
461
462 const sf::Vector2f item_size(
463 GetAllocation().size.x - 2 * border_width,
464 line_height + 2 * padding
465 );
466
467 auto available_space = static_cast<float>( Renderer::Get().GetWindowSize().y ) - ( GetAbsolutePosition().y + item_size.y );
468
469 auto num_displayed_entries = static_cast<IndexType>( available_space / item_size.y );
470
471 num_displayed_entries = ( GetItemCount() < num_displayed_entries ? GetItemCount() : num_displayed_entries );
472
473 return num_displayed_entries;
474}
475
476ComboBox::IndexType ComboBox::GetDisplayedItemStart() const {
477 return m_start_entry;

Callers 1

Calls 1

GetFontLineHeightMethod · 0.80

Tested by

no test coverage detected