Menu

using magic numbers in pedigree.php

Help
Anonymous
2004-05-08
2004-05-09
  • Anonymous

    Anonymous - 2004-05-08

    Hi there

    I was viewing a pedigree in different screen resolutions and it seems like there is a very unpleasant inconsistant behaviour.
    You are using some magic numbers to set the starting x coordinate of the tree.
    However these numbers can only look good in a specific resolution (probably the one you used when writing the code).
    When you change the resolution, the tree gets shifted.

    here is an example:
    if ($PEDIGREE_GENERATIONS <= 2) $basexoffset += 170 * (4 - $PEDIGREE_GENERATIONS);

    What is 170?  How come this is not a variable which depends on the current resolution?
    You can obtain the screen width via javascript and pass it to PHP.

    The same goes to the y coordinate. 
    Can you please explain about all the magic numbers that you are using?

    thanks in advance

     
    • John Finlay

      John Finlay - 2004-05-09

      What resolution are you having trouble with?

      The pedigree chart was not designed for screen resolutions smaller than 1024x768.  There will likely be overlap on smaller screen resolutions caused by the header moving down too far.

      The magic numbers that you are citing are to adjust the tree based on the number of generations in the tree.  This line says if there is a 1 or 2 generation tree then move the tree over 170 pixels times 4 - the number of generations.  This line should only get called if you have set the gedcom configuration option for "show empty boxes" to "no".  Without this adjustment a smaller tree will overlap the chart adjustment form.  Thus the magic number relates to the height and width of the form div, which is static thus justifying the magic number.

      Talking more about the future, work is being done to further convert the pages to be more driven by CSS and DIVs so that instead of using the $basexoffset and the $baseyoffset variables in the theme.php file, this will be set by a CSS stylesheet.

      --John

       

Log in to post a comment.