Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ log = "0.4"
bitflags = { version = "2.4", features = ["serde"] }
ctor = "0.2"
convert_case = "0.8"
titlecase = "3.6"
unicode-segmentation = "1.13.2"
indoc = "2.0.5"
derivative = "2.2"
thiserror = "2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2035,6 +2035,7 @@ fn static_node_properties() -> NodeProperties {
map.insert("selective_color_properties".to_string(), Box::new(node_properties::selective_color_properties));
map.insert("exposure_properties".to_string(), Box::new(node_properties::exposure_properties));
map.insert("math_properties".to_string(), Box::new(node_properties::math_properties));
map.insert("string_capitalization_properties".to_string(), Box::new(node_properties::string_capitalization_properties));
map.insert("rectangle_properties".to_string(), Box::new(node_properties::rectangle_properties));
map.insert("grid_properties".to_string(), Box::new(node_properties::grid_properties));
map.insert("spiral_properties".to_string(), Box::new(node_properties::spiral_properties));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use graph_craft::{Type, concrete};
use graphene_std::NodeInputDecleration;
use graphene_std::animation::RealTimeMode;
use graphene_std::extract_xy::XY;
use graphene_std::logic::StringCapitalization;
use graphene_std::raster::curve::Curve;
use graphene_std::raster::{
BlendMode, CellularDistanceFunction, CellularReturnType, Color, DomainWarpType, FractalType, LuminanceCalculation, NoiseType, RedGreenBlue, RedGreenBlueAlpha, RelativeAbsolute,
Expand Down Expand Up @@ -244,6 +245,7 @@ pub(crate) fn property_from_type(
Some(x) if x == TypeId::of::<RedGreenBlue>() => enum_choice::<RedGreenBlue>().for_socket(default_info).property_row(),
Some(x) if x == TypeId::of::<RedGreenBlueAlpha>() => enum_choice::<RedGreenBlueAlpha>().for_socket(default_info).property_row(),
Some(x) if x == TypeId::of::<XY>() => enum_choice::<XY>().for_socket(default_info).property_row(),
Some(x) if x == TypeId::of::<StringCapitalization>() => enum_choice::<StringCapitalization>().for_socket(default_info).property_row(),
Some(x) if x == TypeId::of::<NoiseType>() => enum_choice::<NoiseType>().for_socket(default_info).property_row(),
Some(x) if x == TypeId::of::<FractalType>() => enum_choice::<FractalType>().for_socket(default_info).disabled(false).property_row(),
Some(x) if x == TypeId::of::<CellularDistanceFunction>() => enum_choice::<CellularDistanceFunction>().for_socket(default_info).disabled(false).property_row(),
Expand Down Expand Up @@ -1588,6 +1590,101 @@ pub(crate) fn exposure_properties(node_id: NodeId, context: &mut NodePropertiesC
vec![LayoutGroup::row(exposure), LayoutGroup::row(offset), LayoutGroup::row(gamma_correction)]
}

pub(crate) fn string_capitalization_properties(node_id: NodeId, context: &mut NodePropertiesContext) -> Vec<LayoutGroup> {
use graphene_std::logic::string_capitalization::*;

// Read the current values before borrowing context mutably for widgets
let (is_simple_case, use_joiner_enabled, joiner_value) = match get_document_node(node_id, context) {
Ok(document_node) => {
let is_simple = matches!(
document_node.inputs.get(CapitalizationInput::INDEX).and_then(|input| input.as_value()),
Some(TaggedValue::StringCapitalization(StringCapitalization::LowerCase | StringCapitalization::UpperCase))
);
let use_joiner = match document_node.inputs.get(UseJoinerInput::INDEX).and_then(|input| input.as_value()) {
Some(&TaggedValue::Bool(x)) => x,
_ => true,
};
let joiner = match document_node.inputs.get(JoinerInput::INDEX).and_then(|input| input.as_non_exposed_value()) {
Some(TaggedValue::String(x)) => Some(x.clone()),
_ => None,
};
(is_simple, use_joiner, joiner)
}
Err(err) => {
log::error!("Could not get document node in string_capitalization_properties: {err}");
return Vec::new();
}
};

// The joiner controls are disabled when lowercase/UPPERCASE are selected (they don't use word boundaries)
let joiner_disabled = is_simple_case || !use_joiner_enabled;

let capitalization = enum_choice::<StringCapitalization>()
.for_socket(ParameterWidgetsInfo::new(node_id, CapitalizationInput::INDEX, true, context))
.property_row();

// Joiner row: the UseJoiner checkbox is drawn in the assist area, followed by the Joiner text input
let mut joiner_widgets = start_widgets(ParameterWidgetsInfo::new(node_id, JoinerInput::INDEX, false, context));
if let Some(joiner) = joiner_value {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: UseJoiner control is conditionally hidden when JoinerInput is exposed, because both controls are gated on joiner_value being non-exposed.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At editor/src/messages/portfolio/document/node_graph/node_properties.rs, line 1628:

<comment>`UseJoiner` control is conditionally hidden when `JoinerInput` is exposed, because both controls are gated on `joiner_value` being non-exposed.</comment>

<file context>
@@ -1588,6 +1590,101 @@ pub(crate) fn exposure_properties(node_id: NodeId, context: &mut NodePropertiesC
+
+	// Joiner row: the UseJoiner checkbox is drawn in the assist area, followed by the Joiner text input
+	let mut joiner_widgets = start_widgets(ParameterWidgetsInfo::new(node_id, JoinerInput::INDEX, false, context));
+	if let Some(joiner) = joiner_value {
+		let joiner_is_empty = joiner.is_empty();
+		joiner_widgets.extend_from_slice(&[
</file context>

let joiner_is_empty = joiner.is_empty();
joiner_widgets.extend_from_slice(&[
Separator::new(SeparatorStyle::Unrelated).widget_instance(),
Separator::new(SeparatorStyle::Related).widget_instance(),
CheckboxInput::new(use_joiner_enabled)
.disabled(is_simple_case)
.on_update(update_value(|x: &CheckboxInput| TaggedValue::Bool(x.checked), node_id, UseJoinerInput::INDEX))
.on_commit(commit_value)
.widget_instance(),
Separator::new(SeparatorStyle::Related).widget_instance(),
Separator::new(SeparatorStyle::Unrelated).widget_instance(),
TextInput::new(joiner)
.placeholder(if joiner_is_empty { "Empty" } else { "" })
.disabled(joiner_disabled)
.on_update(update_value(|x: &TextInput| TaggedValue::String(x.value.clone()), node_id, JoinerInput::INDEX))
.on_commit(commit_value)
.widget_instance(),
]);
}

// Preset buttons for common joiner values, indented to align with the input field
let mut joiner_preset_buttons = vec![TextLabel::new("").widget_instance()];
add_blank_assist(&mut joiner_preset_buttons);
joiner_preset_buttons.push(Separator::new(SeparatorStyle::Unrelated).widget_instance());
for (label, value, tooltip) in [
("Empty", "", "Join words without any separator."),
("Space", " ", "Join words with a space."),
("Kebab", "-", "Join words with a hyphen."),
("Snake", "_", "Join words with an underscore."),
] {
let value = value.to_string();
joiner_preset_buttons.push(
TextButton::new(label)
.tooltip_description(tooltip)
.disabled(is_simple_case)
.on_update(move |_: &TextButton| Message::Batched {
messages: Box::new([
NodeGraphMessage::SetInputValue {
node_id,
input_index: UseJoinerInput::INDEX,
value: TaggedValue::Bool(true),
}
.into(),
NodeGraphMessage::SetInputValue {
node_id,
input_index: JoinerInput::INDEX,
value: TaggedValue::String(value.clone()),
}
.into(),
]),
})
.on_commit(commit_value)
.widget_instance(),
);
}

vec![capitalization, LayoutGroup::row(joiner_widgets), LayoutGroup::row(joiner_preset_buttons)]
}

pub(crate) fn rectangle_properties(node_id: NodeId, context: &mut NodePropertiesContext) -> Vec<LayoutGroup> {
use graphene_std::vector::generator_nodes::rectangle::*;

Expand Down
1 change: 1 addition & 0 deletions node-graph/graph-craft/src/document/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ tagged_value! {
LuminanceCalculation(raster_nodes::adjustments::LuminanceCalculation),
QRCodeErrorCorrectionLevel(vector_nodes::generator_nodes::QRCodeErrorCorrectionLevel),
XY(graphene_core::extract_xy::XY),
StringCapitalization(graphene_core::logic::StringCapitalization),
RedGreenBlue(raster_nodes::adjustments::RedGreenBlue),
RedGreenBlueAlpha(raster_nodes::adjustments::RedGreenBlueAlpha),
RealTimeMode(graphene_core::animation::RealTimeMode),
Expand Down
2 changes: 2 additions & 0 deletions node-graph/interpreted-executor/src/node_registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ fn node_registry() -> HashMap<ProtoNodeIdentifier, HashMap<NodeIOTypes, NodeCons
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => graphene_std::blending::BlendMode]),
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => graphene_std::raster::adjustments::LuminanceCalculation]),
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => graphene_std::extract_xy::XY]),
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => graphene_std::logic::StringCapitalization]),
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => graphene_std::raster::adjustments::RedGreenBlue]),
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => graphene_std::raster::adjustments::RedGreenBlueAlpha]),
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => graphene_std::animation::RealTimeMode]),
Expand Down Expand Up @@ -203,6 +204,7 @@ fn node_registry() -> HashMap<ProtoNodeIdentifier, HashMap<NodeIOTypes, NodeCons
async_node!(graphene_core::memo::MemoNode<_, _>, input: Context, fn_params: [Context => graphene_std::raster::LuminanceCalculation]),
async_node!(graphene_core::memo::MemoNode<_, _>, input: Context, fn_params: [Context => graphene_std::vector::QRCodeErrorCorrectionLevel]),
async_node!(graphene_core::memo::MemoNode<_, _>, input: Context, fn_params: [Context => graphene_std::extract_xy::XY]),
async_node!(graphene_core::memo::MemoNode<_, _>, input: Context, fn_params: [Context => graphene_std::logic::StringCapitalization]),
async_node!(graphene_core::memo::MemoNode<_, _>, input: Context, fn_params: [Context => graphene_std::raster::RedGreenBlue]),
async_node!(graphene_core::memo::MemoNode<_, _>, input: Context, fn_params: [Context => graphene_std::raster::RedGreenBlueAlpha]),
async_node!(graphene_core::memo::MemoNode<_, _>, input: Context, fn_params: [Context => graphene_std::animation::RealTimeMode]),
Expand Down
3 changes: 3 additions & 0 deletions node-graph/nodes/gcore/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ dyn-any = { workspace = true }
glam = { workspace = true }
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: Custom agent: PR title enforcement

PR title does not follow the required "New nodes" dedicated format. Rename it to New nodes: 'Name1', 'Name2', and 'Name3' (with actual node names in single quotes).

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At node-graph/nodes/gcore/Cargo.toml, line 31:

<comment>PR title does not follow the required "New nodes" dedicated format. Rename it to `New nodes: 'Name1', 'Name2', and 'Name3'` (with actual node names in single quotes).</comment>

<file context>
@@ -28,6 +28,9 @@ dyn-any = { workspace = true }
 glam = { workspace = true }
 log = { workspace = true }
 serde_json = { workspace = true }
+convert_case = { workspace = true }
+titlecase = { workspace = true }
+unicode-segmentation = { workspace = true }
</file context>

log = { workspace = true }
serde_json = { workspace = true }
convert_case = { workspace = true }
titlecase = { workspace = true }
unicode-segmentation = { workspace = true }

# Optional workspace dependencies
serde = { workspace = true, optional = true }
Expand Down
Loading
Loading