Skip to content

Commit a2a6b3e

Browse files
committed
Footprint widget
1 parent 84b3c90 commit a2a6b3e

4 files changed

Lines changed: 49 additions & 29 deletions

File tree

editor/src/messages/portfolio/document/node_graph/document_node_definitions.rs

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
122122
properties: Some("value_properties"),
123123
},
124124
DocumentNodeDefinition {
125-
identifier: "Number Value",
125+
identifier: "Real Number Value",
126126
category: "Value",
127127
node_template: NodeTemplate {
128128
document_node: DocumentNode {
@@ -141,13 +141,13 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
141141
properties: Some("value_properties"),
142142
},
143143
DocumentNodeDefinition {
144-
identifier: "Percentage Value",
144+
identifier: "Whole Number Value",
145145
category: "Value",
146146
node_template: NodeTemplate {
147147
document_node: DocumentNode {
148148
implementation: DocumentNodeImplementation::ProtoNode(ops::identity::IDENTIFIER),
149149
manual_composition: Some(generic!(T)),
150-
inputs: vec![NodeInput::value(TaggedValue::Percentage(0.), false)],
150+
inputs: vec![NodeInput::value(TaggedValue::U32(0), false)],
151151
..Default::default()
152152
},
153153
persistent_node_metadata: DocumentNodePersistentMetadata {
@@ -156,17 +156,17 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
156156
..Default::default()
157157
},
158158
},
159-
description: Cow::Borrowed("Constructs a decimal value between 0 and 1."),
159+
description: Cow::Borrowed("Constructs a positive integer value."),
160160
properties: Some("value_properties"),
161161
},
162162
DocumentNodeDefinition {
163-
identifier: "Number Value",
163+
identifier: "Percentage Value",
164164
category: "Value",
165165
node_template: NodeTemplate {
166166
document_node: DocumentNode {
167167
implementation: DocumentNodeImplementation::ProtoNode(ops::identity::IDENTIFIER),
168168
manual_composition: Some(generic!(T)),
169-
inputs: vec![NodeInput::value(TaggedValue::U32(0), false)],
169+
inputs: vec![NodeInput::value(TaggedValue::Percentage(0.), false)],
170170
..Default::default()
171171
},
172172
persistent_node_metadata: DocumentNodePersistentMetadata {
@@ -175,7 +175,7 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
175175
..Default::default()
176176
},
177177
},
178-
description: Cow::Borrowed("Constructs a positive integer value."),
178+
description: Cow::Borrowed("Constructs a decimal value between 0 and 1."),
179179
properties: Some("value_properties"),
180180
},
181181
DocumentNodeDefinition {
@@ -235,6 +235,25 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
235235
description: Cow::Borrowed("Constructs a string value which can be set to any plain text."),
236236
properties: Some("value_properties"),
237237
},
238+
DocumentNodeDefinition {
239+
identifier: "Footprint Value",
240+
category: "Value",
241+
node_template: NodeTemplate {
242+
document_node: DocumentNode {
243+
implementation: DocumentNodeImplementation::ProtoNode(ops::identity::IDENTIFIER),
244+
manual_composition: Some(generic!(T)),
245+
inputs: vec![NodeInput::value(TaggedValue::Footprint(Footprint::default()), false)],
246+
..Default::default()
247+
},
248+
persistent_node_metadata: DocumentNodePersistentMetadata {
249+
input_metadata: vec![("Value", "").into()],
250+
output_names: vec!["Out".to_string()],
251+
..Default::default()
252+
},
253+
},
254+
description: Cow::Borrowed("Constructs a string value which can be set to any plain text."),
255+
properties: Some("value_properties"),
256+
},
238257
DocumentNodeDefinition {
239258
identifier: "Color Value",
240259
category: "Value",

editor/src/messages/portfolio/document/node_graph/node_properties.rs

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1967,21 +1967,25 @@ pub fn value_properties(node_id: NodeId, context: &mut NodePropertiesContext) ->
19671967
return Vec::new();
19681968
}
19691969

1970-
let LayoutGroup::Row { widgets: mut type_widgets } = type_widgets.remove(0) else {
1971-
log::error!("Could not get autogenerated widgets for value node");
1972-
return Vec::new();
1973-
};
1970+
for row in &mut type_widgets {
1971+
let LayoutGroup::Row { widgets: type_widgets_first_row } = row else {
1972+
log::error!("Could not get autogenerated widgets for value node");
1973+
continue;
1974+
};
19741975

1975-
if type_widgets.len() <= 2 {
1976-
log::error!("Could not generate type widgets for value node");
1977-
return Vec::new();
1978-
}
1976+
if type_widgets_first_row.len() <= 2 {
1977+
log::error!("Could not generate type widgets for value node");
1978+
continue;
1979+
}
19791980

1980-
//Remove the name and blank assist
1981-
type_widgets.remove(0);
1982-
type_widgets.remove(0);
1981+
//Remove the name and blank assist
1982+
type_widgets_first_row.remove(0);
1983+
type_widgets_first_row.remove(0);
1984+
}
19831985

1984-
vec![LayoutGroup::Row { widgets: select_value_widgets }, LayoutGroup::Row { widgets: type_widgets }]
1986+
let mut full_value_widgets = vec![LayoutGroup::Row { widgets: select_value_widgets }];
1987+
full_value_widgets.extend(type_widgets);
1988+
full_value_widgets
19851989
}
19861990

19871991
pub struct ParameterWidgetsInfo<'a> {

node-graph/gmath-nodes/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
use glam::{DAffine2, DVec2};
22
use graphene_core::gradient::GradientStops;
33
use graphene_core::registry::types::Fraction;
4-
use graphene_core::registry::types::{Fraction, Percentage, PixelSize, TextArea};
5-
use graphene_core::transform::Footprint;
64
use graphene_core::{Color, Ctx, num_traits};
75
use log::warn;
86
use math_parser::ast;

node-graph/graph-craft/src/document/value.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,15 @@ pub use glam::{DAffine2, DVec2, IVec2, UVec2};
77
use graphene_application_io::SurfaceFrame;
88
use graphene_brush::brush_cache::BrushCache;
99
use graphene_brush::brush_stroke::BrushStroke;
10+
use graphene_core::choice_type::{ChoiceTypeStatic, ChoiceWidgetHint, VariantMetadata};
1011
use graphene_core::raster::Image;
1112
use graphene_core::raster_types::CPU;
1213
use graphene_core::registry::types::Percentage;
13-
use graphene_core::registry::{ChoiceTypeStatic, ChoiceWidgetHint, VariantMetadata};
1414
use graphene_core::transform::ReferencePoint;
1515
use graphene_core::uuid::NodeId;
1616
use graphene_core::vector::style::Fill;
1717
use graphene_core::{AsU32, Color, MemoHash, Node, Type};
1818
use graphene_svg_renderer::RenderMetadata;
19-
use std::borrow::Cow;
2019
use std::fmt::Display;
2120
use std::hash::Hash;
2221
use std::marker::PhantomData;
@@ -78,21 +77,21 @@ macro_rules! tagged_value {
7877
static VALUES: [(TaggedValueChoice, VariantMetadata); 2 + COUNT] = [
7978

8079
(TaggedValueChoice::None, VariantMetadata {
81-
name: Cow::Borrowed(stringify!(None)),
82-
label: Cow::Borrowed(stringify!(None)),
80+
name: stringify!(None),
81+
label: stringify!(None),
8382
docstring: None,
8483
icon: None,
8584
}),
8685
(TaggedValueChoice::Percentage, VariantMetadata {
87-
name: Cow::Borrowed(stringify!(Percentage)),
88-
label: Cow::Borrowed(stringify!(Percentage)),
86+
name: stringify!(Percentage),
87+
label: stringify!(Percentage),
8988
docstring: None,
9089
icon: None,
9190
}),
9291
$(
9392
(TaggedValueChoice::$identifier, VariantMetadata {
94-
name: Cow::Borrowed(stringify!($identifier)),
95-
label: Cow::Borrowed(stringify!($identifier)),
93+
name: stringify!($identifier),
94+
label: stringify!($identifier),
9695
docstring: None,
9796
icon: None,
9897
}),

0 commit comments

Comments
 (0)