コード例 #1
0
ファイル: mainmenu.py プロジェクト: kfields/arcade-imgui
    def draw(self):
        imgui.new_frame()

        imgui.set_next_window_position(16, 32, imgui.ONCE)
        imgui.set_next_window_size(512, 512, imgui.ONCE)

        if imgui.begin_main_menu_bar():
            # first menu dropdown
            if imgui.begin_menu('File', True):
                imgui.menu_item('New', 'Ctrl+N', False, True)
                imgui.menu_item('Open ...', 'Ctrl+O', False, True)

                # submenu
                if imgui.begin_menu('Open Recent', True):
                    imgui.menu_item('doc.txt', None, False, True)
                    imgui.end_menu()

                imgui.end_menu()

            imgui.end_main_menu_bar()

        imgui.end_frame()

        imgui.render()

        self.renderer.render(imgui.get_draw_data())
コード例 #2
0
ファイル: checkboxflags.py プロジェクト: kfields/arcade-imgui
    def draw(self):
        imgui.new_frame()

        imgui.set_next_window_position(16, 32, imgui.ONCE)
        imgui.set_next_window_size(512, 512, imgui.ONCE)

        imgui.begin("Example: checkboxes for flags", flags=self.flags)

        clicked, self.flags = imgui.checkbox_flags(
            "No resize", self.flags, imgui.WINDOW_NO_RESIZE
        )
        clicked, self.flags = imgui.checkbox_flags(
            "No move", self.flags, imgui.WINDOW_NO_MOVE
        )
        clicked, self.flags = imgui.checkbox_flags(
            "No collapse", self.flags, imgui.WINDOW_NO_COLLAPSE
        )
        # note: it also allows to use multiple flags at once
        clicked, self.flags = imgui.checkbox_flags(
            "No resize & no move", self.flags,
            imgui.WINDOW_NO_RESIZE | imgui.WINDOW_NO_MOVE
        )
        imgui.text("Current flags value: {0:b}".format(self.flags))
        imgui.end()

        imgui.end_frame()

        imgui.render()

        self.renderer.render(imgui.get_draw_data())
コード例 #3
0
    def on_draw(self):
        imgui.create_context()

        imgui.new_frame()

        imgui.begin("FrameBuffer", True)
        fbs = [
            o for o in gc.get_referrers(FrameBuffer)
            if isinstance(o, FrameBuffer)
        ]
        gl.glClearColor(0, 0, 0, 1)
        gl.glClear(gl.GL_COLOR_BUFFER_BIT)
        clicked, self.current_framebuffer = imgui.combo(
            "FrameBuffer", self.current_framebuffer, [str(fb) for fb in fbs])

        fb = fbs[self.current_framebuffer]
        w, h = fb.size
        for name, tex in fb.textures.items():
            imgui.text(name)
            imgui.image(tex.name, 200, 200 * h / w)
        imgui.end()

        imgui.render()
        imgui.end_frame()

        data = imgui.get_draw_data()
        if data:
            self.imgui_renderer.render(imgui.get_draw_data())
コード例 #4
0
ファイル: popupmodal.py プロジェクト: kfields/arcade-imgui
    def draw(self):
        imgui.new_frame()

        imgui.set_next_window_position(16, 32, imgui.ONCE)
        imgui.set_next_window_size(512, 512, imgui.ONCE)

        imgui.begin("Example: simple popup modal")

        if imgui.button("Open Modal popup"):
            imgui.open_popup("select-popup")

        imgui.same_line()

        if imgui.begin_popup_modal("select-popup")[0]:
            imgui.text("Select an option:")
            imgui.separator()
            imgui.selectable("One")
            imgui.selectable("Two")
            imgui.selectable("Three")
            imgui.end_popup()

        imgui.end()

        imgui.end_frame()

        imgui.render()

        self.renderer.render(imgui.get_draw_data())
コード例 #5
0
ファイル: checkbox.py プロジェクト: kfields/arcade-imgui
    def draw(self):
        imgui.new_frame()

        imgui.set_next_window_position(16, 32, imgui.ONCE)
        imgui.set_next_window_size(512, 512, imgui.ONCE)

        imgui.begin("Example: checkboxes")

        # note: first element of return two-tuple notifies if there was a click
        #       event in currently processed frame and second element is actual
        #       checkbox state.
        _, self.checkbox1_enabled = imgui.checkbox("Checkbox 1",
                                                   self.checkbox1_enabled)
        _, self.checkbox2_enabled = imgui.checkbox("Checkbox 2",
                                                   self.checkbox2_enabled)

        imgui.text("Checkbox 1 state value: {}".format(self.checkbox1_enabled))
        imgui.text("Checkbox 2 state value: {}".format(self.checkbox2_enabled))

        imgui.end()

        imgui.end_frame()

        imgui.render()

        self.renderer.render(imgui.get_draw_data())
コード例 #6
0
ファイル: gui.py プロジェクト: shrionit/MyGameEngine
 def show(self):
     self.process_inputs()
     imgui.new_frame()
     self.draw()
     imgui.render()
     self.render(imgui.get_draw_data())
     imgui.end_frame()
コード例 #7
0
ファイル: coloredit4.py プロジェクト: kfields/arcade-imgui
    def draw(self):
        imgui.new_frame()

        imgui.set_next_window_position(16, 32, imgui.ONCE)
        imgui.set_next_window_size(512, 512, imgui.ONCE)

        imgui.begin("Example: color edit with alpha")

        # note: first element of return two-tuple notifies if the color was changed
        #       in currently processed frame and second element is current value
        #       of color and alpha
        _, self.color = imgui.color_edit4("Alpha",
                                          *self.color,
                                          show_alpha=True)
        _, self.color = imgui.color_edit4("No alpha",
                                          *self.color,
                                          show_alpha=False)

        imgui.end()

        imgui.end_frame()

        imgui.render()

        self.renderer.render(imgui.get_draw_data())
コード例 #8
0
    def draw(self):
        imgui.new_frame()

        imgui.set_next_window_position(16, 32, imgui.ONCE)
        imgui.set_next_window_size(256, 256, imgui.ONCE)

        imgui.begin("Circle")
        draw_list = imgui.get_window_draw_list()
        draw_list.add_circle(100,
                             60,
                             30,
                             imgui.get_color_u32_rgba(1, 1, 0, 1),
                             thickness=3)
        imgui.end()

        imgui.set_next_window_position(270, 32, imgui.ONCE)
        imgui.set_next_window_size(256, 256, imgui.ONCE)

        imgui.begin("Filled Circle")
        draw_list = imgui.get_window_draw_list()
        draw_list.add_circle_filled(100, 60, 30,
                                    imgui.get_color_u32_rgba(1, 1, 0, 1))
        imgui.end()

        imgui.end_frame()

        imgui.render()

        self.renderer.render(imgui.get_draw_data())
コード例 #9
0
    def draw(self):
        imgui.new_frame()

        imgui.set_next_window_position(16, 32, imgui.ONCE)
        imgui.set_next_window_size(512, 512, imgui.ONCE)

        imgui.begin("Example: item groups")

        imgui.begin_group()
        imgui.text("First group (buttons):")
        imgui.button("Button A")
        imgui.button("Button B")
        imgui.end_group()

        imgui.same_line(spacing=50)

        imgui.begin_group()
        imgui.text("Second group (text and bullet texts):")
        imgui.bullet_text("Bullet A")
        imgui.bullet_text("Bullet B")
        imgui.end_group()

        imgui.end()

        imgui.end_frame()

        imgui.render()

        self.renderer.render(imgui.get_draw_data())
コード例 #10
0
ファイル: dnd.py プロジェクト: kfields/arcade-imgui
    def draw(self):
        imgui.new_frame()

        imgui.set_next_window_position(16, 32, imgui.ONCE)
        imgui.set_next_window_size(512, 512, imgui.ONCE)

        imgui.begin("Example: drag and drop")

        imgui.button('source')
        if imgui.begin_drag_drop_source():
            imgui.set_drag_drop_payload('itemtype', b'payload')
            imgui.button('dragged source')
            imgui.end_drag_drop_source()

        imgui.button('dest')
        if imgui.begin_drag_drop_target():
            payload = imgui.accept_drag_drop_payload('itemtype')
            if payload is not None:
                print('Received:', payload)
            imgui.end_drag_drop_target()

        imgui.end()

        imgui.end_frame()

        imgui.render()

        self.renderer.render(imgui.get_draw_data())
コード例 #11
0
    def draw(self):
        imgui.new_frame()

        pos_x = 10
        pos_y = 10
        sz = 20

        draw_list = imgui.get_window_draw_list()

        for i in range(0, imgui.COLOR_COUNT):
            name = imgui.get_style_color_name(i)
            draw_list.add_rect_filled(pos_x, pos_y, pos_x + sz, pos_y + sz,
                                      imgui.get_color_u32_idx(i))
            imgui.dummy(sz, sz)
            imgui.same_line()

        rgba_color = imgui.get_color_u32_rgba(1, 1, 0, 1)
        draw_list.add_rect_filled(pos_x, pos_y, pos_x + sz, pos_y + sz,
                                  rgba_color)

        imgui.end_frame()

        imgui.render()

        self.renderer.render(imgui.get_draw_data())
コード例 #12
0
ファイル: demo.py プロジェクト: kfields/arcade-imgui
    def draw(self):
        imgui.new_frame()

        imgui.set_next_window_position(16, 32, imgui.ONCE)
        imgui.set_next_window_size(512, 512, imgui.ONCE)

        if imgui.begin_main_menu_bar():
            if imgui.begin_menu("File", True):

                clicked_quit, selected_quit = imgui.menu_item(
                    "Quit", 'Cmd+Q', False, True)

                if clicked_quit:
                    exit(1)

                imgui.end_menu()
            imgui.end_main_menu_bar()

        imgui.show_test_window()

        imgui.begin("Custom window", True)
        imgui.text("Bar")
        imgui.text_colored("Eggs", 0.2, 1., 0.)
        imgui.end()

        imgui.end_frame()

        imgui.render()

        self.renderer.render(imgui.get_draw_data())
コード例 #13
0
def main():
    try:

        # initilize imgui context (see documentation)
        imgui.create_context()
        imgui.get_io().display_size = 100, 100
        imgui.get_io().fonts.get_tex_data_as_rgba32()

        # start new frame context
        imgui.new_frame()

        # open new window context
        imgui.begin("Your first window!", True)

        # draw text label inside of current window
        imgui.text("Hello world!")

        # close current window context
        imgui.end()

        # pass all drawing comands to the rendering pipeline
        # and close frame context
        imgui.render()
        imgui.end_frame()

    except ModuleNotFoundError:
        print("Error found")
コード例 #14
0
ファイル: window.py プロジェクト: johanfforsberg/voxpaint
    def _render_gui(self):
        w, h = self.get_size()

        imgui.new_frame()

        if self.stroke_tool and self.stroke_tool.show_rect:
            if self.stroke_tool.rect:
                rect = self.stroke_tool.rect
                p0 = self._to_window_coords(*rect.topleft)
                p1 = self._to_window_coords(*rect.bottomright)
                ui.render_selection_rectangle(self, p0, p1)

        with imgui.font(self._font):

            ui.render_menu(self)

            if self.drawing:

                imgui.set_next_window_size(115, h - 20)
                imgui.set_next_window_position(w - 115, 20)

                imgui.begin("Sidebar",
                            False,
                            flags=(imgui.WINDOW_NO_TITLE_BAR
                                   | imgui.WINDOW_NO_RESIZE
                                   | imgui.WINDOW_NO_MOVE))

                ui.render_tools(self.tools, self.icons)
                imgui.separator()

                ui.render_palette(self.drawing)
                imgui.separator()

                ui.render_layers(self.view)

                imgui.end()

                ui.render_unsaved_exit(self)
                ui.render_unsaved_close_drawing(self)

                render_plugins_ui(self.drawing)

            ui.render_new_drawing_popup(self)

            if self._error:
                imgui.open_popup("Error")
                if imgui.begin_popup_modal("Error")[0]:
                    imgui.text(self._error)
                    if imgui.button("Doh!"):
                        self._error = None
                        imgui.close_current_popup()
                    imgui.end_popup()

        imgui.render()
        imgui.end_frame()
        data = imgui.get_draw_data()
        self.imgui_renderer.render(data)
コード例 #15
0
    def exec_snippet(self, source):

        # Strip out new_frame/end_frame from source
        if "# later" in source:
            raise Skipped(msg="multi-stage snippet, can't comprehend")

        lines = [
            line
            if all([
                "imgui.new_frame()" not in line,
                "imgui.render()" not in line,
                "imgui.end_frame()" not in line
            ]) else ""
            for line in
            source.split('\n')
        ]
        source = "\n".join(lines)

        if (
            "import array" in source
            and sys.version_info < (3, 0)
        ):
            pytest.skip(
                "array.array does not work properly under py27 as memory view"
            )

        code = compile(source, '<str>', 'exec')
        frameinfo = getframeinfo(currentframe())

        imgui.create_context()
        io = imgui.get_io()
        io.delta_time = 1.0 / 60.0
        io.display_size = 300, 300

        # setup default font
        io.fonts.get_tex_data_as_rgba32()
        io.fonts.add_font_default()
        io.fonts.texture_id = 0  # set any texture ID to avoid segfaults

        imgui.new_frame()

        exec_ns = _ns(locals(), globals())

        try:
            exec(code, exec_ns, exec_ns)
        except Exception as err:
            # note: quick and dirty way to annotate sources with error marker
            print_exc()
            lines = source.split('\n')
            lines.insert(sys.exc_info()[2].tb_next.tb_lineno, "^^^")
            self.code = "\n".join(lines)
            imgui.end_frame()
            raise

        imgui.render()
コード例 #16
0
ファイル: graphics_context.py プロジェクト: eherr/vis_utils
    def draw_imgui(self):
        io = self.io
        # start new frame context
        imgui.new_frame()
        if self.activate_plots:
            self.plot_manager.render_imgui()
        if self.show_console:
            self.console.render_lines()

        imgui.render()
        data = imgui.get_draw_data()
        self.imgui_renderer.render(data)
        imgui.end_frame()
コード例 #17
0
    def draw(self):
        imgui.new_frame()

        imgui.set_next_window_position(16, 32, imgui.ONCE)
        imgui.set_next_window_size(512, 512, imgui.ONCE)

        imgui.begin("Example: empty window")
        imgui.end()

        imgui.end_frame()

        imgui.render()

        self.renderer.render(imgui.get_draw_data())
コード例 #18
0
    def render(self):
        imgui.new_frame()

        imgui.begin("Test Window")
        imgui.text("This is the test window.")
        changed, self.test_input = imgui.input_int("Integer Input Test",
                                                   self.test_input)

        imgui.end()

        imgui.end_frame()

        imgui.render()

        self.renderer.render(imgui.get_draw_data())
コード例 #19
0
def draw_ui():
    imgui.new_frame()
    if _ui_state == UIState.MAIN_MENU:
        glfw.set_input_mode(window, glfw.CURSOR, glfw.CURSOR_NORMAL)
        menus.show_main_menu()
    if _ui_state == UIState.IN_GAME_HUD:
        hud.show_ingame_hud()
        if console.SHOW_CONSOLE:
            glfw.set_input_mode(window, glfw.CURSOR, glfw.CURSOR_NORMAL)
        else:
            glfw.set_input_mode(window, glfw.CURSOR, glfw.CURSOR_DISABLED)
    draw_console()
    imgui.render()
    imgui_renderer.render(imgui.get_draw_data())
    imgui.end_frame()
コード例 #20
0
    def draw(self):
        imgui.new_frame()

        imgui.set_next_window_position(16, 32, imgui.ONCE)
        imgui.set_next_window_size(512, 512, imgui.ONCE)

        imgui.begin("Image example")
        imgui.image(self.texture.glo, *self.texture.size)
        imgui.end()

        imgui.end_frame()

        imgui.render()

        self.renderer.render(imgui.get_draw_data())
コード例 #21
0
ファイル: font.py プロジェクト: kfields/arcade-imgui
    def draw(self):
        imgui.new_frame()

        imgui.begin("Font")

        imgui.text("Text displayed using default font")
        with imgui.font(self.new_font):
            imgui.text("Text displayed using custom font")

        imgui.end()

        imgui.end_frame()

        imgui.render()

        self.renderer.render(imgui.get_draw_data())
コード例 #22
0
    def draw(self):
        imgui.new_frame()

        imgui.set_next_window_position(16, 32, imgui.ONCE)
        imgui.set_next_window_size(512, 512, imgui.ONCE)

        imgui.begin("Example: drag int")
        changed, self.values = imgui.drag_int4("drag ints", *self.values)
        imgui.text("Changed: %s, Values: %s" % (changed, self.values))
        imgui.end()

        imgui.end_frame()

        imgui.render()

        self.renderer.render(imgui.get_draw_data())
コード例 #23
0
    def on_draw(self):
        arcade.start_render()

        imgui.new_frame()

        if self.window.view_metrics:
            self.window.view_metrics = imgui.show_metrics_window(closable=True)

        self.draw_mainmenu()
        self.draw_navbar()

        imgui.set_next_window_position(288, 32, imgui.ONCE)
        imgui.set_next_window_size(512, 512, imgui.ONCE)

        self.draw()

        imgui.end_frame()
コード例 #24
0
    def draw_ui(self):
        io = self.io
        # start new frame context
        imgui.new_frame()
        #imgui.begin("Console", True)
        #imgui.text("Hello world!")
        #imgui.end()
        if self.draw_plot:
            #self.plot_manager.draw(self.camera.get_orthographic_matrix())
            self.plot_manager.render_imgui()
        if self.show_console:
            self.console.render_lines()

        imgui.render()
        data = imgui.get_draw_data()
        self.imgui_renderer.render(data)
        imgui.end_frame()
コード例 #25
0
ファイル: text.py プロジェクト: kfields/arcade-imgui
    def draw(self):
        imgui.new_frame()

        imgui.set_next_window_position(16, 32, imgui.ONCE)
        imgui.set_next_window_size(512, 512, imgui.ONCE)

        imgui.begin("Text")
        draw_list = imgui.get_window_draw_list()
        draw_list.add_text(20, 35, imgui.get_color_u32_rgba(1, 1, 0, 1),
                           "Hello!")
        imgui.end()

        imgui.end_frame()

        imgui.render()

        self.renderer.render(imgui.get_draw_data())
コード例 #26
0
ファイル: bullettext.py プロジェクト: kfields/arcade-imgui
    def draw(self):
        imgui.new_frame()

        imgui.set_next_window_position(16, 32, imgui.ONCE)
        imgui.set_next_window_size(512, 512, imgui.ONCE)

        imgui.begin("Example: bullet text")
        imgui.bullet_text("Bullet 1")
        imgui.bullet_text("Bullet 2")
        imgui.bullet_text("Bullet 3")
        imgui.end()

        imgui.end_frame()

        imgui.render()

        self.renderer.render(imgui.get_draw_data())
コード例 #27
0
    def draw(self):
        imgui.new_frame()

        imgui.set_next_window_position(16, 32, imgui.ONCE)
        imgui.set_next_window_size(512, 512, imgui.ONCE)

        imgui.begin("Example: popup context window")
        if imgui.begin_popup_context_window(mouse_button=0):
            imgui.selectable("Clear")
            imgui.end_popup()
        imgui.end()

        imgui.end_frame()

        imgui.render()

        self.renderer.render(imgui.get_draw_data())
コード例 #28
0
    def draw(self):
        imgui.new_frame()

        imgui.set_next_window_position(16, 32, imgui.ONCE)
        imgui.set_next_window_size(512, 512, imgui.ONCE)

        imgui.begin("Example: color button")
        imgui.color_button("Button 1", 1, 0, 0, 1, 0, 10, 10)
        imgui.color_button("Button 2", 0, 1, 0, 1, 0, 10, 10)
        imgui.color_button("Wide Button", 0, 0, 1, 1, 0, 20, 10)
        imgui.color_button("Tall Button", 1, 0, 1, 1, 0, 10, 20)
        imgui.end()

        imgui.end_frame()

        imgui.render()

        self.renderer.render(imgui.get_draw_data())
コード例 #29
0
ファイル: bullet.py プロジェクト: kfields/arcade-imgui
    def draw(self):
        imgui.new_frame()

        imgui.set_next_window_position(16, 32, imgui.ONCE)
        imgui.set_next_window_size(512, 512, imgui.ONCE)

        imgui.begin("Example: bullets")

        for i in range(10):
            imgui.bullet()

        imgui.end()

        imgui.end_frame()

        imgui.render()

        self.renderer.render(imgui.get_draw_data())
コード例 #30
0
ファイル: fontimage.py プロジェクト: kfields/arcade-imgui
    def draw(self):
        imgui.new_frame()

        imgui.set_next_window_position(16, 32, imgui.ONCE)
        imgui.set_next_window_size(512, 512, imgui.ONCE)

        imgui.begin("Font image example")
        texture_id = imgui.get_io().fonts.texture_id
        draw_list = imgui.get_window_draw_list()
        draw_list.add_image(texture_id, (20, 35), (180, 80),
                            col=imgui.get_color_u32_rgba(0.5, 0.5, 1, 1))
        imgui.end()

        imgui.end_frame()

        imgui.render()

        self.renderer.render(imgui.get_draw_data())