Browse Source

Expose cursor API from pugl, with added diagonal resize cursors

Signed-off-by: falkTX <falktx@falktx.com>
pull/351/head
falkTX 3 years ago
parent
commit
7357d71fa9
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
7 changed files with 39 additions and 3 deletions
  1. +1
    -2
      Makefile.base.mk
  2. +17
    -0
      dgl/Base.hpp
  3. +1
    -0
      dgl/TopLevelWidget.hpp
  4. +9
    -0
      dgl/Window.hpp
  5. +5
    -0
      dgl/src/TopLevelWidget.cpp
  6. +5
    -0
      dgl/src/Window.cpp
  7. +1
    -1
      dgl/src/pugl-upstream

+ 1
- 2
Makefile.base.mk View File

@@ -304,8 +304,7 @@ ifeq ($(HAVE_X11),true)
DGL_FLAGS += $(shell $(PKG_CONFIG) --cflags x11) -DHAVE_X11
DGL_SYSTEM_LIBS += $(shell $(PKG_CONFIG) --libs x11)
ifeq ($(HAVE_XCURSOR),true)
# TODO -DHAVE_XCURSOR
DGL_FLAGS += $(shell $(PKG_CONFIG) --cflags xcursor)
DGL_FLAGS += $(shell $(PKG_CONFIG) --cflags xcursor) -DHAVE_XCURSOR
DGL_SYSTEM_LIBS += $(shell $(PKG_CONFIG) --libs xcursor)
endif
ifeq ($(HAVE_XEXT),true)


+ 17
- 0
dgl/Base.hpp View File

@@ -130,6 +130,23 @@ enum CrossingMode {
kCrossingUngrab ///< Crossing due to a grab release
};

/**
A mouse cursor type.

This is a portable subset of mouse cursors that exist on X11, MacOS, and Windows.
*/
enum MouseCursor {
kMouseCursorArrow, ///< Default pointing arrow
kMouseCursorCaret, ///< Caret (I-Beam) for text entry
kMouseCursorCrosshair, ///< Cross-hair
kMouseCursorHand, ///< Hand with a pointing finger
kMouseCursorNotAllowed, ///< Operation not allowed
kMouseCursorLeftRight, ///< Left/right arrow for horizontal resize
kMouseCursorUpDown, ///< Up/down arrow for vertical resize
kMouseCursorDiagonal, ///< Top-left to bottom-right arrow for diagonal resize
kMouseCursorAntiDiagonal ///< Bottom-left to top-right arrow for diagonal resize
};

/**
Scroll direction.



+ 1
- 0
dgl/TopLevelWidget.hpp View File

@@ -103,6 +103,7 @@ public:
// 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 setCursor(MouseCursor cursor);
bool addIdleCallback(IdleCallback* callback, uint timerFrequencyInMs = 0);
bool removeIdleCallback(IdleCallback* callback);
double getScaleFactor() const noexcept;


+ 9
- 0
dgl/Window.hpp View File

@@ -284,6 +284,15 @@ public:
*/
const void* getClipboard(const char*& mimeType, size_t& dataSize);

/**
Set the mouse cursor.

This changes the system cursor that is displayed when the pointer is inside the window.
May fail if setting the cursor is not supported on this system,
for example if compiled on X11 without Xcursor support.
*/
bool setCursor(MouseCursor cursor);

/**
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().


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

@@ -70,6 +70,11 @@ const void* TopLevelWidget::getClipboard(const char*& mimeType, size_t& dataSize
return pData->window.getClipboard(mimeType, dataSize);
}

bool TopLevelWidget::setCursor(const MouseCursor cursor)
{
return pData->window.setCursor(cursor);
}

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


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

@@ -271,6 +271,11 @@ const void* Window::getClipboard(const char*& mimeType, size_t& dataSize)
return clipboard;
}

bool Window::setCursor(const MouseCursor cursor)
{
return puglSetCursor(pData->view, static_cast<PuglCursor>(cursor)) == PUGL_SUCCESS;
}

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


+ 1
- 1
dgl/src/pugl-upstream

@@ -1 +1 @@
Subproject commit f69d953d95dae70e32d37e522076fd41cec31a22
Subproject commit d6c17abe22399acefc00fd0b78b99ea38ce27f41

Loading…
Cancel
Save