Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion include/mostly_harmless/gui/mostlyharmless_WebviewEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,12 @@ namespace mostly_harmless::gui {
* ```
*
* beginParamGesture is expected to be called when a slider first begins being dragged,
* setParamValue while it is being changed, and endParamValue once the user stops dragging.
* setParamValue while it is being changed, and endParamGesture once the user stops dragging.
* These functions are bound to internal native functions (which you can override if you like), beginParamChangeGestureCallback(),
* paramChangeGestureCallback(), and endParamChangeGestureCallback(). These functions are actually promises, which we don't really leverage here, aside from to report errors in the case of an arg-parsing failure.
* The default implementation will attempt to parse the args (and assert fail if it failed),
* and then enqueue the param changes to the guiToProcQueue, for the host and audio side to pick up.
* performCompleteParamGesture() is equivalent to calling beginParamGesture(),setParamValue(), and endParamGesture() in one operation - this is useful for buttons, comboboxes etc.
*
* For what I've been calling "ouroborosing" the cursor position, and generally providing the facilities to hide the cursor, snap back to original mouse down position on a drag etc, we also provide some extra helpers here.
* `beginScopedCursorMoveGesture()` caches the mouse down position at the time of calling, and hides the cursor.
Expand Down
8 changes: 8 additions & 0 deletions source/gui/mostlyharmless_WebviewEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ namespace mostly_harmless::gui {
return endParamChangeGestureCallback(args);
};

auto performCompleteParamGestureCallback_ = [this](const choc::value::ValueView& args) -> choc::value::Value {
beginParamChangeGestureCallback(args);
paramChangeGestureCallback(args);
endParamChangeGestureCallback(args);
return {};
};

auto cacheCursorDownPositionCallback_ = [this](const choc::value::ValueView& args) -> choc::value::Value {
std::uint32_t x, y;
cursor::getCursorPosition(&x, &y);
Expand Down Expand Up @@ -92,6 +99,7 @@ namespace mostly_harmless::gui {
};

m_internalWebview->bind("cacheCursorDownPosition", std::move(cacheCursorDownPositionCallback_));
m_internalWebview->bind("performCompleteParamGesture", std::move(performCompleteParamGestureCallback_));
m_internalWebview->bind("beginParamGesture", std::move(beginParamGestureCallback_));
m_internalWebview->bind("setParamValue", std::move(paramChangeCallback_));
m_internalWebview->bind("endParamGesture", std::move(endParamGestureCallback_));
Expand Down
Loading