Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PinPivotRect isn't applied when the link is drawn with an arrow #167

Closed
gnif opened this issue Jul 10, 2022 · 1 comment
Closed

PinPivotRect isn't applied when the link is drawn with an arrow #167

gnif opened this issue Jul 10, 2022 · 1 comment
Assignees

Comments

@gnif
Copy link

gnif commented Jul 10, 2022

I am attempting to draw all the input arrows on top of each other, providing a perfect overlap so only one arrow is seen.

Without arrows this works fine:
2022-07-10-191134_371x253_scrot

With the arrows it does not:
2022-07-10-191222_284x223_scrot

To set the pivot point I am using the following code

ImVec2 min = ImGui::GetItemRectMin(); 
ImVec2 max = ImGui::GetItemRectMax(); 
ImVec2 pos =
{
  kind == ed::PinKind::Input ? min.x - 9.0f : max.x + 9.0f,
  min.y + (max.y - min.y) / 2.0f
};
ed::PinPivotRect(pos, pos);
@thedmd
Copy link
Owner

thedmd commented Aug 21, 2022

You can now request link origin to be snapped to pin direction by setting style variable:

ed::PushStyleVar(ed::StyleVar_SnapLinkToPinDir, 1);

By default links are links origins are closest points between pins, this variable change that.

image

You can recreate example above using this patch:

 examples/blueprints-example/blueprints-example.cpp | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/examples/blueprints-example/blueprints-example.cpp b/examples/blueprints-example/blueprints-example.cpp
index c14c2e3..7826d9a 100644
--- a/examples/blueprints-example/blueprints-example.cpp
+++ b/examples/blueprints-example/blueprints-example.cpp
@@ -917,6 +917,8 @@ struct Example:
 
             util::BlueprintNodeBuilder builder(m_HeaderBackground, GetTextureWidth(m_HeaderBackground), GetTextureHeight(m_HeaderBackground));
 
+            ed::PushStyleVar(ed::StyleVar_PinRadius, 10.0f);
+            ed::PushStyleVar(ed::StyleVar_SnapLinkToPinDir, 1);
             for (auto& node : m_Nodes)
             {
                 if (node.Type != NodeType::Blueprint && node.Type != NodeType::Simple)
@@ -977,6 +979,8 @@ struct Example:
                         builder.EndHeader();
                     }
 
+                    ed::PushStyleVar(ed::StyleVar_PinArrowSize, 10.0f);
+                    ed::PushStyleVar(ed::StyleVar_PinArrowWidth, 10.0f);
                     for (auto& input : node.Inputs)
                     {
                         auto alpha = ImGui::GetStyle().Alpha;
@@ -1000,6 +1004,7 @@ struct Example:
                         ImGui::PopStyleVar();
                         builder.EndInput();
                     }
+                    ed::PopStyleVar(2);
 
                     if (isSimple)
                     {
@@ -1054,6 +1059,7 @@ struct Example:
 
                 builder.End();
             }
+            ed::PopStyleVar(2);
 
             for (auto& node : m_Nodes)
             {

@thedmd thedmd closed this as completed Aug 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants