| 479 | } |
| 480 | |
| 481 | void RibbonButtonDrawer::drawButtonDropItem_( const MenuItemInfo& item, const DrawButtonParams& params ) const |
| 482 | { |
| 483 | float iconSize = params.iconSize * 0.5f; |
| 484 | float fontScale = 1.f; |
| 485 | const float baseFontSize = RibbonFontManager::getFontSizeByType( RibbonFontManager::FontType::Icons ); |
| 486 | if ( params.sizeType == DrawButtonParams::SizeType::Big ) |
| 487 | fontScale = iconSize / baseFontSize; |
| 488 | else |
| 489 | fontScale = iconSize * 1.5f / baseFontSize; |
| 490 | RibbonFontHolder iconsFont( RibbonFontManager::FontType::Icons, fontScale ); |
| 491 | |
| 492 | auto frameHeight = ImGui::GetFrameHeight(); |
| 493 | ImVec2 itemSize = ImVec2( frameHeight, frameHeight ); |
| 494 | ImVec2 dropBtnPos; |
| 495 | if ( params.sizeType == DrawButtonParams::SizeType::Small ) |
| 496 | { |
| 497 | itemSize.x = params.itemSize.x * cSmallItemDropSizeModifier; |
| 498 | itemSize.y = params.itemSize.y; |
| 499 | dropBtnPos.x = params.itemSize.x; |
| 500 | dropBtnPos.y = 0.0f; |
| 501 | } |
| 502 | else if ( params.sizeType == DrawButtonParams::SizeType::SmallText ) |
| 503 | { |
| 504 | itemSize.x = params.itemSize.y; |
| 505 | itemSize.y = params.itemSize.y; |
| 506 | dropBtnPos.x = params.itemSize.x - itemSize.x; |
| 507 | dropBtnPos.y = 0.0f; |
| 508 | } |
| 509 | else |
| 510 | { |
| 511 | assert( params.sizeType == DrawButtonParams::SizeType::Big ); |
| 512 | itemSize.y = params.itemSize.y; |
| 513 | dropBtnPos.x = params.itemSize.x - itemSize.x; |
| 514 | dropBtnPos.y = 0.0f; |
| 515 | } |
| 516 | ImGui::SetCursorPos( dropBtnPos ); |
| 517 | auto absMinPos = ImGui::GetCurrentContext()->CurrentWindow->DC.CursorPos; |
| 518 | |
| 519 | auto name = "##DropDown" + item.item->name(); |
| 520 | auto nameWindow = name + "Popup"; |
| 521 | bool menuOpened = ImGui::IsPopupOpen( nameWindow.c_str() ); |
| 522 | |
| 523 | bool dropBtnEnabled = !item.item->dropItems().empty(); |
| 524 | |
| 525 | int pushedColors = pushRibbonButtonColors( dropBtnEnabled, menuOpened, params.forceHovered, params.rootType ); |
| 526 | ImGui::PushStyleVar( ImGuiStyleVar_FrameRounding, cHeaderQuickAccessFrameRounding ); |
| 527 | bool comboPressed = ( ImGui::Button( name.c_str(), itemSize ) || UI::TestEngine::createButton( name ) ) && dropBtnEnabled; |
| 528 | |
| 529 | auto iconRealSize = ImGui::CalcTextSize( "\xef\x81\xb8" ); //down icon |
| 530 | ImGui::SetCursorPosX( dropBtnPos.x + ( itemSize.x - iconRealSize.x + 1 ) * 0.5f ); |
| 531 | if ( params.sizeType == DrawButtonParams::SizeType::Big ) |
| 532 | ImGui::SetCursorPosY( params.itemSize.y - frameHeight + ( frameHeight - iconRealSize.y - 1 ) * 0.5f ); |
| 533 | else |
| 534 | ImGui::SetCursorPosY( dropBtnPos.y + ( itemSize.y - iconRealSize.y - 1 ) * 0.5f ); |
| 535 | |
| 536 | ImGui::Text( "%s", "\xef\x81\xb8" ); |
| 537 | |
| 538 | ImGui::PopStyleVar(); |