Browse Source

Expose clipboard functions from pugl, tested to work in Cardinal

pull/351/head
falkTX 3 years ago
parent
commit
83e8afdb77
4 changed files with 43 additions and 0 deletions
  1. +2
    -0
      dgl/TopLevelWidget.hpp
  2. +21
    -0
      dgl/Window.hpp
  3. +10
    -0
      dgl/src/TopLevelWidget.cpp
  4. +10
    -0
      dgl/src/Window.cpp

+ 2
- 0
dgl/TopLevelWidget.hpp View File

@@ -101,6 +101,8 @@ public:
void repaint(const Rectangle<uint>& rect) noexcept;

// TODO group stuff after here, convenience functions present in Window class
bool setClipboard(const char* mimeType, const void* data, size_t dataSize);
const void* getClipboard(const char*& mimeType, size_t& dataSize);
bool addIdleCallback(IdleCallback* callback, uint timerFrequencyInMs = 0);
bool removeIdleCallback(IdleCallback* callback);
double getScaleFactor() const noexcept;


+ 21
- 0
dgl/Window.hpp View File

@@ -263,6 +263,27 @@ public:
*/
void setIgnoringKeyRepeat(bool ignore) noexcept;

/**
Set the clipboard contents.

This sets the system clipboard contents,
which can be retrieved with getClipboard() or pasted into other applications.

If using a string, the use of a null terminator is required (and must be part of dataSize).@n
The MIME type of the data "text/plain" is assumed if null is used.
*/
bool setClipboard(const char* mimeType, const void* data, size_t dataSize);

/**
Get the clipboard contents.

This gets the system clipboard contents,
which may have been set with setClipboard() or copied from another application.

returns the clipboard contents, or null.
*/
const void* getClipboard(const char*& mimeType, size_t& dataSize);

/**
Add a callback function to be triggered on every idle cycle or on a specific timer frequency.
You can add more than one, and remove them at anytime with removeIdleCallback().


+ 10
- 0
dgl/src/TopLevelWidget.cpp View File

@@ -60,6 +60,16 @@ void TopLevelWidget::setSize(const Size<uint>& size)
pData->window.setSize(size);
}

bool TopLevelWidget::setClipboard(const char* mimeType, const void* data, size_t dataSize)
{
return pData->window.setClipboard(mimeType, data, dataSize);
}

const void* TopLevelWidget::getClipboard(const char*& mimeType, size_t& dataSize)
{
return pData->window.getClipboard(mimeType, dataSize);
}

bool TopLevelWidget::addIdleCallback(IdleCallback* const callback, const uint timerFrequencyInMs)
{
return pData->window.addIdleCallback(callback, timerFrequencyInMs);


+ 10
- 0
dgl/src/Window.cpp View File

@@ -257,6 +257,16 @@ void Window::setIgnoringKeyRepeat(const bool ignore) noexcept
puglSetViewHint(pData->view, PUGL_IGNORE_KEY_REPEAT, ignore);
}

bool Window::setClipboard(const char* const mimeType, const void* const data, const size_t dataSize)
{
return puglSetClipboard(pData->view, mimeType, data, dataSize) == PUGL_SUCCESS;
}

const void* Window::getClipboard(const char*& mimeType, size_t& dataSize)
{
return puglGetClipboard(pData->view, &mimeType, &dataSize);
}

bool Window::addIdleCallback(IdleCallback* const callback, const uint timerFrequencyInMs)
{
DISTRHO_SAFE_ASSERT_RETURN(callback != nullptr, false)


Loading…
Cancel
Save