Skip to content

Commit

Permalink
graphics_view: fix drag and drop
Browse files Browse the repository at this point in the history
  • Loading branch information
JoepVanlier committed Jul 9, 2024
1 parent 72fb5b7 commit 2c171ba
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
15 changes: 5 additions & 10 deletions plugin/components/graphics_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@
#include <cmath>
#include <cstdio>

struct YsfxGraphicsView::Impl final : public better::AsyncUpdater::Listener,
public juce::FileDragAndDropTarget {
struct YsfxGraphicsView::Impl final : public better::AsyncUpdater::Listener {
static uint32_t translateKeyCode(int code);
static uint32_t translateModifiers(juce::ModifierKeys mods);
static void translateKeyPress(const juce::KeyPress &key, uint32_t &ykey, uint32_t &ymods);
Expand Down Expand Up @@ -106,10 +105,6 @@ struct YsfxGraphicsView::Impl final : public better::AsyncUpdater::Listener,
juce::StringArray m_droppedFiles;
juce::String m_droppedFileReturned;

// FileDragAndDropTarget implementation
bool isInterestedInFileDrag(const juce::StringArray &files) override;
void filesDropped(const juce::StringArray &files, int x, int y) override;

//--------------------------------------------------------------------------
// The background thread will trigger these async updates.

Expand Down Expand Up @@ -874,18 +869,18 @@ void YsfxGraphicsView::Impl::endPopupMenu(int menuResult)
}

//------------------------------------------------------------------------------
bool YsfxGraphicsView::Impl::isInterestedInFileDrag(const juce::StringArray &files)
bool YsfxGraphicsView::isInterestedInFileDrag(const juce::StringArray &files)
{
(void)files;
return true;
}

void YsfxGraphicsView::Impl::filesDropped(const juce::StringArray &files, int x, int y)
void YsfxGraphicsView::filesDropped(const juce::StringArray &files, int x, int y)
{
(void)x;
(void)y;
std::lock_guard<std::mutex> lock{m_droppedFilesMutex};
m_droppedFiles = files;
std::lock_guard<std::mutex> lock{m_impl->m_droppedFilesMutex};
m_impl->m_droppedFiles = files;
}

//------------------------------------------------------------------------------
Expand Down
6 changes: 5 additions & 1 deletion plugin/components/graphics_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include <juce_gui_basics/juce_gui_basics.h>
#include <memory>

class YsfxGraphicsView : public juce::Component {
class YsfxGraphicsView : public juce::Component, public juce::FileDragAndDropTarget {
public:
YsfxGraphicsView();
~YsfxGraphicsView() override;
Expand All @@ -37,6 +37,10 @@ class YsfxGraphicsView : public juce::Component {
void mouseUp(const juce::MouseEvent &event) override;
void mouseWheelMove(const juce::MouseEvent &event, const juce::MouseWheelDetails &wheel) override;

// FileDragAndDropTarget implementation
bool isInterestedInFileDrag(const juce::StringArray &files) override;
void filesDropped(const juce::StringArray &files, int x, int y) override;

private:
float m_pixelFactor{1.0f};

Expand Down

0 comments on commit 2c171ba

Please sign in to comment.