immapp_cpp.pyi 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572
  1. """ImmApp: Immediate App Toolkit for ImGui Bundle"""
  2. ###############################################################################
  3. # This file is a part of Dear ImGui Bundle
  4. # -----------------------------------------------------------------------------
  5. # ImmApp is an Immediate App Toolkit for ImGui Bundle.
  6. #
  7. # It is automatically generated (using https://pthom.github.io/litgen/),
  8. # and is generally very close to the C++ version. Comments, docs are identical.
  9. ###############################################################################
  10. # ruff: noqa: B008, F821
  11. from typing import Tuple, Optional, Callable, List, overload, Any
  12. import enum
  13. from imgui_bundle import imgui_md, hello_imgui, ImVec2, ImVec2Like
  14. from imgui_bundle.imgui_node_editor import (
  15. Config as NodeEditorConfig,
  16. EditorContext as NodeEditorContext,
  17. )
  18. ImPlotFlags = int # see implot.Flags_
  19. ImGuiMd = imgui_md
  20. HelloImGui = hello_imgui
  21. VoidFunction = Callable[[], Any]
  22. ScreenSize = Tuple[int, int]
  23. DefaultScreenSize = (800, 600)
  24. # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! AUTOGENERATED CODE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  25. # <litgen_stub> // Autogenerated code below! Do not edit!
  26. #################### <generated_from:immapp.h> ####################
  27. #################### </generated_from:immapp.h> ####################
  28. #################### <generated_from:immapp_widgets.h> ####################
  29. # #ifdef IMGUI_BUNDLE_WITH_IMPLOT_AND_IMGUI_NODE_EDITOR
  30. #
  31. # These functions wrap ImPlot::BeginPlot and ImPlot::EndPlot,
  32. # but they enable to make the plot content draggable inside a node
  33. def begin_plot_in_node_editor(
  34. title_id: str, size: Optional[ImVec2Like] = None, flags: ImPlotFlags = 0
  35. ) -> bool:
  36. """Python bindings defaults:
  37. If size is None, then its default value will be: ImVec2(-1,0)
  38. """
  39. pass
  40. def end_plot_in_node_editor() -> None:
  41. pass
  42. def show_resizable_plot_in_node_editor(
  43. title_id: str,
  44. size_pixels: ImVec2Like,
  45. plot_function: VoidFunction,
  46. flags: ImPlotFlags = 0,
  47. resize_handle_size_em: float = 1.0,
  48. ) -> ImVec2:
  49. """ShowResizablePlotInNodeEditor: shows a resizable plot inside a node
  50. Returns the new size of the plot
  51. """
  52. pass
  53. def show_resizable_plot_in_node_editor_em(
  54. title_id: str,
  55. size_em: ImVec2Like,
  56. plot_function: VoidFunction,
  57. flags: ImPlotFlags = 0,
  58. resize_handle_size_em: float = 1.0,
  59. ) -> ImVec2:
  60. """ShowResizablePlotInNodeEditor_Em: shows a resizable plot inside a node
  61. Returns the new size of the plot. Units are in em.
  62. """
  63. pass
  64. # #endif
  65. # #ifdef IMGUI_BUNDLE_WITH_IMGUI_NODE_EDITOR
  66. #
  67. def widget_with_resize_handle_in_node_editor(
  68. id: str, gui_function: VoidFunction, resize_handle_size_em: float = 1.0
  69. ) -> ImVec2:
  70. """WidgetWithResizeHandle_InNodeEditor: shows a resizable widget inside a node
  71. Returns the new size of the widget.
  72. """
  73. pass
  74. def widget_with_resize_handle_in_node_editor_em(
  75. id: str, gui_function: VoidFunction, resize_handle_size_em: float = 1.0
  76. ) -> ImVec2:
  77. """WidgetWithResizeHandle_InNodeEditor_Em: shows a resizable widget inside a node
  78. Returns the new size of the widget. Size is in em.
  79. """
  80. pass
  81. # #endif
  82. #################### </generated_from:immapp_widgets.h> ####################
  83. #################### <generated_from:runner.h> ####################
  84. # #ifdef IMGUI_BUNDLE_WITH_IMGUI_NODE_EDITOR
  85. #
  86. # #endif
  87. #
  88. # #ifdef IMGUI_BUNDLE_WITH_IMGUI_NODE_EDITOR
  89. #
  90. # #endif
  91. #
  92. class AddOnsParams:
  93. """///////////////////////////////////////////////////////////////////////////////////////
  94. AddOnParams: require specific ImGuiBundle packages (markdown, node editor, texture viewer)
  95. to be initialized at startup.
  96. /////////////////////////////////////////////////////////////////////////////////////
  97. """
  98. # Set withImplot=True if you need to plot graphs with implot
  99. with_implot: bool = False
  100. # Set withImplot3=True if you need to plot 3 graphs with implot3
  101. with_implot3d: bool = False
  102. # Set withMarkdown=True if you need to render Markdown
  103. # (alternatively, you can set withMarkdownOptions)
  104. with_markdown: bool = False
  105. # Set withNodeEditor=True if you need to render a node editor
  106. # (alternatively, you can set withNodeEditorConfig)
  107. with_node_editor: bool = False
  108. # Set withTexInspect=True if you need to use imgui_tex_inspect
  109. with_tex_inspect: bool = False
  110. # Set withImAnim=True if you need to use ImAnim.
  111. # If True, then iam_update_begin_frame() and iam_clip_update() will be called automatically at each frame
  112. with_im_anim: bool = False
  113. # Set withLatex=True to enable native LaTeX math rendering in markdown
  114. # (via MicroTeX). Implies withMarkdown=True. The $...$ and $$...$$
  115. # syntaxes will be parsed as inline / display math formulas.
  116. # Requires building with IMGUI_BUNDLE_WITH_MICROTEX=ON (default when FreeType is available).
  117. with_latex: bool = False
  118. # #ifdef IMGUI_BUNDLE_WITH_IMGUI_NODE_EDITOR
  119. #
  120. # You can tweak NodeEditorConfig (but this is optional)
  121. with_node_editor_config: Optional[NodeEditorConfig] = None
  122. # If True, the node editor colors will be updated from the ImGui colors
  123. # (i.e. if using a light theme, the node editor will use a light theme, etc.)
  124. # This is called after runnerParams.callbacks.SetupImGuiStyle, in which you can set the ImGui style.
  125. # If you set this to False, you can set the node editor style manually.
  126. # (Note: you can also the theme via RunnerParams.imguiParams.tweakedTheme)
  127. update_node_editor_colors_from_imgui_colors: bool = True
  128. # #endif
  129. #
  130. # You can tweak MarkdownOptions (but this is optional)
  131. with_markdown_options: Optional[ImGuiMd.MarkdownOptions] = None
  132. def __init__(
  133. self,
  134. with_implot: bool = False,
  135. with_implot3d: bool = False,
  136. with_markdown: bool = False,
  137. with_node_editor: bool = False,
  138. with_tex_inspect: bool = False,
  139. with_im_anim: bool = False,
  140. with_latex: bool = False,
  141. with_node_editor_config: Optional[NodeEditorConfig] = None,
  142. update_node_editor_colors_from_imgui_colors: bool = True,
  143. with_markdown_options: Optional[ImGuiMd.MarkdownOptions] = None,
  144. ) -> None:
  145. """Auto-generated default constructor with named params"""
  146. pass
  147. # ///////////////////////////////////////////////////////////////////////////////////////
  148. #
  149. # Helpers to run an app from C++
  150. #
  151. # /////////////////////////////////////////////////////////////////////////////////////
  152. # Run an application using HelloImGui params + some addons
  153. @overload
  154. def run(
  155. runner_params: HelloImGui.RunnerParams,
  156. add_ons_params: Optional[AddOnsParams] = None,
  157. ) -> None:
  158. """Python bindings defaults:
  159. If addOnsParams is None, then its default value will be: AddOnsParams()
  160. """
  161. pass
  162. @overload
  163. def run(
  164. simple_params: HelloImGui.SimpleRunnerParams,
  165. add_ons_params: Optional[AddOnsParams] = None,
  166. ) -> None:
  167. """Python bindings defaults:
  168. If addOnsParams is None, then its default value will be: AddOnsParams()
  169. """
  170. pass
  171. @overload
  172. def run(
  173. gui_function: VoidFunction,
  174. window_title: str = "",
  175. window_size_auto: bool = False,
  176. window_restore_previous_geometry: bool = False,
  177. window_size: Optional[ScreenSize] = None,
  178. fps_idle: float = 10.0,
  179. top_most: bool = False,
  180. ini_disable: bool = False,
  181. with_implot: bool = False,
  182. with_implot3d: bool = False,
  183. with_markdown: bool = False,
  184. with_node_editor: bool = False,
  185. with_tex_inspect: bool = False,
  186. with_im_anim: bool = False,
  187. with_latex: bool = False,
  188. with_node_editor_config: Optional[NodeEditorConfig] = None,
  189. with_markdown_options: Optional[ImGuiMd.MarkdownOptions] = None,
  190. ) -> None:
  191. """///////////////////////////////////////////////////////////////////////////////////////
  192. Helpers to run an app from Python (using named parameters)
  193. /////////////////////////////////////////////////////////////////////////////////////
  194. Helper to run an app inside imgui_bundle, using HelloImGui:
  195. (HelloImGui::SimpleRunnerParams)
  196. - `guiFunction`: the function that will render the ImGui widgets
  197. - `windowTitle`: title of the window
  198. - `windowSizeAuto`: if True, autosize the window from its inner widgets
  199. - `windowRestorePreviousGeometry`: if True, restore window size and position from last run
  200. - `windowSize`: size of the window
  201. - `fpsIdle`: fps of the application when idle
  202. (ImmApp::AddOnsParams)
  203. - `with_implot`: if True, then a context for implot will be created/destroyed automatically
  204. - `with_markdown` / `with_markdown_options`: if specified, then the markdown context will be initialized
  205. (i.e. required fonts will be loaded)
  206. - `with_latex`: if True, enable native LaTeX math rendering in markdown (implies with_markdown)
  207. - `with_node_editor` / `with_node_editor_config`: if specified, then a context for imgui_node_editor
  208. will be created automatically.
  209. Python bindings defaults:
  210. If windowSize is None, then its default value will be: DefaultWindowSize
  211. """
  212. pass
  213. def run_with_markdown(
  214. gui_function: VoidFunction,
  215. window_title: str = "",
  216. window_size_auto: bool = False,
  217. window_restore_previous_geometry: bool = False,
  218. window_size: Optional[ScreenSize] = None,
  219. fps_idle: float = 10.0,
  220. top_most: bool = False,
  221. ini_disable: bool = False,
  222. with_implot: bool = False,
  223. with_implot3d: bool = False,
  224. with_node_editor: bool = False,
  225. with_tex_inspect: bool = False,
  226. with_im_anim: bool = False,
  227. with_latex: bool = False,
  228. with_node_editor_config: Optional[NodeEditorConfig] = None,
  229. with_markdown_options: Optional[ImGuiMd.MarkdownOptions] = None,
  230. ) -> None:
  231. """Run an application with markdown
  232. Python bindings defaults:
  233. If windowSize is None, then its default value will be: DefaultWindowSize
  234. """
  235. pass
  236. # ///////////////////////////////////////////////////////////////////////////////////////
  237. #
  238. # Dpi aware utilities (which call the same utilities from HelloImGui)
  239. #
  240. # /////////////////////////////////////////////////////////////////////////////////////
  241. @overload
  242. def em_size() -> float:
  243. """EmSize() returns the visible font size on the screen. For good results on HighDPI screens, always scale your
  244. widgets and windows relatively to this size.
  245. It is somewhat comparable to the [em CSS Unit](https://lyty.dev/css/css-unit.html).
  246. EmSize() = ImGui::GetFontSize()
  247. """
  248. pass
  249. @overload
  250. def em_size(nb_lines: float) -> float:
  251. """EmSize(nbLines) returns a size corresponding to nbLines text lines"""
  252. pass
  253. # EmToVec2() returns an ImVec2 that you can use to size or place your widgets in a DPI independent way
  254. # (pass sizes that are proportional to the font height)
  255. @overload
  256. def em_to_vec2(x: float, y: float) -> ImVec2:
  257. pass
  258. @overload
  259. def em_to_vec2(v: ImVec2Like) -> ImVec2:
  260. pass
  261. def pixels_to_em(pixels: ImVec2Like) -> ImVec2:
  262. """PixelsToEm() converts a Vec2 in pixels to a Vec2 in em"""
  263. pass
  264. def pixel_size_to_em(pixel_size: float) -> float:
  265. """PixelSizeToEm() converts a size in pixels to a size in em"""
  266. pass
  267. # ///////////////////////////////////////////////////////////////////////////////////////
  268. #
  269. # Utility for ImGui node editor & NanoVG
  270. #
  271. # /////////////////////////////////////////////////////////////////////////////////////
  272. # #ifdef IMGUI_BUNDLE_WITH_IMGUI_NODE_EDITOR
  273. #
  274. def default_node_editor_context() -> NodeEditorContext:
  275. pass
  276. def default_node_editor_config() -> NodeEditorConfig:
  277. pass
  278. def node_editor_settings_location(runner_params: HelloImGui.RunnerParams) -> str:
  279. """NodeEditorSettingsLocation returns the path to the json file for the node editor settings."""
  280. pass
  281. def has_node_editor_settings(runner_params: HelloImGui.RunnerParams) -> bool:
  282. """HasNodeEditorSettings returns True if the json file for the node editor settings exists."""
  283. pass
  284. def delete_node_editor_settings(runner_params: HelloImGui.RunnerParams) -> None:
  285. """DeleteNodeEditorSettings deletes the json file for the node editor settings."""
  286. pass
  287. # #endif
  288. #
  289. # =========================== HelloImGui::ManualRender ==================================
  290. # @@md#HelloImGui::ManualRender
  291. # @@md
  292. # <submodule manual_render>
  293. class manual_render: # Proxy class that introduces typings for the *submodule* manual_render
  294. pass # (This corresponds to a C++ namespace. All methods are static!)
  295. """ namespace ManualRender"""
  296. # Immapp::ManualRender is a namespace that groups functions, allowing fine-grained control over the rendering process:
  297. # - It is customizable like Immapp::Run: initialize it with `RunnerParams` and `AddOnsParams`.
  298. # - `ManualRender::Render()` will render the application for one frame:
  299. # - Ensure that `ManualRender::Render()` is triggered regularly (e.g., through a loop or other mechanism)
  300. # to maintain responsiveness. This method must be called on the main thread.
  301. @staticmethod
  302. def setup_from_runner_params(
  303. runner_params: HelloImGui.RunnerParams,
  304. add_ons_params: Optional[AddOnsParams] = None,
  305. ) -> None:
  306. """Initializes the rendering with the full customizable `RunnerParams`.
  307. This will initialize the platform backend (SDL, Glfw, etc.) and the rendering backend (OpenGL, Vulkan, etc.).
  308. A reference to the user's `RunnerParams` is kept internally (similar to ImmApp::Run).
  309. Python bindings defaults:
  310. If addOnsParams is None, then its default value will be: AddOnsParams()
  311. """
  312. pass
  313. @staticmethod
  314. def setup_from_simple_runner_params(
  315. simple_params: HelloImGui.SimpleRunnerParams,
  316. add_ons_params: Optional[AddOnsParams] = None,
  317. ) -> None:
  318. """Initializes the rendering with `SimpleRunnerParams`.
  319. This will initialize the platform backend (SDL, Glfw, etc.) and the rendering backend (OpenGL, Vulkan, etc.).
  320. Python bindings defaults:
  321. If addOnsParams is None, then its default value will be: AddOnsParams()
  322. """
  323. pass
  324. @staticmethod
  325. def setup_from_gui_function(
  326. gui_function: VoidFunction,
  327. window_title: str = "",
  328. window_size_auto: bool = False,
  329. window_restore_previous_geometry: bool = False,
  330. window_size: Optional[ScreenSize] = None,
  331. fps_idle: float = 10.0,
  332. top_most: bool = False,
  333. ini_disable: bool = False,
  334. with_implot: bool = False,
  335. with_implot3d: bool = False,
  336. with_markdown: bool = False,
  337. with_node_editor: bool = False,
  338. with_tex_inspect: bool = False,
  339. with_latex: bool = False,
  340. with_node_editor_config: Optional[NodeEditorConfig] = None,
  341. with_markdown_options: Optional[ImGuiMd.MarkdownOptions] = None,
  342. ) -> None:
  343. """Initializes the renderer with a simple GUI function and additional parameters.
  344. This will initialize the platform backend (SDL, Glfw, etc.) and the rendering backend (OpenGL, Vulkan, etc.).
  345. Python bindings defaults:
  346. If windowSize is None, then its default value will be: DefaultWindowSize
  347. """
  348. pass
  349. @staticmethod
  350. def render() -> None:
  351. """Renders the current frame. Should be called regularly to maintain the application's responsiveness."""
  352. pass
  353. @staticmethod
  354. def tear_down() -> None:
  355. """Tears down the renderer and releases all associated resources.
  356. This will release the platform backend (SDL, Glfw, etc.) and the rendering backend (OpenGL, Vulkan, etc.).
  357. After calling `TearDown()`, the InitFromXXX can be called with new parameters.
  358. """
  359. pass
  360. # </submodule manual_render>
  361. #################### </generated_from:runner.h> ####################
  362. #################### <generated_from:clock.h> ####################
  363. def clock_seconds() -> float:
  364. """Chronometer in seconds"""
  365. pass
  366. #################### </generated_from:clock.h> ####################
  367. #################### <generated_from:code_utils.h> ####################
  368. # <submodule code_utils>
  369. class code_utils: # Proxy class that introduces typings for the *submodule* code_utils
  370. pass # (This corresponds to a C++ namespace. All methods are static!)
  371. """ namespace CodeUtils"""
  372. @staticmethod
  373. def unindent(code: str, is_markdown: bool) -> str:
  374. pass
  375. @staticmethod
  376. def unindent_code(code: str) -> str:
  377. pass
  378. @staticmethod
  379. def unindent_markdown(code: str) -> str:
  380. pass
  381. # </submodule code_utils>
  382. #################### </generated_from:code_utils.h> ####################
  383. #################### <generated_from:snippets.h> ####################
  384. # <submodule snippets>
  385. class snippets: # Proxy class that introduces typings for the *submodule* snippets
  386. pass # (This corresponds to a C++ namespace. All methods are static!)
  387. #
  388. # TextEditorBundle: addition to ImGuiColorTextEdit, specific to ImGuiBundle
  389. #
  390. class SnippetLanguage(enum.IntEnum):
  391. cpp = enum.auto() # (= 0)
  392. hlsl = enum.auto() # (= 1)
  393. glsl = enum.auto() # (= 2)
  394. c = enum.auto() # (= 3)
  395. sql = enum.auto() # (= 4)
  396. angel_script = enum.auto() # (= 5)
  397. lua = enum.auto() # (= 6)
  398. python = enum.auto() # (= 7)
  399. class SnippetTheme(enum.IntEnum):
  400. auto = enum.auto() # (= 0) # Automatic based on bg color
  401. dark = enum.auto() # (= 1)
  402. light = enum.auto() # (= 2)
  403. @staticmethod
  404. def default_snippet_language() -> SnippetLanguage:
  405. """DefaultSnippetLanguage will be Cpp or Python if using python bindings."""
  406. pass
  407. class SnippetData:
  408. code: str = ""
  409. language: snippets.SnippetLanguage = snippets.default_snippet_language()
  410. palette: snippets.SnippetTheme = snippets.SnippetTheme.auto
  411. show_copy_button: bool = (
  412. True # Displayed on top of the editor (Top Right corner)
  413. )
  414. show_cursor_position: bool = True # Show line and column number
  415. displayed_filename: str = "" # Displayed on top of the editor
  416. height_in_lines: int = 0 # Number of visible lines in the editor
  417. max_height_in_lines: int = (
  418. 40 # If the number of lines in the code exceeds this, the editor will scroll. Set to 0 to disable.
  419. )
  420. read_only: bool = False # Snippets are read-only by default
  421. border: bool = False # Draw a border around the editor
  422. de_indent_code: bool = (
  423. True # Keep the code indentation, but remove main indentation,
  424. )
  425. # so that the displayed code start at column 1
  426. add_final_empty_line: bool = (
  427. False # Add an empty line at the end of the code if missing
  428. )
  429. def __init__(
  430. self,
  431. code: str = "",
  432. language: snippets.SnippetLanguage = snippets.default_snippet_language(),
  433. palette: snippets.SnippetTheme = snippets.SnippetTheme.auto,
  434. show_copy_button: bool = True,
  435. show_cursor_position: bool = True,
  436. displayed_filename: str = "",
  437. height_in_lines: int = 0,
  438. max_height_in_lines: int = 40,
  439. read_only: bool = False,
  440. border: bool = False,
  441. de_indent_code: bool = True,
  442. add_final_empty_line: bool = False,
  443. ) -> None:
  444. """Auto-generated default constructor with named params"""
  445. pass
  446. @staticmethod
  447. def show_editable_code_snippet(
  448. label_id: str,
  449. snippet_data: SnippetData,
  450. width: float = 0.0,
  451. override_height_in_lines: int = 0,
  452. ) -> bool:
  453. pass
  454. @staticmethod
  455. def show_code_snippet(
  456. snippet_data: SnippetData, width: float = 0.0, override_height_in_lines: int = 0
  457. ) -> None:
  458. pass
  459. @staticmethod
  460. @overload
  461. def show_side_by_side_snippets(
  462. snippet1: SnippetData,
  463. snippet2: SnippetData,
  464. hide_if_empty: bool = True,
  465. equal_visible_lines: bool = True,
  466. ) -> None:
  467. pass
  468. @staticmethod
  469. @overload
  470. def show_side_by_side_snippets(
  471. snippets: List[SnippetData],
  472. hide_if_empty: bool = True,
  473. equal_visible_lines: bool = True,
  474. ) -> None:
  475. pass
  476. # </submodule snippets>
  477. #################### </generated_from:snippets.h> ####################
  478. # </litgen_stub> // Autogenerated code end!