1
0
mirror of synced 2024-12-02 19:27:21 +01:00

Allow detaching of links by dragging

This commit is contained in:
WerWolv 2021-01-31 11:00:35 +01:00
parent 5a59bc2abc
commit b330829f09

View File

@ -8,8 +8,16 @@ namespace hex {
ViewDataProcessor::ViewDataProcessor() : View("Data Processor") { ViewDataProcessor::ViewDataProcessor() : View("Data Processor") {
imnodes::Initialize(); imnodes::Initialize();
imnodes::PushAttributeFlag(imnodes::AttributeFlags_EnableLinkDetachWithDragClick);
imnodes::PushAttributeFlag(imnodes::AttributeFlags_EnableLinkCreationOnSnap);
View::subscribeEvent(Events::SettingsChanged, [this](auto) { {
static bool always = true;
imnodes::IO& io = imnodes::GetIO();
io.link_detach_with_modifier_click.modifier = &always;
}
View::subscribeEvent(Events::SettingsChanged, [](auto) {
int theme = ContentRegistry::Settings::getSettingsData()["Interface"]["Color theme"]; int theme = ContentRegistry::Settings::getSettingsData()["Interface"]["Color theme"];
switch (theme) { switch (theme) {
@ -33,6 +41,8 @@ namespace hex {
for (auto &node : this->m_nodes) for (auto &node : this->m_nodes)
delete node; delete node;
imnodes::PopAttributeFlag();
imnodes::PopAttributeFlag();
imnodes::Shutdown(); imnodes::Shutdown();
} }
@ -217,6 +227,13 @@ namespace hex {
imnodes::EndNodeEditor(); imnodes::EndNodeEditor();
{
int linkId;
if (imnodes::IsLinkDestroyed(&linkId)) {
this->eraseLink(linkId);
}
}
{ {
int from, to; int from, to;
if (imnodes::IsLinkCreated(&from, &to)) { if (imnodes::IsLinkCreated(&from, &to)) {