44
55#include " imiv_app.h"
66#include " imiv_actions.h"
7+ #include " imiv_build_config.h"
78#include " imiv_drag_drop.h"
89#include " imiv_file_dialog.h"
910#include " imiv_frame.h"
1718#include " imiv_types.h"
1819#include " imiv_ui.h"
1920#include " imiv_viewer.h"
20- #include " imiv_build_config.h"
2121
2222#include < algorithm>
2323#include < array>
@@ -77,30 +77,29 @@ namespace {
7777 }
7878
7979 ImFont* load_embedded_font_if_present (const unsigned char * data,
80- size_t size_bytes,
81- float size_pixels)
80+ size_t size_bytes, float size_pixels)
8281 {
8382 if (data == nullptr || size_bytes == 0 )
8483 return nullptr ;
8584 ImGuiIO& io = ImGui::GetIO ();
8685 ImFontConfig config;
8786 config.FontDataOwnedByAtlas = false ;
88- return io.Fonts ->AddFontFromMemoryTTF (
89- const_cast < unsigned char *>(data), static_cast <int >(size_bytes),
90- size_pixels, &config);
87+ return io.Fonts ->AddFontFromMemoryTTF (const_cast < unsigned char *>(data),
88+ static_cast <int >(size_bytes),
89+ size_pixels, &config);
9190 }
9291
9392 AppFonts setup_app_fonts (bool verbose_logging)
9493 {
9594 AppFonts fonts;
96- ImGuiIO& io = ImGui::GetIO ();
95+ ImGuiIO& io = ImGui::GetIO ();
9796 const char * ui_font_source = " missing" ;
9897 const char * mono_font_source = " missing" ;
9998
10099 const std::filesystem::path font_root = executable_directory_path ()
101100 / " fonts" ;
102- const std::filesystem::path ui_font_path
103- = font_root / " Droid_Sans " / " DroidSans.ttf" ;
101+ const std::filesystem::path ui_font_path = font_root / " Droid_Sans "
102+ / " DroidSans.ttf" ;
104103 const std::filesystem::path mono_font_path
105104 = font_root / " Droid_Sans_Mono" / " DroidSansMono.ttf" ;
106105
@@ -110,9 +109,10 @@ namespace {
110109 16 .0f );
111110 if (fonts.ui )
112111 ui_font_source = " embedded" ;
113- fonts.mono = load_embedded_font_if_present (
114- g_imiv_font_droidsansmono_ttf, g_imiv_font_droidsansmono_ttf_size,
115- 16 .0f );
112+ fonts.mono
113+ = load_embedded_font_if_present (g_imiv_font_droidsansmono_ttf,
114+ g_imiv_font_droidsansmono_ttf_size,
115+ 16 .0f );
116116 if (fonts.mono )
117117 mono_font_source = " embedded" ;
118118#endif
@@ -128,19 +128,18 @@ namespace {
128128 mono_font_source = " file" ;
129129 }
130130 if (!fonts.ui ) {
131- fonts.ui = io.Fonts ->AddFontDefault ();
131+ fonts.ui = io.Fonts ->AddFontDefault ();
132132 ui_font_source = " default" ;
133133 }
134134 if (!fonts.mono ) {
135- fonts.mono = fonts.ui ;
135+ fonts.mono = fonts.ui ;
136136 mono_font_source = (fonts.ui == fonts.mono && ui_font_source)
137137 ? ui_font_source
138138 : " default" ;
139139 }
140140 io.FontDefault = fonts.ui ;
141141
142- print (" imiv: fonts ui={} mono={}\n " , ui_font_source,
143- mono_font_source);
142+ print (" imiv: fonts ui={} mono={}\n " , ui_font_source, mono_font_source);
144143 return fonts;
145144 }
146145
@@ -242,7 +241,7 @@ namespace {
242241 }
243242
244243 BackendKind requested_backend_for_launch (const AppConfig& config,
245- const PlaceholderUiState& ui_state)
244+ const PlaceholderUiState& ui_state)
246245 {
247246 if (config.requested_backend != BackendKind::Auto)
248247 return config.requested_backend ;
@@ -255,9 +254,10 @@ namespace {
255254 backend_cli_name (active_backend));
256255 }
257256
258- std::vector<std::string>
259- expand_startup_input_paths (const AppConfig& config, bool verbose_logging,
260- ImageSortMode sort_mode, bool sort_reverse)
257+ std::vector<std::string> expand_startup_input_paths (const AppConfig& config,
258+ bool verbose_logging,
259+ ImageSortMode sort_mode,
260+ bool sort_reverse)
261261 {
262262 std::vector<std::string> expanded;
263263 for (const std::string& input_path : config.input_paths ) {
@@ -266,10 +266,10 @@ namespace {
266266 if (std::filesystem::is_directory (path, ec) && !ec) {
267267 std::vector<std::string> directory_paths;
268268 std::string error_message;
269- if (!collect_directory_image_paths (input_path,
270- sort_mode, sort_reverse,
271- directory_paths,
272- error_message)) {
269+ if (!collect_directory_image_paths (input_path, sort_mode,
270+ sort_reverse,
271+ directory_paths,
272+ error_message)) {
273273 print (stderr, " imiv: {}\n " , error_message);
274274 continue ;
275275 }
@@ -328,12 +328,11 @@ run(const AppConfig& config)
328328 = Strutil::fmt::format (" failed to load preferences: {}" ,
329329 prefs_error);
330330 }
331- run_config.input_paths = expand_startup_input_paths (run_config,
332- run_config.verbose ,
333- library.sort_mode ,
334- library.sort_reverse );
335- const BackendKind requested_backend = requested_backend_for_launch (
336- run_config, ui_state);
331+ run_config.input_paths
332+ = expand_startup_input_paths (run_config, run_config.verbose ,
333+ library.sort_mode , library.sort_reverse );
334+ const BackendKind requested_backend
335+ = requested_backend_for_launch (run_config, ui_state);
337336
338337 const bool verbose_logging = run_config.verbose ;
339338 const bool verbose_validation_output
@@ -406,8 +405,9 @@ run(const AppConfig& config)
406405 }
407406
408407 const std::string window_title = build_main_window_title (active_backend);
409- GLFWwindow* window = platform_glfw_create_main_window (
410- active_backend, 1600 , 900 , window_title.c_str (), startup_error);
408+ GLFWwindow* window
409+ = platform_glfw_create_main_window (active_backend, 1600 , 900 ,
410+ window_title.c_str (), startup_error);
411411 if (window == nullptr ) {
412412 print (stderr, " imiv: {}\n " , startup_error);
413413 platform_glfw_terminate ();
@@ -619,16 +619,19 @@ run(const AppConfig& config)
619619 bool ocio_preflight_ok = false ;
620620 switch (active_backend) {
621621 case BackendKind::Vulkan:
622- ocio_preflight_ok = preflight_ocio_runtime_shader (
623- ui_state, nullptr , ocio_preflight_error);
622+ ocio_preflight_ok
623+ = preflight_ocio_runtime_shader (ui_state, nullptr ,
624+ ocio_preflight_error);
624625 break ;
625626 case BackendKind::Metal:
626- ocio_preflight_ok = preflight_ocio_runtime_shader_metal (
627- ui_state, nullptr , ocio_preflight_error);
627+ ocio_preflight_ok
628+ = preflight_ocio_runtime_shader_metal (ui_state, nullptr ,
629+ ocio_preflight_error);
628630 break ;
629631 case BackendKind::OpenGL:
630- ocio_preflight_ok = preflight_ocio_runtime_shader_glsl (
631- ui_state, nullptr , ocio_preflight_error);
632+ ocio_preflight_ok
633+ = preflight_ocio_runtime_shader_glsl (ui_state, nullptr ,
634+ ocio_preflight_error);
632635 break ;
633636 case BackendKind::Auto:
634637 ocio_preflight_error
@@ -688,9 +691,8 @@ run(const AppConfig& config)
688691#endif
689692
690693#if defined(IMGUI_ENABLE_TEST_ENGINE)
691- ViewerStateJsonWriteContext test_engine_state_ctx = { &viewer, &workspace,
692- &ui_state,
693- active_backend };
694+ ViewerStateJsonWriteContext test_engine_state_ctx
695+ = { &viewer, &workspace, &ui_state, active_backend };
694696 TestEngineHooks test_engine_hooks;
695697 test_engine_hooks.image_window_title = image_window_title ();
696698 test_engine_hooks.screen_capture = renderer_screen_capture;
@@ -746,7 +748,7 @@ run(const AppConfig& config)
746748 ,
747749 test_engine_show_windows_ptr (test_engine_runtime)
748750#endif
749- ,
751+ ,
750752 window, renderer_state);
751753 if (ui_state.style_preset != applied_style_preset) {
752754 ui_state.style_preset = static_cast <int >(
@@ -773,13 +775,12 @@ run(const AppConfig& config)
773775 ImGui::RenderPlatformWindowsDefault ();
774776 renderer_finish_platform_windows (renderer_state);
775777 }
776- process_developer_post_render_actions (developer_ui,
777- active_image_view (workspace)
778- != nullptr
779- ? active_image_view (workspace)
780- ->viewer
781- : viewer,
782- renderer_state);
778+ process_developer_post_render_actions (
779+ developer_ui,
780+ active_image_view (workspace) != nullptr
781+ ? active_image_view (workspace)->viewer
782+ : viewer,
783+ renderer_state);
783784#if defined(IMGUI_ENABLE_TEST_ENGINE)
784785 test_engine_post_swap (test_engine_runtime);
785786#endif
@@ -811,7 +812,8 @@ run(const AppConfig& config)
811812 print (stderr, " imiv: failed to wait for renderer idle: {}\n " ,
812813 prefs_save_error);
813814
814- for (const std::unique_ptr<ImageViewWindow>& view : workspace.view_windows ) {
815+ for (const std::unique_ptr<ImageViewWindow>& view :
816+ workspace.view_windows ) {
815817 if (view == nullptr )
816818 continue ;
817819 renderer_destroy_texture (renderer_state, view->viewer .texture );
0 commit comments