def scroll_button_pressed(self, button): GUISystem.set_drag(self) if self.vertical: self.start_pos = GUISystem.gui_system.cursor_y else: self.start_pos = GUISystem.gui_system.cursor_x self.start_offset = self.offset
def handle_left_pressed(self): self.cursor_pos = len(self.text) self.focused = True self.use_stacked_labels() self.set_bg_color(self.focus_color) GUISystem.set_focus(self) if self.on_selected is not None: self.on_selected(self)
def __init__(self): GUIFrame.__init__(self) self.components = None self.envedit_data = None # GUI settings self.bg_color = (0, 0, 0, 0.8) self.bbox.width = 300 self.padding = 10 master_layout = GUIDockLayout() self.set_child(master_layout) self.layout = GUIStackLayout() master_layout.set_child_dock(self.layout, GUIDockLayout.TOP) title = GUILabel() title.text_size = 30 title.set_font(GUISystem.get_font("default_light")) title.set_text("Components") self.layout.add_child(title) spacer = GUIComponent() spacer.bbox.height = 20 self.layout.add_child(spacer) self.add_component_dropdown = GUIDropdown() self.add_component_dropdown.child.set_text("Add Component...") scroll_container = GUIScrollContainer(scroll_v=True, scroll_h=True) master_layout.set_child_dock(scroll_container, GUIDockLayout.CENTER) self.component_layout = GUIStackLayout() scroll_container.set_child(self.component_layout)
def __init__(self): GUIFrame.__init__(self) # Scene graph self.envedit_data = None # GUI settings self.bg_color = (0, 0, 0, 0.8) self.bbox.width = 300 self.padding = 10 master_layout = GUIDockLayout() self.set_child(master_layout) layout = GUIStackLayout() master_layout.set_child_dock(layout, GUIDockLayout.TOP) title = GUILabel() title.text_size = 30 title.set_font(GUISystem.get_font("default_light")) title.set_text("Scene Graph") layout.add_child(title) spacer = GUIComponent() spacer.bbox.height = 20 layout.add_child(spacer) scroll_container = GUIScrollContainer(scroll_v=True, scroll_h=True) master_layout.set_child_dock(scroll_container, GUIDockLayout.CENTER) self.scene_list = GUIList() scroll_container.set_child(self.scene_list)
def __init__(self): GUIFrame.__init__(self) self.text = "" self.font = GUISystem.get_font("default") self.text_color = (1, 1, 1, 1) self.bg_color = (1, 0, 1, 0) self.text_size = 12 self.frame = None
def handle_special_key(self, key): if key == "backspace": if self.cursor_pos != 0: self.set_text(self.text[:self.cursor_pos - 1] + self.text[self.cursor_pos:]) self.cursor_pos -= 1 self.update() elif key == "arrow_left": if self.cursor_pos != 0: self.cursor_pos -= 1 self.update() elif key == "arrow_right": if self.cursor_pos != len(self.text): self.cursor_pos += 1 self.update() elif key == "delete": if self.cursor_pos != len(self.text): self.set_text(self.text[:self.cursor_pos] + self.text[self.cursor_pos + 1:]) self.update() elif key == "enter": GUISystem.release_focus()
def list_item_right_released(self, item): # Create context menu menu = GUISystem.create_context_menu() add_node_button = GUIMenuItem() add_node_button.child.set_text("Create Child Node") add_node_button.on_release = self.add_node_handler add_node_button.data = item menu.child.add_child(add_node_button) if item.data is not self.envedit_data.scene_root: del_node_button = GUIMenuItem() del_node_button.child.set_text("Delete Node") del_node_button.on_release = self.del_node_handler del_node_button.data = item menu.child.add_child(del_node_button) ren_node_button = GUIMenuItem() ren_node_button.child.set_text("Rename Node") ren_node_button.on_release = self.ren_node_handler ren_node_button.data = item menu.child.add_child(ren_node_button) import_node_button = GUIMenuItem() import_node_button.child.set_text("Import Node Tree") import_node_button.on_release = self.import_node_handler import_node_button.data = item menu.child.add_child(import_node_button) export_node_button = GUIMenuItem() export_node_button.child.set_text("Export Node Tree") export_node_button.on_release = self.export_node_handler export_node_button.data = item menu.child.add_child(export_node_button) # No clue why this works menu.update() menu.update()
def handle_left_pressed(self): GUIButton.handle_left_pressed(self) GUISystem.place_dropdown(self, self.menu)
def remove_item(self, item): if type(item) == GUIListDropdown and item.expanded: item.collapse() item.deselect() self.child.remove_child(item) GUISystem.update_all()
def add_item(self, item, index=-1): item.list_container = self self.child.add_child(item, index) GUISystem.update_all()
def handle_left_pressed(self): self.set_bg_color(self.pressed_color) if self.on_click is not None: self.on_click(self) GUISystem.set_focus(self)
def __init__(self): ShowBase.__init__(self) # Allows importing components from project folder sys.path.append(".") # Initial scene setup self.disableMouse() self.setBackgroundColor(0.15, 0.15, 0.15, 1) EComponent.panda_root_node = self.render.attach_new_node(PandaNode("Root")) EComponent.base = self # Attach a directional light to the camera self.dir_light = DirectionalLight("cam_dir_light") dir_light_path = self.camera.attach_new_node(self.dir_light) EComponent.panda_root_node.setLight(dir_light_path) # Set up scene data self.envedit_data = EnveditData() self.envedit_data.update_callback = self.update_gui self.envedit_data.scene_root = GraphNode("Scene Root", []) self.envedit_data.panda_root_node = EComponent.panda_root_node # Read the project config file config_path = Path("project.yaml") config = None if not config_path.exists(): sys.stderr.write("Error: Could not find project.yaml.") return with open("project.yaml", "r") as file: config = yaml.load(file, Loader=yaml.FullLoader) self.envedit_data.project_name = config["project"] # Set up GUI system self.gui_system = GUISystem(self) GUIFontLoader.base = self GUISystem.fonts["default"] = GUIFontLoader.load_font("open-sans/OpenSans-Regular.ttf") GUISystem.fonts["default_bold"] = GUIFontLoader.load_font("open-sans/OpenSans-Bold.ttf") GUISystem.fonts["default_light"] = GUIFontLoader.load_font("open-sans/OpenSans-Light.ttf") window_layout = GUIDockLayout() self.gui_system.window.set_child(window_layout) # Set up Tkinter (for file dialogs) root = tk.Tk() root.withdraw() # Set up gizmo system self.gizmo_system = GizmoSystem(self, self.envedit_data) # Add floor self.floor_node = FloorNode(self) floor_path = self.render.attach_new_node(self.floor_node) floor_path.setTwoSided(True) floor_path.set_shader_input("object_id", 0) # Add camera controller self.cam_controller = CameraController(self, self.render, self.camera) # Add graph viewer self.graph_viewer = GraphViewer() window_layout.set_child_dock(self.graph_viewer, GUIDockLayout.LEFT) self.graph_viewer.set_envedit_data(self.envedit_data) # Add component viewer self.component_viewer = ComponentViewer() window_layout.set_child_dock(self.component_viewer, GUIDockLayout.RIGHT) self.component_viewer.set_envedit_data(self.envedit_data) self.component_viewer.set_components(config["components"]) component_reloader = ComponentReloader(self.component_viewer) # Add toolbar self.toolbar = Toolbar() window_layout.set_child_dock(self.toolbar, GUIDockLayout.TOP) self.toolbar.set_envedit_data(self.envedit_data) # Add empty center panel self.center_panel = CenterPanel(self.cam_controller) window_layout.set_child_dock(self.center_panel, GUIDockLayout.CENTER) # Add task to update nodes self.add_task(self.update_nodes) # Set up event handlers for key combinations self.accept("control-n", self.handle_new) self.accept("control-o", self.handle_open) self.accept("control-s", self.handle_save) self.update_gui()
def select(self): self.set_bg_color(self.active_color) self.list_container.set_selected_item(self) if self.select_callback is not None: self.select_callback(self) GUISystem.set_focus(self)
def handle_left_released(self): GUIButton.handle_left_released(self) GUISystem.close_context_menu()