Skip to content

Commit

Permalink
- fix add node popup being masked when the viewport is too narrow
Browse files Browse the repository at this point in the history
  • Loading branch information
christoph-hart committed Sep 30, 2024
1 parent ec69c81 commit 575e7e2
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 11 deletions.
2 changes: 1 addition & 1 deletion currentGitHash.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
73072e0f0f0cb10acde81852bca6877866ccf5f0
ec69c814adffb911f800b32a8bef6d9d6924b252
2 changes: 1 addition & 1 deletion hi_backend/backend/currentGit.h
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#define PREVIOUS_HISE_COMMIT "73072e0f0f0cb10acde81852bca6877866ccf5f0"
#define PREVIOUS_HISE_COMMIT "ec69c814adffb911f800b32a8bef6d9d6924b252"
76 changes: 67 additions & 9 deletions hi_scripting/scripting/scriptnode/ui/DspNetworkComponents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1000,7 +1000,7 @@ void DspNetworkGraph::paintOverChildren(Graphics& g)
{
for(auto b: bypassList)
{
if(b->parent.node == sn)
if(b->parent.node.get() == sn)
{
NodeComponent* nb = &b->parent;

Expand Down Expand Up @@ -2026,9 +2026,56 @@ bool DspNetworkGraph::Actions::showKeyboardPopup(DspNetworkGraph& g, KeyboardPop

auto r = sp->getLocalArea(nc, midPoint.toNearestInt());

auto popupBounds = newPopup->getLocalBounds();

if(sp->getLocalBounds().reduced(-3).contains(popupBounds))
{
sp->setCurrentModalWindow(newPopup, r);
}
else
{
auto bpe = g.findParentComponentOfClass<BackendRootWindow>();

struct PopupWrapper: public Component,
public ModalBaseWindow
{
PopupWrapper(KeyboardPopup* p):
content(p)
{
p->parentIsViewport = false;
addAndMakeVisible(p);
setSize(p->getWidth(), p->getHeight());
setName("Add node");
}

sp->setCurrentModalWindow(newPopup, r);
void paint(Graphics& g) override
{
g.fillAll(Colour(0xFF222222));

auto b = getLocalBounds().toFloat();
b = b.removeFromTop(24);
g.setColour(Colours::white.withAlpha(0.8f));

g.setFont(GLOBAL_BOLD_FONT());
g.drawText(getName(), b, Justification::centred);
}

void resized() override
{
auto b = getLocalBounds();
b.removeFromTop(24);
content->setBounds(b);
}

ScopedPointer<KeyboardPopup> content;
};

auto w = new PopupWrapper(newPopup);

bpe->setModalComponent(w);
}


}
}

Expand Down Expand Up @@ -2519,17 +2566,25 @@ void NetworkPanel::fillIndexList(StringArray& sa)

void KeyboardPopup::addNodeAndClose(String path)
{
auto sp = findParentComponentOfClass<ZoomableViewport>();
bool pc = parentIsViewport;

std::function<void(Component*)> cleanup = [pc](Component* c)
{
if(pc)
c->findParentComponentOfClass<ZoomableViewport>()->setCurrentModalWindow(nullptr, {});
else
c->findParentComponentOfClass<BackendRootWindow>()->clearModalComponent();
};

auto container = node.get();
auto ap = addPosition;

Component::SafePointer<Component> safeThis(this);

if (path.startsWith("ScriptNode"))
{
auto f = [sp, container, ap]()
auto f = [container, ap, cleanup, safeThis]()
{
sp->setCurrentModalWindow(nullptr, {});

auto clipboard = SystemClipboard::getTextFromClipboard();
auto data = clipboard.fromFirstOccurrenceOf("ScriptNode", false, false);
auto newTree = ValueTreeConverters::convertBase64ToValueTree(data, true);
Expand All @@ -2555,14 +2610,16 @@ void KeyboardPopup::addNodeAndClose(String path)
network->runPostInitFunctions();
}

sp->setCurrentModalWindow(nullptr, {});
if(safeThis != nullptr)
cleanup(safeThis.getComponent());
};

MessageManager::callAsync(f);
}
else
{
auto f = [sp, path, container, ap]()

auto f = [path, container, ap, cleanup, safeThis]()
{
if (path.isNotEmpty())
{
Expand All @@ -2583,7 +2640,8 @@ void KeyboardPopup::addNodeAndClose(String path)
network->addToSelection(dynamic_cast<NodeBase*>(newNode.getObject()), ModifierKeys());
}

sp->setCurrentModalWindow(nullptr, {});
if(safeThis != nullptr)
cleanup(safeThis.getComponent());;
};

MessageManager::callAsync(f);
Expand Down
2 changes: 2 additions & 0 deletions hi_scripting/scripting/scriptnode/ui/DspNetworkComponents.h
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,8 @@ class KeyboardPopup : public Component,
ScopedPointer<OneLiner> oneLiner;
ScopedPointer<ImagePreviewCreator> currentPreview;

bool parentIsViewport = true;

KeyboardPopup(NodeBase* container, int addPosition_):
node(container),
network(node->getRootNetwork()),
Expand Down

0 comments on commit 575e7e2

Please sign in to comment.