[comp.sys.mac] pie menus

llkl@uhura.cc.rochester.edu (Laurie Kleiner) (12/04/89)

Dear Net-Landers,

	I have been following the debate in comp.cog-eng about new menu
interfaces.   I am especially interested in circular "pie menus" and am
wondering if anyone in MacLand has done anything with this idea.  
	I got the hypercard XCMD's from sumex-aim (pie-menu?) but haven't 
been able to implement it.  Maybe someone has just been playing with 
circles and irregularily shaped buttons (can you do that in SuperCard?).     
	I'm hoping to make this into a senior project, so any leads at
all would be appreaciated (other systems, papers, etc). 

-- 
-------------------------------------------------------------------------------
Laurie Kleiner                                     LLKL_SS@DB1.CC.ROCHESTER.EDU 
            Old enough to know better, stupid enough to do it anyhow. 
-------------------------------------------------------------------------------

krona@nada.kth.se (Kjell Krona) (12/06/89)

I have made a VERY simple stack with pie-menus, by simply creating
several different cards, and moving between them. The only restraint
is that you have to do a calculation yourself to find out which
menu region you are in. This is simple with four slices, but
rapidly becomes more complicated...

	- kjell

writer@neptune.UUCP (Writer) (12/09/89)

In article <2477@draken.nada.kth.se> krona@nada.kth.se (Kjell Krona) writes:
>I have made a VERY simple stack with pie-menus...
>... This is simple with four slices, but rapidly becomes more complicated...

This got me thinking and programming, so here is my gift to the world:
-a button that, when clicked, returns the angle from the central point
of the button.  This is based on the following assumptions (please 
don't abuse me if I did this un-mathematically... it's been years 
since a history prof has asked me to calculate the cosine of Napoleon.)

Quadrants and angles:
     ---0/360---
     ..4..|..1..
     .....|.....
 270 ----------- 90 deg
     ..3..|..2..
     .....|.....
     --180 deg--

Here's the button script:

on mouseUp
  put the rect of me into var
  put trunc((item 1 of var+item 3 of var)/2) into rx
  put trunc((item 2 of var+item 4 of var)/2) into ry
    -- rx and ry are the coordinates of the middle of the button
  if (item 1 of the clickloc)> rx
  then put "1 2" into var1 else put "3 4" into var1
    -- if the click is on the right-hand side of the vertical 
    -- centerline, then it is in quadrant 1 or 2
  if (item 2 of the clickloc)> ry
  then put "2 3" into var2 else put "1 4" into var2
    -- if the click is below the horizontal centerline,
    -- then it is in quadrant 2 or 3
  repeat with count = 1 to 4
    if var1 contains count and var2 contains count
    then put count into quad
  end repeat
    -- find the shared quadrant 
    -- quad has the appropriate quadrant number in it (see diagram)
  
  put (item 1 of the clickloc)-rx into lx
  put -1*((item 2 of the clickloc)-ry) into ly
    -- align lx and ly (the click) to the center point of the button,
    -- in standard x-y coordinates (not the edge of the screen)

  if quad = 1 then put 0 into temp
  if quad = 2 then put -180 into temp
  if quad = 3 then put 180 into temp
  if quad = 4 then put -360 into temp
    -- housekeeping to keep the angle and the quadrants correct

  put abs(trunc(temp+(atan((abs(lx)/abs(ly)))*57.730721))) into ang

  put ang -- the angle! (Yay!)

end mouseUp

So there you have it... many apologies if I've typo'd.
Your button can be any size, and if you are using it with a diagram,
then put it on the background level, or make it transparent.

Center it around a pie chart, and this should give you enough information 
to determine where in the pie the user clicked.  You could use
(lx^2+ly^2) = r^2 (where r is the radius of the pie) to check if the user
is within the bounds of the circle.

-Nigel, Waterloo co-op at large.