Skip to content

Commit

Permalink
✨ [Nodes] Show description of inputs next to the pin
Browse files Browse the repository at this point in the history
  • Loading branch information
JulesFouchy committed Mar 18, 2024
1 parent 6300369 commit e251d78
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 7 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

- ✨ The slider for some parameters (Zoom, Time Speed, etc.) now behaves logarithmically, meaning it will have equal precision in the 0-1 range as in 1-∞. Basically this means they are more practical to use.
- ✨ When using a Drag widget, the mouse position now stays locked in place instead of wrapping around the screen.
- ✨ Some node inputs now have a little info icon next to their pin, explaining what the parameter does in more details.
- 🐛 Remove incompatible link when creating a link backward from a pin

## 🐣beta-15
Expand Down
1 change: 1 addition & 0 deletions src/Nodes/NodeInputDefinition.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class NodeInputDefinition {
NodeInputDefinition(NodeInputDefinition_Data const&);

auto name() const -> auto const& { return _data.name; }
auto description() const -> auto const& { return _data.description; }
auto signature() const -> auto const& { return _data.signature; }
void set_description(std::string const& description) { _data.description = description; }

Expand Down
10 changes: 5 additions & 5 deletions src/Nodes/NodesConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -410,13 +410,13 @@ static auto make_node(Cool::NodeDefinitionAndCategoryName const& cat_id, Cool::G
{
for (size_t i = 0; i < def.signature().arity; ++i)
{
node.input_pins().push_back(Cool::InputPin{/*pin_name=*/Cool::String::replace_all(def.main_function().argument_names[i], "_", " ")});
node.input_pins().push_back(Cool::InputPin{/*pin_name=*/Cool::String::replace_all(def.main_function().argument_names[i], "_", " "), ""});
}
}
node.output_pins().emplace_back("OUT");
node.output_pins().emplace_back("OUT", "");

for (auto const& function_input : def.function_inputs())
node.input_pins().push_back(Cool::InputPin{function_input.name()});
node.input_pins().push_back(Cool::InputPin{function_input.name(), function_input.description()});

for (auto const& value_input_def : def.value_inputs())
{
Expand All @@ -429,7 +429,7 @@ static auto make_node(Cool::NodeDefinitionAndCategoryName const& cat_id, Cool::G
}; },
value_input_def
));
node.input_pins().push_back(Cool::InputPin{std::visit([](auto&& value_input_def) { return value_input_def.var_data.name; }, value_input_def)});
node.input_pins().push_back(std::visit([](auto&& value_input_def) { return Cool::InputPin{value_input_def.var_data.name, value_input_def.description.value_or("")}; }, value_input_def));
}

// Get the variables from the inputs
Expand All @@ -440,7 +440,7 @@ static auto make_node(Cool::NodeDefinitionAndCategoryName const& cat_id, Cool::G
apply_settings_to_inputs_no_history(settings, node.value_inputs(), to_string(node));

for (auto const& output_index_name : def.output_indices())
node.output_pins().push_back(Cool::OutputPin{output_index_name});
node.output_pins().push_back(Cool::OutputPin{output_index_name, ""});

return node;
}
Expand Down
13 changes: 12 additions & 1 deletion website/content/Tutorials/30-Writing Nodes/20-Inputs.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,15 @@ To declare a function that takes multiple inputs, here is the syntax:
INPUT (Oklab_PremultipliedA, Oklab_PremultipliedA)->Oklab_PremultipliedA 'Blend Mode';
```

All the possible types for function inputs are the same as for the `main` function (see the [Primitive Types section](10-Primitive%20types.md)).
All the possible types for function inputs are the same as for the `main` function (see the [Primitive Types section](10-Primitive%20types.md)).

## Descriptions

You can add a description to your inputs, by using a comment with **3 slashes (`///`)** :

```glsl
INPUT float 'Progression'; /// When set to 0 you get Curve 1; when set to 1 you get Curve 2.
```

This will add a "<span class="icon-info"></span>" next to the pin, that will show your description when hovered.
![Description](img/description.png)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit e251d78

Please sign in to comment.