@@ -62,7 +62,7 @@ static bool g_show_modal = false;
62
62
static const vector<pair<string, string>> g_help_strings = {
63
63
{" h" , " Show this help window" },
64
64
{" Left click+drag" , " Rotate the camera" },
65
- {" Scroll mouse" , " Zoom the camera" },
65
+ {" Scroll mouse/pinch " , " Zoom the camera" },
66
66
{" 1" , " Switch to XY orthographic view" },
67
67
{" 2" , " Switch to XZ orthographic view" },
68
68
{" 3" , " Switch to ZY orthographic view" },
@@ -84,6 +84,23 @@ static const vector<pair<string, string>> g_help_strings = {
84
84
{" p" , " Toggle display of 1D X, Y, Z projections of the points" }};
85
85
static const map<string, string> g_tooltip_map (g_help_strings.begin(), g_help_strings.end());
86
86
87
+ static auto tooltip (const char *text, float wrap_width = 400 .f)
88
+ {
89
+ if (ImGui::BeginItemTooltip ())
90
+ {
91
+ ImGui::PushTextWrapPos (wrap_width);
92
+ ImGui::TextUnformatted (text);
93
+ ImGui::PopTextWrapPos ();
94
+ ImGui::EndTooltip ();
95
+ }
96
+ }
97
+
98
+ static auto hotkey_tooltip (const char *name, float wrap_width = 400 .f)
99
+ {
100
+ if (auto t = g_tooltip_map.find (name); t != g_tooltip_map.end ())
101
+ tooltip (fmt::format (" {}.\n Key: {}" , t->second , t->first ).c_str (), wrap_width);
102
+ }
103
+
87
104
static float4x4 layout_2d_matrix (int num_dims, int2 dims)
88
105
{
89
106
float cell_spacing = 1 .f / (num_dims - 1 );
@@ -305,8 +322,9 @@ SampleViewer::SampleViewer()
305
322
m_params.callbacks .ShowStatus = [this ]()
306
323
{
307
324
ImGui::SetCursorPosY (ImGui::GetCursorPosY () - ImGui::GetFontSize () * 0 .15f );
308
- ImGui::Text (" Reset + randomize: %3.3f ms | Sampling: %3.3f ms | Total: %3.3f ms (%3.0f pps)" , m_time1,
309
- m_time2, m_time1 + m_time2, m_point_count / (m_time1 + m_time2));
325
+ ImGui::Text (" %3.3f / %3.3f ms (%3.0f pps)" , m_time2, m_time1 + m_time2, m_point_count / (m_time1 + m_time2));
326
+ tooltip (" Shows A/B (points per second) where A is how long it took to call Sampler::sample(), and B includes "
327
+ " other setup costs." );
310
328
// ImGui::SameLine();
311
329
ImGui::SameLine (ImGui::GetIO ().DisplaySize .x - 16 .f * ImGui::GetFontSize ());
312
330
ImGui::SetCursorPosY (ImGui::GetCursorPosY () - ImGui::GetFontSize () * 0 .15f );
@@ -470,17 +488,20 @@ void SampleViewer::draw_about_dialog()
470
488
ImVec2 center = ImGui::GetMainViewport ()->GetCenter ();
471
489
ImGui::SetNextWindowPos (center, ImGuiCond_Appearing, ImVec2 (0 .5f , 0 .5f ));
472
490
ImGui::SetNextWindowFocus ();
491
+ const float2 col_width = {11 * HelloImGui::EmSize (), 32 * HelloImGui::EmSize ()};
492
+ ImGui::SetNextWindowContentSize (float2{col_width[0 ] + col_width[1 ], 0 });
473
493
474
- if (ImGui::BeginPopupModal (" About" , nullptr , ImGuiWindowFlags_AlwaysAutoResize))
494
+ if (ImGui::BeginPopupModal (" About" , nullptr ,
495
+ ImGuiWindowFlags_HorizontalScrollbar | ImGuiWindowFlags_NoSavedSettings |
496
+ ImGuiWindowFlags_AlwaysAutoResize))
475
497
{
476
- const int col_width[2 ] = {11 , 34 };
477
498
478
499
ImGui::Spacing ();
479
500
480
501
if (ImGui::BeginTable (" about_table1" , 2 ))
481
502
{
482
- ImGui::TableSetupColumn (" one " , ImGuiTableColumnFlags_WidthFixed, HelloImGui::EmSize () * col_width[0 ]);
483
- ImGui::TableSetupColumn (" two " , ImGuiTableColumnFlags_WidthFixed, HelloImGui::EmSize () * col_width[1 ]);
503
+ ImGui::TableSetupColumn (" icon " , ImGuiTableColumnFlags_WidthFixed, col_width[0 ]);
504
+ ImGui::TableSetupColumn (" description " , ImGuiTableColumnFlags_WidthFixed, col_width[1 ]);
484
505
485
506
ImGui::TableNextRow ();
486
507
ImGui::TableNextColumn ();
@@ -494,7 +515,7 @@ void SampleViewer::draw_about_dialog()
494
515
HelloImGui::ImageFromAsset (" app_settings/icon.png" , {128 , 128 }); // show the app icon
495
516
496
517
ImGui::TableNextColumn ();
497
- ImGui::PushTextWrapPos (ImGui::GetCursorPos ().x + HelloImGui::EmSize () * col_width[1 ]);
518
+ ImGui::PushTextWrapPos (ImGui::GetCursorPos ().x + col_width[1 ]);
498
519
499
520
ImGui::PushFont (m_bold[30 ]);
500
521
ImGui::Text (" Samplin' Safari" );
@@ -520,7 +541,7 @@ void SampleViewer::draw_about_dialog()
520
541
521
542
ImGui::Spacing ();
522
543
523
- ImGui::Text (" It is developed by Wojciech Jarosz, and is freely available under a 3-clause BSD license." );
544
+ ImGui::Text (" It is developed by Wojciech Jarosz, and is available under a 3-clause BSD license." );
524
545
525
546
ImGui::PopTextWrapPos ();
526
547
ImGui::EndTable ();
@@ -529,7 +550,7 @@ void SampleViewer::draw_about_dialog()
529
550
auto right_align = [](const string &text)
530
551
{
531
552
auto posX = (ImGui::GetCursorPosX () + ImGui::GetColumnWidth () - ImGui::CalcTextSize (text.c_str ()).x -
532
- ImGui::GetScrollX () - 2 * ImGui::GetStyle ().ItemSpacing .x );
553
+ 2 * ImGui::GetStyle ().ItemSpacing .x );
533
554
if (posX > ImGui::GetCursorPosX ())
534
555
ImGui::SetCursorPosX (posX);
535
556
ImGui::Text (text);
@@ -545,17 +566,38 @@ void SampleViewer::draw_about_dialog()
545
566
ImGui::PopFont ();
546
567
547
568
ImGui::TableNextColumn ();
548
- ImGui::PushTextWrapPos (ImGui::GetCursorPos ().x + HelloImGui::EmSize () * ( col_width[1 ] - 1 ));
569
+ ImGui::PushTextWrapPos (ImGui::GetCursorPos ().x + col_width[1 ] - HelloImGui::EmSize ( ));
549
570
ImGui::PushFont (m_regular[14 ]);
550
571
ImGui::Text (desc);
551
572
ImGui::PopFont ();
552
573
};
553
574
554
575
if (ImGui::BeginTabBar (" AboutTabBar" ))
555
576
{
577
+ if (ImGui::BeginTabItem (" Keybindings" , nullptr ))
578
+ {
579
+ ImGui::PushTextWrapPos (ImGui::GetCursorPos ().x + col_width[0 ] + col_width[1 ]);
580
+ ImGui::Text (" The following keyboard shortcuts are available (these are also described in tooltips over "
581
+ " their respective controls)." );
582
+
583
+ ImGui::Spacing ();
584
+ ImGui::PopTextWrapPos ();
585
+
586
+ if (ImGui::BeginTable (" about_table3" , 2 ))
587
+ {
588
+ ImGui::TableSetupColumn (" Key" , ImGuiTableColumnFlags_WidthFixed, col_width[0 ]);
589
+ ImGui::TableSetupColumn (" Description" , ImGuiTableColumnFlags_WidthFixed, col_width[1 ]);
590
+
591
+ for (auto item : g_help_strings)
592
+ item_and_description (item.first , item.second );
593
+
594
+ ImGui::EndTable ();
595
+ }
596
+ ImGui::EndTabItem ();
597
+ }
556
598
if (ImGui::BeginTabItem (" Credits" ))
557
599
{
558
- ImGui::PushTextWrapPos (ImGui::GetCursorPos ().x + HelloImGui::EmSize () * ( col_width[0 ] + col_width[1 ]) );
600
+ ImGui::PushTextWrapPos (ImGui::GetCursorPos ().x + col_width[0 ] + col_width[1 ]);
559
601
ImGui::Text (" Samplin' Safari was originally created as part of the publication:" );
560
602
561
603
ImGui::Spacing ();
@@ -576,10 +618,8 @@ void SampleViewer::draw_about_dialog()
576
618
577
619
if (ImGui::BeginTable (" about_table2" , 2 ))
578
620
{
579
- ImGui::TableSetupColumn (" one" , ImGuiTableColumnFlags_WidthFixed,
580
- HelloImGui::EmSize () * col_width[0 ]);
581
- ImGui::TableSetupColumn (" two" , ImGuiTableColumnFlags_WidthFixed,
582
- HelloImGui::EmSize () * col_width[1 ]);
621
+ ImGui::TableSetupColumn (" one" , ImGuiTableColumnFlags_WidthFixed, col_width[0 ]);
622
+ ImGui::TableSetupColumn (" two" , ImGuiTableColumnFlags_WidthFixed, col_width[1 ]);
583
623
584
624
item_and_description (" bitcount" ,
585
625
" Mike Pedersen's MIT-licensed fast, cross-platform bit counting functions." );
@@ -618,29 +658,6 @@ void SampleViewer::draw_about_dialog()
618
658
}
619
659
ImGui::EndTabItem ();
620
660
}
621
- if (ImGui::BeginTabItem (" Keybindings" , nullptr ))
622
- {
623
- ImGui::PushTextWrapPos (ImGui::GetCursorPos ().x + HelloImGui::EmSize () * (col_width[0 ] + col_width[1 ]));
624
- ImGui::Text (" The following keyboard shortcuts are available (these are also described in tooltips over "
625
- " their respective controls)." );
626
-
627
- ImGui::Spacing ();
628
- ImGui::PopTextWrapPos ();
629
-
630
- if (ImGui::BeginTable (" about_table3" , 2 ))
631
- {
632
- ImGui::TableSetupColumn (" Key" , ImGuiTableColumnFlags_WidthFixed,
633
- HelloImGui::EmSize () * col_width[0 ]);
634
- ImGui::TableSetupColumn (" Description" , ImGuiTableColumnFlags_WidthFixed,
635
- HelloImGui::EmSize () * col_width[1 ]);
636
-
637
- for (auto item : g_help_strings)
638
- item_and_description (item.first , item.second );
639
-
640
- ImGui::EndTable ();
641
- }
642
- ImGui::EndTabItem ();
643
- }
644
661
ImGui::EndTabBar ();
645
662
}
646
663
@@ -669,23 +686,6 @@ void SampleViewer::draw_editor()
669
686
return ret;
670
687
};
671
688
672
- auto tooltip = [](const char *text, float wrap_width = 400 .f )
673
- {
674
- if (ImGui::BeginItemTooltip ())
675
- {
676
- ImGui::PushTextWrapPos (wrap_width);
677
- ImGui::TextUnformatted (text);
678
- ImGui::PopTextWrapPos ();
679
- ImGui::EndTooltip ();
680
- }
681
- };
682
-
683
- auto hotkey_tooltip = [tooltip](const char *name, float wrap_width = 400 .f )
684
- {
685
- if (auto t = g_tooltip_map.find (name); t != g_tooltip_map.end ())
686
- tooltip (fmt::format (" {}.\n Key: {}" , t->second , t->first ).c_str (), wrap_width);
687
- };
688
-
689
689
ImGui::PushItemWidth (ImGui::GetContentRegionAvail ().x * 0 .7f );
690
690
691
691
// =========================================================
@@ -1352,10 +1352,10 @@ void SampleViewer::draw_scene()
1352
1352
camera.persp_factor = lerp (camera0.persp_factor , camera1.persp_factor , t);
1353
1353
if (t >= 1 .0f )
1354
1354
{
1355
- camera.camera_type = camera1.camera_type ;
1356
- // m_params.fpsIdling.fpsIdle = 9.f; // animation is done, reduce FPS
1357
- if (m_animate_start_time != 0 .0f )
1358
- m_params.fpsIdling .enableIdling = m_idling_backup;
1355
+ camera.camera_type = camera1.camera_type ;
1356
+ m_params.fpsIdling .fpsIdle = 9 .f ; // animation is done, reduce FPS
1357
+ // if (m_animate_start_time != 0.0f)
1358
+ // m_params.fpsIdling.enableIdling = m_idling_backup;
1359
1359
m_animate_start_time = 0 .f ;
1360
1360
}
1361
1361
@@ -1439,9 +1439,9 @@ void SampleViewer::set_view(CameraType view)
1439
1439
m_camera[CAMERA_CURRENT].camera_type = (view == m_camera[CAMERA_CURRENT].camera_type ) ? view : CAMERA_CURRENT;
1440
1440
m_view = view;
1441
1441
1442
- // m_params.fpsIdling.fpsIdle = 0.f; // during animation, increase FPS
1443
- m_idling_backup = m_params.fpsIdling .enableIdling ;
1444
- m_params.fpsIdling .enableIdling = false ;
1442
+ m_params.fpsIdling .fpsIdle = 0 .f ; // during animation, increase FPS
1443
+ m_idling_backup = m_params.fpsIdling .enableIdling ;
1444
+ // m_params.fpsIdling.enableIdling = false;
1445
1445
}
1446
1446
}
1447
1447
0 commit comments