Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/slimgui/imgui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,12 @@ def get_foreground_draw_list() -> DrawList:
assert ctx is not None
return ctx._wrap_drawlist(ctx.context.get_foreground_draw_list_internal())

def get_platform_ime_data() -> imgui_ext.PlatformImeData:
'''Access the ImGui `PlatformImeData` structure. This structure holds data to support IME (Input Method Editor).'''
ctx = get_current_context()
assert ctx is not None
return ctx.context.get_platform_ime_data_internal()

def get_window_draw_list() -> DrawList:
'''Get draw list associated to the current window, to append your own drawing primitives.'''
ctx = get_current_context()
Expand Down
18 changes: 18 additions & 0 deletions src/slimgui/slimgui_ext/imgui.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -903,6 +903,22 @@ class PlatformIO:
@property
def textures(self) -> Iterator[TextureData]: ...

class PlatformImeData:
@property
def want_visible(self) -> bool: ...

@property
def want_text_input(self) -> bool: ...

@property
def input_pos(self) -> tuple[float, float]: ...

@property
def input_line_height(self) -> float: ...

@property
def viewport_id(self) -> int: ...

class TextureRect:
@property
def x(self) -> int:
Expand Down Expand Up @@ -3353,6 +3369,8 @@ class Context:

def get_foreground_draw_list_internal(self) -> DrawList: ...

def get_platform_ime_data_internal(self) -> PlatformImeData: ...

def get_window_draw_list_internal(self) -> DrawList: ...

def accept_drag_drop_payload_internal(self, type: str, flags: DragDropFlags = DragDropFlags.NONE) -> Payload | None: ...
Expand Down
13 changes: 13 additions & 0 deletions src/slimgui_ext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,13 @@ NB_MODULE(slimgui_ext, top) {
return nb::make_iterator(nb::type<ImGuiPlatformIO>(), "iterator", plat_io->Textures.begin(), plat_io->Textures.end());
}, nb::keep_alive<0, 1>());

nb::class_<ImGuiPlatformImeData>(m, "PlatformImeData")
.def_ro("want_visible", &ImGuiPlatformImeData::WantVisible)
.def_ro("want_text_input", &ImGuiPlatformImeData::WantTextInput)
.def_ro("input_pos", &ImGuiPlatformImeData::InputPos)
.def_ro("input_line_height", &ImGuiPlatformImeData::InputLineHeight)
.def_ro("viewport_id", &ImGuiPlatformImeData::ViewportId);

nb::class_<ImTextureRect>(m, "TextureRect")
.def_ro("x", &ImTextureRect::x, "Upper-left x-coordinate of rectangle to update")
.def_ro("y", &ImTextureRect::y, "Upper-left y-coordinate of rectangle to update")
Expand Down Expand Up @@ -724,6 +731,12 @@ NB_MODULE(slimgui_ext, top) {
ImGui::SetCurrentContext(prev);
return drawList;
}, nb::rv_policy::reference)
.def("get_platform_ime_data_internal", [](Context* ctx) -> ImGuiPlatformImeData* {
auto prev = ctx->setCurrent();
ImGuiPlatformImeData* ime_data = &ctx->ctx->PlatformImeData;
ImGui::SetCurrentContext(prev);
return ime_data;
}, nb::rv_policy::reference)
.def("get_window_draw_list_internal", [](Context* ctx) -> ImDrawList* {
auto prev = ctx->setCurrent();
ImDrawList* drawList = ImGui::GetWindowDrawList();
Expand Down