Giter Club home page Giter Club logo

Comments (4)

ocornut avatar ocornut commented on May 25, 2024

ButtonBehavior() doesn't support non-rectangular hit testing yet (see #1512) however you could technically have one invisible button covering your whole menu and then perform the geometrical hit testing yourself. See #434 for a pie menu similar to your example.

from imgui.

ocornut avatar ocornut commented on May 25, 2024

Basically you would submit an InvisibleButton() and perform the hit-testing yourself. Since you are doing all the rendering anyhow it doesn't be difficult.

from imgui.

crazydef avatar crazydef commented on May 25, 2024

Yeah, that's an idea. Not quite as simple as it sounds, as I have a layout engine that controls ImGui, but I can probably figure something out with a custom widget for the window in question.

Cheers.

from imgui.

GamingMinds-DanielC avatar GamingMinds-DanielC commented on May 25, 2024

If combining the buttons into one is a problem, you can use multiple buttons as well. You will need to backup a few internals (see ImGui::SetHoveredID() implementation, save everything that is modified in there), then submit an invisible button with the bounding box of your shape and use its hover status as a starting point (filters out foreground windows and other popups), then refine by testing for your custom shape as well. If your hit test passes, you can return the result of the invisible button. If your hit test fails, restore the hover status from before submitting the button. If you wrap this into a helper function (f.e. InvisibleButtonShaped(...)) and use that as a base for individual shaped buttons.

This should already be fine for mouse interaction. If you want advanced functionality for your buttons (like using them as drop targets or having keyboard/gamepad navigation with highlights in the proper shape) it gets more complicated.

from imgui.

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.