Home › Forums › General › Using Ctrlr › Using customComponents to draw knobs and sliders
- This topic has 21 replies, 4 voices, and was last updated 9 years, 7 months ago by zeoka.
-
AuthorPosts
-
September 15, 2014 at 10:16 pm #29065
I’ve done
-- -- Called when the mouse moves over a component -- mouseoverf = function(comp, event) overfx = event.x overfy = event.y if overfx >= af + 2 and overfx <= af + 26 then if overfy >= 4 and overfy <= 28 then comp:setPropertyString ("componentMouseCursor", "7") end elseif overfx >= df+af and overfx <= df+af+24 then if overfy >= 68 - math.floor(sf/2) - 1 and overfy <= 92 - math.floor(sf/2) - 1 then comp:setPropertyString ("componentMouseCursor", "7") end elseif overfx >= rf+4 and overfx <= rf+26 then if overfy >= 68 - math.floor(sf/2) - 1 and overfy <= 92 - math.floor(sf/2) - 1 then comp:setPropertyString ("componentMouseCursor", "7") end else comp:setPropertyString ("componentMouseCursor", "2") end end
-- Called when a mouse DOWN (any mouse button) event happens on a component -- @comp -- @event http://www.rawmaterialsoftware.com/juce/api/classMouseEvent.html -- clickenvf = function(comp, event) clickfx = event.x clickfy = event.y if clickfx >= af + 2 and clickfx <= af + 26 then if clickfy >= 4 and clickfy <= 28 then stdragx = af + 14 stdragy = 16 wichpoint = 1 end elseif clickfx >= df+af and clickfx <= df+af+24 then if clickfy >= 68 - math.floor(sf/2) - 1 and clickfy <= 92 - math.floor(sf/2) - 1 then stdragx = df+af+ 14 stdragy = 80 - math.floor(sf/2) - 1 wichpoint = 2 end elseif clickfx >= rf + 4 and clickfx <= rf + 26 then if clickfy >= 68 - math.floor(sf/2) - 1 and clickfy <= 92 - math.floor(sf/2) - 1 then stdragx = rf+12 stdragy = 80 - math.floor(sf/2) - 1 wichpoint = 3 end end end
then
-- Called when the mouse is dragged over a component (mouse button is down and the mouse is moved) -- dragf = function(comp, event) dragfx = event.x dragfy = event.y enddragfx = (dragfx - stdragx) enddragfy = 127 - (dragfy - stdragy) if wichpoint == 1 then if enddragfx >= 0 and enddragfx <= 127 then panel:getModulatorByName("EnvFAttack"):setModulatorValue(enddragfx,false,true,false) end elseif wichpoint == 2 then if enddragfx >= 0 and enddragfx <= 127 then panel:getModulatorByName("EnvFDecay"):setModulatorValue(enddragfx,false,true,false) end if enddragfy >= 0 and enddragfy <= 127 then panel:getModulatorByName("EnvFSustain"):setModulatorValue(enddragfy,false,true,false) end elseif wichpoint == 3 then if enddragfx >= 0 and enddragfx <= 127 then panel:getModulatorByName("EnvFRelease"):setModulatorValue(127 - enddragfx,false,true,false) end if enddragfy >= 0 and enddragfy <= 127 then panel:getModulatorByName("EnvFSustain"):setModulatorValue(enddragfy,false,true,false) end end end
a simplified version of your envelope
working but a few laggy 🙂
a problem is the mouse movement seems to be (too much in my taste)relative to drawing values….
I need to affineis there a way graphics could be objects ? could be very practicle to handle them
- This reply was modified 9 years, 7 months ago by zeoka.
September 16, 2014 at 1:20 pm #29098this is not laggy but jumpy
it’s like I start draw always at value zero
my last operations must be just wrong -
AuthorPosts
- The forum ‘Using Ctrlr’ is closed to new topics and replies.
There is currently 0 users and 88 guests online
No users are currently activeForum Statistics
Threads: 2,495, Posts: 17,374, Members: 77,605Most users ever online was 12 on January 22, 2019 3:47 pm