@@ -453,8 +453,17 @@ void SampleViewer::draw_about_dialog()
453
453
ImVec2 center = ImGui::GetMainViewport ()->GetCenter ();
454
454
ImGui::SetNextWindowPos (center, ImGuiCond_Appearing, ImVec2 (0 .5f , 0 .5f ));
455
455
ImGui::SetNextWindowFocus ();
456
- const float2 col_width = {11 * HelloImGui::EmSize (), 32 * HelloImGui::EmSize ()};
457
- ImGui::SetNextWindowContentSize (float2{col_width[0 ] + col_width[1 ], 0 });
456
+ constexpr float icon_size = 128 .f ;
457
+ float2 col_width = {icon_size + HelloImGui::EmSize (), 32 * HelloImGui::EmSize ()};
458
+ float2 display_size = ImGui::GetIO ().DisplaySize ;
459
+ #ifdef __EMSCRIPTEN__
460
+ display_size = float2{window_width (), window_height ()};
461
+ #endif
462
+ col_width[1 ] = clamp (col_width[1 ], 5 * HelloImGui::EmSize (),
463
+ display_size.x - ImGui::GetStyle ().WindowPadding .x - 2 * ImGui::GetStyle ().ItemSpacing .x -
464
+ ImGui::GetStyle ().ScrollbarSize - col_width[0 ]);
465
+
466
+ ImGui::SetNextWindowContentSize (float2{col_width[0 ] + col_width[1 ] + ImGui::GetStyle ().ItemSpacing .x , 0 });
458
467
459
468
bool about_open = true ;
460
469
if (ImGui::BeginPopupModal (" About" , &about_open,
@@ -473,12 +482,12 @@ void SampleViewer::draw_about_dialog()
473
482
ImGui::TableNextColumn ();
474
483
// right align the image
475
484
{
476
- auto posX = (ImGui::GetCursorPosX () + ImGui::GetColumnWidth () - 128 . f - ImGui::GetScrollX () -
485
+ auto posX = (ImGui::GetCursorPosX () + ImGui::GetColumnWidth () - icon_size -
477
486
2 * ImGui::GetStyle ().ItemSpacing .x );
478
487
if (posX > ImGui::GetCursorPosX ())
479
488
ImGui::SetCursorPosX (posX);
480
489
}
481
- HelloImGui::ImageFromAsset (" app_settings/icon.png" , {128 , 128 }); // show the app icon
490
+ HelloImGui::ImageFromAsset (" app_settings/icon.png" , {icon_size, icon_size }); // show the app icon
482
491
483
492
ImGui::TableNextColumn ();
484
493
ImGui::PushTextWrapPos (ImGui::GetCursorPos ().x + col_width[1 ]);
@@ -635,7 +644,7 @@ void SampleViewer::draw_about_dialog()
635
644
ImGui::CloseCurrentPopup ();
636
645
g_dismissed_version = version_combined ();
637
646
}
638
- ImGui::SetItemDefaultFocus ();
647
+ // ImGui::SetItemDefaultFocus();
639
648
640
649
ImGui::EndPopup ();
641
650
g_open_help = false ;
0 commit comments