ADSR Class [for uiCustomComponent]: NEED 'OnMouseDown() Snap MouseXY to NodeXY': Any Ctrlr Hooks(or trix) for this? #624
-
Working on an ADSR Class and needing To break down what's needed in simple terms:
Any thoughts regarding how one might implement 'snap mouse cursor to XY' are much appreciated |
Beta Was this translation helpful? Give feedback.
Replies: 11 comments 35 replies
-
Hi, there's a JUCE class especially for ADSR management. |
Beta Was this translation helpful? Give feedback.
-
Please take a look at @dnaldoog d990 panel, there's a ADSR graph with nodes you can move with mouse down etc : https://sourceforge.net/projects/jd990-super-editor/ |
Beta Was this translation helpful? Give feedback.
-
What is it exactly that you need to know about mouse movement or dragging? It's not clear to me what the problem is. |
Beta Was this translation helpful? Give feedback.
-
Same feeling... Don't understand what the problem is. In the OnMouseDown method you need to track the anchors zones. For the moment, yep, 3 methods by envelope but you can easily make only 3 for all envelopes if you prefer. For the colour you use According to the envelope type, it is a matter to adapt the standard paint env code that you can find in different panels. |
Beta Was this translation helpful? Give feedback.
-
@Ted-juh
/** The source device that generated this event. */
MouseInputSource source;
|
Beta Was this translation helpful? Give feedback.
-
@damiensellier .. I just added LMouseInputSource, built successfully and the object/method are now exposed to Ctrlr. Ctrlr might be lying & just mimicking what's in the
LMouseInputSource Luabind Add
#ifndef L_MOUSE_INPUT_SOURCE
#define L_MOUSE_INPUT_SOURCE
extern "C"
{
#include "lua.h"
}
class LMouseInputSource
{
public:
static void wrapForLua(lua_State* L);
};
#endif
#include "LMouseInputSource.h"
LMouseInputSource::wrapForLua(L);
void LMouseEvent::wrapForLua (lua_State *L)
{
using namespace luabind;
module(L)
[
class_<MouseEvent>("MouseEvent")
.def("getMouseDownX", &MouseEvent::getMouseDownX)
.def_readonly("source", &MouseEvent::source) <<----
.def_readonly("x", &MouseEvent::x)
.def_readonly("y", &MouseEvent::y) UPDATE 3/25
void LMouseInputSource::wrapForLua(lua_State* L)
{
using namespace luabind;
module(L)
[
class_<MouseInputSource>("MouseInputSource")
.def("setScreenPosition", &MouseInputSource::setScreenPosition)
];
} UPDATE 3/25--
-- Called when a mouse is down on this component
--
ButtonOnClick = function(--[[ CtrlrComponent --]] comp, --[[ MouseEvent --]] event)
what(event.x)
what(event.source)
end
|
Beta Was this translation helpful? Give feedback.
-
Hi UC, sounds good! |
Beta Was this translation helpful? Give feedback.
-
Thanks @damiensellier for posting that panel as an example of an ADSR (type) graph. I have been working on and off on a complete rewrite of the JD-990 panel. The code in that currently released panel was written when I was just starting out with Ctrlr and as such could use a few improvements and streamlining. Anyway, I have separated the latest graph code and added it to a dedicated panel, which should make it easier to decipher for @unityconstruct and others. |
Beta Was this translation helpful? Give feedback.
-
Bump: does this panel work in 5.6.31? |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
I fail to understand why this method would differ from withNewPosition (which is a Mouse event). To me it should pass the new coordinates to the mouse. Doesn't matter that much, it works as intended the way it is now. User cases: Or for a linear bar, snap to the value instead of that the point you clicked becomes the new value. Or, with a long combobox or menu, make it jump back to the start. |
Beta Was this translation helpful? Give feedback.
@damiensellier .. I just added LMouseInputSource, built successfully and the object/method are now exposed to Ctrlr. Ctrlr might be lying & just mimicking what's in the
wrapForLua
setup, but about to find out. If it actually works, not sure if you are ok if I pull from CtrlrX, update & do PR. If not, I can just maintain it in my fork. THX for your responses above as they more or less led me to where I needed to be.LMouseInputSource Luabind Add