XWidgetSoft Forum

XWidget & XLaunchpad , Desktop customization
It is currently May 10th, 2025, 11:31 am

All times are UTC - 8 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: July 14th, 2012, 6:09 pm 
Offline

Joined: July 14th, 2012, 6:04 pm
Posts: 1
Hi!

I'm trying to make an analog clock resembling a diver's watch with a bezel that can be rotated by clicking, holding and dragging the mouse.
However, I have no idea on how to implement a mouse-draggable rotatable bezel.

Here's an example of a diver's dial with round bezel marker:
Image

I would like to figure out how to rotate the round marker at 12 o'clock around the dial by using the mouse.

Any suggestions would be appreciated...


Top
 Profile  
 
PostPosted: August 31st, 2012, 1:24 am 
Offline
User avatar

Joined: August 29th, 2012, 2:34 am
Posts: 56
The main idea is to add a timer to your project (30 ms update interval should give u smooth animation), then to find the angle between your rotator and the mouse. I made this example http://4ybak47.deviantart.com/art/Arrow ... -324420348 so the arrow will always rotate towards the mouse. If you wish to give some animation effect, just connect this function onMouseClick event and call the animation to the found angle
Code:
midX = rotator.Left + rotator.Width / 2;
midY = rotator.Top + rotator.Height / 2;

//Remember to multiply the the scale factor (in my case the arrow is scaled to 30% so the value will be  30 / 100 = .3 )
//And so midX = midX * .3; and midY = midY * .3;

angle = Math.atan2(mouseY - (Top + midY), mouseX - (Left + midX))
//Adding 180 to the angle resulting an extra 180 rotation, since my image it flipped in the horizontal direction
angle = angle* 180 / 3.1413 + 180
rotator.RotateAngle = angle;


Download source code from : http://4ybak47.deviantart.com/art/Arrow ... -324420348


Attachments:
Arrow_Rotator.png
Arrow_Rotator.png [ 130.46 KiB | Viewed 3866 times ]

_________________
Image
Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: Bing [Bot] and 48 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Powered by phpBB® Forum Software © phpBB Group