def create_window_dock(glfw_window, menu_bar=False): imgui.set_next_window_bg_alpha(0) imgui.push_style_var(imgui.STYLE_WINDOW_PADDING, (0, 0)) begin_maximized_window("Background Window", glfw_window, menu_bar) imgui.pop_style_var(1) imgui.dock_space("Window Dock Space", 0., 0., 1 << 3) imgui.end()
def draw_console(): global _console_text_temp if console.SHOW_CONSOLE: imgui.set_next_window_bg_alpha(0.35) imgui.set_next_window_position(0, 0) imgui.set_next_window_size(screen_utils.WIDTH, 110) imgui.begin( "ConsoleWindow", False, imgui.WINDOW_NO_MOVE | imgui.WINDOW_NO_RESIZE | imgui.WINDOW_NO_COLLAPSE | imgui.WINDOW_NO_TITLE_BAR | imgui.WINDOW_NO_SAVED_SETTINGS) imgui.begin_child("ConsoleOutput", 0, -25, False) for text, color in console.text_buffer: if color is None: color = (0.25, 0.75, 1) imgui.text_colored(text, color[0], color[1], color[2], 0.8) imgui.text("") imgui.set_scroll_y(imgui.get_scroll_max_y()) imgui.end_child() buf_size = 256 if len(_console_text_temp) > 0 and not _console_text_temp[0] == "/": buf_size = 64 enter, text = imgui.input_text("Input", _console_text_temp, buf_size, imgui.INPUT_TEXT_ENTER_RETURNS_TRUE) if enter: if str.startswith(text, "/"): text = str.replace(text, "/", "", 1) console.handle_input(text) else: client_net.send_message(text) text = "" _console_text_temp = text imgui.end()
def draw_gui(self, sp, wp, c: OrthographicCamera): # render price pointer win_p = sp[0] - 100, c.viewport()[1] - sp[1] - 30 imgui.set_next_window_position(win_p[0], win_p[1]) imgui.set_next_window_bg_alpha(0.1) imgui.begin( "mouse_pointer", False, imgui.WINDOW_NO_MOVE | imgui.WINDOW_NO_TITLE_BAR | imgui.WINDOW_NO_RESIZE | imgui.WINDOW_ALWAYS_AUTO_RESIZE) imgui.text("R$ %.2f" % wp[1]) self.current_pointer = (wp[0], wp[1]) imgui.end() # render box measure if self.dragging: ss = c.project(self.start[0], self.start[1]) se = c.project(self.end[0], self.end[1]) win_p = (ss[0] + se[0]) / 2, c.viewport()[1] - (ss[1] + se[1]) / 2 imgui.set_next_window_position(win_p[0], win_p[1]) imgui.set_next_window_bg_alpha(0.9) imgui.begin( "box_measure", False, imgui.WINDOW_NO_MOVE | imgui.WINDOW_NO_TITLE_BAR | imgui.WINDOW_NO_RESIZE | imgui.WINDOW_ALWAYS_AUTO_RESIZE) imgui.text("R$ %.2f -> %.2f" % (self.start[1], self.end[1])) imgui.text("Profit: R$ %.2f (%.2f%%)" % (self.end[1] - self.start[1], ((self.end[1] - self.start[1]) / self.start[1] * 100))) imgui.end()
def draw_gui(self, camera, data, timeline): io = imgui.get_io() if not io.want_capture_mouse: x = imgui.get_mouse_pos().x y = camera.viewport()[1] - imgui.get_mouse_pos().y p = camera.unproject(x, y) i = timeline.intersect(p[0]) if i[0]: date = timeline.index_date(i[1]) if date is not None: df = data[data.Date == date] wp = x + 20, camera.viewport()[1] - y - 100 imgui.set_next_window_position(wp[0], wp[1]) imgui.set_next_window_bg_alpha(0.8) imgui.begin( "pointer", False, imgui.WINDOW_NO_MOVE | imgui.WINDOW_NO_TITLE_BAR | imgui.WINDOW_NO_RESIZE | imgui.WINDOW_ALWAYS_AUTO_RESIZE) imgui.text("Date: " + str(date)) for index, row in df.iterrows(): imgui.separator() imgui.text(row["Pattern"] + ": " + str(row["CandleTime"])) imgui.end() pass
def show_main_menu(): global text, ip_text style: GuiStyle = imgui.get_style() style.window_border_size = 0 style.colors[imgui.COLOR_BUTTON] = Vec4(0.26, 0.59, 0.5, 0.4) style.colors[imgui.COLOR_BUTTON_ACTIVE] = Vec4(0.06, 0.53, 0.4, 1.0) style.colors[imgui.COLOR_BUTTON_HOVERED] = Vec4(0.26, 0.59, 0.5, 1.0) imgui.set_next_window_bg_alpha(0) imgui.set_next_window_position(300, 220) imgui.set_next_window_size(180, 200) imgui.begin("tremor0", False, imgui.WINDOW_NO_COLLAPSE | imgui.WINDOW_NO_MOVE | imgui.WINDOW_NO_RESIZE | imgui.WINDOW_NO_TITLE_BAR | imgui.WINDOW_ALWAYS_USE_WINDOW_PADDING) _, username = imgui.input_text("Name", text, 16) _, ip = imgui.input_text("Host", ip_text, 32) ip_text = ip text = username imgui.end() imgui.set_next_window_bg_alpha(0) imgui.set_next_window_size(100, 100) imgui.set_next_window_position(200, 200) imgui.begin("tremor1", False, imgui.WINDOW_NO_COLLAPSE | imgui.WINDOW_NO_MOVE | imgui.WINDOW_NO_RESIZE | imgui.WINDOW_NO_TITLE_BAR | imgui.WINDOW_ALWAYS_USE_WINDOW_PADDING) imgui.text_colored("Tremor", 0.9, 0.6, 1.0) play_clicked = imgui.button("Play", 82, 25) exit_clicked = imgui.button("Exit", 82, 25) if exit_clicked: graphics_subsystem.request_close() if play_clicked: print(username) client_net.connect_to_server((ip, 27070), username) imgui.end()
def draw_gui(camera, data, timeline): x = imgui.get_mouse_pos().x y = camera.viewport()[1] - imgui.get_mouse_pos().y p = camera.unproject(x, y) r = intersect(p[0], p[1], data, timeline) if r is not None: wp = x + 20, camera.viewport()[1] - y - 100 imgui.set_next_window_position(wp[0], wp[1]) imgui.set_next_window_bg_alpha(0.8) imgui.begin( "pointer", False, imgui.WINDOW_NO_MOVE | imgui.WINDOW_NO_TITLE_BAR | imgui.WINDOW_NO_RESIZE | imgui.WINDOW_ALWAYS_AUTO_RESIZE) imgui.text("Date: " + str(r.date)) imgui.separator() imgui.text("Low: %.2f" % float(r.min_value)) imgui.text("Max: %.2f" % float(r.max_value)) imgui.text("Open: %.2f" % float(r.open_value)) imgui.text("Close: %.2f" % float(r.close_value)) imgui.end()
def invisible_window(window): "Draw a transparent imgui window on top of the drawing" w, h = window.get_size() wx0, wy0 = window._to_window_coords(0, 0) wx1, wy1 = window._to_window_coords(*window.drawing.size) imgui.set_next_window_size(wx1 - wx0, wy0 - wy1) imgui.set_next_window_position(wx0, h - wy0) imgui.set_next_window_bg_alpha(0) with imgui.istyled(imgui.STYLE_WINDOW_ROUNDING, 0, imgui.STYLE_WINDOW_BORDERSIZE, 0, imgui.STYLE_WINDOW_PADDING, (0, 0)): imgui.begin("selection point", False, flags=(imgui.WINDOW_NO_TITLE_BAR | imgui.WINDOW_NO_RESIZE | imgui.WINDOW_NO_MOVE | imgui.WINDOW_NO_INPUTS)) yield imgui.end()
while (glfw.get_time() < time_at_beginning_of_previous_frame + 1.0 / TARGET_FRAMERATE): pass # set for comparison on the next frame time_at_beginning_of_previous_frame = glfw.get_time() if not animation_paused: animation_time += 1.0 / 60.0 * animation_time_multiplier # Poll for and process events glfw.poll_events() impl.process_inputs() imgui.new_frame() imgui.set_next_window_bg_alpha(0.05) imgui.begin("Time", True) clicked_animation_paused, animation_paused = imgui.checkbox( "Pause", animation_paused) clicked_camera, camera.r = imgui.slider_float("Camera Radius", camera.r, 10, 1000.0) clicked_animation_time_multiplier, animation_time_multiplier = imgui.slider_float( "Sim Speed", animation_time_multiplier, 0.1, 10.0) if imgui.button("Restart"): animation_time = 0.0 if imgui.tree_node("From World Space, Against Arrows, Read Bottom Up", imgui.TREE_NODE_DEFAULT_OPEN): if imgui.tree_node("Paddle 1->World", imgui.TREE_NODE_DEFAULT_OPEN): imgui.text("f_paddle1_to_world(x) = ")