@@ -202,7 +202,35 @@ impl LayoutHolder for GradientTool {
202202 . selected_index ( Some ( ( self . options . gradient_type == GradientType :: Radial ) as u32 ) )
203203 . widget_instance ( ) ;
204204
205- widgets. extend ( [ gradient_type, Separator :: new ( SeparatorStyle :: Unrelated ) . widget_instance ( ) ] ) ;
205+ let spread_method = RadioInput :: new ( vec ! [
206+ RadioEntryData :: new( "Pad" ) . label( "Pad" ) . tooltip_label( "Pad" ) . on_update( move |_| {
207+ GradientToolMessage :: UpdateOptions {
208+ options: GradientOptionsUpdate :: SetSpreadMethod ( GradientSpreadMethod :: Pad ) ,
209+ }
210+ . into( )
211+ } ) ,
212+ RadioEntryData :: new( "Reflect" ) . label( "Reflect" ) . tooltip_label( "Reflect" ) . on_update( move |_| {
213+ GradientToolMessage :: UpdateOptions {
214+ options: GradientOptionsUpdate :: SetSpreadMethod ( GradientSpreadMethod :: Reflect ) ,
215+ }
216+ . into( )
217+ } ) ,
218+ RadioEntryData :: new( "Repeat" ) . label( "Repeat" ) . tooltip_label( "Repeat" ) . on_update( move |_| {
219+ GradientToolMessage :: UpdateOptions {
220+ options: GradientOptionsUpdate :: SetSpreadMethod ( GradientSpreadMethod :: Repeat ) ,
221+ }
222+ . into( )
223+ } ) ,
224+ ] )
225+ . selected_index ( Some ( self . options . spread_method as u32 ) )
226+ . widget_instance ( ) ;
227+
228+ widgets. extend ( [
229+ gradient_type,
230+ Separator :: new ( SeparatorStyle :: Unrelated ) . widget_instance ( ) ,
231+ spread_method,
232+ Separator :: new ( SeparatorStyle :: Unrelated ) . widget_instance ( ) ,
233+ ] ) ;
206234 }
207235
208236 let reverse_stops = IconButton :: new ( "Reverse" , 24 )
@@ -217,36 +245,6 @@ impl LayoutHolder for GradientTool {
217245 } )
218246 . widget_instance ( ) ;
219247
220- let spread_method = RadioInput :: new ( vec ! [
221- RadioEntryData :: new( "Pad" ) . label( "Pad" ) . tooltip_label( "Pad" ) . on_update( move |_| {
222- GradientToolMessage :: UpdateOptions {
223- options: GradientOptionsUpdate :: SetSpreadMethod ( GradientSpreadMethod :: Pad ) ,
224- }
225- . into( )
226- } ) ,
227- RadioEntryData :: new( "Reflect" ) . label( "Reflect" ) . tooltip_label( "Reflect" ) . on_update( move |_| {
228- GradientToolMessage :: UpdateOptions {
229- options: GradientOptionsUpdate :: SetSpreadMethod ( GradientSpreadMethod :: Reflect ) ,
230- }
231- . into( )
232- } ) ,
233- RadioEntryData :: new( "Repeat" ) . label( "Repeat" ) . tooltip_label( "Repeat" ) . on_update( move |_| {
234- GradientToolMessage :: UpdateOptions {
235- options: GradientOptionsUpdate :: SetSpreadMethod ( GradientSpreadMethod :: Repeat ) ,
236- }
237- . into( )
238- } ) ,
239- ] )
240- . selected_index ( Some ( self . options . spread_method as u32 ) )
241- . widget_instance ( ) ;
242-
243- let mut widgets = vec ! [
244- gradient_type,
245- Separator :: new( SeparatorStyle :: Unrelated ) . widget_instance( ) ,
246- spread_method,
247- Separator :: new( SeparatorStyle :: Unrelated ) . widget_instance( ) ,
248- reverse_stops,
249- ] ;
250248 widgets. push ( reverse_stops) ;
251249
252250 if self . options . gradient_type == GradientType :: Radial && !self . data . is_gradient_table {
@@ -325,7 +323,7 @@ fn gradient_space_transform(layer: LayerNodeIdentifier, document: &DocumentMessa
325323}
326324
327325// TODO: This conversion is a temporary solution, this should be removed after migration to Table<GradientStops> for all gradient use.
328- // TODO: We only support linear gradient since there is no place to store the gradient type in the table row currently.
326+ // TODO: We only support linear gradient with pad spread method since there is no place to store the gradient type in the table row currently.
329327fn get_gradient ( layer : LayerNodeIdentifier , network_interface : & NodeNetworkInterface ) -> Option < Gradient > {
330328 match ( get_gradient_table ( layer, network_interface) , graph_modification_utils:: get_gradient ( layer, network_interface) ) {
331329 ( Some ( gradient_graphic) , _) => {
@@ -335,6 +333,7 @@ fn get_gradient(layer: LayerNodeIdentifier, network_interface: &NodeNetworkInter
335333 let gradient = Gradient {
336334 stops,
337335 gradient_type : GradientType :: Linear ,
336+ spread_method : GradientSpreadMethod :: Pad ,
338337 start : transform. transform_point2 ( GRADIENT_TABLE_START ) ,
339338 end : transform. transform_point2 ( GRADIENT_TABLE_END ) ,
340339 } ;
0 commit comments