Ticket #658: autozoom_nice.diff

File autozoom_nice.diff, 3.3 KB (added by jwernerny -2-, 9 years ago)

Patch to navit.c to make autozoom usable.

  • navit/navit.c

     
    11/**
    22 * Navit, a modular navigation system.
    3  * Copyright (C) 2005-2009 Navit Team
     3 * Copyright (C) 2005-2010 Navit Team
    44 *
    55 * This program is free software; you can redistribute it and/or
    66 * modify it under the terms of the GNU General Public License
     
    571571        if (abs(new_scale - scale) < 2) {
    572572                return; // Smoothing
    573573        }
    574        
     574
    575575        if (new_scale >= this_->autozoom_min) {
    576576                navit_scale(this_, (long)new_scale, &pc, 0);
    577577        } else {
     
    588588 * @param factor The zoom factor, usually 2
    589589 * @param p The invariant point (if set to NULL, default to center)
    590590 * @returns nothing
    591  */
     591 *
     592 *      This function works both for the case where autozooming is inactive and when
     593 *      it is active.  If autozooming is not active, the scale (zoom) is simply
     594 *      adjusted by the passed factor.  If autozooming is active, the autozoom time
     595 *      window (this_->autozoom_secs) is adjusted by the factor and the screen is
     596 *      forced to redraw by a call to navit_cmd_set_center_cursor().  The result of
     597 *      changing this_->autozoom_secs is to change the how much of the map is shown
     598 *      at a given speed.
     599*/
    592600void
    593601navit_zoom_in(struct navit *this_, int factor, struct point *p)
    594602{
    595         long scale=transform_get_scale(this_->trans)/factor;
    596         if (scale < 1)
    597                 scale=1;
    598         navit_scale(this_, scale, p, 1);
    599 }
     603        long scale;     
     604        if (! this_->autozoom_active)           /* if not autozooming */
     605        {
     606                /* ... simply adjust the scale  */
     607                scale=transform_get_scale(this_->trans)/factor;
     608                if (scale < 1)
     609                        scale=1;
     610                navit_scale(this_, scale, p, 1);
     611        }
     612        else
     613        {
     614                /* ... adjust the autozoom "size" (autozoom_secs) */
     615                this_->autozoom_secs /= factor;
     616                if (this_->autozoom_secs < this_->autozoom_min)
     617                        this_->autozoom_secs = this_->autozoom_min;
     618                navit_cmd_set_center_cursor(this_); /* force redraw autozoom */
     619        }
     620} /* end: navit_zoom_in */
    600621
    601622/**
    602623 * Change the current zoom level
     
    605626 * @param factor The zoom factor, usually 2
    606627 * @param p The invariant point (if set to NULL, default to center)
    607628 * @returns nothing
    608  */
     629 *
     630 *      This function works both for the case where autozooming is inactive and when
     631 *      it is active.  If autozooming is not active, the scale (zoom) is simply
     632 *      adjusted by the passed factor.  If autozooming is active, the autozoom time
     633 *      window (this_->autozoom_secs) is adjusted by the factor and the screen is
     634 *      forced to redraw by a call to navit_cmd_set_center_cursor().  The result of
     635 *      changing this_->autozoom_secs is to change the how much of the map is shown
     636 *      at a given speed.
     637 *
     638 *
     639*/
    609640void
    610641navit_zoom_out(struct navit *this_, int factor, struct point *p)
    611642{
    612         long scale=transform_get_scale(this_->trans)*factor;
    613         navit_scale(this_, scale, p, 1);
    614 }
     643        if (! this_->autozoom_active)           /* if not autozooming */
     644        {
     645                /* ... simply adjust the scale  */
     646                long scale=transform_get_scale(this_->trans)*factor;
     647                navit_scale(this_, scale, p, 1);
     648        }
     649        else
     650        {
     651                /* ... adjust the autozoom "size" (autozoom_secs) */
     652                this_->autozoom_secs *= factor;
     653                navit_cmd_set_center_cursor(this_); /* force redraw autozoom */
     654        }
     655} /* end: navit_zoom_out(..) */
    615656
    616657static int
    617658navit_cmd_zoom_in(struct navit *this_)