MCPcopy Create free account
hub / github.com/MeshInspector/MeshLib / beginPopup

Method beginPopup

source/MRViewer/MRModalDialog.cpp:22–88  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20}
21
22bool ModalDialog::beginPopup()
23{
24 const auto windowWidth = settings_.windowWidth > 0.f ? settings_.windowWidth : cModalWindowWidth * UI::scale();
25 const ImVec2 windowSize { windowWidth, -1 };
26 ImGui::SetNextWindowSize( windowSize, ImGuiCond_Always );
27 ImGuiMV::SetNextWindowPosMainViewport( Vector2f( getViewerInstance().framebufferSize ) * 0.5f, ImGuiCond_Always, ImVec2( 0.5f, 0.5f ) );
28
29 setStyle_();
30
31 const ImGuiWindowFlags flags = ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoTitleBar;
32 if ( !ImGui::BeginModalNoAnimation( label_.c_str(), nullptr, flags ) )
33 {
34 unsetStyle_();
35 return false;
36 }
37
38 if ( const auto& headline = settings_.headline; !headline.empty() )
39 {
40 RibbonFontHolder headerFont( RibbonFontManager::FontType::Headline );
41
42 const auto headlineWidth = ImGui::CalcTextSize( headline.c_str() ).x;
43 ImGui::SetCursorPosX( ( windowSize.x - headlineWidth ) * 0.5f );
44 ImGui::Text( "%s", headline.c_str() );
45
46 headerFont.popFont();
47 }
48
49 if ( settings_.closeButton )
50 {
51 const auto closeButtonWidth = StyleConsts::Modal::exitBtnSize * UI::scale();
52 ImGui::SameLine( ImGui::GetWindowContentRegionMax().x - closeButtonWidth );
53 if ( ImGui::ModalExitButton() )
54 {
55 ImGui::CloseCurrentPopup();
56 if ( settings_.onWindowClose )
57 settings_.onWindowClose();
58 }
59 }
60
61 if ( const auto& text = settings_.text; !text.empty() )
62 {
63 const auto textWidth = ImGui::CalcTextSize( text.c_str() ).x;
64 if ( textWidth < ( windowSize.x - cModalWindowPaddingX * UI::scale() * 2.f ) )
65 {
66 ImGui::SetCursorPosX( ( windowSize.x - textWidth ) * 0.5f );
67 ImGui::Text( "%s", text.c_str() );
68 }
69 else
70 {
71 ImGui::TextWrapped( "%s", text.c_str() );
72 }
73 }
74
75 if ( auto* dontShowAgain = settings_.dontShowAgain )
76 {
77 const auto dontShowAgainText = s_tr( "Do not show this message again" );
78 const auto checkboxWidth = ImGui::GetFrameHeight() + ImGui::GetStyle().ItemInnerSpacing.x + ImGui::CalcTextSize( dontShowAgainText.c_str() ).x;
79 ImGui::SetCursorPosX( ( windowWidth - checkboxWidth ) * 0.5f );

Callers 6

drawDialogMethod · 0.80
saveChangesPopupFunction · 0.80
saveCustomConfigModalFunction · 0.80
draw_helpersMethod · 0.80
drawModalMessage_Method · 0.80
drawResetDialog_Method · 0.80

Calls 10

ImVec2Class · 0.85
BeginModalNoAnimationFunction · 0.85
TextClass · 0.85
ModalExitButtonFunction · 0.85
popFontMethod · 0.80
scaleFunction · 0.70
checkboxFunction · 0.70
emptyMethod · 0.45

Tested by

no test coverage detected