88#include " imiv_file_dialog.h"
99#include " imiv_ocio.h"
1010#include " imiv_test_engine.h"
11+ #include " imiv_ui_metrics.h"
1112
1213#include < algorithm>
1314#include < cstring>
@@ -158,7 +159,8 @@ namespace {
158159 void draw_preferences_section_heading (const char * title)
159160 {
160161 const ImVec2 separator_padding
161- = ImVec2 (ImGui::GetStyle ().SeparatorTextPadding .x , 1 .0f );
162+ = ImVec2 (ImGui::GetStyle ().SeparatorTextPadding .x ,
163+ UiMetrics::Preferences::kSectionSeparatorTextPaddingY );
162164 ImGui::PushStyleVar (ImGuiStyleVar_SeparatorTextPadding,
163165 separator_padding);
164166 ImGui::PushStyleColor (ImGuiCol_Text,
@@ -176,7 +178,7 @@ namespace {
176178 return false ;
177179 }
178180 ImGui::TableSetupColumn (" Label" , ImGuiTableColumnFlags_WidthFixed,
179- 150 . 0f );
181+ UiMetrics::Preferences:: kLabelColumnWidth );
180182 ImGui::TableSetupColumn (" Control" , ImGuiTableColumnFlags_WidthStretch);
181183 return true ;
182184 }
@@ -218,8 +220,8 @@ namespace {
218220 {
219221 ImGui::PushID (id);
220222 const float spacing = ImGui::GetStyle ().ItemSpacing .x ;
221- const float button_width = 22 . 0f ;
222- const float value_width = 38 . 0f ;
223+ const float button_width = UiMetrics::Preferences:: kStepperButtonWidth ;
224+ const float value_width = UiMetrics::Preferences:: kStepperValueWidth ;
223225 const float suffix_width = (suffix != nullptr && suffix[0 ] != ' \0 ' )
224226 ? ImGui::CalcTextSize (suffix).x + spacing
225227 : 0 .0f ;
@@ -281,27 +283,33 @@ draw_info_window(const ViewerState& viewer, bool& show_window,
281283{
282284 if (!show_window)
283285 return ;
284- set_aux_window_defaults (ImVec2 (72 .0f , 72 .0f ), ImVec2 (360 .0f , 600 .0f ),
286+ set_aux_window_defaults (UiMetrics::AuxiliaryWindows::kInfoOffset ,
287+ UiMetrics::AuxiliaryWindows::kInfoSize ,
285288 reset_layout);
286- ImGui::PushStyleVar (ImGuiStyleVar_WindowPadding, ImVec2 (10 .0f , 10 .0f ));
289+ ImGui::PushStyleVar (ImGuiStyleVar_WindowPadding,
290+ UiMetrics::kAuxWindowPadding );
287291 if (ImGui::Begin (k_info_window_title, &show_window)) {
288292 const float close_height = ImGui::GetFrameHeightWithSpacing ();
289- const float body_height = std::max (100 .0f ,
290- ImGui::GetContentRegionAvail ().y
291- - close_height - 4 .0f );
293+ const float body_height
294+ = std::max (UiMetrics::AuxiliaryWindows::kInfoBodyMinHeight ,
295+ ImGui::GetContentRegionAvail ().y - close_height
296+ - UiMetrics::AuxiliaryWindows::kBodyBottomGap );
292297 ImGui::BeginChild (" ##iv_info_scroll" , ImVec2 (0 .0f , body_height), true ,
293298 ImGuiWindowFlags_HorizontalScrollbar);
294299 if (viewer.image .path .empty ()) {
295- draw_padded_message (" No image loaded." , 8 .0f , 8 .0f );
300+ draw_padded_message (
301+ " No image loaded." ,
302+ UiMetrics::AuxiliaryWindows::kEmptyMessagePadding .x ,
303+ UiMetrics::AuxiliaryWindows::kEmptyMessagePadding .y );
296304 register_layout_dump_synthetic_item (" text" , " No image loaded." );
297305 } else {
298306 if (ImGui::BeginTable (" ##iv_info_table" , 2 ,
299307 ImGuiTableFlags_SizingStretchProp
300308 | ImGuiTableFlags_BordersInnerV
301309 | ImGuiTableFlags_RowBg)) {
302- ImGui::TableSetupColumn (" Field " ,
303- ImGuiTableColumnFlags_WidthFixed,
304- 120 . 0f );
310+ ImGui::TableSetupColumn (
311+ " Field " , ImGuiTableColumnFlags_WidthFixed,
312+ UiMetrics::AuxiliaryWindows:: kInfoTableLabelWidth );
305313 ImGui::TableSetupColumn (" Value" ,
306314 ImGuiTableColumnFlags_WidthStretch);
307315
@@ -329,7 +337,8 @@ draw_info_window(const ViewerState& viewer, bool& show_window,
329337 register_layout_dump_synthetic_item (" text" , " iv Info content" );
330338 }
331339 ImGui::EndChild ();
332- ImGui::SetCursorPosY (ImGui::GetCursorPosY () + 3 .0f );
340+ ImGui::SetCursorPosY (ImGui::GetCursorPosY ()
341+ + UiMetrics::AuxiliaryWindows::kInfoCloseGap );
333342 if (ImGui::Button (" Close" ))
334343 show_window = false ;
335344 }
@@ -343,14 +352,17 @@ draw_preferences_window(PlaceholderUiState& ui, bool& show_window,
343352{
344353 if (!show_window)
345354 return ;
346- set_aux_window_defaults (ImVec2 (740 .0f , 72 .0f ), ImVec2 (300 .0f , 700 .0f ),
355+ set_aux_window_defaults (UiMetrics::AuxiliaryWindows::kPreferencesOffset ,
356+ UiMetrics::AuxiliaryWindows::kPreferencesSize ,
347357 reset_layout);
348- ImGui::PushStyleVar (ImGuiStyleVar_WindowPadding, ImVec2 (10 .0f , 10 .0f ));
358+ ImGui::PushStyleVar (ImGuiStyleVar_WindowPadding,
359+ UiMetrics::kAuxWindowPadding );
349360 if (ImGui::Begin (k_preferences_window_title, &show_window)) {
350361 const float close_height = ImGui::GetFrameHeightWithSpacing ();
351- const float body_height = std::max (120 .0f ,
352- ImGui::GetContentRegionAvail ().y
353- - close_height - 4 .0f );
362+ const float body_height
363+ = std::max (UiMetrics::AuxiliaryWindows::kPreferencesBodyMinHeight ,
364+ ImGui::GetContentRegionAvail ().y - close_height
365+ - UiMetrics::AuxiliaryWindows::kBodyBottomGap );
354366 ImGui::BeginChild (" ##iv_prefs_body" , ImVec2 (0 .0f , body_height), false ,
355367 ImGuiWindowFlags_None);
356368
@@ -442,7 +454,8 @@ draw_preferences_window(PlaceholderUiState& ui, bool& show_window,
442454 == OcioConfigSource::User) {
443455 if (begin_preferences_form_table (" ##pref_ocio_user" )) {
444456 preferences_form_next_row (" Path" );
445- const float browse_width = 64 .0f ;
457+ const float browse_width
458+ = UiMetrics::Preferences::kOcioBrowseButtonWidth ;
446459 const float field_width
447460 = std::max (60 .0f , ImGui::GetContentRegionAvail ().x
448461 - browse_width - spacing);
@@ -655,10 +668,13 @@ draw_preferences_window(PlaceholderUiState& ui, bool& show_window,
655668
656669 ImGui::EndChild ();
657670 clamp_placeholder_ui_state (ui);
658- ImGui::SetCursorPosY (ImGui::GetCursorPosY () + 4 .0f );
659- const float close_button_width = 72 .0f ;
660- const float x = ImGui::GetCursorPosX ();
661- const float available_width = ImGui::GetContentRegionAvail ().x ;
671+ ImGui::SetCursorPosY (
672+ ImGui::GetCursorPosY ()
673+ + UiMetrics::AuxiliaryWindows::kPreferencesCloseGap );
674+ const float close_button_width
675+ = UiMetrics::Preferences::kCloseButtonWidth ;
676+ const float x = ImGui::GetCursorPosX ();
677+ const float available_width = ImGui::GetContentRegionAvail ().x ;
662678 if (available_width > close_button_width) {
663679 ImGui::SetCursorPosX (
664680 x + (available_width - close_button_width) * 0 .5f );
@@ -684,22 +700,25 @@ draw_preview_window(PlaceholderUiState& ui, bool& show_window,
684700{
685701 if (!show_window)
686702 return ;
687- set_aux_window_defaults (ImVec2 (1030 .0f , 72 .0f ), ImVec2 (300 .0f , 360 .0f ),
703+ set_aux_window_defaults (UiMetrics::AuxiliaryWindows::kPreviewOffset ,
704+ UiMetrics::AuxiliaryWindows::kPreviewSize ,
688705 reset_layout);
689- ImGui::PushStyleVar (ImGuiStyleVar_WindowPadding, ImVec2 (10 .0f , 10 .0f ));
706+ ImGui::PushStyleVar (ImGuiStyleVar_WindowPadding,
707+ UiMetrics::kAuxWindowPadding );
690708 if (ImGui::Begin (k_preview_window_title, &show_window)) {
691709 const float close_height = ImGui::GetFrameHeightWithSpacing ();
692- const float body_height = std::max (120 .0f ,
693- ImGui::GetContentRegionAvail ().y
694- - close_height - 4 .0f );
710+ const float body_height
711+ = std::max (UiMetrics::AuxiliaryWindows::kPreviewBodyMinHeight ,
712+ ImGui::GetContentRegionAvail ().y - close_height
713+ - UiMetrics::AuxiliaryWindows::kBodyBottomGap );
695714 ImGui::BeginChild (" ##iv_preview_body" , ImVec2 (0 .0f , body_height), false ,
696715 ImGuiWindowFlags_NoScrollbar);
697716
698717 if (ImGui::BeginTable (" ##iv_preview_form" , 2 ,
699718 ImGuiTableFlags_SizingStretchProp
700719 | ImGuiTableFlags_NoSavedSettings)) {
701720 ImGui::TableSetupColumn (" Label" , ImGuiTableColumnFlags_WidthFixed,
702- 90 . 0f );
721+ UiMetrics::Preview:: kLabelColumnWidth );
703722 ImGui::TableSetupColumn (" Control" ,
704723 ImGuiTableColumnFlags_WidthStretch);
705724
0 commit comments