Code Monkey home page Code Monkey logo

Comments (4)

Nelarius avatar Nelarius commented on June 2, 2024

This is one way of doing it. You need to create a draw list after imnodes::BeginNodeEditor and submit the draw calls (AddRectFilled, etc.) before you start a single node! In this way, all the nodes get rendered after the custom rectangle, and look like they are on top of it.

imnodes::BeginNodeEditor();

ImDrawList* draw_list = ImGui::GetWindowDrawList();
draw_list->AddRectFilled(
    ImVec2(100, 100),
    ImVec2(400, 300),
    IM_COL32(200, 200, 200, 100));

imnodes::BeginNode(1);
imnodes::BeginNodeTitleBar();

// the rest of the node, etc..

image

There is one drawback: you probably need to know the size of the rectangle based on the nodes themselves. But you don't know where the nodes are going to be until you render them! One solution is to render the rectangle based on the nodes of the previous frame, but this means that if the nodes are moved around the rectangle might be a bit laggy.

from imnodes.

ketoo avatar ketoo commented on June 2, 2024

Thanks, this way is a cheap way to meet the goal. About the size of the rect, it's fine as the application has the position of all nodes. The only issue is the rect's position is not the saome coordinate system with imnodes, need to do an extra job to fix this. If imnodes can provide two interfaces as below would be great:

void AddRect(const ImVec2& p_min, const ImVec2& p_max, ImU32 col, float rounding, ImDrawCornerFlags rounding_corners, float thickness);

void AddRectFilled(const ImVec2& p_min, const ImVec2& p_max, ImU32 col, float rounding, ImDrawCornerFlags rounding_corners);

Actually I want to do this job and do a PR, but unfortunately, I can't do this job as I have not understood imnodes's coordinate system very clean.

from imnodes.

Nelarius avatar Nelarius commented on June 2, 2024

I saw you opened the pr for fetching the panning value, I guess that solves the problem for now? 🙂 The pr is also, IMO, a better solution than adding AddRect functions 👍

from imnodes.

ketoo avatar ketoo commented on June 2, 2024

Yes, now meet the goal, thanks for your help!

from imnodes.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.