Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
blueloveTH committed Aug 23, 2023
1 parent 3707907 commit 13be737
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 0 deletions.
16 changes: 16 additions & 0 deletions include/imgui_bindings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,22 @@ struct PyImDrawList: OpaquePointer<ImDrawList>{
self->AddPolyline(pts.data(), pts.size(), ImColor(col), flags, thickness);
return vm->None;
});

vm->bind(type, "AddImageQuad(self, texture: Texture, p1: vec2, p2: vec2, p3: vec2, p4: vec2, uv1: vec2, uv2: vec2, uv3: vec2, uv4: vec2, col: vec4)", [](VM* vm, ArgsView args){
PyImDrawList& self = _CAST(PyImDrawList&, args[0]);
Texture& texture = CAST(Texture&, args[1]);
ImVec2 p1 = py_cast<ImVec2>(vm, args[2]);
ImVec2 p2 = py_cast<ImVec2>(vm, args[3]);
ImVec2 p3 = py_cast<ImVec2>(vm, args[4]);
ImVec2 p4 = py_cast<ImVec2>(vm, args[5]);
ImVec2 uv1 = py_cast<ImVec2>(vm, args[6]);
ImVec2 uv2 = py_cast<ImVec2>(vm, args[7]);
ImVec2 uv3 = py_cast<ImVec2>(vm, args[8]);
ImVec2 uv4 = py_cast<ImVec2>(vm, args[9]);
ImVec4 col = py_cast<ImVec4>(vm, args[10]);
self->AddImageQuad(texture.imgui_id(), p1, p2, p3, p4, uv1, uv2, uv3, uv4, ImColor(col));
return vm->None;
});
}
};

Expand Down
16 changes: 16 additions & 0 deletions include/template/imgui_bindings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,22 @@ struct PyImDrawList: OpaquePointer<ImDrawList>{
self->AddPolyline(pts.data(), pts.size(), ImColor(col), flags, thickness);
return vm->None;
});

vm->bind(type, "AddImageQuad(self, texture: Texture, p1: vec2, p2: vec2, p3: vec2, p4: vec2, uv1: vec2, uv2: vec2, uv3: vec2, uv4: vec2, col: vec4)", [](VM* vm, ArgsView args){
PyImDrawList& self = _CAST(PyImDrawList&, args[0]);
Texture& texture = CAST(Texture&, args[1]);
ImVec2 p1 = py_cast<ImVec2>(vm, args[2]);
ImVec2 p2 = py_cast<ImVec2>(vm, args[3]);
ImVec2 p3 = py_cast<ImVec2>(vm, args[4]);
ImVec2 p4 = py_cast<ImVec2>(vm, args[5]);
ImVec2 uv1 = py_cast<ImVec2>(vm, args[6]);
ImVec2 uv2 = py_cast<ImVec2>(vm, args[7]);
ImVec2 uv3 = py_cast<ImVec2>(vm, args[8]);
ImVec2 uv4 = py_cast<ImVec2>(vm, args[9]);
ImVec4 col = py_cast<ImVec4>(vm, args[10]);
self->AddImageQuad(texture.imgui_id(), p1, p2, p3, p4, uv1, uv2, uv3, uv4, ImColor(col));
return vm->None;
});
}
};

Expand Down
1 change: 1 addition & 0 deletions moc/gen_imgui_pyi.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def AddTriangleFilled(self, p1: vec2, p2: vec2, p3: vec2, col: vec4): ...
def AddCircle(self, center: vec2, radius: float, col: vec4, num_segments: int = 0, thickness: float = 1.0): ...
def AddCircleFilled(self, center: vec2, radius: float, col: vec4, num_segments: int = 0): ...
def AddPolyline(self, points: list[vec2], col: vec4, flags: int = 0, thickness: float = 1.0): ...
def AddImageQuad(self, texture: Texture, p1: vec2, p2: vec2, p3: vec2, p4: vec2, uv1: vec2, uv2: vec2, uv3: vec2, uv4: vec2, col: vec4): ...
''')

# structs
Expand Down
1 change: 1 addition & 0 deletions workdir/ImGui.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class ImDrawList:
def AddCircle(self, center: vec2, radius: float, col: vec4, num_segments: int = 0, thickness: float = 1.0): ...
def AddCircleFilled(self, center: vec2, radius: float, col: vec4, num_segments: int = 0): ...
def AddPolyline(self, points: list[vec2], col: vec4, flags: int = 0, thickness: float = 1.0): ...
def AddImageQuad(self, texture: Texture, p1: vec2, p2: vec2, p3: vec2, p4: vec2, uv1: vec2, uv2: vec2, uv3: vec2, uv4: vec2, col: vec4): ...

class ImDrawData:
Valid: bool # bool
Expand Down

0 comments on commit 13be737

Please sign in to comment.