Skip to content

Commit 4a46495

Browse files
committed
[UPD] : update the doc for the new places system
1 parent 0cdbfa0 commit 4a46495

4 files changed

Lines changed: 119 additions & 88 deletions

File tree

ImGuiFileDialog.cpp

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -325,14 +325,23 @@ inline bool inRadioButton(const char* vLabel, bool vToggled) {
325325
#define defaultPlacePaneWith 150.0f
326326
#endif // defaultPlacePaneWith
327327
#ifndef placesButtonString
328-
#define placesButtonString "Place"
328+
#define placesButtonString "Places"
329329
#endif // placesButtonString
330-
#ifndef bookmarksGroupString
331-
#define bookmarksGroupString "Bookmarks"
332-
#endif // bookmarksGroupString
333330
#ifndef placesButtonHelpString
334-
#define placesButtonHelpString "Place"
331+
#define placesButtonHelpString "Places"
335332
#endif // placesButtonHelpString
333+
#ifndef placesBookmarksGroupName
334+
#define placesBookmarksGroupName "Bookmarks"
335+
#endif // placesBookmarksName
336+
#ifndef placesBookmarksDisplayOrder
337+
#define placesBookmarksDisplayOrder 0
338+
#endif // placesBookmarksDisplayOrder
339+
#ifndef placesDevicesGroupName
340+
#define placesDevicesGroupName "Devices"
341+
#endif // placesDevicesGroupName
342+
#ifndef placesDevicesDisplayOrder
343+
#define placesDevicesDisplayOrder 10
344+
#endif // placesDevicesDisplayOrder
336345
#ifndef addPlaceButtonString
337346
#define addPlaceButtonString "+"
338347
#endif // addPlaceButtonString
@@ -2990,17 +2999,15 @@ IGFD::PlacesFeature::PlacesFeature() {
29902999
#ifdef USE_PLACES_FEATURE
29913000
void IGFD::PlacesFeature::m_InitPlaces(FileDialogInternal& vFileDialogInternal) {
29923001
#ifdef USE_PLACES_BOOKMARKS
2993-
AddPlacesGroup(PLACE_BOOKMARKS_NAME, PLACE_BOOKMARKS_DISPLAY_ORDER, true);
3002+
AddPlacesGroup(placesBookmarksGroupName, placesBookmarksDisplayOrder, true);
29943003
#endif // USE_PLACES_BOOKMARK
29953004
#ifdef USE_PLACES_DEVICES
2996-
AddPlacesGroup(PLACE_DEVICES_NAME, PLACE_DEVICES_DISPLAY_ORDER, false);
2997-
auto devices_ptr = GetPlacesGroupPtr(PLACE_DEVICES_NAME);
3005+
AddPlacesGroup(placesDevicesGroupName, placesDevicesDisplayOrder, false);
3006+
auto devices_ptr = GetPlacesGroupPtr(placesDevicesGroupName);
29983007
if (devices_ptr != nullptr && vFileDialogInternal.fileManager.GetFileSystemInstance() != nullptr) {
29993008
const auto& devices = vFileDialogInternal.fileManager.GetFileSystemInstance()->GetDevicesList();
3000-
IGFD::FileStyle style;
3001-
style.icon = PLACE_DEVICES_ICON;
30023009
for (const auto& device : devices) {
3003-
devices_ptr->AddPlace(device.first + " " + device.second, device.first + IGFD::Utils::GetPathSeparator(), false, style);
3010+
devices_ptr->AddPlace(device.first + " " + device.second, device.first + IGFD::Utils::GetPathSeparator(), false);
30043011
}
30053012
devices_ptr = nullptr;
30063013
}
@@ -3014,9 +3021,7 @@ void IGFD::PlacesFeature::m_DrawPlacesButton() {
30143021

30153022
bool IGFD::PlacesFeature::m_DrawPlacesPane(FileDialogInternal& vFileDialogInternal, const ImVec2& vSize) {
30163023
bool res = false;
3017-
30183024
ImGui::BeginChild("##placespane", vSize);
3019-
30203025
for (const auto& group : m_OrderedGroups) {
30213026
auto group_ptr = group.second.lock();
30223027
if (group_ptr != nullptr) {
@@ -3025,10 +3030,7 @@ bool IGFD::PlacesFeature::m_DrawPlacesPane(FileDialogInternal& vFileDialogIntern
30253030
ImGui::PushID(group_ptr.get());
30263031
if (IMGUI_BUTTON(addPlaceButtonString "##ImGuiFileDialogAddPlace")) {
30273032
if (!vFileDialogInternal.fileManager.IsComposerEmpty()) {
3028-
PlaceStruct place;
3029-
place.name = vFileDialogInternal.fileManager.GetBack();
3030-
place.path = vFileDialogInternal.fileManager.GetCurrentPath();
3031-
group_ptr->places.push_back(place);
3033+
group_ptr->AddPlace(vFileDialogInternal.fileManager.GetBack(), vFileDialogInternal.fileManager.GetCurrentPath(), true);
30323034
}
30333035
}
30343036
if (group_ptr->selectedPlaceForEdition >= 0 && group_ptr->selectedPlaceForEdition < (int)group_ptr->places.size()) {
@@ -3039,7 +3041,6 @@ bool IGFD::PlacesFeature::m_DrawPlacesPane(FileDialogInternal& vFileDialogIntern
30393041
--group_ptr->selectedPlaceForEdition;
30403042
}
30413043
}
3042-
30433044
if (group_ptr->selectedPlaceForEdition >= 0 && group_ptr->selectedPlaceForEdition < (int)group_ptr->places.size()) {
30443045
ImGui::SameLine();
30453046
ImGui::PushItemWidth(vSize.x - ImGui::GetCursorPosX());
@@ -3052,7 +3053,6 @@ bool IGFD::PlacesFeature::m_DrawPlacesPane(FileDialogInternal& vFileDialogIntern
30523053
ImGui::PopID();
30533054
ImGui::Separator();
30543055
}
3055-
30563056
if (!group_ptr->places.empty()) {
30573057
group_ptr->clipper.Begin((int)group_ptr->places.size(), ImGui::GetTextLineHeightWithSpacing());
30583058
while (group_ptr->clipper.Step()) {
@@ -3081,13 +3081,10 @@ bool IGFD::PlacesFeature::m_DrawPlacesPane(FileDialogInternal& vFileDialogIntern
30813081
}
30823082
group_ptr->clipper.End();
30833083
}
3084-
30853084
}
30863085
}
30873086
}
3088-
30893087
ImGui::EndChild();
3090-
30913088
return res;
30923089
}
30933090

ImGuiFileDialog.h

Lines changed: 53 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -562,47 +562,6 @@ As you see the current item is flashed by default for 1 second. You can define t
562562
```cpp
563563
ImGuiFileDialog::Instance()->SetFlashingAttenuationInSeconds(1.0f);
564564
```
565-
566-
################################################################
567-
## Places
568-
################################################################
569-
570-
You can create/edit/call path place and load/save them.
571-
572-
Activate this feature by uncommenting: `#define USE_PLACES_FEATURE` in your custom config file (CustomImGuiFileDialogConfig.h)
573-
574-
More customization options:
575-
576-
```cpp
577-
#define placesPaneWith 150.0f => width of the place pane
578-
#define IMGUI_TOGGLE_BUTTON ToggleButton => customize the Toggled button (button stamp must be : (const char* label,
579-
bool *toggle) #define placesButtonString "Place" => the text in the toggle button #define
580-
placesButtonHelpString "Place" => the helper text when mouse over the button #define addPlaceButtonString "+"
581-
=> the button for add a place #define removePlaceButtonString "-" => the button for remove the selected place
582-
```
583-
584-
* You can select each place to edit the displayed name corresponding to a path
585-
* Double-click on the label to apply the place
586-
587-
![place.gif](https://github.com/aiekick/ImGuiFileDialog/blob/master/doc/place.gif)
588-
589-
You can also serialize/deserialize place (for example to load/save from/to a file):
590-
```cpp
591-
Load => ImGuiFileDialog::Instance()->DeserializePlaces(bookmarString);
592-
Save => std::string placesString = ImGuiFileDialog::Instance()->SerializePlaces();
593-
```
594-
(please see example code for details)
595-
596-
you can also add/remove place by code :
597-
and in this case, you can also avoid serialization of code based place
598-
599-
```cpp
600-
Add => ImGuiFileDialog::Instance()->AddPlace(places_name, places_path);
601-
Remove => ImGuiFileDialog::Instance()->RemovePlace(places_name);
602-
Save => std::string placesString = ImGuiFileDialog::Instance()->SerializePlaces(true); // true for prevent
603-
serialization of code based place
604-
```
605-
606565
################################################################
607566
## Path Edition :
608567
################################################################
@@ -1091,6 +1050,59 @@ vFileInfosPtr->tooltipMessage = toStr("%s : %s\n%s : %s", //
10911050
vFileInfosPtr->tooltipColumn = 1;
10921051
```
10931052
1053+
################################################################
1054+
## Places
1055+
################################################################
1056+
1057+
the Places system is a generic way for add custom links in the left side pane
1058+
1059+
you can organize them by groups
1060+
1061+
The bookmarks and devices are now groups in the left side pane.
1062+
1063+
for using it you need to
1064+
```cpp
1065+
#define USE_PLACES_FEATURE
1066+
1067+
// for have default bookmark editable groups
1068+
#define USE_PLACES_BOOKMARKS
1069+
1070+
// for have default groups for system devices (returned by the IFileSystem interface)
1071+
#define USE_PLACES_DEVICES
1072+
```
1073+
1074+
see the config file for more customization
1075+
1076+
you can also add your custom groups editable or not like what is done
1077+
the DemoApp branch with the "quick access" paths of win10
1078+
1079+
You must add a group first, then add a place to it :
1080+
1081+
```cpp
1082+
// you must add a group first, specifu display order, and say if the user can add or remove palce like (bookmarks)
1083+
ImGuiFileDialog::Instance()->AddPlacesGroup(group_name, display_order, can_be_user_edited);
1084+
// then you must get the group
1085+
auto places_ptr = ImGuiFileDialog::Instance()->GetPlacesGroupPtr(group_name);
1086+
if (places_ptr != nullptr) {
1087+
// then add a place to the group
1088+
// you msut specify the place name, the palce path, say if the palce can be serialized, and sepcify the style
1089+
// for the moment the style support only the icon, can be extended if user needed in futur
1090+
places_ptr->AddPlace(place_name, place_path, can_be_saved, style);
1091+
}
1092+
```
1093+
1094+
for editable group :
1095+
* You can select each place to edit the displayed name corresponding to a path
1096+
* Double-click on the label to apply the place
1097+
1098+
You can also serialize/deserialize groups and places (for example to load/save from/to a file):
1099+
```cpp
1100+
Load => ImGuiFileDialog::Instance()->DeserializePlaces(placesString);
1101+
Save => std::string placesString = ImGuiFileDialog::Instance()->SerializePlaces();
1102+
```
1103+
1104+
(please see DemoApp branch for details)
1105+
10941106
################################################################
10951107
## How to Integrate ImGuiFileDialog in your project
10961108
################################################################

ImGuiFileDialogConfig.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,17 @@
130130
//#define placesPaneWith 150.0f
131131
//#define IMGUI_TOGGLE_BUTTON ToggleButton
132132
//#define placesButtonString "Place"
133-
//#define placesButtonHelpString "Place"
133+
//#define placesButtonHelpString "Places"
134134
//#define addPlaceButtonString "+"
135135
//#define removePlaceButtonString "-"
136+
137+
// a group for bookmarks will be added by default, but you can also create it yourself and many more
138+
// #define USE_PLACES_BOOKMARKS
139+
// #define PLACE_BOOKMARKS_NAME "Bookmarks"
140+
// #define PLACE_BOOKMARKS_DISPLAY_ORDER 0 // to the first
141+
142+
// a group for system devices (returned by IFileSystem), but you can also add yours
143+
// #define USE_PLACES_DEVICES
144+
// #define PLACE_DEVICES_NAME "Devices"
145+
// #define PLACE_DEVICES_DISPLAY_ORDER 10 // to the end
146+
// #define PLACE_DEVICES_ICON ""

README.md

Lines changed: 35 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -493,47 +493,58 @@ ImGuiFileDialog::Instance()->SetFlashingAttenuationInSeconds(1.0f);
493493
494494
</blockquote></details>
495495
496-
<details open><summary><h2>Bookmarks :</h2></summary><blockquote>
496+
<details open><summary><h2>Places :</h2></summary><blockquote>
497497
498-
You can create/edit/call path bookmarks and load/save them.
498+
the Places system is a generic way for add custom links in the left side pane
499499
500-
Activate this feature by uncommenting: `#define USE_BOOKMARK` in your custom config file (CustomImGuiFileDialogConfig.h)
500+
you can organize them by groups
501501
502-
More customization options:
502+
The bookmarks and devices are now groups in the left side pane.
503503
504+
for using it you need to
504505
```cpp
505-
#define bookmarkPaneWith 150.0f => width of the bookmark pane
506-
#define IMGUI_TOGGLE_BUTTON ToggleButton => customize the Toggled button (button stamp must be : (const char* label, bool *toggle)
507-
#define bookmarksButtonString "Bookmark" => the text in the toggle button
508-
#define bookmarksButtonHelpString "Bookmark" => the helper text when mouse over the button
509-
#define addBookmarkButtonString "+" => the button for add a bookmark
510-
#define removeBookmarkButtonString "-" => the button for remove the selected bookmark
506+
#define USE_PLACES_FEATURE
507+
508+
// for have default bookmark editable groups
509+
#define USE_PLACES_BOOKMARKS
510+
511+
// for have default groups for system devices (returned by the IFileSystem interface)
512+
#define USE_PLACES_DEVICES
511513
```
512514

513-
* You can select each bookmark to edit the displayed name corresponding to a path
514-
* Double-click on the label to apply the bookmark
515+
see the config file for more customization
516+
517+
you can also add your custom groups editable or not like what is done
518+
the DemoApp branch with the "quick access" paths of win10
515519

516-
![bookmarks.gif](https://github.com/aiekick/ImGuiFileDialog/blob/DemoApp/doc/bookmarks.gif)
520+
You must add a group first, then add a place to it :
517521

518-
You can also serialize/deserialize bookmarks (for example to load/save from/to a file):
519522
```cpp
520-
Load => ImGuiFileDialog::Instance()->DeserializeBookmarks(bookmarString);
521-
Save => std::string bookmarkString = ImGuiFileDialog::Instance()->SerializeBookmarks();
523+
// you must add a group first, specifu display order, and say if the user can add or remove palce like (bookmarks)
524+
ImGuiFileDialog::Instance()->AddPlacesGroup(group_name, display_order, can_be_user_edited);
525+
// then you must get the group
526+
auto places_ptr = ImGuiFileDialog::Instance()->GetPlacesGroupPtr(group_name);
527+
if (places_ptr != nullptr) {
528+
// then add a place to the group
529+
// you msut specify the place name, the palce path, say if the palce can be serialized, and sepcify the style
530+
// for the moment the style support only the icon, can be extended if user needed in futur
531+
places_ptr->AddPlace(place_name, place_path, can_be_saved, style);
532+
}
522533
```
523534
524-
you can also add/remove bookmark by code :
535+
for editable group :
536+
* You can select each place to edit the displayed name corresponding to a path
537+
* Double-click on the label to apply the place
525538
526-
and in this case, you can also avoid serialization of code based bookmark
539+
![places.gif](https://github.com/aiekick/ImGuiFileDialog/blob/DemoApp/doc/places.gif)
527540
541+
You can also serialize/deserialize groups and places (for example to load/save from/to a file):
528542
```cpp
529-
Add => ImGuiFileDialog::Instance()->AddBookmark(bookmark_name, bookmark_path);
530-
Remove => ImGuiFileDialog::Instance()->RemoveBookmark(bookmark_name);
531-
532-
// true for prevent serialization of code based bookmarks
533-
Save => std::string bookmarkString = ImGuiFileDialog::Instance()->SerializeBookmarks(true);
543+
Load => ImGuiFileDialog::Instance()->DeserializePlaces(placesString);
544+
Save => std::string placesString = ImGuiFileDialog::Instance()->SerializePlaces();
534545
```
535546

536-
(please see example code for details)
547+
(please see DemoApp branch for details)
537548

538549
</blockquote></details>
539550

0 commit comments

Comments
 (0)