7#include "imgui/imgui.h"
8#include "nlohmann/json.hpp"
34 std::vector<std::shared_ptr<Handler>> subhandlers;
35 std::mutex subhandlers_mtx;
38 std::string handler_tree_icon =
"N";
42 std::vector<std::shared_ptr<Handler>> subhandlers_marked_for_del;
44 bool handler_can_be_selected =
true;
45 bool handler_can_be_dragged =
true;
46 bool handler_can_be_dragged_to =
true;
47 bool handler_can_subhandlers_be_dragged =
true;
49 bool handler_can_be_reorg =
false;
51 void delSubHandlersNow()
53 subhandlers_mtx.lock();
54 if (subhandlers_marked_for_del.size())
56 for (
auto &h : subhandlers_marked_for_del)
57 subhandlers.erase(std::find(subhandlers.begin(), subhandlers.end(), h));
58 subhandlers_marked_for_del.clear();
60 subhandlers_mtx.unlock();
63 bool isParent(
const std::shared_ptr<Handler> &dragged,
const std::shared_ptr<Handler> &potential_child);
93 virtual std::string
getName() {
return "!!!Invalid!!!"; }
112 virtual void addSubHandler(std::shared_ptr<Handler> handler,
bool ontop =
false);
118 virtual void delSubHandler(std::shared_ptr<Handler> handler,
bool now =
false);
174 virtual std::string getID() = 0;
SatDump's handler base class.
Definition handler.h:32
virtual void delSubHandler(std::shared_ptr< Handler > handler, bool now=false)
Delete a subhandler.
Definition handler.cpp:159
virtual void drawContents(ImVec2 win_size)=0
Render explorer contents (center/left)
void setCanBeDragged(bool v)
Set if a handler can be dragged around in the tree.
Definition handler.h:136
virtual void resetConfig()
Optional, allows resetting the handler's configuration.
Definition handler.h:171
void setSubHandlersCanBeDragged(bool v)
Set if a handler's subhandlers can be dragged to in the tree.
Definition handler.h:148
std::string getTreeID()
Get this handler's ImGui ID for rendering in the tree.
Definition handler.h:99
virtual std::string getName()
Get this handler's readable name.
Definition handler.h:93
virtual void drawMenuBar()
Render explorer menu bar (in the left sidebar)
Definition handler.h:79
virtual std::vector< std::shared_ptr< Handler > > getAllSubHandlers()
Get all current subhandlers.
Definition handler.cpp:169
virtual nlohmann::json getConfig()
Optional, allows getting a configuration/state as JSON.
Definition handler.cpp:178
virtual void addSubHandler(std::shared_ptr< Handler > handler, bool ontop=false)
Add a new subhandler.
Definition handler.cpp:149
virtual bool drawTreeMenu(std::shared_ptr< Handler > &h)
Render explorer menu bar (in the left sidebar)
Definition handler.cpp:34
void setCanBeDraggedTo(bool v)
Set if a handler can be dragged to in the tree.
Definition handler.h:142
bool hasSubhandlers()
Check if this handler contains any sub-handlers.
Definition handler.cpp:141
void setCanSubBeReorgTo(bool v)
Set if a handler's subhandlers can be reordered.
Definition handler.h:154
void setCanBeSelected(bool v)
Set if a handler can be select in the tree.
Definition handler.h:130
virtual void drawMenu()=0
Render explorer menu left sidebar.
virtual void setConfig(nlohmann::json p)
Optional, allows setting a configuration/state from JSON.
Definition handler.h:160
Handler Tree Drawer.
Definition tree.h:19