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

Margin to the node Rect for overlapping pins #247

Open
TiberiusFaber opened this issue Jul 27, 2023 · 2 comments
Open

Margin to the node Rect for overlapping pins #247

TiberiusFaber opened this issue Jul 27, 2023 · 2 comments

Comments

@TiberiusFaber
Copy link

We would need to apply margins to the node Rect in order to display the pins overlapping on the node itself. Outer pins could be drawn by applying horizontal and vertical layout, but these methods don't allow overlap. We have managed to find a workaround to the left most pins by adding padding, that seems to modify the position of the background node rect, but the right pins will always be either inside the node, or fall out of it. To achieve what we need it would be good to have a margin property, that could shrink the node and its borders by a given amount so we would have the desired visual results.

void ed::Node::Draw(ImDrawList* drawList, DrawFlags flags)
{
    auto& editorStyle = Editor->GetStyle();
    ImRect margin = editorStyle.NodeMargin;
    const ImRect bounds = ImRect(
        m_Bounds.Min.x + margin.Min.x,
        m_Bounds.Min.y + margin.Min.y,
        m_Bounds.Max.x - margin.Max.x,
        m_Bounds.Max.y - margin.Max.y
    );

...
        drawList->AddRectFilled(
            bounds.Min,
            bounds.Max,
            m_Color, 
            m_Rounding);

...
 DrawBorder(drawList, bounds, m_BorderColor, m_BorderWidth);

...
}
@TiberiusFaber
Copy link
Author

With this code we can have the desired result as you can see in the next gif:
widgets-example_d_qHoZwKGuBY

@thedmd
Copy link
Owner

thedmd commented Sep 1, 2023

Do I understand correctly that you want to use BeginHorizontal/Vertical to layout pins on the edge of the node?

For this case margin sound like good enhancement.

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