podgorskiy / bimpy

imgui for python
https://podgorskiy.github.io/bimpy/
MIT License
202 stars 33 forks source link

Upgrade ImGui to version 1.74 #27

Closed JoelLinn closed 4 years ago

JoelLinn commented 4 years ago

Breaking changes (additionally to braking changes in ImGui 1.65 to 1.74):

JoelLinn commented 4 years ago

Example script to see some of the changes in action:

import bimpy

ctx = bimpy.Context()

ctx.init(600, 600, "Hello")

str_ = bimpy.String()
f = bimpy.Float()
f2a = bimpy.Float()
f2b = bimpy.Float()
f2a.value = 1/3.0

style = bimpy.get_style()
style.window_menu_button_position = bimpy.Direction.Right
bimpy.set_style(style)

while(not ctx.should_close()):
    ctx.new_frame()

    bimpy.show_about_window()
    bimpy.show_demo_window()
    bimpy.show_metrics_window()

    bimpy.set_next_window_bg_alpha(0.5)
    bimpy.begin("test")    
    bimpy.begin_tab_bar("my tab bar")
    if bimpy.begin_tab_item("Page 1"):
        bimpy.text("Hello, world!")
        if bimpy.button("OK"):
            print(str_.value)
        bimpy.input_text_with_hint('string', "type some text here and press ok to print it to console", str_, 256)
        bimpy.slider_float("float", f, 0.0, 1.0)
        bimpy.end_tab_item()
    bimpy.push_style_var(bimpy.Style.TabRounding, 15)
    if bimpy.begin_tab_item("Page 2"):
        bimpy.input_float2("2 float input", f2a, f2b, "%.5f")
        bimpy.end_tab_item()
    bimpy.push_style_var(bimpy.Style.TabRounding, 0)
    if bimpy.begin_tab_item("Page 3"):
        bimpy.text("Floats from page 2:")
        bimpy.text(str(f2a.value))
        bimpy.text(str(f2b.value))
        bimpy.end_tab_item()
    bimpy.pop_style_var(2)
    if bimpy.begin_tab_item("Page 4"):
        if bimpy.button("ImGui light style"):
            bimpy.style_colors_light()
        if bimpy.button("bimpy light style"):
            bimpy.themes.set_light_theme()
    bimpy.end_tab_bar()
    bimpy.set_scroll_y(bimpy.get_scroll_max_y() / 2)
    bimpy.end()

    ctx.render()
JoelLinn commented 4 years ago

Using the new render implementations also seems to fix a bug in the draw_commands example when more circles than a specific number are drawn: image

JoelLinn commented 4 years ago

Superseeded by #30