class MyGui: def __init__(self, window): self.window = window # Must create or set the context before instantiating the renderer imgui.create_context() self.renderer = ArcadeRenderer(window) # Window variables self.test_input = 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("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())
class MyGui: def __init__(self, window): self.window = window # Must create or set the context before instantiating the renderer imgui.create_context() self.renderer = ArcadeRenderer(window) 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())
class MyGui: def __init__(self, window): self.window = window # Must create or set the context before instantiating the renderer imgui.create_context() self.renderer = ArcadeRenderer(window) self.texture = window.ctx.load_texture(RESOURCE_PATH / "robocute.png", flip=False) 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") draw_list = imgui.get_window_draw_list() #imgui.image(self.texture.glo, *self.texture.size) #draw_list.add_image(self.texture_id, (0, 0), (self.width, self.height)) draw_list.add_image(self.texture.glo, (0, 0), self.texture.size) imgui.end() imgui.end_frame() imgui.render() self.renderer.render(imgui.get_draw_data())
class MyGui: def __init__(self, window): self.window = window # Must create or set the context before instantiating the renderer imgui.create_context() self.renderer = ArcadeRenderer(window) self.visible = True 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: collapsing header") expanded, self.visible = imgui.collapsing_header( "Expand me!", self.visible) if expanded: imgui.text("Now you see me!") imgui.end() imgui.end_frame() imgui.render() self.renderer.render(imgui.get_draw_data())
class MyGui: def __init__(self, window): self.window = window # Must create or set the context before instantiating the renderer imgui.create_context() self.renderer = ArcadeRenderer(window) io = imgui.get_io() self.new_font = io.fonts.add_font_from_file_ttf( str(RESOURCE_PATH / "DroidSans.ttf"), 20) self.renderer.refresh_font_texture() 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())
class MyGui: def __init__(self, window): self.window = window # Must create or set the context before instantiating the renderer imgui.create_context() self.renderer = ArcadeRenderer(window) def render(self): 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() imgui.end_frame() imgui.render() self.renderer.render(imgui.get_draw_data())
class MyGui: def __init__(self, window): self.window = window # Must create or set the context before instantiating the renderer imgui.create_context() self.renderer = ArcadeRenderer(window) def draw(self): imgui.new_frame() imgui.set_next_window_position(16, 32, imgui.ONCE) imgui.set_next_window_size(512, 512, imgui.ONCE) style = imgui.get_style() imgui.begin("Colors") imgui.columns(4) for color in range(0, imgui.COLOR_COUNT): imgui.text("Color: {}".format(color)) imgui.color_button("color#{}".format(color), *style.colors[color]) imgui.next_column() imgui.end() imgui.end_frame() imgui.render() self.renderer.render(imgui.get_draw_data())
class MyGui: def __init__(self, window): self.window = window # Must create or set the context before instantiating the renderer imgui.create_context() self.renderer = ArcadeRenderer(window) self.sprite = arcade.Sprite(":resources:images/space_shooter/playerShip1_orange.png", SPRITE_SCALING) image = self.sprite.texture.image self.texture = window.ctx.texture(image.size, components=3, data=image.convert("RGB").tobytes()) 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("Sprite") imgui.image(self.texture.glo, *self.texture.size) imgui.end() imgui.end_frame() imgui.render() self.renderer.render(imgui.get_draw_data())
class MyGui: def __init__(self, window): self.window = window # Must create or set the context before instantiating the renderer imgui.create_context() self.renderer = ArcadeRenderer(window) 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: dummy elements") imgui.text("Some text with bullets:") imgui.bullet_text("Bullet A") imgui.bullet_text("Bullet B") imgui.dummy(0, 50) imgui.bullet_text("Text after dummy") imgui.end() imgui.end_frame() imgui.render() self.renderer.render(imgui.get_draw_data())
class MyGui: def __init__(self, window): self.window = window # Must create or set the context before instantiating the renderer imgui.create_context() self.renderer = ArcadeRenderer(window) 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: tooltip") imgui.button("Click me!") if imgui.is_item_hovered(): imgui.begin_tooltip() imgui.text("This button is clickable.") imgui.text("This button has full window tooltip.") texture_id = imgui.get_io().fonts.texture_id imgui.image(texture_id, 512, 64, border_color=(1, 0, 0, 1)) imgui.end_tooltip() imgui.end() imgui.end_frame() imgui.render() self.renderer.render(imgui.get_draw_data())
class MyGui: def __init__(self, window): self.window = window # Must create or set the context before instantiating the renderer imgui.create_context() self.renderer = ArcadeRenderer(window) 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())
class MyGui: def __init__(self, window): self.window = window # Must create or set the context before instantiating the renderer imgui.create_context() self.renderer = ArcadeRenderer(window) def draw(self): imgui.new_frame() imgui.set_next_window_position(16, 32, imgui.ONCE) imgui.set_next_window_size(512, 512, imgui.ONCE) 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() imgui.end_frame() imgui.render() self.renderer.render(imgui.get_draw_data())
class MyGui: def __init__(self, window): self.window = window # Must create or set the context before instantiating the renderer imgui.create_context() self.renderer = ArcadeRenderer(window) 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())
class MyGui: def __init__(self, window): self.window = window # Must create or set the context before instantiating the renderer imgui.create_context() self.renderer = ArcadeRenderer(window) self.current = 2 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: combo widget") clicked, self.current = imgui.combo( "combo", self.current, ["first", "second", "third"] ) imgui.end() imgui.end_frame() imgui.render() self.renderer.render(imgui.get_draw_data())
class MyGui: def __init__(self, window): self.window = window # Must create or set the context before instantiating the renderer imgui.create_context() self.renderer = ArcadeRenderer(window) self.value = 42 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.value = imgui.drag_int( "drag int", self.value, ) imgui.text("Changed: %s, Value: %s" % (changed, self.value)) imgui.end() imgui.end_frame() imgui.render() self.renderer.render(imgui.get_draw_data())
class MyGui: def __init__(self, window): self.window = window # Must create or set the context before instantiating the renderer imgui.create_context() self.renderer = ArcadeRenderer(window) 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: child region") imgui.begin_child("region", 150, -50, border=True) imgui.text("inside region") imgui.end_child() imgui.text("outside region") imgui.end() imgui.end_frame() imgui.render() self.renderer.render(imgui.get_draw_data())
class MyGui: def __init__(self, window): self.window = window # Must create or set the context before instantiating the renderer imgui.create_context() self.renderer = ArcadeRenderer(window) 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())
class MyGui: def __init__(self, window): self.window = window # Must create or set the context before instantiating the renderer imgui.create_context() self.renderer = ArcadeRenderer(window) 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())
class MyGui: def __init__(self, window): self.window = window # Must create or set the context before instantiating the renderer imgui.create_context() self.renderer = ArcadeRenderer(window) 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())
class MyGui: def __init__(self, window): self.window = window # Must create or set the context before instantiating the renderer imgui.create_context() self.renderer = ArcadeRenderer(window) # note: the variable that contains the color data, should be initialized # outside of the main interaction loop self.color_1 = 1., .0, .5 self.color_2 = 0., .8, .3 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 without 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 changed, self.color_1 = imgui.color_edit3("Color 1", *self.color_1) changed, self.color_2 = imgui.color_edit3("Color 2", *self.color_2) imgui.end() imgui.end_frame() imgui.render() self.renderer.render(imgui.get_draw_data())
class MyGui: def __init__(self, window): self.window = window # Must create or set the context before instantiating the renderer imgui.create_context() self.renderer = ArcadeRenderer(window) 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 view") imgui.text("Right-click to set value.") if imgui.begin_popup_context_item("Item Context Menu", mouse_button=0): imgui.selectable("Set to Zero") imgui.end_popup() imgui.end() imgui.end_frame() imgui.render() self.renderer.render(imgui.get_draw_data())
class MyGui: def __init__(self, window): self.window = window # Must create or set the context before instantiating the renderer imgui.create_context() self.renderer = ArcadeRenderer(window) 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())
class MyGui: def __init__(self, window): self.window = window # Must create or set the context before instantiating the renderer imgui.create_context() self.renderer = ArcadeRenderer(window) 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("Line") draw_list = imgui.get_window_draw_list() draw_list.add_line(20, 35, 180, 80, imgui.get_color_u32_rgba(1,1,0,1), 3) draw_list.add_line(180, 35, 20, 80, imgui.get_color_u32_rgba(1,0,0,1), 3) imgui.end() imgui.begin("Poly Line") draw_list = imgui.get_window_draw_list() draw_list.add_polyline([(20, 35), (90, 35), (55, 80)], imgui.get_color_u32_rgba(1,1,0,1), closed=False, thickness=3) draw_list.add_polyline([(110, 35), (180, 35), (145, 80)], imgui.get_color_u32_rgba(1,0,0,1), closed=True, thickness=3) imgui.end() imgui.end_frame() imgui.render() self.renderer.render(imgui.get_draw_data())
class MyGui: def __init__(self, window): self.window = window # Must create or set the context before instantiating the renderer imgui.create_context() self.renderer = ArcadeRenderer(window) # Window variables self.test_input = 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 indenting") imgui.text("Some text with bullets:") imgui.bullet_text("Bullet A") imgui.indent() imgui.bullet_text("Bullet B (first indented)") imgui.bullet_text("Bullet C (indent continues)") imgui.unindent() imgui.bullet_text("Bullet D (indent cleared)") imgui.end() imgui.end_frame() imgui.render() self.renderer.render(imgui.get_draw_data())
class MyGui: def __init__(self, window): self.window = window # Must create or set the context before instantiating the renderer imgui.create_context() self.renderer = ArcadeRenderer(window) self.values = 88.0, 42.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 float") changed, self.values = imgui.drag_float2("Default", *self.values) changed, self.values = imgui.drag_float2("Less precise", *self.values, format="%.1f") imgui.text("Changed: %s, Values: %s" % (changed, self.values)) imgui.end() imgui.end_frame() imgui.render() self.renderer.render(imgui.get_draw_data())
class Gui: def __init__(self, window): self.window = window # Must create or set the context before instantiating the renderer imgui.create_context() self.renderer = ArcadeRenderer(window) def draw(self): imgui.render() self.renderer.render(imgui.get_draw_data())
class MyGui: def __init__(self, window): self.window = window # Must create or set the context before instantiating the renderer imgui.create_context() self.renderer = ArcadeRenderer(window) 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: Columns - File list") imgui.columns(4, 'fileLlist') imgui.separator() imgui.text("ID") imgui.next_column() imgui.text("File") imgui.next_column() imgui.text("Size") imgui.next_column() imgui.text("Last Modified") imgui.next_column() imgui.separator() imgui.set_column_offset(1, 40) imgui.next_column() imgui.text('FileA.txt') imgui.next_column() imgui.text('57 Kb') imgui.next_column() imgui.text('12th Feb, 2016 12:19:01') imgui.next_column() imgui.next_column() imgui.text('ImageQ.png') imgui.next_column() imgui.text('349 Kb') imgui.next_column() imgui.text('1st Mar, 2016 06:38:22') imgui.next_column() imgui.columns(1) imgui.end() imgui.end_frame() imgui.render() self.renderer.render(imgui.get_draw_data())
class ArcadeImGui: def __init__(self, window): self.window = window # Must create or set the context before instantiating the renderer imgui.create_context() self.renderer = ArcadeRenderer(window) def __enter__(self): imgui.new_frame() def __exit__(self, exc_type, exc_val, exc_tb): self.render() def render(self): imgui.render() self.renderer.render(imgui.get_draw_data())
class MyGui: def __init__(self, window): self.window = window # Must create or set the context before instantiating the renderer imgui.create_context() self.renderer = ArcadeRenderer(window) 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("Rectangle") draw_list = imgui.get_window_draw_list() draw_list.add_rect(20, 35, 90, 80, imgui.get_color_u32_rgba(1, 1, 0, 1), thickness=3) draw_list.add_rect(110, 35, 180, 80, imgui.get_color_u32_rgba(1, 0, 0, 1), rounding=5, 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 Rectangle") draw_list = imgui.get_window_draw_list() draw_list.add_rect_filled(20, 35, 90, 80, imgui.get_color_u32_rgba(1, 1, 0, 1)) draw_list.add_rect_filled(110, 35, 180, 80, imgui.get_color_u32_rgba(1, 0, 0, 1), 5) imgui.end() imgui.end_frame() imgui.render() self.renderer.render(imgui.get_draw_data())
class MyGui: def __init__(self, window): self.window = window # Must create or set the context before instantiating the renderer imgui.create_context() self.renderer = ArcadeRenderer(window) # note: these should be initialized outside of the main interaction # loop self.flags = imgui.WINDOW_NO_RESIZE | imgui.WINDOW_NO_MOVE 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())