9
9
#include " window.h"
10
10
#include " message.h"
11
11
12
+ enum WIV_OVERLAY_SHOW_ : uint64_t
13
+ {
14
+ WIV_OVERLAY_SHOW_IMAGE_DIMS = 1 << 0 ,
15
+ WIV_OVERLAY_SHOW_SCALE = 1 << 1 ,
16
+ WIV_OVERLAY_SHOW_SCALED_DIMS = 1 << 2 ,
17
+ WIV_OVERLAY_SHOW_KERNEL_INDEX = 1 << 3 ,
18
+ WIV_OVERLAY_SHOW_KERNEL_SIZE = 1 << 4
19
+ };
20
+
21
+ namespace
22
+ {
23
+ // The order has to be same as in the enum WIV_KERNEL_FUNCTION_.
24
+ constexpr std::array kernel_function_names{
25
+ " Lanczos" ,
26
+ " Ginseng" ,
27
+ " Hamming" ,
28
+ " Power of cosine" ,
29
+ " Kaiser" ,
30
+ " Power of Garamond" ,
31
+ " Power of Blackman" ,
32
+ " GNW" ,
33
+ " Said" ,
34
+ " Nearest neighbor" ,
35
+ " Linear" ,
36
+ " Bicubic" ,
37
+ " Modified FSR" ,
38
+ " BC-Spline"
39
+ };
40
+ }
41
+
12
42
void User_interface::create (HWND hwnd, ID3D11Device* device, ID3D11DeviceContext* device_context, bool * should_update)
13
43
{
14
44
this ->hwnd = hwnd;
@@ -40,15 +70,15 @@ void User_interface::create(HWND hwnd, ID3D11Device* device, ID3D11DeviceContext
40
70
ImGui_ImplDX11_Init (device, device_context);
41
71
}
42
72
43
- void User_interface::update (float scale )
73
+ void User_interface::update ()
44
74
{
45
75
// Feed inputs to dear imgui, start new frame.
46
76
ImGui_ImplDX11_NewFrame ();
47
77
ImGui_ImplWin32_NewFrame ();
48
78
ImGui::NewFrame ();
49
79
50
80
input ();
51
- overlay (scale );
81
+ overlay ();
52
82
context_menu ();
53
83
window_settings ();
54
84
window_about ();
@@ -264,7 +294,7 @@ void User_interface::input()
264
294
//
265
295
}
266
296
267
- void User_interface::overlay (float scale )
297
+ void User_interface::overlay ()
268
298
{
269
299
if (is_overlay_open) {
270
300
@@ -280,27 +310,21 @@ void User_interface::overlay(float scale)
280
310
ImGui::SetNextWindowPos (window_pos, ImGuiCond_Always, window_pos_pivot);
281
311
282
312
ImGui::SetNextWindowBgAlpha (0 .35f );
283
- if (ImGui::Begin (" ##overlay" , nullptr , ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoNav | ImGuiWindowFlags_NoMove)) {
284
- ImGui::Text (" Scale: %.6f" , scale);
285
-
286
- // Context menu.
287
- if (ImGui::BeginPopupContextWindow ()) {
288
- if (ImGui::MenuItem (" Top-left" , nullptr , g_config.overlay_position .val == 0 ))
289
- g_config.overlay_position .val = 0 ;
290
- if (ImGui::MenuItem (" Top-right" , nullptr , g_config.overlay_position .val == 1 ))
291
- g_config.overlay_position .val = 1 ;
292
- if (ImGui::MenuItem (" Bottom-left" , nullptr , g_config.overlay_position .val == 2 ))
293
- g_config.overlay_position .val = 2 ;
294
- if (ImGui::MenuItem (" Bottom-right" , nullptr , g_config.overlay_position .val == 3 ))
295
- g_config.overlay_position .val = 3 ;
296
- ImGui::Separator ();
297
- if (ImGui::MenuItem (" Save position" ))
298
- g_config.write ();
299
- ImGui::Separator ();
300
- if (ImGui::MenuItem (" Close" ))
301
- is_overlay_open = false ;
302
- ImGui::EndPopup ();
313
+ if (ImGui::Begin (" ##overlay" , nullptr , ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_AlwaysAutoResize)) {
314
+ if (g_config.overlay_config .val & WIV_OVERLAY_SHOW_IMAGE_DIMS) {
315
+ ImGui::Text (" Image W: %i" , g_info.image_width );
316
+ ImGui::Text (" Image H: %i" , g_info.image_height );
303
317
}
318
+ if (g_config.overlay_config .val & WIV_OVERLAY_SHOW_SCALE)
319
+ ImGui::Text (" Scale: %.6f" , g_info.scale );
320
+ if (g_config.overlay_config .val & WIV_OVERLAY_SHOW_SCALED_DIMS) {
321
+ ImGui::Text (" Scaled W: %i" , g_info.scaled_width );
322
+ ImGui::Text (" Scaled H: %i" , g_info.scaled_height );
323
+ }
324
+ if (g_config.overlay_config .val & WIV_OVERLAY_SHOW_KERNEL_INDEX)
325
+ ImGui::Text (kernel_function_names[g_info.kernel_index ]);
326
+ if (g_config.overlay_config .val & WIV_OVERLAY_SHOW_KERNEL_SIZE)
327
+ ImGui::Text (" Kernel size: %i" , g_info.kernel_size );
304
328
}
305
329
306
330
ImGui::End ();
@@ -418,8 +442,6 @@ void User_interface::window_settings()
418
442
ImGui::Spacing ();
419
443
ImGui::ColorEdit4 (" Background color" , g_config.clear_color .val .data (), ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_DisplayHSV);
420
444
ImGui::Spacing ();
421
- ImGui::Checkbox (" Show overlay on start" , &g_config.overlay_show .val );
422
- ImGui::Spacing ();
423
445
ImGui::Checkbox (" Read only thumbnail in RAW images" , &g_config.raw_thumb .val );
424
446
ImGui::Spacing ();
425
447
}
@@ -500,26 +522,7 @@ void User_interface::window_settings()
500
522
ImGui::SeparatorText (" Scale" );
501
523
ImGui::Checkbox (" Use cylindrical filtering (Jinc based)" , &scale.kernel_cylindrical_use .val );
502
524
ImGui::Spacing ();
503
-
504
- // The order has to be same as in the enum WIV_KERNEL_FUNCTION_.
505
- static constinit const std::array kernel_index_items{
506
- " Lanczos" ,
507
- " Ginseng" ,
508
- " Hamming" ,
509
- " Power of cosine" ,
510
- " Kaiser" ,
511
- " Power of Garamond" ,
512
- " Power of Blackman" ,
513
- " GNW" ,
514
- " Said" ,
515
- " Nearest neighbor" ,
516
- " Linear" ,
517
- " Bicubic" ,
518
- " Modified FSR" ,
519
- " BC-Spline"
520
- };
521
-
522
- ImGui::Combo (" Kernel-function" , &scale.kernel_index .val , kernel_index_items.data (), kernel_index_items.size ());
525
+ ImGui::Combo (" Kernel-function" , &scale.kernel_index .val , kernel_function_names.data (), kernel_function_names.size ());
523
526
const auto & i{ scale.kernel_index .val };
524
527
dimm (i == WIV_KERNEL_FUNCTION_NEAREST || i == WIV_KERNEL_FUNCTION_LINEAR || i == WIV_KERNEL_FUNCTION_BICUBIC || i == WIV_KERNEL_FUNCTION_FSR || i == WIV_KERNEL_FUNCTION_BCSPLINE);
525
528
ImGui::InputFloat (" Radius##kernel" , &scale.kernel_radius .val , 0 .0f , 0 .0f , " %.6f" );
@@ -640,6 +643,30 @@ void User_interface::window_settings()
640
643
ImGui::ColorEdit3 (" Second tile color" , g_config.alpha_tile2_color .val .data (), ImGuiColorEditFlags_DisplayHSV);
641
644
ImGui::Spacing ();
642
645
}
646
+ if (ImGui::CollapsingHeader (" Overlay" )) {
647
+ ImGui::Checkbox (" Show overlay on start" , &g_config.overlay_show .val );
648
+ ImGui::Spacing ();
649
+ static constinit const std::array overlay_position_items{
650
+ " Top-left" ,
651
+ " Top-right" ,
652
+ " Bottom-left" ,
653
+ " Bottom-right"
654
+ };
655
+ ImGui::Combo (" Overlay position" , &g_config.overlay_position .val , overlay_position_items.data (), overlay_position_items.size ());
656
+ ImGui::Spacing ();
657
+ ImGui::TextUnformatted (" Show:" );
658
+ if (ImGui::Selectable (" Image dimensions" , g_config.overlay_config .val & WIV_OVERLAY_SHOW_IMAGE_DIMS))
659
+ g_config.overlay_config .val ^= WIV_OVERLAY_SHOW_IMAGE_DIMS;
660
+ if (ImGui::Selectable (" Scale factor" , g_config.overlay_config .val & WIV_OVERLAY_SHOW_SCALE))
661
+ g_config.overlay_config .val ^= WIV_OVERLAY_SHOW_SCALE;
662
+ if (ImGui::Selectable (" Scaled dimensions" , g_config.overlay_config .val & WIV_OVERLAY_SHOW_SCALED_DIMS))
663
+ g_config.overlay_config .val ^= WIV_OVERLAY_SHOW_SCALED_DIMS;
664
+ if (ImGui::Selectable (" Kernel function" , g_config.overlay_config .val & WIV_OVERLAY_SHOW_KERNEL_INDEX))
665
+ g_config.overlay_config .val ^= WIV_OVERLAY_SHOW_KERNEL_INDEX;
666
+ if (ImGui::Selectable (" Scale kernel size" , g_config.overlay_config .val & WIV_OVERLAY_SHOW_KERNEL_SIZE))
667
+ g_config.overlay_config .val ^= WIV_OVERLAY_SHOW_KERNEL_SIZE;
668
+ ImGui::Spacing ();
669
+ }
643
670
ImGui::SeparatorText (" Changes" );
644
671
if (ImGui::Button (" Write changes" )) {
645
672
g_config.write ();
0 commit comments