| 208 | } |
| 209 | |
| 210 | void Toolbar::drawCustomizeModal_() |
| 211 | { |
| 212 | if ( !ribbonMenu_ ) |
| 213 | return; |
| 214 | |
| 215 | const auto& buttonDrawer = ribbonMenu_->getRibbonButtonDrawer(); |
| 216 | |
| 217 | ImVec2 windowPaddingSize = ImVec2( 3 * cDefaultItemSpacing * UI::scale(), 3 * cDefaultItemSpacing * UI::scale() ); |
| 218 | ImVec2 childWindowPadding = ImVec2( 12 * UI::scale(), 4 * UI::scale() ); |
| 219 | ImVec2 itemSpacing = ImVec2( 12 * UI::scale(), 0 ); |
| 220 | const ImVec2 smallItemSize = { cQuickAccessBarHeight * UI::scale() - 2.0f * childWindowPadding.y, cQuickAccessBarHeight * UI::scale() - 2.0f * childWindowPadding.y }; |
| 221 | |
| 222 | const int virtualMaxItemCount = std::max( maxItemCount_, 14 ); |
| 223 | const float itemsWindowWidth = childWindowPadding.x * 2 |
| 224 | + smallItemSize.x * virtualMaxItemCount |
| 225 | + itemSpacing.x * ( virtualMaxItemCount - 1 ); |
| 226 | |
| 227 | ImVec2 windowSize( itemsWindowWidth + windowPaddingSize.x * 2, 530 * UI::scale() ); |
| 228 | ImGui::SetNextWindowSize( windowSize, ImGuiCond_Always ); |
| 229 | ImVec2 center = ImGui::GetMainViewport()->GetCenter(); |
| 230 | ImGui::SetNextWindowPos( center, ImGuiCond_Appearing, ImVec2( 0.5f, 0.5f ) ); |
| 231 | ImGui::SetNextWindowViewport( ImGui::GetMainViewport()->ID ); |
| 232 | ImGui::SetNextWindowSizeConstraints( ImVec2( windowSize.x, -1 ), ImVec2( windowSize.x, 0 ) ); |
| 233 | |
| 234 | ImGui::PushStyleVar( ImGuiStyleVar_WindowPadding, windowPaddingSize ); |
| 235 | if ( !ImGui::BeginModalNoAnimation( "Toolbar Customize", nullptr, ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoTitleBar ) ) |
| 236 | { |
| 237 | ImGui::PopStyleVar(); |
| 238 | return; |
| 239 | } |
| 240 | |
| 241 | bool shouldClose = ImGui::ModalBigTitle( _tr( "Customize Viewport Toolbar" ) ); |
| 242 | if ( shouldClose ) |
| 243 | ImGui::CloseCurrentPopup(); |
| 244 | |
| 245 | MR_FINALLY_ON_SUCCESS{ |
| 246 | // Must clear late, otherwise `UI::checkbox()` sometimes get called twice with the same string, |
| 247 | // which triggers an assertion in the UI test engine. |
| 248 | if ( shouldClose ) |
| 249 | searchString_.clear(); |
| 250 | }; |
| 251 | |
| 252 | ImGui::Text( "%s", _tr( "Select icons to show in Toolbar" ) ); |
| 253 | |
| 254 | ImGui::SameLine(); |
| 255 | auto& style = ImGui::GetStyle(); |
| 256 | float textPosX = windowSize.x - ( ImGui::CalcTextSize( _tr( "Icons in Toolbar" ) ).x + ImGui::CalcTextSize( " : 00/00" ).x ) - style.WindowPadding.x; |
| 257 | ImGui::SetCursorPosX( textPosX ); |
| 258 | ImGui::PushStyleVar( ImGuiStyleVar_ItemSpacing, ImVec2( 0, 12 * UI::scale() ) ); |
| 259 | ImGui::Text( "%s : %02d/%02d", _tr( "Icons in Toolbar" ), int( itemsListCustomize_.size() ), maxItemCount_ ); |
| 260 | ImGui::PopStyleVar(); |
| 261 | |
| 262 | ImGui::PushStyleVar( ImGuiStyleVar_WindowPadding, childWindowPadding ); |
| 263 | ImGui::PushStyleVar( ImGuiStyleVar_ItemSpacing, itemSpacing ); |
| 264 | |
| 265 | DrawButtonParams params{ DrawButtonParams::SizeType::Small, smallItemSize, cMiddleIconSize, DrawButtonParams::RootType::Toolbar }; |
| 266 | |
| 267 | ImGui::PushStyleColor( ImGuiCol_ChildBg, ColorTheme::getRibbonColor( ColorTheme::RibbonColorsType::QuickAccessBackground ).getUInt32() ); |
nothing calls this directly
no test coverage detected