GithubHelp home page GithubHelp logo

Comments (4)

pthom avatar pthom commented on June 3, 2024 1

@hugle: This example is different. Here you are trying to edit a list of float.
In the ImGui code, the declaration is as below:

bool ImGui::DragFloat4(const char* label, float v[4], float v_speed, float v_min, float v_max, const char* format, ImGuiSliderFlags flags)

It is true that in some cases you can see C++ code like this

ImGui::DragFloat4(const char* label, &someImVec4Value)

However, this uses the fact that the memory layout of ImVec4 and float[4] happens to be the same in C and C++. There is no such thing in Python, and IMHO this is for the better

from imgui_bundle.

hugle avatar hugle commented on June 3, 2024

I use get_style() and has no problem, but you will need to set x, y, z, w one by one in python as no API binding for python for direct assignment:

padding_list = [1.0,1.0,1.0,1.0]
style = ed.get_style()
style.node_padding.x = padding_list[0]
style.node_padding.y = padding_list[1]
style.node_padding.z = padding_list[2]
style.node_padding.w = padding_list[3]

from imgui_bundle.

pthom avatar pthom commented on June 3, 2024

Hello,

node_padding is a ImVec4, thus you should use

    ed.push_style_var(ed.StyleVar.node_padding, ImVec4(1, 1, 1, 1))

or

    style = ed.get_style()
    style.node_padding = ImVec4(8, 8, 8, 8)

from imgui_bundle.

hugle avatar hugle commented on June 3, 2024

Thanks @pthom , if ImVec4 is prefered. I would recommend update some of the imgui API (example below) from List[float] to ImVec4. Otherwise conversion between them is required, that would be redundant:

def drag_float4(
label: str,
v: List[float],
v_speed: float = 1.0,
v_min: float = 0.0,
v_max: float = 0.0,
format: str = "%.3",
flags: SliderFlags = 0,
) -> Tuple[bool, List[float]]:
pass

from imgui_bundle.

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.