infinipaint/src/GUIStuff/Elements/TreeListing.hpp

61 lines
2.1 KiB
C++
Raw Normal View History

2025-12-20 16:38:51 +03:00
#pragma once
#include "Element.hpp"
2025-12-21 00:33:04 +03:00
#include <Helpers/NetworkingObjects/NetObjID.hpp>
2026-04-06 20:16:25 +03:00
#include <set>
namespace GUIStuff {
typedef std::vector<size_t> TreeListingObjIndexList;
2026-04-07 10:24:02 +03:00
bool is_tree_listing_obj_index_parent(const TreeListingObjIndexList& parentToCheck, const TreeListingObjIndexList& obj);
2026-04-06 20:16:25 +03:00
}
bool operator<(const GUIStuff::TreeListingObjIndexList& a, const GUIStuff::TreeListingObjIndexList& b);
2025-12-20 16:38:51 +03:00
namespace GUIStuff {
class GUIManager;
class TreeListing : public Element {
public:
2025-12-21 00:33:04 +03:00
static constexpr float ENTRY_HEIGHT = 25.0f;
2026-04-06 20:16:25 +03:00
static constexpr float ICON_SIZE = 25.0f;
2026-04-06 20:16:25 +03:00
struct ObjInfo {
TreeListingObjIndexList objIndex;
bool isDirectory = false;
bool isOpen = false;
};
2026-04-06 20:16:25 +03:00
struct DirectoryInfo {
size_t dirSize;
bool isOpen;
2025-12-21 00:33:04 +03:00
};
2025-12-23 17:17:33 +03:00
2026-04-06 20:16:25 +03:00
struct Data {
std::set<TreeListingObjIndexList>* selectedIndices = nullptr;
std::function<std::optional<DirectoryInfo>(const TreeListingObjIndexList& objIndex)> dirInfo;
std::function<void(const TreeListingObjIndexList& objIndex, bool isOpen)> setDirectoryOpen;
std::function<void(const TreeListingObjIndexList& objIndex)> drawNonDirectoryObjIconGUI;
std::function<void(const TreeListingObjIndexList& objIndex)> drawObjGUI;
std::function<void(const TreeListingObjIndexList& objIndex)> onDoubleClick;
std::function<void()> onSelectChange;
std::function<void(const std::vector<TreeListingObjIndexList>& objIndices, const TreeListingObjIndexList& newObjIndex)> moveObj;
2025-12-23 17:17:33 +03:00
};
TreeListing(GUIManager& gui);
2026-04-06 20:16:25 +03:00
void layout(const Clay_ElementId& id, const Data& newDisplayData);
2025-12-20 16:38:51 +03:00
private:
2026-04-06 20:16:25 +03:00
void recursive_visible_flattened_obj_list(std::vector<ObjInfo>& objs, const TreeListingObjIndexList& objIndex);
2026-04-07 10:24:02 +03:00
void move_selected_objects();
bool isDragging = false;
size_t dragIndexStart;
size_t dragIndexEnd;
2026-04-07 14:35:34 +03:00
bool dragFromTop;
2026-04-07 10:24:02 +03:00
2026-04-06 20:16:25 +03:00
std::vector<ObjInfo> flattenedIndexList;
Data d;
2025-12-20 16:38:51 +03:00
};
}