@@ -44,6 +44,9 @@ pub struct ShapeToolOptions {
4444 grid_type : GridType ,
4545 spiral_type : SpiralType ,
4646 turns : f64 ,
47+ arrow_shaft_width : f64 ,
48+ arrow_head_width : f64 ,
49+ arrow_head_length : f64 ,
4750}
4851
4952impl Default for ShapeToolOptions {
@@ -58,6 +61,9 @@ impl Default for ShapeToolOptions {
5861 spiral_type : SpiralType :: Archimedean ,
5962 turns : 5. ,
6063 grid_type : GridType :: Rectangular ,
64+ arrow_shaft_width : 14.0 ,
65+ arrow_head_width : 32.0 ,
66+ arrow_head_length : 28.0 ,
6167 }
6268 }
6369}
@@ -76,6 +82,9 @@ pub enum ShapeOptionsUpdate {
7682 SpiralType ( SpiralType ) ,
7783 Turns ( f64 ) ,
7884 GridType ( GridType ) ,
85+ ArrowShaftWidth ( f64 ) ,
86+ ArrowHeadWidth ( f64 ) ,
87+ ArrowHeadLength ( f64 ) ,
7988}
8089
8190#[ impl_message( Message , ToolMessage , Shape ) ]
@@ -236,6 +245,51 @@ fn create_weight_widget(line_weight: f64) -> WidgetInstance {
236245 . widget_instance ( )
237246}
238247
248+ fn create_arrow_shaft_width_widget ( shaft_width : f64 ) -> WidgetInstance {
249+ NumberInput :: new ( Some ( shaft_width) )
250+ . unit ( " px" )
251+ . label ( "Shaft" )
252+ . min ( 0.1 )
253+ . max ( 1000. )
254+ . on_update ( |number_input : & NumberInput | {
255+ ShapeToolMessage :: UpdateOptions {
256+ options : ShapeOptionsUpdate :: ArrowShaftWidth ( number_input. value . unwrap ( ) ) ,
257+ }
258+ . into ( )
259+ } )
260+ . widget_instance ( )
261+ }
262+
263+ fn create_arrow_head_width_widget ( head_width : f64 ) -> WidgetInstance {
264+ NumberInput :: new ( Some ( head_width) )
265+ . unit ( " px" )
266+ . label ( "Head W" )
267+ . min ( 0.1 )
268+ . max ( 1000. )
269+ . on_update ( |number_input : & NumberInput | {
270+ ShapeToolMessage :: UpdateOptions {
271+ options : ShapeOptionsUpdate :: ArrowHeadWidth ( number_input. value . unwrap ( ) ) ,
272+ }
273+ . into ( )
274+ } )
275+ . widget_instance ( )
276+ }
277+
278+ fn create_arrow_head_length_widget ( head_length : f64 ) -> WidgetInstance {
279+ NumberInput :: new ( Some ( head_length) )
280+ . unit ( " px" )
281+ . label ( "Head L" )
282+ . min ( 0.1 )
283+ . max ( 1000. )
284+ . on_update ( |number_input : & NumberInput | {
285+ ShapeToolMessage :: UpdateOptions {
286+ options : ShapeOptionsUpdate :: ArrowHeadLength ( number_input. value . unwrap ( ) ) ,
287+ }
288+ . into ( )
289+ } )
290+ . widget_instance ( )
291+ }
292+
239293fn create_spiral_type_widget ( spiral_type : SpiralType ) -> WidgetInstance {
240294 let entries = vec ! [ vec![
241295 MenuListEntry :: new( "Archimedean" ) . label( "Archimedean" ) . on_commit( move |_| {
@@ -304,6 +358,15 @@ impl LayoutHolder for ShapeTool {
304358 widgets. push ( Separator :: new ( SeparatorStyle :: Unrelated ) . widget_instance ( ) ) ;
305359 }
306360
361+ if self . options . shape_type == ShapeType :: Arrow {
362+ widgets. push ( create_arrow_shaft_width_widget ( self . options . arrow_shaft_width ) ) ;
363+ widgets. push ( Separator :: new ( SeparatorStyle :: Related ) . widget_instance ( ) ) ;
364+ widgets. push ( create_arrow_head_width_widget ( self . options . arrow_head_width ) ) ;
365+ widgets. push ( Separator :: new ( SeparatorStyle :: Related ) . widget_instance ( ) ) ;
366+ widgets. push ( create_arrow_head_length_widget ( self . options . arrow_head_length ) ) ;
367+ widgets. push ( Separator :: new ( SeparatorStyle :: Unrelated ) . widget_instance ( ) ) ;
368+ }
369+
307370 if self . options . shape_type != ShapeType :: Line {
308371 widgets. append ( & mut self . options . fill . create_widgets (
309372 "Fill" ,
@@ -414,6 +477,15 @@ impl<'a> MessageHandler<ToolMessage, &mut ToolActionMessageContext<'a>> for Shap
414477 ShapeOptionsUpdate :: GridType ( grid_type) => {
415478 self . options . grid_type = grid_type;
416479 }
480+ ShapeOptionsUpdate :: ArrowShaftWidth ( shaft_width) => {
481+ self . options . arrow_shaft_width = shaft_width;
482+ }
483+ ShapeOptionsUpdate :: ArrowHeadWidth ( head_width) => {
484+ self . options . arrow_head_width = head_width;
485+ }
486+ ShapeOptionsUpdate :: ArrowHeadLength ( head_length) => {
487+ self . options . arrow_head_length = head_length;
488+ }
417489 }
418490
419491 update_dynamic_hints ( & self . fsm_state , responses, & self . tool_data ) ;
@@ -905,7 +977,18 @@ impl Fsm for ShapeToolFsmState {
905977 ShapeType :: Star => Star :: update_shape ( document, input, viewport, layer, tool_data, modifier, responses) ,
906978 ShapeType :: Circle => Circle :: update_shape ( document, input, viewport, layer, tool_data, modifier, responses) ,
907979 ShapeType :: Arc => Arc :: update_shape ( document, input, viewport, layer, tool_data, modifier, responses) ,
908- ShapeType :: Arrow => Arrow :: update_shape ( document, input, viewport, layer, tool_data, modifier, responses) ,
980+ ShapeType :: Arrow => Arrow :: update_shape (
981+ document,
982+ input,
983+ viewport,
984+ layer,
985+ tool_data,
986+ modifier,
987+ tool_options. arrow_shaft_width ,
988+ tool_options. arrow_head_width ,
989+ tool_options. arrow_head_length ,
990+ responses,
991+ ) ,
909992 ShapeType :: Spiral => Spiral :: update_shape ( document, input, viewport, layer, tool_data, responses) ,
910993 ShapeType :: Grid => Grid :: update_shape ( document, input, layer, tool_options. grid_type , tool_data, modifier, responses) ,
911994 ShapeType :: Rectangle => Rectangle :: update_shape ( document, input, viewport, layer, tool_data, modifier, responses) ,
0 commit comments