Skip to content

Margin to the node Rect for overlapping pins #247

@TiberiusFaber

Description

@TiberiusFaber

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);

...
}

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions