Skip to content

Commit 92c7ef3

Browse files
committed
[ADD] : add a Places System who is extending the current Bookamarks mode to know places, quick access, favorites, devices, etc..
1 parent 553ffe7 commit 92c7ef3

2 files changed

Lines changed: 29 additions & 8 deletions

File tree

ImGuiFileDialog.cpp

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2452,12 +2452,12 @@ void IGFD::FileManager::DrawPathComposer(const FileDialogInternal& vFileDialogIn
24522452
if (ImGui::IsItemHovered()) ImGui::SetTooltip(buttonResetPathString);
24532453

24542454
#ifdef _IGFD_WIN_
2455-
ImGui::SameLine();
2455+
/*ImGui::SameLine();
24562456
24572457
if (IMGUI_BUTTON(drivesButtonString)) {
24582458
drivesClicked = true;
24592459
}
2460-
if (ImGui::IsItemHovered()) ImGui::SetTooltip(buttonDriveString);
2460+
if (ImGui::IsItemHovered()) ImGui::SetTooltip(buttonDriveString);*/
24612461
#endif // _IGFD_WIN_
24622462

24632463
ImGui::SameLine();
@@ -2991,6 +2991,25 @@ IGFD::PlacesFeature::PlacesFeature() {
29912991
}
29922992

29932993
#ifdef USE_PLACES_FEATURE
2994+
void IGFD::PlacesFeature::m_InitPlaces(FileDialogInternal& vFileDialogInternal) {
2995+
#ifdef USE_PLACES_BOOKMARKS
2996+
AddPlacesGroup(PLACE_BOOKMARKS_NAME, PLACE_BOOKMARKS_DISPLAY_ORDER, true);
2997+
#endif // USE_PLACES_BOOKMARK
2998+
#ifdef USE_PLACES_DEVICES
2999+
AddPlacesGroup(PLACE_DEVICES_NAME, PLACE_DEVICES_DISPLAY_ORDER, false);
3000+
auto devices_ptr = GetPlacesGroupPtr(PLACE_DEVICES_NAME);
3001+
if (devices_ptr != nullptr && vFileDialogInternal.fileManager.GetFileSystemInstance() != nullptr) {
3002+
const auto& devices = vFileDialogInternal.fileManager.GetFileSystemInstance()->GetDevicesList();
3003+
IGFD::FileStyle style;
3004+
style.icon = ICON_IGFD_DRIVES;
3005+
for (const auto& device : devices) {
3006+
devices_ptr->AddPlace(device.first + " " + device.second, device.first, false, style);
3007+
}
3008+
devices_ptr = nullptr;
3009+
}
3010+
#endif // USE_PLACES_DEVICES
3011+
}
3012+
29943013
void IGFD::PlacesFeature::m_DrawPlacesButton() {
29953014
IMGUI_TOGGLE_BUTTON(placesButtonString, &m_PlacesPaneShown);
29963015
if (ImGui::IsItemHovered()) ImGui::SetTooltip(placesButtonHelpString);
@@ -3109,7 +3128,7 @@ void IGFD::PlacesFeature::DeserializePlaces(const std::string& vPlaces) {
31093128
}*/
31103129
}
31113130

3112-
bool IGFD::PlacesFeature::AddGroup(const std::string& vGroupName, const size_t& vDisplayOrder, const bool& vCanBeEdited) {
3131+
bool IGFD::PlacesFeature::AddPlacesGroup(const std::string& vGroupName, const size_t& vDisplayOrder, const bool& vCanBeEdited) {
31133132
if (vGroupName.empty()) {
31143133
return false;
31153134
}
@@ -3123,7 +3142,7 @@ bool IGFD::PlacesFeature::AddGroup(const std::string& vGroupName, const size_t&
31233142
return true;
31243143
}
31253144

3126-
bool IGFD::PlacesFeature::RemoveGroup(const std::string& vGroupName) {
3145+
bool IGFD::PlacesFeature::RemovePlacesGroup(const std::string& vGroupName) {
31273146
for (auto it = m_Groups.begin(); it != m_Groups.end(); ++it) {
31283147
if ((*it).second->name == vGroupName) {
31293148
m_Groups.erase(it);
@@ -3133,7 +3152,7 @@ bool IGFD::PlacesFeature::RemoveGroup(const std::string& vGroupName) {
31333152
return false;
31343153
}
31353154

3136-
IGFD::PlacesFeature::GroupStruct* IGFD::PlacesFeature::getGroupPtr(const std::string& vGroupName) {
3155+
IGFD::PlacesFeature::GroupStruct* IGFD::PlacesFeature::GetPlacesGroupPtr(const std::string& vGroupName) {
31373156
if (m_Groups.find(vGroupName) != m_Groups.end()) {
31383157
return m_Groups.at(vGroupName).get();
31393158
}
@@ -3541,6 +3560,7 @@ void IGFD::KeyExplorerFeature::SetFlashingAttenuationInSeconds(float vAttenValue
35413560
#pragma region FileDialog
35423561

35433562
IGFD::FileDialog::FileDialog() : PlacesFeature(), KeyExplorerFeature(), ThumbnailFeature() {
3563+
m_InitPlaces(m_FileDialogInternal);
35443564
}
35453565
IGFD::FileDialog::~FileDialog() = default;
35463566

ImGuiFileDialog.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2064,6 +2064,7 @@ class IGFD_API PlacesFeature {
20642064
bool m_PlacesPaneShown = false;
20652065

20662066
protected:
2067+
void m_InitPlaces(FileDialogInternal& vFileDialogInternal);
20672068
void m_DrawPlacesButton(); // draw place button
20682069
bool m_DrawPlacesPane(FileDialogInternal& vFileDialogInternal, const ImVec2& vSize); // draw place Pane
20692070

@@ -2072,12 +2073,12 @@ class IGFD_API PlacesFeature {
20722073
const bool& vForceSerialisationForAll = true); // for avoid serialization of places with flag canBeSaved to false
20732074
void DeserializePlaces( // deserialize place : load place buffer to load in the dialog (saved from
20742075
const std::string& vPlaces); // previous use with SerializePlaces()) place buffer to load
2075-
bool AddGroup( // add a group
2076+
bool AddPlacesGroup( // add a group
20762077
const std::string& vGroupName, // the group name
20772078
const size_t& vDisplayOrder, // the display roder of the group
20782079
const bool& vCanBeEdited); // let the user add/remove place in the group
2079-
bool RemoveGroup(const std::string& vGroupName); // remove the group
2080-
GroupStruct* getGroupPtr(const std::string& vGroupName); // get the group, if not existed, will be created
2080+
bool RemovePlacesGroup(const std::string& vGroupName); // remove the group
2081+
GroupStruct* GetPlacesGroupPtr(const std::string& vGroupName); // get the group, if not existed, will be created
20812082
#endif // USE_PLACES_FEATURE
20822083
};
20832084

0 commit comments

Comments
 (0)