@@ -140,6 +140,9 @@ namespace IGFD
140140#ifndef okCancelButtonAlignement
141141#define okCancelButtonAlignement 0 .0f
142142#endif // okCancelButtonAlignement
143+ #ifndef invertOkAndCancelButtons
144+ #define invertOkAndCancelButtons false
145+ #endif // invertOkAndCancelButtons
143146#ifndef resetButtonString
144147#define resetButtonString " R"
145148#endif // resetButtonString
@@ -3863,34 +3866,56 @@ namespace IGFD
38633866 }
38643867 }
38653868
3866- bool IGFD::FileDialog::prDrawValidationButtons ()
3869+ bool IGFD::FileDialog::prDrawOkButton ()
38673870 {
3868- bool res = false ;
3869-
38703871 auto & fdFile = prFileDialogInternal.puFileManager ;
3871-
3872- ImGui::SetCursorPosX (ImGui::GetCursorPosX () + (ImGui::GetContentRegionAvail ().x - prOkCancelButtonWidth) * okCancelButtonAlignement);
3873-
3874- ImGui::BeginGroup ();
3875-
3876- // OK Button
38773872 if (prFileDialogInternal.puCanWeContinue && strlen (fdFile.puFileNameBuffer ))
38783873 {
38793874 if (IMGUI_BUTTON (okButtonString " ##validationdialog" , ImVec2 (okButtonWidth, 0 .0f )) || prFileDialogInternal.puIsOk )
38803875 {
38813876 prFileDialogInternal.puIsOk = true ;
3882- res = true ;
3877+ return true ;
38833878 }
38843879
3885- ImGui::SameLine ();
3880+ if (!invertOkAndCancelButtons)
3881+ ImGui::SameLine ();
38863882 }
38873883
3888- // Cancel Button
3884+ return false ;
3885+ }
3886+
3887+ bool IGFD::FileDialog::prDrawCancelButton ()
3888+ {
38893889 if (IMGUI_BUTTON (cancelButtonString " ##validationdialog" , ImVec2 (cancelButtonWidth, 0 .0f )) ||
38903890 prFileDialogInternal.puNeedToExitDialog ) // dialog exit asked
38913891 {
38923892 prFileDialogInternal.puIsOk = false ;
3893- res = true ;
3893+ return true ;
3894+ }
3895+
3896+ if (invertOkAndCancelButtons)
3897+ ImGui::SameLine ();
3898+
3899+ return false ;
3900+ }
3901+
3902+ bool IGFD::FileDialog::prDrawValidationButtons ()
3903+ {
3904+ bool res = false ;
3905+
3906+ ImGui::SetCursorPosX (ImGui::GetCursorPosX () + (ImGui::GetContentRegionAvail ().x - prOkCancelButtonWidth) * okCancelButtonAlignement);
3907+
3908+ ImGui::BeginGroup ();
3909+
3910+ if (invertOkAndCancelButtons)
3911+ {
3912+ prDrawCancelButton ();
3913+ prDrawOkButton ();
3914+ }
3915+ else
3916+ {
3917+ prDrawOkButton ();
3918+ prDrawCancelButton ();
38943919 }
38953920
38963921 ImGui::EndGroup ();
0 commit comments