Exemple #1
0
    def draw_menu(self):
        imgui.push_style_var(imgui.STYLE_WINDOW_PADDING, (8, 8))
        if imgui.begin_menu_bar():
            # first menu dropdown
            if imgui.begin_menu('菜单', True):
                if utils.is_menu_item_click('导出', 'Ctrl+O+P', False, True):
                    print "暂不支持"
                if utils.is_menu_item_click('设置', 'Ctrl+Alt+S', False, True):
                    print "设置"
                imgui.end_menu()

            if imgui.begin_menu("工具", True):
                if utils.is_menu_item_click("查找", "Ctrl+F", False, True):
                    print "查找"
                if utils.is_menu_item_click("自定义GM", "Ctrl+G", False, True):
                    print "自定义GM"
                imgui.end_menu()

            if imgui.begin_menu("帮助", True):
                if utils.is_menu_item_click("文档", "F1", False, True):
                    print "文档"
                if utils.is_menu_item_click("快捷键", "Ctrl+M", False, True):
                    print "快捷键"
                if utils.is_menu_item_click("关于...", None, False, True):
                    print "关于"
                imgui.end_menu()

            imgui.end_menu_bar()
        imgui.pop_style_var()
Exemple #2
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)

        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())
Exemple #3
0
    def update(self, dt):
        imgui.new_frame()

        self.crosshair()

        if self.showTestWindow:
            self.testWindow()

        if self.showDrawTools:  # show Drawing Tools window
            self.drawTools()

        if self.showLayers:
            self.layers()

        if imgui.begin_main_menu_bar():  # stat menu bar (top bar)

            if imgui.begin_menu("File", True):  # start menu bar entry: File
                clicked_quit, selected_quit = imgui.menu_item(  # start File menu entry: Quit
                    "Quit",
                    'Cmd+Q',
                    False,
                    True  # Name label, Shortcut label, Check bool, Enabled bool
                )
                if clicked_quit:  # event: if entry quit is clicked
                    exit(1)
                if selected_quit:
                    pass
                imgui.end_menu()  # end File menu

            if imgui.begin_menu("Draw", True):
                clicked_draw, selected_draw = imgui.menu_item(
                    "Draw Tools", "", self.showDrawTools, True)
                if clicked_draw:
                    if self.showDrawTools:
                        self.showDrawTools = False
                    else:
                        self.showDrawTools = True

                clicked_layers, selected_layers = imgui.menu_item(
                    "Layers", "", self.showLayers, True)
                if clicked_layers:
                    if self.showLayers:
                        self.showLayers = False
                    else:
                        self.showLayers = True
                imgui.end_menu()

            # Example of a window, check line 59
            if imgui.begin_menu("Test", True):  # start menu bar entry: Test
                clicked_test, selected_test = imgui.menu_item(
                    "Test", "Ctrl+Alt+Del", self.showTestWindow, True)
                if clicked_test:
                    if self.showTestWindow:
                        self.showTestWindow = False
                    else:
                        self.showTestWindow = True
                imgui.end_menu()  # end Test menu

            imgui.end_main_menu_bar()
Exemple #4
0
def draw_imgui(scene: Scene):
    if Settings.GuiEnabled:
        # Menu Bar
        if imgui.begin_main_menu_bar():
            if imgui.begin_menu("File"):
                imgui.menu_item("Open")

                if imgui.menu_item("Exit")[0]:
                    glfw.terminate()

                imgui.end_menu()

            if imgui.begin_menu("View"):

                if imgui.menu_item("Grid",
                                   shortcut='G',
                                   selected=Settings.GridEnabled)[0]:
                    Settings.GridEnabled = not Settings.GridEnabled

                if imgui.menu_item("GUI",
                                   shortcut='TAB',
                                   selected=Settings.GuiEnabled)[0]:
                    Settings.GuiEnabled = not Settings.GuiEnabled

                if imgui.menu_item("Stats",
                                   shortcut='P',
                                   selected=Settings.StatsEnabled)[0]:
                    Settings.StatsEnabled = not Settings.StatsEnabled

                imgui.end_menu()
            if Settings.StatsEnabled:
                imgui.same_line(imgui.get_window_width() - 150)
                imgui.text("FPS: " + "%.2f" % Global.fps + "  " +
                           "%.2f" % Global.frametime + "ms")
        imgui.end_main_menu_bar()

        # imgui.show_demo_window()

        # Scene
        imgui.begin("Scene")
        draw_node_item(scene.nodelist[0], scene)
        imgui.end()

        imgui.begin("Properties")
        imgui.text("Model")

        imgui.end()

    else:
        pass
Exemple #5
0
 def render_callback(self, time: float, frametime: float):
     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()
         changed, value = imgui.input_text("", self.input_text, 30)
         if changed:
             imgui.set_next_window_position(imgui.get_item_rect_min().x,
                                            imgui.get_item_rect_max().y)
             imgui.set_next_window_size(imgui.get_item_rect_size().x, 0)
             if imgui.begin("##popup", False,
                            imgui.WINDOW_NO_TITLE_BAR | imgui.WINDOW_NO_MOVE | imgui.WINDOW_NO_RESIZE):
                 for index, row in symbol_list.iterrows():
                     if value.upper() in row[0]:
                         opened, selected = imgui.selectable(row[0] + " - " + row[2])
                         if imgui.is_item_clicked():
                             input_text = row[0]
                             selected_symbol = row[0]
             imgui.end()
         if imgui.button("download"):
             yfc.download(self.selected_symbol, symbol_data_file())
         imgui.end_main_menu_bar()
     pass
Exemple #6
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)

        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())
Exemple #7
0
def update(dt):
    # Start rendering a new frame
    imgui.new_frame()

    ### MENU BAR BEGIN ###
    if imgui.begin_main_menu_bar():
        if imgui.begin_menu("File", True):
            clicked_quit, selected_quit = imgui.menu_item(
                "Quit", "Esc", False, True)
            if clicked_quit:
                exit(1)
            imgui.end_menu()
        # End rendering the menu bar
        imgui.end_main_menu_bar()
    if quit_the_app:
        exit(1)
    ### MENU BAR END ###

    # Show a basic test window, if you want
    # show_test_window()

    # TODO: Do any imgui stuff you want here. Here's a simple example...
    # imgui.begin("My Cool Sub-Window", True) # start rendering a sub-window
    # imgui.set_window_size(window_width / 2, window_height) # take up half the screen
    # imgui.text("Here's some awesome text!") # render some text
    # if imgui.button("Click Me!"): # buttons are rendered and checked for clicks in one line!
    #     imgui.text("Button clicked!")
    # imgui.end() # end the sub-window

    # Clear the OpenGL buffer for the background color.
    gl.glClearColor(1, 1, 1, 1)
    gl.glClear(gl.GL_COLOR_BUFFER_BIT)
Exemple #8
0
    def update(dt):
        imgui.new_frame()
        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()

        show_test_window()
        #imgui.show_test_window()

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

        imgui.text_ansi("B\033[31marA\033[mnsi ")
        imgui.text_ansi_colored("Eg\033[31mgAn\033[msi ", 0.2, 1., 0.)

        imgui.end()
    def render_ui(self, time, rotation, translation, model):
        imgui.new_frame()
        if imgui.begin_main_menu_bar():
            if imgui.begin_menu("File", True):

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

                if clicked_quit:
                    exit(1)

                imgui.end_menu()
            imgui.end_main_menu_bar()

        # imgui.show_test_window()
        imgui.begin("Custom window", True)
        value = self.slider_value
        changed, changed_value = imgui.slider_int(
            "slide ints", value,
            min_value=0, max_value=100,
            format="%d"
        ) 
        if changed:
            self.slider_value = changed_value
        imgui.text(string("time: \n", time))
        imgui.text(string("rotation: \n", rotation))
        imgui.text(string("translation: \n", translation))
        imgui.text(string("model = translation * rotation: \n", model))
        imgui.end()

        imgui.render()
        self.imgui.render(imgui.get_draw_data())
Exemple #10
0
    def draw(self, *args, **kwargs):
        imgui.new_frame()

        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()

        gl.glClearColor(1., 1., 1., 1)
        gl.glClear(gl.GL_COLOR_BUFFER_BIT)

        imgui.render()
Exemple #11
0
    def render_ui(self):
        """Render the UI"""
        imgui.new_frame()
        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()

        # Create window with the framebuffer image
        imgui.begin("Custom window with Image", True)
        # Create an image control by passing in the OpenGL texture ID (glo)
        # and pass in the image size as well.
        # The texture needs to he registered using register_texture for this to work
        imgui.image(self.fbo.color_attachments[0].glo, *self.fbo.size)
        imgui.end()

        imgui.render()
        self.imgui.render(imgui.get_draw_data())
Exemple #12
0
def main(recfile):
    imgui.create_context()
    window = impl_glfw_init()
    impl = GlfwRenderer(window)
    slamgui = SLAMGUI(recfile)

    while not glfw.window_should_close(window):
        glfw.poll_events()
        impl.process_inputs()
        imgui.new_frame()

        if imgui.begin_main_menu_bar():
            if imgui.begin_menu("File", True):
                clicked_quit, _ = imgui.menu_item("Quit", 'Cmd+Q', False, True)
                if clicked_quit:
                    exit(0)
                imgui.end_menu()
            imgui.end_main_menu_bar()

        slamgui.render()
        gl.glClearColor(0, 0, 0, 1)
        gl.glClear(gl.GL_COLOR_BUFFER_BIT)

        imgui.render()
        impl.render(imgui.get_draw_data())
        glfw.swap_buffers(window)

    impl.shutdown()
    glfw.terminate()
Exemple #13
0
 def menu_bar(self):
     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:
                 self.cleanup()
                 exit(0)
             imgui.end_menu()
         changed, value = imgui.input_text("", self.input_text, 30)
         if changed:
             imgui.set_next_window_position(imgui.get_item_rect_min().x,
                                            imgui.get_item_rect_max().y)
             imgui.set_next_window_size(imgui.get_item_rect_size().x, 0)
             if imgui.begin(
                     "##popup", False, imgui.WINDOW_NO_TITLE_BAR
                     | imgui.WINDOW_NO_MOVE | imgui.WINDOW_NO_RESIZE):
                 for index, row in self.symbol_list.iterrows():
                     if value.upper() in row[0]:
                         _, _ = imgui.selectable(row[0] + " - " + row[2])
                         if imgui.is_item_clicked():
                             self.input_text = row[0]
                             self.load_symbol(str(row[0]).lower())
             imgui.end()
         imgui.end_main_menu_bar()
Exemple #14
0
    def render(self):
        # Clear frame.
        glClearColor(0.2, 0.3, 0.3, 1.0)
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)

        # Draw.
        # self.draw_grid()

        # Menu.
        self.imgui_impl.process_inputs()
        imgui.new_frame()

        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.render()
        self.imgui_impl.render(imgui.get_draw_data())
Exemple #15
0
 def draw_menu(self):
     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()
         if imgui.begin_menu("Controls", True):
             clicked_scene, selected_scene = imgui.menu_item(
                 "Scene", "Cmd+S", False, True
             )
             if clicked_scene:
                 self.scene_controls = True
             imgui.end_menu()
         imgui.end_main_menu_bar()
Exemple #16
0
 def draw_menu(self):
     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()
Exemple #17
0
    def draw_mainmenu(self):
        if imgui.begin_main_menu_bar():
            # File
            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()
            # View
            if imgui.begin_menu('View', True):
                clicked_metrics, self.window.view_metrics = imgui.menu_item(
                    "Metrics", 'Cmd+M', self.window.view_metrics, True)

                imgui.end_menu()

            imgui.end_main_menu_bar()
Exemple #18
0
def replay(fname):
    imgui.create_context()
    window = impl_glfw_init()
    impl = GlfwRenderer(window)
    replaygui = ReplayGUI(fname)

    while not glfw.window_should_close(window):
        glfw.poll_events()
        impl.process_inputs()
        imgui.new_frame()

        if imgui.begin_main_menu_bar():
            if imgui.begin_menu("File", True):
                clicked_quit, _ = imgui.menu_item(
                    "Quit", 'Cmd+Q', False, True)
                if clicked_quit:
                    exit(0)
                imgui.end_menu()
            if imgui.begin_menu("View", True):
                _, replaygui.show_frontview = imgui.menu_item(
                    "Front view", selected=replaygui.show_frontview)
                imgui.end_menu()
            if imgui.begin_menu("Tools", True):
                clicked, _ = imgui.menu_item("Learn control params")
                if clicked:
                    replaygui.learn_controls = True
                clicked, _ = imgui.menu_item("Lap timer")
                if clicked:
                    replaygui.lap_timer = True
                imgui.end_menu()
            imgui.end_main_menu_bar()

        replaygui.render()
        gl.glClearColor(0, 0, 0, 1)
        gl.glClear(gl.GL_COLOR_BUFFER_BIT)

        imgui.render()
        impl.render(imgui.get_draw_data())
        glfw.swap_buffers(window)

    impl.shutdown()
    glfw.terminate()
Exemple #19
0
def main():
    pygame.init()
    size = 800, 600

    pygame.display.set_mode(size, pygame.DOUBLEBUF | pygame.OPENGL | pygame.RESIZABLE)

    imgui.create_context()
    impl = PygameRenderer()

    io = imgui.get_io()
    io.display_size = size

    while 1:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                sys.exit()

            impl.process_event(event)

        imgui.new_frame()

        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.same_line()
        imgui.text_colored("Eggs", 0.2, 1., 0.)
        #imgui.same_line()
        imgui.bullet_text("bullet_text")
        # 不换行
        #imgui.same_line()
        imgui.end()

        # note: cannot use screen.fill((1, 1, 1)) because pygame's screen
        #       does not support fill() on OpenGL sufraces
        gl.glClearColor(1, 1, 1, 1)
        gl.glClear(gl.GL_COLOR_BUFFER_BIT)
        imgui.render()
        impl.render(imgui.get_draw_data())

        pygame.display.flip()
def menubar():
    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()
        if imgui.begin_menu("About", True):

            clicked_about, _ = imgui.menu_item(
                "About me..", 'F1', True, True
            )

            if clicked_about:
                imgui.open_popup("about-p")
            imgui.end_menu()
    imgui.end_main_menu_bar()
Exemple #21
0
def _imgui_pick_file_menu(base_path, wildcard="*"):
    MAX_FILE_DISPLAY_LENGTH = 60

    try:
        entries = []
        for name in os.listdir(base_path):
            entries.append(
                (not os.path.isdir(os.path.join(base_path, name)), name))

        imgui.text("New:")
        imgui.same_line()
        imgui.push_item_width(-1)
        changed, value = imgui.input_text("", "", 255,
                                          imgui.INPUT_TEXT_ENTER_RETURNS_TRUE)
        if changed:
            return os.path.join(base_path, value)
        imgui.separator()
        for w in WILDCARDS:
            if imgui.button(w):
                return os.path.join(base_path, w)
            imgui.same_line()
        imgui.dummy(0, 0)
        imgui.separator()

        if len(entries) == 0:
            imgui.dummy(200, 0)

        for not_is_dir, name in sorted(entries):
            display_name = name
            if len(display_name) > MAX_FILE_DISPLAY_LENGTH:
                display_name = display_name[:MAX_FILE_DISPLAY_LENGTH //
                                            2] + "..." + display_name[
                                                -MAX_FILE_DISPLAY_LENGTH // 2:]

            if not not_is_dir:
                if imgui.begin_menu(display_name):
                    selected_path = _imgui_pick_file_menu(
                        os.path.join(base_path, name), wildcard)
                    imgui.end_menu()
                    if selected_path is not None:
                        return os.path.join(base_path, selected_path)
            else:
                if not fnmatch.fnmatch(name, wildcard):
                    continue
                clicked, state = imgui.menu_item(display_name, None, False)
                if clicked:
                    return os.path.join(base_path, name)

        imgui.separator()
        imgui.text("Pick: %s" % wildcard)
    except:
        imgui.text("Unable to open dir")
Exemple #22
0
    def draw(self):
        flags = imgui.WINDOW_MENU_BAR

        imgui.begin("Child Window - File Browser", flags=flags)

        if imgui.begin_menu_bar():
            if imgui.begin_menu('File'):
                imgui.menu_item('Close')
                imgui.end_menu()

            imgui.end_menu_bar()

        imgui.end()
Exemple #23
0
def main():
    pygame.init()
    clock = pygame.time.Clock()
    size = 640, 480

    pygame.display.set_mode(size, pygame.HWSURFACE | pygame.DOUBLEBUF | pygame.OPENGL)

    io = imgui.get_io()
    io.fonts.add_font_default()
    io.display_size = size

    renderer = PygameRenderer()

    while 1:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                sys.exit()

            renderer.process_event(event)

        imgui.new_frame()

        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:
                    pygame.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()

        # note: cannot use screen.fill((1, 1, 1)) because pygame's screen
        #       does not support fill() on OpenGL sufraces
        gl.glClearColor(1, 1, 1, 1)
        gl.glClear(gl.GL_COLOR_BUFFER_BIT)
        imgui.render()

        pygame.display.flip()
        clock.tick(60)
Exemple #24
0
def on_frame():
    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()
Exemple #25
0
def main():
    window, gl_context = impl_pysdl2_init()
    impl = SDL2Impl(window)

    opened = True

    running = True
    event = SDL_Event()
    while running:
        while SDL_PollEvent(ctypes.byref(event)) != 0:
            if event.type == SDL_QUIT:
                running = False
                break
            impl.process_event(event)
        impl.process_inputs()

        imgui.new_frame()

        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_user_guide()
        imgui.show_test_window()

        if opened:
            expanded, opened = imgui.begin("fooo", True)
            imgui.text("Bar")
            imgui.text_colored("Eggs", 0.2, 1., 0.)
            imgui.end()

        with imgui.styled(imgui.STYLE_ALPHA, 1):
            imgui.show_metrics_window()

        gl.glClearColor(114 / 255., 144 / 255., 154 / 255., 1)
        gl.glClear(gl.GL_COLOR_BUFFER_BIT)

        imgui.render()

        SDL_GL_SwapWindow(window)

    impl.shutdown()
    SDL_GL_DeleteContext(gl_context)
    SDL_DestroyWindow(window)
    SDL_Quit()
def main():
    window = impl_glfw_init()
    impl = GlfwRenderer(window)

    box1 = box2 = box3 = True

    while not glfw.window_should_close(window):
        glfw.poll_events()
        impl.process_inputs()

        imgui.new_frame()

        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.begin("Scope Test")

        box1 = imgui.checkbox("Checkbox", box1)[1]

        with imgui.scope(2):
            imgui.new_line()
            imgui.text("Same name, different scope:")
            box2 = imgui.checkbox("Checkbox", box2)[1]

        imgui.new_line()
        imgui.text("Same name, same scope:")
        imgui.text("(This will not work right)")
        box3 = imgui.checkbox("Checkbox", box3)[1]

        imgui.end()

        gl.glClearColor(1., 1., 1., 1)
        gl.glClear(gl.GL_COLOR_BUFFER_BIT)

        imgui.render()
        glfw.swap_buffers(window)

    impl.shutdown()
    imgui.shutdown()
    glfw.terminate()
Exemple #27
0
    def render_ui(self, t, dt):
        imgui.new_frame()

        if imgui.begin_main_menu_bar():
            if imgui.begin_menu("Test Menu"):
                imgui.end_menu()

            imgui.end_main_menu_bar()

        imgui.begin("Control")
        imgui.text(f"FPS {1.0 / (dt):.2f}")
        imgui.end()
        imgui.render()

        self.imgui.render(imgui.get_draw_data())
Exemple #28
0
def main():
    window, gl_context = impl_pysdl2_init()
    imgui.create_context()
    impl = SDL2Renderer(window)

    running = True
    event = SDL_Event()
    while running:
        while SDL_PollEvent(ctypes.byref(event)) != 0:
            if event.type == SDL_QUIT:
                running = False
                break
            impl.process_event(event)
        impl.process_inputs()

        imgui.new_frame()

        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()

        show_test_window()
        #imgui.show_test_window()

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

        gl.glClearColor(1., 1., 1., 1)
        gl.glClear(gl.GL_COLOR_BUFFER_BIT)

        imgui.render()
        impl.render(imgui.get_draw_data())
        SDL_GL_SwapWindow(window)

    impl.shutdown()
    SDL_GL_DeleteContext(gl_context)
    SDL_DestroyWindow(window)
    SDL_Quit()
Exemple #29
0
def menu(label, widget, enabled=True):
    """ Create an expandable menu in the `main_menu_bar`.

    Widgets commonly used in menus are `menu_item`, and `separator`.
    """
    while True:
        expanded = imgui.begin_menu(label, enabled)
        try:
            if expanded:
                next(widget)
        except StopIteration as e:
            return e.value
        finally:
            if expanded:
                imgui.end_menu()
        yield
Exemple #30
0
 def _on_menu(self):
     # 绘制并处理主菜单条
     running = True
     if imgui.begin_main_menu_bar():
         # 在主菜单条上增加File菜单
         if imgui.begin_menu("File", True):
             # 在File菜单被点击后显示需要的菜单项
             clicked_quit, selected_quit = imgui.menu_item("Quit", 'CTRL+Q')
             # 如果Quit菜单项被点击,结束App
             if clicked_quit:
                 running = False
             # 结束File菜单的处理
             imgui.end_menu()
         # 结束主菜单条的处理
         imgui.end_main_menu_bar()
     return running
Exemple #31
0
def main():
    pygame.init()

    size = 800, 600

    pygame.display.set_mode(size, pygame.DOUBLEBUF | pygame.OPENGL)
    pygame.display.set_caption("GBDev tool window")
    io = imgui.get_io()
    io.fonts.add_font_default()
    io.display_size = size

    renderer = PygameRenderer()

    while 1:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                sys.exit()

            renderer.process_event(event)

        imgui.new_frame()

        if imgui.begin_main_menu_bar():
            if imgui.begin_menu("Menu", True):
                open_gbtd, selected_none = imgui.menu_item("Open GBTD", None, False, True)
                open_gbtk, selected_none = imgui.menu_item("Open GBTK", None, False, True)
                
                export_json, selected_none = imgui.menu_item("Export Default Json", None, False, True)

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

                if clicked_quit:
                    exit(1)
                if open_gbtd:
                    os.system("wine tools/GBTD/GBTD.EXE &")
                if open_gbtk:
                    os.system("wine tools/GBTK.exe &")
                if export_json:
                    tools.json2c.default_use()
                imgui.end_menu()
            imgui.end_main_menu_bar()

        imgui.begin("Data", True)

        img_path = "data/img"
        onlyfiles = [f for f in listdir(img_path) if isfile(join(img_path, f))]
        #print(onlyfiles)
        for file in onlyfiles:
            imgui_image_menu(img_path+"/"+file)

        imgui.end()

        imgui.begin("Images", True)

        imgs_id = []
        for img_filename in onlyfiles:
            if img_filename.split(".")[-1] == "png":
                imgs_id.append((img_path+"/"+img_filename, img_manager.load_image(img_path+"/"+img_filename)))

        for img in imgs_id:
            img_size = img_manager.get_image_size(img[0])
            if img[1] is not 0 and img_size is not ():
                imgui.image(img[1], img_size[0]*2, img_size[1]*2, (0,1), (1,0))
                imgui.same_line()


        imgui.end()
        # note: cannot use screen.fill((1, 1, 1)) because pygame's screen
        #       does not support fill() on OpenGL sufraces
        gl.glClearColor(1, 1, 1, 1)
        gl.glClear(gl.GL_COLOR_BUFFER_BIT)
        imgui.render()

        pygame.display.flip()