@@ -127,16 +127,21 @@ fn numeric_fields(app: &mut EffectcraftApp, ui: &mut egui::Ui, p: &egui::Painter
127127 let row = i / 2 ;
128128 let fx = x0 + col as f32 * ( w / 2.0 ) ;
129129 let fy = y + row as f32 * 28.0 ;
130- p. text ( pos2 ( fx, fy + 9.0 ) , Align2 :: LEFT_CENTER , glyph, Tokens :: semibold ( 11.0 ) , t. text_dim ) ;
131- let ( r, nv, _) = widgets:: hot_number_at (
132- ui,
133- pos2 ( fx + 26.0 , fy) ,
134- egui:: Id :: unique ( ( "char" , key) ) ,
135- v,
136- & widgets:: HotSpec { speed : 0.5 , range, decimals : 0 , suffix } ,
137- & t,
138- ) ;
130+ let stroke = key == "strokeWidth" ;
131+ if stroke {
132+ // The stroke-width icon, as in After Effects, not a letter that reads as "width".
133+ crate :: icons:: paint ( p, Rect :: from_min_size ( pos2 ( fx, fy + 1.0 ) , vec2 ( 18.0 , 18.0 ) ) , crate :: icons:: Icon :: StrokeWidth , t. text_dim ) ;
134+ } else {
135+ p. text ( pos2 ( fx, fy + 9.0 ) , Align2 :: LEFT_CENTER , glyph, Tokens :: semibold ( 11.0 ) , t. text_dim ) ;
136+ }
137+ // Fractional stroke widths (the 0.25 / 0.5 / 0.75 presets) show their decimals.
138+ let decimals = if stroke && v. fract ( ) . abs ( ) > 1e-9 { 2 } else { 0 } ;
139+ let ( r, nv, _) =
140+ widgets:: hot_number_at ( ui, pos2 ( fx + 26.0 , fy) , egui:: Id :: unique ( ( "char" , key) ) , v, & widgets:: HotSpec { speed : 0.5 , range, decimals, suffix } , & t) ;
139141 app. auto . add ( & format ! ( "character.{key}" ) , r, key) ;
142+ if stroke {
143+ stroke_width_presets ( app, ui, r, enabled, actions) ;
144+ }
140145 if let Some ( nv) = nv
141146 && enabled
142147 {
@@ -145,6 +150,26 @@ fn numeric_fields(app: &mut EffectcraftApp, ui: &mut egui::Ui, p: &egui::Painter
145150 }
146151}
147152
153+ /// The stroke width's presets menu beside its value (`r`), as in After Effects.
154+ fn stroke_width_presets ( app : & mut EffectcraftApp , ui : & mut egui:: Ui , r : Rect , enabled : bool , actions : & mut Vec < serde_json:: Value > ) {
155+ const PRESETS : [ f64 ; 22 ] = [ 0.25 , 0.5 , 0.75 , 1.0 , 2.0 , 3.0 , 4.0 , 5.0 , 6.0 , 7.0 , 8.0 , 9.0 , 10.0 , 20.0 , 30.0 , 40.0 , 50.0 , 60.0 , 70.0 , 80.0 , 90.0 , 100.0 ] ;
156+ let t = app. tokens ;
157+ let br = Rect :: from_min_size ( pos2 ( r. max . x + 4.0 , r. min . y + 2.0 ) , vec2 ( 16.0 , 16.0 ) ) ;
158+ let pop = egui:: Id :: unique ( "char-stroke-width-pop" ) ;
159+ if widgets:: icon_button ( ui, br, crate :: icons:: Icon :: ChevronDown , false , & t, egui:: Id :: unique ( "char-stroke-width-presets" ) )
160+ . on_hover_text ( tr ( "Stroke width presets" ) )
161+ . clicked ( )
162+ && enabled
163+ {
164+ widgets:: open_popup ( ui, pop) ;
165+ }
166+ app. auto . add ( "character.strokeWidth.presets" , br, "Stroke width presets" ) ;
167+ let labels: Vec < String > = PRESETS . iter ( ) . map ( |v| format ! ( "{v} px" ) ) . collect ( ) ;
168+ if let Some ( v) = widgets:: popup_menu ( ui, pop, br. left_bottom ( ) , & labels, None ) . and_then ( |i| PRESETS . get ( i) ) {
169+ actions. push ( json ! ( { "strokeWidth" : v} ) ) ;
170+ }
171+ }
172+
148173/// Kerning: Metrics / Optical / a manual value (grid row 1, left).
149174fn kerning_field ( app : & mut EffectcraftApp , ui : & mut egui:: Ui , p : & egui:: Painter , g : Grid , doc : & TextDoc , actions : & mut Vec < serde_json:: Value > ) {
150175 let t = app. tokens ;
0 commit comments