24
24
#endif
25
25
26
26
#define ICON_SIZE ImGui::GetFont ()->FontSize + 3
27
- #define GUI_ELEMENT_SIZE 24
27
+ #define GUI_ELEMENT_SIZE std::max (GImGui->FontSize + 10 .f, 24 .f)
28
28
#define DEFAULT_ICON_SIZE 32
29
29
#define PI 3 .141592f
30
30
@@ -1330,7 +1330,7 @@ namespace ifd {
1330
1330
1331
1331
1332
1332
/* **** CONTENT *****/
1333
- float bottomBarHeight = (GImGui->FontSize + ImGui::GetStyle ().FramePadding .y * 2 . 0f + ImGui::GetStyle ().ItemSpacing .y * 2 .0f ) * 2 ;
1333
+ float bottomBarHeight = (GImGui->FontSize + ImGui::GetStyle ().FramePadding .y + ImGui::GetStyle ().ItemSpacing .y * 2 .0f ) * 2 ;
1334
1334
if (ImGui::BeginTable (" ##table" , 2 , ImGuiTableFlags_Resizable, ImVec2 (0 , -bottomBarHeight))) {
1335
1335
ImGui::TableSetupColumn (" ##tree" , ImGuiTableColumnFlags_WidthFixed, 125 .0f );
1336
1336
ImGui::TableSetupColumn (" ##content" , ImGuiTableColumnFlags_WidthStretch);
@@ -1384,8 +1384,9 @@ namespace ifd {
1384
1384
}
1385
1385
1386
1386
// buttons
1387
- ImGui::SetCursorPosX (ImGui::GetWindowWidth () - 250 );
1388
- if (ImGui::Button (m_type == IFD_DIALOG_SAVE ? " Save" : " Open" , ImVec2 (250 / 2 - ImGui::GetStyle ().ItemSpacing .x , 0 .0f ))) {
1387
+ float ok_cancel_width = GUI_ELEMENT_SIZE * 7 ;
1388
+ ImGui::SetCursorPosX (ImGui::GetWindowWidth () - ok_cancel_width);
1389
+ if (ImGui::Button (m_type == IFD_DIALOG_SAVE ? " Save" : " Open" , ImVec2 (ok_cancel_width / 2 - ImGui::GetStyle ().ItemSpacing .x , 0 .0f ))) {
1389
1390
std::string filename (m_inputTextbox);
1390
1391
bool success = false ;
1391
1392
if (!filename.empty () || m_type == IFD_DIALOG_DIRECTORY)
@@ -1398,8 +1399,17 @@ namespace ifd {
1398
1399
#endif
1399
1400
}
1400
1401
ImGui::SameLine ();
1401
- if (ImGui::Button (" Cancel" , ImVec2 (-FLT_MIN, 0 .0f )))
1402
- m_finalize ();
1402
+ if (ImGui::Button (" Cancel" , ImVec2 (-FLT_MIN, 0 .0f ))) {
1403
+ if (m_type == IFD_DIALOG_DIRECTORY)
1404
+ m_isOpen = false ;
1405
+ else
1406
+ m_finalize ();
1407
+ }
1408
+
1409
+ int escapeKey = ImGui::GetIO ().KeyMap [ImGuiKey_Escape];
1410
+ if (ImGui::IsWindowFocused (ImGuiFocusedFlags_RootAndChildWindows) &&
1411
+ escapeKey >= 0 && ImGui::IsKeyPressed (escapeKey))
1412
+ m_isOpen = false ;
1403
1413
}
1404
1414
}
1405
1415
0 commit comments