Allow setting handlers not to be draggable

This commit is contained in:
Aang23 2025-01-02 17:20:09 +01:00
parent 5c6866a3af
commit 49d166cef1
4 changed files with 42 additions and 3 deletions

View file

@ -11,6 +11,10 @@ namespace satdump
{
instrument_products = std::make_shared<DummyHandler>("Instruments");
general_products = std::make_shared<DatasetProductHandler>();
instrument_products->setCanBeDragged(false);
instrument_products->setCanBeDraggedTo(false);
instrument_products->setSubHandlersCanBeDragged(false);
general_products->setCanBeDragged(false);
addSubHandler(instrument_products);
addSubHandler(general_products);
}

View file

@ -41,7 +41,8 @@ namespace satdump
h = handler;
// TODOREWORK CLEANUP
if (ImGui::BeginDragDropSource(ImGuiDragDropFlags_SourceAllowNullID))
if (handler_can_subhandlers_be_dragged && handler->handler_can_be_dragged &&
ImGui::BeginDragDropSource(ImGuiDragDropFlags_SourceAllowNullID))
{
auto del = [this](std::shared_ptr<Handler> handler)
{
@ -55,7 +56,7 @@ namespace satdump
ImGui::EndDragDropSource();
}
if (ImGui::BeginDragDropTarget())
if (handler->handler_can_be_dragged_to && ImGui::BeginDragDropTarget())
{
if (const ImGuiPayload *payload = ImGui::AcceptDragDropPayload("VIEWER_HANDLER"))
{

View file

@ -28,13 +28,17 @@ namespace satdump
* handler as a dependency.
*/
class Handler
{ // TODOREWORK PRIVATE DELETE STUFF
{
private:
TreeDrawerToClean tree_local;
std::vector<std::shared_ptr<Handler>> subhandlers;
std::mutex subhandlers_mtx;
std::vector<std::shared_ptr<Handler>> subhandlers_marked_for_del;
bool handler_can_be_dragged = true;
bool handler_can_be_dragged_to = true;
bool handler_can_subhandlers_be_dragged = true;
public:
/**
* @brief Render viewer menu left sidebar
@ -88,6 +92,33 @@ namespace satdump
*/
void delSubHandler(std::shared_ptr<Handler> handler);
/**
* @brief Set if a handler can be dragged around in the tree
* @param v true to have it be draggable
*/
void setCanBeDragged(bool v)
{
handler_can_be_dragged = v;
}
/**
* @brief Set if a handler can be dragged to in the tree
* @param v true to have it be a valid drag target
*/
void setCanBeDraggedTo(bool v)
{
handler_can_be_dragged_to = v;
}
/**
* @brief Set if a handler's subhandlers can be dragged to in the tree
* @param v true to have them be draggable
*/
void setSubHandlersCanBeDragged(bool v)
{
handler_can_subhandlers_be_dragged = v;
}
public:
static std::string getID(); // TODOREWORK
static std::shared_ptr<Handler> getInstance();

View file

@ -36,7 +36,9 @@ namespace satdump
auto &ch = product->images[channel_selection_curr_id];
if (ch.wavenumber != -1)
{
ImGui::Text("Wavenumber : %f", ch.wavenumber);
}
}
if (needs_to_be_disabled)
@ -58,6 +60,7 @@ namespace satdump
if (needs_to_be_disabled)
style::endDisabled();
ImGui::SameLine();
ImGui::ProgressBar(progress);
}