Skip to content

Commit

Permalink
Merge pull request #1975 from alcomposer/fix-dnd-highlight-welcome
Browse files Browse the repository at this point in the history
Fix welcome panel NVG window occluding the DnD highlight
  • Loading branch information
timothyschoen authored Nov 26, 2024
2 parents 95e3d0c + 14cbae0 commit b430e63
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 10 deletions.
10 changes: 10 additions & 0 deletions Source/Components/WelcomePanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,11 @@ class WelcomePanel : public Component
break;
}
}

bool hitTest(int x, int y)
{
return getLocalBounds().reduced(12).contains(Point<int>(x, y));
}

void mouseEnter(MouseEvent const& e) override
{
Expand Down Expand Up @@ -372,6 +377,11 @@ class WelcomePanel : public Component
return Rectangle<int>(20, getHeight() - 80, 16, 16);
}

bool hitTest(int x, int y) override
{
return getLocalBounds().reduced(12).contains(Point<int>(x, y));
}

void mouseEnter(MouseEvent const& e) override
{
isHovered = true;
Expand Down
33 changes: 23 additions & 10 deletions Source/PluginEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -489,18 +489,25 @@ void PluginEditor::paint(Graphics& g)
baseColour = baseColour.brighter(baseColour.getBrightness() / 2.5f);
}

bool rounded = wantsRoundedCorners();

if (rounded) {
#if JUCE_MAC || JUCE_LINUX
if (wantsRoundedCorners()) {
g.setColour(baseColour);
g.fillRoundedRectangle(getLocalBounds().toFloat(), Corners::windowCornerRadius);
#else
g.fillAll(baseColour);
#endif
} else {
g.fillAll(baseColour);
}
#else
g.fillAll(baseColour);
#endif

// Paint a background only for the welcome panel.
// We need to do this because we can't push the NVG window to the edge
// as it will block the DnD highlight of the window border
// This is easier than having to replicate the DnD highlight at the edge of the NVG window.
if (welcomePanel->isVisible()) {
g.setColour(findColour(PlugDataColour::panelBackgroundColourId));
g.fillRect(workArea.withTrimmedTop(4));
}
}

// Paint file drop outline
Expand Down Expand Up @@ -647,10 +654,16 @@ void PluginEditor::resized()
palettes->setBounds(0, toolbarHeight, palettes->getWidth(), workAreaHeight);

auto sidebarWidth = sidebar->isVisible() ? sidebar->getWidth() : 0;
auto workArea = Rectangle<int>(paletteWidth, toolbarHeight, (getWidth() - sidebarWidth - paletteWidth), workAreaHeight);
tabComponent.setBounds(workArea);
welcomePanel->setBounds(workArea.withTrimmedTop(4));
nvgSurface.updateBounds(welcomePanel->isVisible() ? workArea.withTrimmedTop(6) : workArea.withTrimmedTop(31));
workArea = Rectangle<int>(paletteWidth, toolbarHeight, (getWidth() - sidebarWidth - paletteWidth), workAreaHeight);

auto insetWorkArea = workArea;

if (welcomePanel->isVisible())
insetWorkArea.reduce(2,0);

tabComponent.setBounds(insetWorkArea);
welcomePanel->setBounds(insetWorkArea.withTrimmedTop(4));
nvgSurface.updateBounds(welcomePanel->isVisible() ? insetWorkArea.withTrimmedTop(6) : insetWorkArea.withTrimmedTop(31));

sidebar->setBounds(getWidth() - sidebar->getWidth(), toolbarHeight, sidebar->getWidth(), workAreaHeight);

Expand Down
2 changes: 2 additions & 0 deletions Source/PluginEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ class PluginEditor final : public AudioProcessorEditor

static inline int numEditors = 0;

Rectangle<int> workArea;

// Used in plugin
std::unique_ptr<MouseRateReducedComponent<ResizableCornerComponent>> cornerResizer;

Expand Down

0 comments on commit b430e63

Please sign in to comment.