ioxu / boxer

workflow tool
MIT License
1 stars 0 forks source link

sort out imgui context creation/ begin and end contexts #21

Open ioxu opened 8 months ago

ioxu commented 8 months ago

presently imgui context is created in Ui.__init() with:

        imgui.create_context()
        self._imgui_io = imgui.get_io()
        self.imgui_renderer = create_renderer(self.application_root.window)
        # stop imgui from controlling mouse cursor:
        self._imgui_io.config_flags += imgui.CONFIG_NO_MOUSE_CURSOR_CHANGE

        io = imgui.get_io()

        print("Ui: loading fonts ..")
        self.font_default = io.fonts.add_font_from_file_ttf("boxer/resources/fonts/DejaVuSansCondensed.ttf", 14 )
        self.font_small = io.fonts.add_font_from_file_ttf("boxer/resources/fonts/DejaVuSansCondensed.ttf", 10.5 )
        self.font_t1 = io.fonts.add_font_from_file_ttf("boxer/resources/fonts/DejaVuSansCondensed.ttf", 23 )
        self.imgui_renderer.refresh_font_texture()

        self.time = 0.0

        # border size for windows
        self.style = imgui.get_style()

and ends in Application.on_draw() with

        # NOTE: the imgui context is initialised in self.ui.__init__
        imgui.new_frame()
        #----------------------
        # ui containers
        imgui.push_font(self.ui.font_small)
        self.container.draw()
        imgui.pop_font()
        #----------------------
        # ui
        self.ui.draw()
        #----------------------
        imgui.end_frame()
        imgui.render()

        self.ui.imgui_renderer.render(imgui.get_draw_data())
ioxu commented 8 months ago

I don't like how context creation in one place, and the render callback called in another.