Hello friends, i'm a noob here at Indigo forum (as you may know), and this is my fist request for help.

I've played with AMS some time ago, made a few simple installers (one still working at my working place, as a software installer form our server).

Past this years, and back to AMS, i'm trying to make a multimedia player (which is almost finished, wiht the help of a lot of reading in this forum),

but my doubt is, how can i do a mouse control on a costume image(s) rotary knob (volume) for the player.

I've tryed an approach for the volume slider with the "Slider_Framework" from Worm, and BioHazard code to "Display Audio Volume (via Images)"

but not with the result i want.

So what i'm asking here is, if you can guide me on creating the rotary movement controled by the mouse.

I think that includes math, angles, mouse actions and positions, to drag the knob, but i don't know how.

Point me some directions please, i'll try to do my best.

Another question: Can this code be usefull?

(It's from Eclipse (Android)

================================================== ================================================== =

local gAActiveKnob = nil

local xData, yData, tanData

local this_control

--Based on the X and Y positions of the cursor, determines the closest index in the slider, and checks if the cursor is in range of the slider

function CalculateKnobPosition(mapargs)

local dk_data = {}

local mid_x, mid_y

local ctrl_x, ctrl_y

local calc_x,calc_y

local radians, degrees

local press_x = mapargs.context_event_data.x

local press_y = mapargs.context_event_data.y

this_control = mapargs.context_control

dk_data = gre.get_data(this_control..".grd_width",this_contr ol..".grd_height",this_control..".grd_x",this_cont rol..".grd_y",this_control..".angle")

mid_x = dk_data[this_control..".grd_width"] / 2

mid_y = dk_data[this_control..".grd_height"] / 2

ctrl_x = dk_data[this_control..".grd_x"]

ctrl_y = dk_data[this_control..".grd_y"]

calc_x = press_x - mid_x - ctrl_x

calc_y = press_y - mid_y - ctrl_y

radians = math.atan2(calc_y, calc_x)

degrees = math.deg(radians)

-- rotate quadrant to align control rotation degrees

if(degrees < 0)then

--on the top portion of the circle

degrees = 90 - math.abs(degrees)

if(degrees < 0)then

degrees = 360 - math.abs(degrees)

end

else

degrees = 90 + math.abs(degrees)

end

-- apply start and end stops

--[[if(degrees > 54 and degrees < 90)then

degrees = 54

elseif(degrees > 90 and degrees < 126)then

degrees = 126

end--]]

print("press_x:" ..press_x .." press_y:" ..press_y )

print("ctrl_x:" ..ctrl_x .." ctrl_y:" ..ctrl_y )

print("calc_x:" ..calc_x .." calc_y:" ..calc_y )

print("x:" ..press_x - mid_x.." y:" ..press_y - mid_y .. " deg:"..degrees)

local data = {}

data["controls_layer.degrees.text"] = string.format("%3.1fº",degrees)

data[this_control..".angle"] = degrees

gre.set_data(data)

end

--Checks if motion is on current slider if so, calculates slider position

function CBKnobMotion(mapargs)

if gAActiveKnob == nil then

return

end

local control_name = mapargs.context_control

if gAActiveKnob == control_name then

CalculateKnobPosition(mapargs)

else

gAActiveKnob = nil

end

end

function CBKnobPress(mapargs)

gAActiveKnob = mapargs.context_control

CalculateKnobPosition(mapargs)

end

--When the slider is released set the active slider to nil

function CBKnobRelease(mapargs)

gAActiveKnob = nil

end

================================================== =================================================

I've played with AMS some time ago, made a few simple installers (one still working at my working place, as a software installer form our server).

Past this years, and back to AMS, i'm trying to make a multimedia player (which is almost finished, wiht the help of a lot of reading in this forum),

but my doubt is, how can i do a mouse control on a costume image(s) rotary knob (volume) for the player.

I've tryed an approach for the volume slider with the "Slider_Framework" from Worm, and BioHazard code to "Display Audio Volume (via Images)"

but not with the result i want.

So what i'm asking here is, if you can guide me on creating the rotary movement controled by the mouse.

I think that includes math, angles, mouse actions and positions, to drag the knob, but i don't know how.

Point me some directions please, i'll try to do my best.

Another question: Can this code be usefull?

(It's from Eclipse (Android)

================================================== ================================================== =

local gAActiveKnob = nil

local xData, yData, tanData

local this_control

--Based on the X and Y positions of the cursor, determines the closest index in the slider, and checks if the cursor is in range of the slider

function CalculateKnobPosition(mapargs)

local dk_data = {}

local mid_x, mid_y

local ctrl_x, ctrl_y

local calc_x,calc_y

local radians, degrees

local press_x = mapargs.context_event_data.x

local press_y = mapargs.context_event_data.y

this_control = mapargs.context_control

dk_data = gre.get_data(this_control..".grd_width",this_contr ol..".grd_height",this_control..".grd_x",this_cont rol..".grd_y",this_control..".angle")

mid_x = dk_data[this_control..".grd_width"] / 2

mid_y = dk_data[this_control..".grd_height"] / 2

ctrl_x = dk_data[this_control..".grd_x"]

ctrl_y = dk_data[this_control..".grd_y"]

calc_x = press_x - mid_x - ctrl_x

calc_y = press_y - mid_y - ctrl_y

radians = math.atan2(calc_y, calc_x)

degrees = math.deg(radians)

-- rotate quadrant to align control rotation degrees

if(degrees < 0)then

--on the top portion of the circle

degrees = 90 - math.abs(degrees)

if(degrees < 0)then

degrees = 360 - math.abs(degrees)

end

else

degrees = 90 + math.abs(degrees)

end

-- apply start and end stops

--[[if(degrees > 54 and degrees < 90)then

degrees = 54

elseif(degrees > 90 and degrees < 126)then

degrees = 126

end--]]

print("press_x:" ..press_x .." press_y:" ..press_y )

print("ctrl_x:" ..ctrl_x .." ctrl_y:" ..ctrl_y )

print("calc_x:" ..calc_x .." calc_y:" ..calc_y )

print("x:" ..press_x - mid_x.." y:" ..press_y - mid_y .. " deg:"..degrees)

local data = {}

data["controls_layer.degrees.text"] = string.format("%3.1fº",degrees)

data[this_control..".angle"] = degrees

gre.set_data(data)

end

--Checks if motion is on current slider if so, calculates slider position

function CBKnobMotion(mapargs)

if gAActiveKnob == nil then

return

end

local control_name = mapargs.context_control

if gAActiveKnob == control_name then

CalculateKnobPosition(mapargs)

else

gAActiveKnob = nil

end

end

function CBKnobPress(mapargs)

gAActiveKnob = mapargs.context_control

CalculateKnobPosition(mapargs)

end

--When the slider is released set the active slider to nil

function CBKnobRelease(mapargs)

gAActiveKnob = nil

end

================================================== =================================================

## Comment