Footprint widget

This commit is contained in:
Adam
2025-07-26 14:55:40 -07:00
parent 84b3c90dc8
commit a2a6b3e12f
4 changed files with 62 additions and 42 deletions
@@ -122,7 +122,7 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
properties: Some("value_properties"), properties: Some("value_properties"),
}, },
DocumentNodeDefinition { DocumentNodeDefinition {
identifier: "Number Value", identifier: "Real Number Value",
category: "Value", category: "Value",
node_template: NodeTemplate { node_template: NodeTemplate {
document_node: DocumentNode { document_node: DocumentNode {
@@ -140,6 +140,25 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
description: Cow::Borrowed("Constructs a number which can be set to any real number"), description: Cow::Borrowed("Constructs a number which can be set to any real number"),
properties: Some("value_properties"), properties: Some("value_properties"),
}, },
DocumentNodeDefinition {
identifier: "Whole Number Value",
category: "Value",
node_template: NodeTemplate {
document_node: DocumentNode {
implementation: DocumentNodeImplementation::ProtoNode(ops::identity::IDENTIFIER),
manual_composition: Some(generic!(T)),
inputs: vec![NodeInput::value(TaggedValue::U32(0), false)],
..Default::default()
},
persistent_node_metadata: DocumentNodePersistentMetadata {
input_metadata: vec![("Value", "").into()],
output_names: vec!["Out".to_string()],
..Default::default()
},
},
description: Cow::Borrowed("Constructs a positive integer value."),
properties: Some("value_properties"),
},
DocumentNodeDefinition { DocumentNodeDefinition {
identifier: "Percentage Value", identifier: "Percentage Value",
category: "Value", category: "Value",
@@ -159,25 +178,6 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
description: Cow::Borrowed("Constructs a decimal value between 0 and 1."), description: Cow::Borrowed("Constructs a decimal value between 0 and 1."),
properties: Some("value_properties"), properties: Some("value_properties"),
}, },
DocumentNodeDefinition {
identifier: "Number Value",
category: "Value",
node_template: NodeTemplate {
document_node: DocumentNode {
implementation: DocumentNodeImplementation::ProtoNode(ops::identity::IDENTIFIER),
manual_composition: Some(generic!(T)),
inputs: vec![NodeInput::value(TaggedValue::U32(0), false)],
..Default::default()
},
persistent_node_metadata: DocumentNodePersistentMetadata {
input_metadata: vec![("Value", "").into()],
output_names: vec!["Out".to_string()],
..Default::default()
},
},
description: Cow::Borrowed("Constructs a positive integer value."),
properties: Some("value_properties"),
},
DocumentNodeDefinition { DocumentNodeDefinition {
identifier: "Bool Value", identifier: "Bool Value",
category: "Value", category: "Value",
@@ -235,6 +235,25 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
description: Cow::Borrowed("Constructs a string value which can be set to any plain text."), description: Cow::Borrowed("Constructs a string value which can be set to any plain text."),
properties: Some("value_properties"), properties: Some("value_properties"),
}, },
DocumentNodeDefinition {
identifier: "Footprint Value",
category: "Value",
node_template: NodeTemplate {
document_node: DocumentNode {
implementation: DocumentNodeImplementation::ProtoNode(ops::identity::IDENTIFIER),
manual_composition: Some(generic!(T)),
inputs: vec![NodeInput::value(TaggedValue::Footprint(Footprint::default()), false)],
..Default::default()
},
persistent_node_metadata: DocumentNodePersistentMetadata {
input_metadata: vec![("Value", "").into()],
output_names: vec!["Out".to_string()],
..Default::default()
},
},
description: Cow::Borrowed("Constructs a string value which can be set to any plain text."),
properties: Some("value_properties"),
},
DocumentNodeDefinition { DocumentNodeDefinition {
identifier: "Color Value", identifier: "Color Value",
category: "Value", category: "Value",
@@ -1967,21 +1967,25 @@ pub fn value_properties(node_id: NodeId, context: &mut NodePropertiesContext) ->
return Vec::new(); return Vec::new();
} }
let LayoutGroup::Row { widgets: mut type_widgets } = type_widgets.remove(0) else { for row in &mut type_widgets {
log::error!("Could not get autogenerated widgets for value node"); let LayoutGroup::Row { widgets: type_widgets_first_row } = row else {
return Vec::new(); log::error!("Could not get autogenerated widgets for value node");
}; continue;
};
if type_widgets.len() <= 2 { if type_widgets_first_row.len() <= 2 {
log::error!("Could not generate type widgets for value node"); log::error!("Could not generate type widgets for value node");
return Vec::new(); continue;
}
//Remove the name and blank assist
type_widgets_first_row.remove(0);
type_widgets_first_row.remove(0);
} }
//Remove the name and blank assist let mut full_value_widgets = vec![LayoutGroup::Row { widgets: select_value_widgets }];
type_widgets.remove(0); full_value_widgets.extend(type_widgets);
type_widgets.remove(0); full_value_widgets
vec![LayoutGroup::Row { widgets: select_value_widgets }, LayoutGroup::Row { widgets: type_widgets }]
} }
pub struct ParameterWidgetsInfo<'a> { pub struct ParameterWidgetsInfo<'a> {
-2
View File
@@ -1,8 +1,6 @@
use glam::{DAffine2, DVec2}; use glam::{DAffine2, DVec2};
use graphene_core::gradient::GradientStops; use graphene_core::gradient::GradientStops;
use graphene_core::registry::types::Fraction; use graphene_core::registry::types::Fraction;
use graphene_core::registry::types::{Fraction, Percentage, PixelSize, TextArea};
use graphene_core::transform::Footprint;
use graphene_core::{Color, Ctx, num_traits}; use graphene_core::{Color, Ctx, num_traits};
use log::warn; use log::warn;
use math_parser::ast; use math_parser::ast;
+7 -8
View File
@@ -7,16 +7,15 @@ pub use glam::{DAffine2, DVec2, IVec2, UVec2};
use graphene_application_io::SurfaceFrame; use graphene_application_io::SurfaceFrame;
use graphene_brush::brush_cache::BrushCache; use graphene_brush::brush_cache::BrushCache;
use graphene_brush::brush_stroke::BrushStroke; use graphene_brush::brush_stroke::BrushStroke;
use graphene_core::choice_type::{ChoiceTypeStatic, ChoiceWidgetHint, VariantMetadata};
use graphene_core::raster::Image; use graphene_core::raster::Image;
use graphene_core::raster_types::CPU; use graphene_core::raster_types::CPU;
use graphene_core::registry::types::Percentage; use graphene_core::registry::types::Percentage;
use graphene_core::registry::{ChoiceTypeStatic, ChoiceWidgetHint, VariantMetadata};
use graphene_core::transform::ReferencePoint; use graphene_core::transform::ReferencePoint;
use graphene_core::uuid::NodeId; use graphene_core::uuid::NodeId;
use graphene_core::vector::style::Fill; use graphene_core::vector::style::Fill;
use graphene_core::{AsU32, Color, MemoHash, Node, Type}; use graphene_core::{AsU32, Color, MemoHash, Node, Type};
use graphene_svg_renderer::RenderMetadata; use graphene_svg_renderer::RenderMetadata;
use std::borrow::Cow;
use std::fmt::Display; use std::fmt::Display;
use std::hash::Hash; use std::hash::Hash;
use std::marker::PhantomData; use std::marker::PhantomData;
@@ -78,21 +77,21 @@ macro_rules! tagged_value {
static VALUES: [(TaggedValueChoice, VariantMetadata); 2 + COUNT] = [ static VALUES: [(TaggedValueChoice, VariantMetadata); 2 + COUNT] = [
(TaggedValueChoice::None, VariantMetadata { (TaggedValueChoice::None, VariantMetadata {
name: Cow::Borrowed(stringify!(None)), name: stringify!(None),
label: Cow::Borrowed(stringify!(None)), label: stringify!(None),
docstring: None, docstring: None,
icon: None, icon: None,
}), }),
(TaggedValueChoice::Percentage, VariantMetadata { (TaggedValueChoice::Percentage, VariantMetadata {
name: Cow::Borrowed(stringify!(Percentage)), name: stringify!(Percentage),
label: Cow::Borrowed(stringify!(Percentage)), label: stringify!(Percentage),
docstring: None, docstring: None,
icon: None, icon: None,
}), }),
$( $(
(TaggedValueChoice::$identifier, VariantMetadata { (TaggedValueChoice::$identifier, VariantMetadata {
name: Cow::Borrowed(stringify!($identifier)), name: stringify!($identifier),
label: Cow::Borrowed(stringify!($identifier)), label: stringify!($identifier),
docstring: None, docstring: None,
icon: None, icon: None,
}), }),