@@ -310,17 +310,42 @@ fn line_join_widget(document_node: &DocumentNode, node_id: u64, index: usize, na
310
310
LayoutGroup :: Row { widgets }
311
311
}
312
312
313
- fn gradient_type_widget ( document_node : & DocumentNode , node_id : u64 , index : usize , name : & str , blank_assist : bool ) -> LayoutGroup {
314
- let mut widgets = start_widgets ( document_node, node_id, index, name, FrontendGraphDataType :: General , blank_assist) ;
313
+ fn fill_type_widget ( document_node : & DocumentNode , node_id : u64 , index : usize ) -> LayoutGroup {
314
+ let mut widgets = start_widgets ( document_node, node_id, index, "Fill Type" , FrontendGraphDataType :: General , true ) ;
315
+ if let & NodeInput :: Value {
316
+ tagged_value : TaggedValue :: FillType ( fill_type) ,
317
+ exposed : false ,
318
+ } = & document_node. inputs [ index]
319
+ {
320
+ let entries = vec ! [
321
+ RadioEntryData :: new( "Solid" ) . on_update( update_value( move |_| TaggedValue :: FillType ( FillType :: Solid ) , node_id, index) ) ,
322
+ RadioEntryData :: new( "Gradient" ) . on_update( update_value( move |_| TaggedValue :: FillType ( FillType :: Gradient ) , node_id, index) ) ,
323
+ ] ;
324
+
325
+ widgets. extend_from_slice ( & [
326
+ WidgetHolder :: unrelated_separator ( ) ,
327
+ RadioInput :: new ( entries)
328
+ . selected_index ( match fill_type {
329
+ FillType :: None | FillType :: Solid => 0 ,
330
+ FillType :: Gradient => 1 ,
331
+ } )
332
+ . widget_holder ( ) ,
333
+ ] ) ;
334
+ }
335
+ LayoutGroup :: Row { widgets }
336
+ }
337
+
338
+ fn gradient_type_widget ( document_node : & DocumentNode , node_id : u64 , index : usize ) -> LayoutGroup {
339
+ let mut widgets = start_widgets ( document_node, node_id, index, "Gradient Type" , FrontendGraphDataType :: General , true ) ;
315
340
if let & NodeInput :: Value {
316
341
tagged_value : TaggedValue :: GradientType ( gradient_type) ,
317
342
exposed : false ,
318
343
} = & document_node. inputs [ index]
319
344
{
320
- let entries = [ ( "Linear" , GradientType :: Linear ) , ( "Radial" , GradientType :: Radial ) ]
321
- . into_iter ( )
322
- . map ( | ( name , val ) | RadioEntryData :: new ( name ) . on_update ( update_value ( move |_| TaggedValue :: GradientType ( val ) , node_id, index) ) )
323
- . collect ( ) ;
345
+ let entries = vec ! [
346
+ RadioEntryData :: new ( "Linear" ) . on_update ( update_value ( move |_| TaggedValue :: GradientType ( GradientType :: Linear ) , node_id , index ) ) ,
347
+ RadioEntryData :: new( "Radial" ) . on_update( update_value( move |_| TaggedValue :: GradientType ( GradientType :: Radial ) , node_id, index) ) ,
348
+ ] ;
324
349
325
350
widgets. extend_from_slice ( & [ WidgetHolder :: unrelated_separator ( ) , RadioInput :: new ( entries) . selected_index ( gradient_type as u32 ) . widget_holder ( ) ] ) ;
326
351
}
@@ -1541,6 +1566,7 @@ pub fn stroke_properties(document_node: &DocumentNode, node_id: NodeId, _context
1541
1566
]
1542
1567
}
1543
1568
1569
+ /// Fill Node Widgets LayoutGroup
1544
1570
pub fn fill_properties ( document_node : & DocumentNode , node_id : NodeId , _context : & mut NodePropertiesContext ) -> Vec < LayoutGroup > {
1545
1571
let fill_type_index = 1 ;
1546
1572
let solid_color_index = 2 ;
@@ -1560,40 +1586,21 @@ pub fn fill_properties(document_node: &DocumentNode, node_id: NodeId, _context:
1560
1586
let mut widgets = Vec :: new ( ) ;
1561
1587
let gradient = fill_type == Some ( graphene_core:: vector:: style:: FillType :: Gradient ) ;
1562
1588
let solid = fill_type == Some ( graphene_core:: vector:: style:: FillType :: Solid ) ;
1563
- let empty = fill_type == Some ( graphene_core:: vector:: style:: FillType :: None ) ;
1564
- if fill_type. is_none ( ) || solid || empty {
1589
+
1590
+ let fill_type_switch = fill_type_widget ( document_node, node_id, fill_type_index) ;
1591
+ widgets. push ( fill_type_switch) ;
1592
+
1593
+ if fill_type. is_none ( ) || solid {
1565
1594
let solid_color = color_widget ( document_node, node_id, solid_color_index, "Color" , ColorInput :: default ( ) , true ) ;
1566
1595
widgets. push ( solid_color) ;
1567
1596
}
1568
1597
1569
1598
if fill_type. is_none ( ) || gradient {
1570
- let gradient_type = gradient_type_widget ( document_node, node_id, gradient_type_index, "Gradient Type" , true ) ;
1571
- widgets. push ( gradient_type ) ;
1599
+ let gradient_type_switch = gradient_type_widget ( document_node, node_id, gradient_type_index) ;
1600
+ widgets. push ( gradient_type_switch ) ;
1572
1601
gradient_positions ( & mut widgets, document_node, "Gradient Positions" , node_id, positions_index) ;
1573
1602
}
1574
1603
1575
- if gradient || solid || empty {
1576
- let new_fill_type = if gradient { FillType :: Solid } else { FillType :: Gradient } ;
1577
- let switch_button = TextButton :: new ( if gradient { "Use Solid Color" } else { "Use Gradient" } )
1578
- . tooltip ( if gradient {
1579
- "Change this fill from a gradient to a solid color, keeping the 0% stop color"
1580
- } else {
1581
- "Change this fill from a solid color to a gradient"
1582
- } )
1583
- . on_update ( update_value ( move |_| TaggedValue :: FillType ( new_fill_type) , node_id, fill_type_index) ) ;
1584
-
1585
- widgets. push ( LayoutGroup :: Row {
1586
- widgets : {
1587
- let mut widgets = Vec :: new ( ) ;
1588
- widgets. push ( TextLabel :: new ( "" ) . widget_holder ( ) ) ;
1589
- add_blank_assist ( & mut widgets) ;
1590
- widgets. push ( WidgetHolder :: unrelated_separator ( ) ) ;
1591
- widgets. push ( switch_button. widget_holder ( ) ) ;
1592
- widgets
1593
- } ,
1594
- } ) ;
1595
- }
1596
-
1597
1604
widgets
1598
1605
}
1599
1606
0 commit comments