User Tools

Site Tools


script_rotating_app_wheel

====== About the script ====== * Purpose : This script will take all app shortcuts and place them in a circle. When you scroll the container (desktop) the circle will rotate. * Author : TBog * Link: www.google.com/+BogdanTautuTBog ====== How to use the script ====== - All items that participate in the wheel must be off the grid and pinned. - The desktop must be set to scroll horizontal only - Make 2 shortcuts and place one to the far left and one to the far right. They will delimit the scroll space. Name them with a dot character. - Set the script to the Position changed event of the container (desktop). - You can change the order of the items in the circle using “Move forward/backwards” button. The top-most item is at 12-o'clock and going clockwise. Caution: on my device (stock i9505 with android 4.4.2) LLX v9.9.7 crashes after i rotate a couple of times. Others do not have this issue. TODO: after the crash is fixed i will improve the following: * Make the scrolling infinite * Make a setup script (will need to be able to create shortcuts from script) * Make the visible item count customizable and hide excess items ====== Script code ====== <code> var c = LL.getEvent().getContainer(); var a = []; var na = 0; /*how much to rotate, to increase speed multiply with something greater than 1*/ var offsetRot = c.getPositionX() / c.getWidth() * Math.PI * -2; var items = c.getItems(); for ( var i=items.getLength()-1; i>=0; i-=1 ) { var item = items.getAt(i); if ( item.getType()!='Shortcut' ) { /*alert(item.getType());*/ continue; } if ( item.getLabel().substr(0,1)=='.' ) continue; a[na++] = item; } var x,y; var w2 = c.getWidth()/2; var h2 = c.getHeight()/2; var radius = Math.min(w2, h2) * 0.8; for ( var i=0; i<na; i+=1 ) { x = Math.cos(Math.PI*2*i/na-Math.PI/2+offsetRot) * radius; y = Math.sin(Math.PI*2*i/na-Math.PI/2+offsetRot) * radius; /* move circle to the middle of the screen */ x+= w2; y+= h2; /* offset to item pivot */ x-= a[i].getWidth()/2; y-= a[i].getHeight()/2; a[i].setPosition(x, y); } </code>

script_rotating_app_wheel.txt · Last modified: 2014/03/13 03:00 by tbog