
    cc                     B    d dl Z d dlZddlmZ ddlmZ  G d de      Zy)    N   )AbstractClassicTool)utilities_smooth_pathc                   Z     e Zd Zd Z fdZd Zd Zd Zd Zd Z	ddZ
d Zd	 Zd
 Z xZS )
ToolPencilc                    t         |   dt        d      d|       d| _        d | _        t        d      | _        t        j                  j                  | _	        t        j                  j                  | _
        d| _        d| _        | j                  dd	       | j                  d
| j                         | j                  d| j                         y )NpencilPencilztool-pencil-symbolicTRoundnoneF
line_shaperounddashes-typepencil-outline)super__init___use_operator_path_shape_labelcairoLineCapROUND_cap_id_join_id_dashes_type_use_outlineadd_tool_action_enumadd_tool_action_boolean)selfwindowkwargs	__class__s      5/usr/lib/python3/dist-packages/drawing/tool_pencil.pyr   zToolPencil.__init__   s    '8Qx[*@&I$$*j$$$$,--%%$-$$L'2M4+<+<=/1B1BC    c                 j   | j                  d      }|dk(  rOt        j                  j                  | _        t        j
                  j                  | _        t        d      | _	        y t        j                  j                  | _        t        j
                  j                  | _        t        d      | _	        y )Nr   thinSquarer   )get_option_valuer   r   BUTTr   LineJoinBEVELr   r   r   r   )r    argsstate_as_strings      r$   _set_active_shapezToolPencil._set_active_shape(   sv    )),7/--$$4<>>''4={4--%%4<>>''4=z4r%   c                     t        d      S )NzPencil options)r   )r    s    r$   get_options_labelzToolPencil.get_options_label3   s    	
	r%   c                    | j                  d      | _        | j                  dk7  }| j                  d      | _        | j                          |r| j                  dz   t        d      z   }nd }| j                         j                         rd }|(| j                  }n| j                  dz   t        d      z   }||g}t        t        d |            S )Nr   r   r   z - Dashedz*Press <Alt> to toggle the 'outline' option)
r)   r   r   r/   labelr   	get_imageget_mouse_is_pressedlistfilter)r    
use_dasheslabel_optionslabel_modifier_alt	full_lists        r$   get_editing_tipszToolPencil.get_editing_tips6   s    ++M:$  F**++,<=$::%(3==	^^**,JJM

U*FGH 01)	fT9%	&&r%   c                     | j                  |j                  ||       d | _        | j                  |j                         d| j
                  v r| j                   | _        y y )NALT)set_common_valuesbuttonr   update_modifier_statestate_modifier_keysr   )r    eventsurfaceevent_xevent_ys        r$   on_press_on_areazToolPencil.on_press_on_areaN   sU    w8$*U[[)
d!!!,,,4 "r%   c                    | j                         }| j                  '|j                  | j                  | j                         n|j                  | j                         |j                  ||       |j                         | _        y N)get_contextr   move_tox_pressy_pressappend_pathline_to	copy_path)r    rG   rH   cairo_contexts       r$   
_add_pointzToolPencil._add_pointV   sd    ""$-	ZZt||4TZZ()&&($*r%   c                 p    | j                  ||       |sy | j                         }| j                  |       y rK   )rT   build_operationdo_tool_operation)r    rE   rF   rG   rH   render	operations          r$   on_motion_on_areazToolPencil.on_motion_on_area_   s2    //'7#		""$)#r%   c                 X   | j                  ||       | j                  |k(  rh| j                  |k(  rY| j                         j	                  |d      \  }}||z
  }|dkD  rd}nd}||z
  }	|	dkD  rd}
nd}
| j                  ||z   ||
z          | j                         }| j                  |       y )NFr   g?gɿ)rT   rN   rO   r5   get_event_coordsrV   apply_operation)r    rE   rF   rG   rH   float_xfloat_y
decimals_xdelta_x
decimals_ydelta_yrY   s               r$   on_release_on_areazToolPencil.on_release_on_areaf   s    //'7#	\\W!8 nn&77uE7G'!:1nGG'!:1nGG??7W$g&78""$)y!r%   c                 :   | j                   | j                  | j                  | j                  | j	                         j                          | j                  | j                  | j                  | j                  | j                  | j                  | j                  d}|S )N)tool_idrgbargba2	antialiassmoothoutlineoperator
line_widthline_cap	line_joindashespath)id
main_colorsecondary_color_use_antialiasr5   is_zoomed_surface_sharpr   	_operator
tool_widthr   r   r   r   )r    rY   s     r$   rV   zToolPencil.build_operation~   s|    gg??  ##!99;;~~||::) 
r%   c                    |d   y | j                  |      }|j                  |d          |d   }| j                  |||d   |d          |j                  |d          |d   rt	        ||d          n|j                  |d          |d   r9 |j                  |d	     |j                  |d
z  dz          |j                           |j                  |d     |j                  |       |j                          y )Nrq   rl   rm   rp   rn   ro   rj   rk   rh   g333333?   rg   )
start_tool_operationset_operatorset_dashes_and_capset_line_joinr   rP   set_source_rgbaset_line_widthstroke_preservestroke)r    rY   rS   rm   s       r$   rW   zToolPencil.do_tool_operation   s   v	++I6-Yz23&*-#H-y/DFi45x	&(9:Yv./y =  )G"45
S 01 45  "-6!23z*r%   )T)__name__
__module____qualname____gtype_name__r   r/   r1   r=   rI   rT   rZ   rd   rV   rW   __classcell__)r#   s   @r$   r   r      s;    D	"'0-)$"0"r%   r   )r   mathabstract_classic_toolr   utilities_pathsr   r    r%   r$   <module>r      s   $  6 2P$ Pr%   