Skip to content

Commit 348d8cc

Browse files
committed
Improve about dialog and image info layout
1 parent 9cb101e commit 348d8cc

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

src/app-gui.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,7 +1016,8 @@ void HDRViewApp::draw_about_dialog(bool &open)
10161016
auto &io = ImGui::GetIO();
10171017

10181018
// Center window horizontally, align near top vertically
1019-
ImGui::SetNextWindowPos(ImVec2(io.DisplaySize.x / 2, 5.f * EmSize()), ImGuiCond_Always, ImVec2(0.5f, 0.0f));
1019+
auto pos = ImVec2(io.DisplaySize.x / 2, min(5.f * EmSize(), 0.1f * io.DisplaySize.y));
1020+
ImGui::SetNextWindowPos(pos, ImGuiCond_Always, ImVec2(0.5f, 0.0f));
10201021

10211022
ImGui::SetNextWindowFocus();
10221023
constexpr float icon_size = 128.f;
@@ -1029,12 +1030,13 @@ void HDRViewApp::draw_about_dialog(bool &open)
10291030
// window size constraints so ImGui lays out text properly and wrapping
10301031
// will occur at the window content width.
10311032
{
1032-
ImGuiStyle &style = ImGui::GetStyle();
1033-
float padding = style.WindowPadding.x;
1034-
float max_window_width = io.DisplaySize.x - 2.f * padding;
1035-
float target_width = clamp(desired_window_width, min_window_width, max_window_width);
1033+
ImGuiStyle &style = ImGui::GetStyle();
1034+
float padding = style.WindowPadding.x;
1035+
float max_window_width = io.DisplaySize.x - 2.f * padding;
1036+
float max_window_height = io.DisplaySize.y - 2.f * padding - pos.y;
1037+
float target_width = clamp(desired_window_width, min_window_width, max_window_width);
10361038

1037-
ImGui::SetNextWindowSizeConstraints(ImVec2(min_window_width, 0.f), ImVec2(max_window_width, FLT_MAX));
1039+
ImGui::SetNextWindowSizeConstraints(ImVec2(min_window_width, 0.f), ImVec2(max_window_width, max_window_height));
10381040
ImGui::SetNextWindowSize(ImVec2(target_width, 0.f), ImGuiCond_Always);
10391041
}
10401042

@@ -1124,7 +1126,7 @@ void HDRViewApp::draw_about_dialog(bool &open)
11241126
{
11251127
if (ImGui::BeginTabItem("Keybindings", nullptr))
11261128
{
1127-
ImVec2 child_size = ImVec2(0, EmSize(13.f));
1129+
ImVec2 child_size = ImVec2(0, EmSize(14.f));
11281130
ImGui::PushStyleColor(ImGuiCol_ChildBg, IM_COL32_BLACK_TRANS);
11291131
ImGui::BeginChild(ImGui::GetID("cfg_infos"), child_size, ImGuiChildFlags_AlwaysUseWindowPadding);
11301132

src/image-gui.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -627,9 +627,15 @@ void Image::draw_info()
627627
if (selected_view == 0)
628628
{
629629
ImGui::PushStyleColor(ImGuiCol_ChildBg, IM_COL32_BLACK_TRANS);
630-
if (ImGui::PE::Begin("Image info", ImGuiTableFlags_Resizable | ImGuiTableFlags_NoBordersInBodyUntilResize |
631-
ImGuiTableFlags_ScrollY))
630+
if (ImGui::PE::Begin("Image info", ImGuiTableFlags_ScrollY))
632631
{
632+
// calculate left column based on the longest property name
633+
ImGui::PushFont(hdrview()->font("sans bold"), ImGui::GetStyle().FontSizeBase);
634+
float col_width = ImGui::CalcTextSize("Channel selector").x + ImGui::GetStyle().CellPadding.x;
635+
ImGui::PopFont();
636+
637+
ImGui::TableSetupColumn("Property", ImGuiTableColumnFlags_WidthFixed, col_width);
638+
633639
ImGui::Indent(ImGui::GetStyle().CellPadding.x);
634640
filtered_property("File name", filename);
635641
filtered_property(

0 commit comments

Comments
 (0)