³ò
^WjIc           @   s]   d  Z  d d k Z d d k Z d d k Z d d k l Z d d k Z d d d „  ƒ  YZ d S(   s   lens.py - Magnifying glass.iÿÿÿÿN(   t   prefst   MagnifyingGlassc           B   sA   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d e d „ Z RS(   sÏ  The MagnifyingGlass creates cursors from the raw pixbufs containing
    the unscaled data for the currently displayed images. It does this by
    looking at the cursor position and calculating what image data to put
    in the "lens" cursor.

    Note: The mapping is highly dependent on the exact layout of the main
    window images, thus this module isn't really independent from the main
    module as it uses implementation details not in the interface.
    c         C   s   | |  _  d  S(   N(   t   _window(   t   selft   window(    (    sD   /home/sork/Pontus/Programmering/Python/Comix/comix-4.0.4/src/lens.pyt   __init__   s    c         C   su   |  i  i i p d Sn |  i | | ƒ } t i i t i i ƒ  | t d d t d d ƒ } |  i  i	 i
 | ƒ d S(   s´   Calculate what image data to put in the lens and update the cursor
        with it; <x> and <y> are the positions of the cursor within the
        main window layout area.
        Ns	   lens sizei   (   R   t   file_handlert   file_loadedt   _get_lens_pixbuft   gtkt   gdkt   Cursort   display_get_defaultR    t   cursor_handlert   set_cursor_type(   R   t   xt   yt   pixbuft   cursor(    (    sD   /home/sork/Pontus/Programmering/Python/Comix/comix-4.0.4/src/lens.pyt   set_lens_cursor   s    c         C   sP   | i  ƒ  o) |  i i ƒ  \ } } |  i | | ƒ n |  i i i t i ƒ d S(   s=   Toggle on or off the lens depending on the state of <action>.N(   t
   get_activeR   t   get_layout_pointer_positionR   R   R   R   t   NORMAL(   R   t   actionR   R   (    (    sD   /home/sork/Pontus/Programmering/Python/Comix/comix-4.0.4/src/lens.pyt   toggle'   s    c   
   	   C   sK  t  i i t  i i t d t d t d ƒ } | i d ƒ |  i i ƒ  oµ |  i i	 o |  i i
 i ƒ  \ } } n |  i i
 i ƒ  \ } } |  i i i ƒ  } |  i i i ƒ  } |  i | | | | | | d d t ƒ|  i | | | | | | d d t ƒn> |  i i
 i ƒ  } |  i i i ƒ  }	 |  i | | | |	 | ƒ t i | d ƒ S(   s‚   Get a pixbuf containing the appropiate image data for the lens
        where <x> and <y> are the positions of the cursor.
        i   s	   lens sizei»   i    t   lefti   (   R	   R
   t   Pixbuft   COLORSPACE_RGBt   TrueR    t   fillR   t   displayed_doublet   is_manga_modeR   t   get_pixbufst
   left_imaget   size_requestt   right_imaget   _add_subpixbuft   Falset   imaget
   add_border(
   R   R   R   t   canvast   r_source_pixbuft   l_source_pixbuft   l_image_sizet   r_image_sizet   source_pixbuft
   image_size(    (    sD   /home/sork/Pontus/Programmering/Python/Comix/comix-4.0.4/src/lens.pyR   /   s"    i    c         C   s?  |  i  i ƒ  \ } }	 | o# t d | | | d d ƒ }
 n( t d | | | d d ƒ | d }
 t d |	 | d d ƒ } | |
 8} | | 8} t d } t d o! | t i | ƒ 7} | d } n | d j o t | i ƒ  ƒ | d } n t | i ƒ  ƒ | d } | | 9} | | 9} t d	 | } t d
 | } | } | | d j } | | d j } t d t	 t
 i | d | | ƒ ƒ ƒ } t d t	 t
 i | d | | ƒ ƒ ƒ } | d j o | | i ƒ  | } } nZ | d j o$ | i ƒ  | } | i ƒ  | } n) | d j o | i ƒ  | | } } n t d o5 | d j o | i ƒ  | } q{| i ƒ  | } n t d o5 | d j o | i ƒ  | } q»| i ƒ  | } n | | d } | | d } | d j  o | | 7} d } n | d j  o | | 7} d } n t d t | i ƒ  | | ƒ ƒ } t d t | i ƒ  | | ƒ ƒ } | d j  p | d j  o d Sn | i t	 | ƒ t	 | ƒ t	 | ƒ t	 | ƒ ƒ } | i t	 t
 i | | i ƒ  ƒ ƒ t	 t
 i | | i ƒ  ƒ ƒ t i i ƒ } | d j o | i t i i ƒ } nM | d j o | i t i i ƒ } n' | d j o | i t i i ƒ } n t d o | i d t ƒ } n t d o | i d t ƒ } n | o
 d } n  t | i ƒ  | i ƒ  | ƒ } | o
 d } n  t | i ƒ  | i ƒ  | ƒ } | i d d | i ƒ  | i ƒ  | | | ƒ d S(   s÷  Copy a subpixbuf from <source_pixbuf> to <canvas> as it should
        be in the lens if the coordinates <x>, <y> are the mouse pointer
        position on the main window layout area.

        The displayed image (scaled from the <source_pixbuf>) must have
        size <image_size>.

        If <other_image_width> is given, it is the width of the "other" image
        in double page mode.

        The image we are getting the coordinates for is the left one unless
        <left> is False.
        i    i   i   t   rotations   auto rotate from exifih  iZ   i  s   lens magnifications	   lens sizei´   s   horizontal flips   vertical flipNt
   horizontal(   iZ   i  (   iZ   i  (   iZ   i  (   R   t   get_visible_area_sizet   maxR    R&   t   get_implied_rotationt   floatt
   get_heightt	   get_widtht   intt   matht   ceilt   mint	   subpixbuft   scale_simpleR	   R
   t   INTERP_TILESt   rotate_simplet   PIXBUF_ROTATE_CLOCKWISEt   PIXBUF_ROTATE_UPSIDEDOWNt   PIXBUF_ROTATE_COUNTERCLOCKWISEt   flipR   R%   t	   copy_area(   R   R(   R   R   R.   R-   t   other_image_widthR   t   area_xt   area_yt	   padding_xt	   padding_yR/   t   scalet
   source_magt   widtht   heightt
   paste_leftt	   paste_topt   dest_xt   dest_yt   src_xt   src_yR;   (    (    sD   /home/sork/Pontus/Programmering/Python/Comix/comix-4.0.4/src/lens.pyR$   I   sœ    '




**



""

(	   t   __name__t
   __module__t   __doc__R   R   R   R   R   R$   (    (    (    sD   /home/sork/Pontus/Programmering/Python/Comix/comix-4.0.4/src/lens.pyR      s   
				(    (   RU   R8   R	   R   t   preferencesR    R&   R   (    (    (    sD   /home/sork/Pontus/Programmering/Python/Comix/comix-4.0.4/src/lens.pys   <module>   s   