@@ -348,6 +348,12 @@ inline bool inRadioButton(const char* vLabel, bool vToggled) {
348348#ifndef removePlaceButtonString
349349#define removePlaceButtonString " -"
350350#endif // removePlaceButtonString
351+ #ifndef validatePlaceButtonString
352+ #define validatePlaceButtonString " ok"
353+ #endif // validatePlaceButtonString
354+ #ifndef editPlaceButtonString
355+ #define editPlaceButtonString " E"
356+ #endif // editPlaceButtonString
351357#ifndef IMGUI_TOGGLE_BUTTON
352358inline bool inToggleButton (const char * vLabel, bool * vToggled) {
353359 bool pressed = false ;
@@ -3012,6 +3018,7 @@ bool IGFD::PlacesFeature::m_DrawPlacesPane(FileDialogInternal& vFileDialogIntern
30123018 auto group_ptr = group.second .lock ();
30133019 if (group_ptr != nullptr ) {
30143020 if (ImGui::CollapsingHeader (group_ptr->name .c_str ())) {
3021+ ImGui::BeginChild (group_ptr->name .c_str (), ImVec2 (0 , 0 ), ImGuiChildFlags_AutoResizeY);
30153022 if (group_ptr->canBeEdited ) {
30163023 ImGui::PushID (group_ptr.get ());
30173024 if (IMGUI_BUTTON (addPlaceButtonString " ##ImGuiFileDialogAddPlace" )) {
@@ -3021,13 +3028,18 @@ bool IGFD::PlacesFeature::m_DrawPlacesPane(FileDialogInternal& vFileDialogIntern
30213028 }
30223029 if (group_ptr->selectedPlaceForEdition >= 0 && group_ptr->selectedPlaceForEdition < (int )group_ptr->places .size ()) {
30233030 ImGui::SameLine ();
3024- if (IMGUI_BUTTON (removePlaceButtonString " ##ImGuiFileDialogAddPlace " )) {
3031+ if (IMGUI_BUTTON (removePlaceButtonString " ##ImGuiFileDialogRemovePlace " )) {
30253032 group_ptr->places .erase (group_ptr->places .begin () + group_ptr->selectedPlaceForEdition );
30263033 if (group_ptr->selectedPlaceForEdition == (int )group_ptr->places .size ()) {
30273034 --group_ptr->selectedPlaceForEdition ;
30283035 }
30293036 }
30303037 if (group_ptr->selectedPlaceForEdition >= 0 && group_ptr->selectedPlaceForEdition < (int )group_ptr->places .size ()) {
3038+ ImGui::SameLine ();
3039+ if (IMGUI_BUTTON (validatePlaceButtonString " ##ImGuiFileDialogOkPlace" )) {
3040+ group_ptr->places [(size_t )group_ptr->selectedPlaceForEdition ].name = std::string (group_ptr->editBuffer );
3041+ group_ptr->selectedPlaceForEdition = -1 ;
3042+ }
30313043 ImGui::SameLine ();
30323044 ImGui::PushItemWidth (vSize.x - ImGui::GetCursorPosX ());
30333045 if (ImGui::InputText (" ##ImGuiFileDialogPlaceEdit" , group_ptr->editBuffer , MAX_FILE_DIALOG_NAME_BUFFER)) {
@@ -3040,33 +3052,53 @@ bool IGFD::PlacesFeature::m_DrawPlacesPane(FileDialogInternal& vFileDialogIntern
30403052 ImGui::Separator ();
30413053 }
30423054 if (!group_ptr->places .empty ()) {
3055+ const auto & current_path = vFileDialogInternal.fileManager .GetCurrentPath ();
30433056 group_ptr->clipper .Begin ((int )group_ptr->places .size (), ImGui::GetTextLineHeightWithSpacing ());
30443057 while (group_ptr->clipper .Step ()) {
30453058 for (int i = group_ptr->clipper .DisplayStart ; i < group_ptr->clipper .DisplayEnd ; i++) {
3046- if (i < 0 ) continue ;
3047- const PlaceStruct& place = group_ptr->places [(size_t )i];
3048- ImGui::PushID (i);
3049- std::string place_name = place.name ;
3050- if (!place.style .icon .empty ()) {
3051- place_name = place.style .icon + " " + place_name;
3059+ if (i < 0 ) {
3060+ continue ;
30523061 }
3053- if (ImGui::Selectable (place_name.c_str (), group_ptr->selectedPlaceForEdition == i, ImGuiSelectableFlags_AllowDoubleClick) ||
3054- (group_ptr->selectedPlaceForEdition == -1 && place.path == vFileDialogInternal.fileManager .GetCurrentPath ())) { // select if path is current
3055- group_ptr->selectedPlaceForEdition = i;
3056- IGFD::Utils::ResetBuffer (group_ptr->editBuffer );
3057- IGFD::Utils::AppendToBuffer (group_ptr->editBuffer , MAX_FILE_DIALOG_NAME_BUFFER, place.name );
3058- if (ImGui::IsMouseDoubleClicked (0 )) { // apply path
3059- vFileDialogInternal.fileManager .SetCurrentPath (place.path );
3060- vFileDialogInternal.fileManager .OpenCurrentPath (vFileDialogInternal);
3061- res = true ;
3062+ const PlaceStruct& place = group_ptr->places [(size_t )i];
3063+ if (place.thickness > 0 .0f ) {
3064+ ImGui::SeparatorEx (ImGuiSeparatorFlags_Horizontal, place.thickness );
3065+ } else {
3066+ ImGui::PushID (i);
3067+ std::string place_name = place.name ;
3068+ if (!place.style .icon .empty ()) {
3069+ place_name = place.style .icon + " " + place_name;
30623070 }
3063- }
3064- ImGui::PopID ();
3065- if (ImGui::IsItemHovered ()) ImGui::SetTooltip (" %s" , place.path .c_str ()); // -V111
3071+ if (group_ptr->canBeEdited ) {
3072+ ImGui::PushStyleColor (ImGuiCol_Button, ImVec4 (0 , 0 , 0 , 0 ));
3073+ ImGui::PushStyleVar (ImGuiStyleVar_FramePadding, ImVec2 (0 , 0 ));
3074+ if (ImGui::SmallButton (editPlaceButtonString " ##ImGuiFileDialogPlaceEditButton" )) {
3075+ group_ptr->selectedPlaceForEdition = i;
3076+ IGFD::Utils::ResetBuffer (group_ptr->editBuffer );
3077+ IGFD::Utils::AppendToBuffer (group_ptr->editBuffer , MAX_FILE_DIALOG_NAME_BUFFER, place.name );
3078+ }
3079+ ImGui::PopStyleVar ();
3080+ ImGui::PopStyleColor ();
3081+ ImGui::SameLine ();
3082+ }
3083+ if (ImGui::Selectable (place_name.c_str (), current_path == place.path || group_ptr->selectedPlaceForEdition == i, ImGuiSelectableFlags_AllowDoubleClick)) { // select if path is current
3084+ if (ImGui::IsMouseDoubleClicked (0 )) {
3085+ group_ptr->selectedPlaceForEdition = -1 ; // stop edition
3086+ // apply path
3087+ vFileDialogInternal.fileManager .SetCurrentPath (place.path );
3088+ vFileDialogInternal.fileManager .OpenCurrentPath (vFileDialogInternal);
3089+ res = true ;
3090+ }
3091+ }
3092+ ImGui::PopID ();
3093+ if (ImGui::IsItemHovered ()) {
3094+ ImGui::SetTooltip (" %s" , place.path .c_str ());
3095+ }
3096+ }
30663097 }
30673098 }
30683099 group_ptr->clipper .End ();
30693100 }
3101+ ImGui::EndChild ();
30703102 }
30713103 }
30723104 }
@@ -3155,6 +3187,12 @@ bool IGFD::PlacesFeature::GroupStruct::AddPlace(const std::string& vPlaceName, c
31553187 return true ;
31563188}
31573189
3190+ void IGFD::PlacesFeature::GroupStruct::AddPlaceSeparator (const float & vThickness) {
3191+ PlaceStruct place;
3192+ place.thickness = vThickness;
3193+ places.push_back (place);
3194+ }
3195+
31583196bool IGFD::PlacesFeature::GroupStruct::RemovePlace (const std::string& vPlaceName) {
31593197 if (vPlaceName.empty ()) {
31603198 return false ;
0 commit comments