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

View File

@@ -122,7 +122,7 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
properties: Some("value_properties"),
},
DocumentNodeDefinition {
identifier: "Number Value",
identifier: "Real Number Value",
category: "Value",
node_template: NodeTemplate {
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"),
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 {
identifier: "Percentage Value",
category: "Value",
@@ -159,25 +178,6 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
description: Cow::Borrowed("Constructs a decimal value between 0 and 1."),
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 {
identifier: "Bool 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."),
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 {
identifier: "Color Value",
category: "Value",

View File

@@ -1967,21 +1967,25 @@ pub fn value_properties(node_id: NodeId, context: &mut NodePropertiesContext) ->
return Vec::new();
}
let LayoutGroup::Row { widgets: mut type_widgets } = type_widgets.remove(0) else {
log::error!("Could not get autogenerated widgets for value node");
return Vec::new();
};
for row in &mut type_widgets {
let LayoutGroup::Row { widgets: type_widgets_first_row } = row else {
log::error!("Could not get autogenerated widgets for value node");
continue;
};
if type_widgets.len() <= 2 {
log::error!("Could not generate type widgets for value node");
return Vec::new();
if type_widgets_first_row.len() <= 2 {
log::error!("Could not generate type widgets for value node");
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
type_widgets.remove(0);
type_widgets.remove(0);
vec![LayoutGroup::Row { widgets: select_value_widgets }, LayoutGroup::Row { widgets: type_widgets }]
let mut full_value_widgets = vec![LayoutGroup::Row { widgets: select_value_widgets }];
full_value_widgets.extend(type_widgets);
full_value_widgets
}
pub struct ParameterWidgetsInfo<'a> {

View File

@@ -1,8 +1,6 @@
use glam::{DAffine2, DVec2};
use graphene_core::gradient::GradientStops;
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 log::warn;
use math_parser::ast;

View File

@@ -7,16 +7,15 @@ pub use glam::{DAffine2, DVec2, IVec2, UVec2};
use graphene_application_io::SurfaceFrame;
use graphene_brush::brush_cache::BrushCache;
use graphene_brush::brush_stroke::BrushStroke;
use graphene_core::choice_type::{ChoiceTypeStatic, ChoiceWidgetHint, VariantMetadata};
use graphene_core::raster::Image;
use graphene_core::raster_types::CPU;
use graphene_core::registry::types::Percentage;
use graphene_core::registry::{ChoiceTypeStatic, ChoiceWidgetHint, VariantMetadata};
use graphene_core::transform::ReferencePoint;
use graphene_core::uuid::NodeId;
use graphene_core::vector::style::Fill;
use graphene_core::{AsU32, Color, MemoHash, Node, Type};
use graphene_svg_renderer::RenderMetadata;
use std::borrow::Cow;
use std::fmt::Display;
use std::hash::Hash;
use std::marker::PhantomData;
@@ -78,21 +77,21 @@ macro_rules! tagged_value {
static VALUES: [(TaggedValueChoice, VariantMetadata); 2 + COUNT] = [
(TaggedValueChoice::None, VariantMetadata {
name: Cow::Borrowed(stringify!(None)),
label: Cow::Borrowed(stringify!(None)),
name: stringify!(None),
label: stringify!(None),
docstring: None,
icon: None,
}),
(TaggedValueChoice::Percentage, VariantMetadata {
name: Cow::Borrowed(stringify!(Percentage)),
label: Cow::Borrowed(stringify!(Percentage)),
name: stringify!(Percentage),
label: stringify!(Percentage),
docstring: None,
icon: None,
}),
$(
(TaggedValueChoice::$identifier, VariantMetadata {
name: Cow::Borrowed(stringify!($identifier)),
label: Cow::Borrowed(stringify!($identifier)),
name: stringify!($identifier),
label: stringify!($identifier),
docstring: None,
icon: None,
}),