def __init__(self): GUILayout.__init__(self) self.left_child = GUIComponent() self.right_child = GUIComponent() self.top_child = GUIComponent() self.bottom_child = GUIComponent() self.center_child = GUIComponent()
def __init__(self): GUIComponent.__init__(self) self.bg_color = (0, 0, 0, 0) self.bg_image = None self.padding = 0 self.fit_width_to_content = False # if the width should conform to the child self.fit_height_to_content = False # if the height should conform to the child self.frame = None
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, text=""): GUIListItem.__init__(self) self.fit_width_to_content = False self.fit_height_to_content = True self.expanded = False self.sub_list = [] self.parent = None self.level = 0 self.level_spacer = GUIComponent() self.level_spacer.bbox.width = 0 self.level_spacer.receive_events = False self.dropdown_button = GUIButton() self.dropdown_button.set_bg_image("right_arrow.png") self.dropdown_button.set_normal_color((1, 1, 1, 0.8)) self.dropdown_button.set_hover_color((1, 1, 1, 0.8)) self.dropdown_button.set_pressed_color((1, 1, 1, 0.8)) self.dropdown_button.bbox.width = 16 self.dropdown_button.on_click = self.on_dropdown_click self.spacer = GUIComponent() self.spacer.bbox.width = 6 self.spacer.receive_events = False self.label = GUILabel() self.label.text_size = 15 self.label.set_text(text) self.label.receive_events = False self.layout = GUIStackLayout(vertical=False) self.layout.padding = 12 self.layout.bbox.height = 40 self.layout.add_child(self.level_spacer) self.layout.add_child(self.dropdown_button) self.layout.add_child(self.spacer) self.layout.add_child(self.label) self.set_child(self.layout)
def add_button_handler(self, button): # Add new element to array self.component.property_vals[button.data].append("") # Add new field to list of elements element_layout = GUIStackLayout(vertical=False) element_layout.padding = 4 element_layout.bbox.height = 28 self.property_fields[button.data].add_child(element_layout) inner_property_val = GUITextBox() inner_property_val.data = { "parent": button.data, "index": len(self.component.property_vals[button.data]) - 1 } inner_property_val.set_text("") inner_property_val.on_text_changed = self.text_change_handler element_layout.add_child(inner_property_val) element_spacer = GUIComponent() element_spacer.bbox.width = 4 element_layout.add_child(element_spacer) del_button = GUIButton() del_button.padding = 3 del_button.bbox.width = 16 del_button.bbox.height = 20 del_button.set_normal_color((1, 0, 0, 0.8)) del_button.set_hover_color((1, 0.4, 0.4, 0.8)) del_button.set_pressed_color((0.4, 0, 0, 0.8)) del_button.on_click = self.element_del_button_handler del_button.data = element_layout del_button_label = GUILabel() del_button_label.set_text("X") del_button_label.receive_events = False del_button.set_child(del_button_label) element_layout.add_child(del_button)
def __init__(self): GUIComponent.__init__(self)
def __init__(self, cam_controller): GUIComponent.__init__(self) self.cam_controller = cam_controller
def __init__(self): GUIComponent.__init__(self) self.child = GUIStackLayout() self.selected_item = None
def __init__(self): GUIComponent.__init__(self) self.context_menu_layer = GUIFreeLayout() self.selected_context_menu = False
def __init__(self): GUIFrame.__init__(self) self.envedit_data = None # GUI settings self.bbox.height = 64 self.set_bg_color((0, 0, 0, 0.8)) self.set_child(GUIStackLayout()) buttons_layout = GUIStackLayout(vertical=False) buttons_layout.bbox.height = 34 self.child.add_child(buttons_layout) file_dropdown = GUIDropdown() file_dropdown.child.text_size = 15 file_dropdown.child.set_text("File") file_dropdown.fit_width_to_content = True file_dropdown.padding = 6 new_button = GUIMenuItem() new_button.child.set_text("New") new_button.on_release = self.file_new_option_handler file_dropdown.menu.child.add_child(new_button) open_button = GUIMenuItem() open_button.child.set_text("Open...") open_button.on_release = self.file_open_option_handler file_dropdown.menu.child.add_child(open_button) save_button = GUIMenuItem() save_button.child.set_text("Save") save_button.on_release = self.file_save_option_handler file_dropdown.menu.child.add_child(save_button) save_as_button = GUIMenuItem() save_as_button.child.set_text("Save As...") save_as_button.on_release = self.file_save_as_option_handler file_dropdown.menu.child.add_child(save_as_button) buttons_layout.add_child(file_dropdown) edit_dropdown = GUIDropdown() edit_dropdown.child.text_size = 15 edit_dropdown.child.set_text("Edit") edit_dropdown.fit_width_to_content = True edit_dropdown.padding = 6 buttons_layout.add_child(edit_dropdown) middle_border = GUIFrame() middle_border.set_bg_color((0.2, 0.2, 0.2, 1)) middle_border.bbox.height = 1 self.child.add_child(middle_border) bottom_bar_layout = GUIDockLayout() bottom_bar_layout.bbox.height = 28 self.child.add_child(bottom_bar_layout) icons_layout = GUIStackLayout(vertical=False) bottom_bar_layout.set_child_dock(icons_layout, GUIDockLayout.LEFT) translate_button = GUIButton() translate_button.bbox.width = 30 translate_button.bbox.height = 30 translate_button.set_normal_color((1, 1, 1, 0.9)) translate_button.set_pressed_color((0, 0, 0, 0.9)) translate_button.set_bg_image("translate_icon.png") translate_button.on_click = self.translate_button_handler icons_layout.add_child(translate_button) rotate_button = GUIButton() rotate_button.bbox.width = 30 rotate_button.bbox.height = 30 rotate_button.set_normal_color((1, 1, 1, 0.9)) rotate_button.set_pressed_color((0, 0, 0, 0.9)) rotate_button.set_bg_image("rotate_icon.png") rotate_button.on_click = self.rotate_button_handler icons_layout.add_child(rotate_button) scale_button = GUIButton() scale_button.bbox.width = 30 scale_button.bbox.height = 30 scale_button.set_normal_color((1, 1, 1, 0.9)) scale_button.set_pressed_color((0, 0, 0, 0.9)) scale_button.set_bg_image("scale_icon.png") scale_button.on_click = self.scale_button_handler icons_layout.add_child(scale_button) play_layout = GUIStackLayout(vertical=False) bottom_bar_layout.set_child_dock(play_layout, GUIDockLayout.RIGHT) play_button = GUIButton() play_button.bbox.width = 30 play_button.bbox.height = 30 play_button.set_normal_color((0.2, 0.8, 0.2, 0.9)) play_button.set_hover_color((0.2, 0.9, 0.2, 0.9)) play_button.set_pressed_color((0.2, 0.5, 0.2, 0.9)) play_button.set_bg_image("play_icon.png") play_button.on_click = self.play_button_handler play_layout.add_child(play_button) play_spacer = GUIComponent() play_spacer.bbox.width = 150 play_layout.add_child(play_spacer) bottom_border = GUIFrame() bottom_border.set_bg_color((0.2, 0.2, 0.2, 1)) bottom_border.bbox.height = 2 self.child.add_child(bottom_border)
def setup_drawer(self): if self.component is not None: for property in self.component.property_types: property_type = self.component.property_types[property] property_frame = GUIFrame() property_frame.bbox.height = 30 property_frame.padding = 4 self.properties_layout.add_child(property_frame) property_layout = GUIStackLayout(vertical=False) property_layout.bbox.height = 30 property_frame.set_child(property_layout) property_name = GUILabel() property_name.set_text(property + ":") property_layout.add_child(property_name) spacer = GUIComponent() spacer.bbox.width = 20 property_layout.add_child(spacer) if property_type == PropertyType.INT: property_val = GUINumberBox(use_int=True) property_val.text_box.data = property property_val.text_box.set_text( self.component.property_vals[property]) property_val.text_box.on_text_changed = self.text_change_handler self.property_fields[property] = property_val property_layout.add_child(property_val) elif property_type == PropertyType.FLOAT: property_val = GUINumberBox() property_val.text_box.data = property property_val.text_box.set_text( self.component.property_vals[property]) property_val.text_box.on_text_changed = self.text_change_handler self.property_fields[property] = property_val property_layout.add_child(property_val) elif property_type == PropertyType.BOOL: property_val = GUITextBox() property_val.data = property property_val.set_text( self.component.property_vals[property]) property_val.on_text_changed = self.text_change_handler self.property_fields[property] = property_val property_layout.add_child(property_val) elif property_type == PropertyType.STRING: property_val = GUITextBox() property_val.data = property property_val.set_text( self.component.property_vals[property]) property_val.on_text_changed = self.text_change_handler self.property_fields[property] = property_val property_layout.add_child(property_val) elif property_type == PropertyType.FILE: property_val = GUITextBox() property_val.data = property property_val.set_text( self.component.property_vals[property]) property_val.on_selected = self.file_open_handler self.property_fields[property] = property_val property_layout.add_child(property_val) elif property_type == PropertyType.ARRAY: property_val = GUIStackLayout() property_val.bbox.width = 124 add_button = GUIButton() add_button.padding = 2 add_button.bbox.width = 20 add_button.bbox.height = 20 add_button.data = property add_button.on_click = self.add_button_handler button_label = GUILabel() button_label.receive_events = False button_label.set_text("Add Element") add_button.set_child(button_label) property_val.add_child(add_button) vals = self.component.property_vals[property] for i in range(len(vals)): val = vals[i] element_layout = GUIStackLayout(vertical=False) element_layout.padding = 4 element_layout.bbox.height = 28 property_val.add_child(element_layout) inner_property_val = GUITextBox() inner_property_val.data = { "parent": property, "index": i } inner_property_val.set_text(val) inner_property_val.on_text_changed = self.text_change_handler element_layout.add_child(inner_property_val) element_spacer = GUIComponent() element_spacer.bbox.width = 4 element_layout.add_child(element_spacer) del_button = GUIButton() del_button.padding = 3 del_button.bbox.width = 16 del_button.bbox.height = 20 del_button.set_normal_color((1, 0, 0, 0.8)) del_button.set_hover_color((1, 0.4, 0.4, 0.8)) del_button.set_pressed_color((0.4, 0, 0, 0.8)) del_button.on_click = self.element_del_button_handler del_button.data = element_layout del_button_label = GUILabel() del_button_label.set_text("X") del_button_label.receive_events = False del_button.set_child(del_button_label) element_layout.add_child(del_button) self.property_fields[property] = property_val property_layout.add_child(property_val) property_frame.fit_height_to_content = True property_layout.bbox.height = property_val.bbox.height elif property_type == PropertyType.VECTOR3: property_val = GUIStackLayout(vertical=False) x_val = GUINumberBox() x_val.text_box.data = {"parent": property, "index": 0} x_val.bbox.width = 60 x_val.text_box.set_text( str(self.component.property_vals[property][0])) x_val.text_box.on_text_changed = self.text_change_handler property_val.add_child(x_val) spacer_1 = GUIComponent() spacer_1.bbox.width = 10 property_val.add_child(spacer_1) y_val = GUINumberBox() y_val.text_box.data = {"parent": property, "index": 1} y_val.bbox.width = 60 y_val.text_box.set_text( str(self.component.property_vals[property][1])) y_val.text_box.on_text_changed = self.text_change_handler property_val.add_child(y_val) spacer_2 = GUIComponent() spacer_2.bbox.width = 10 property_val.add_child(spacer_2) z_val = GUINumberBox() z_val.text_box.data = {"parent": property, "index": 2} z_val.bbox.width = 60 z_val.text_box.set_text( str(self.component.property_vals[property][2])) z_val.text_box.on_text_changed = self.text_change_handler property_val.add_child(z_val) self.property_fields[property] = property_val property_layout.add_child(property_val)
class GUIDockLayout(GUILayout): # Enum values for dock LEFT = 0 RIGHT = 1 TOP = 2 BOTTOM = 3 CENTER = 4 def __init__(self): GUILayout.__init__(self) self.left_child = GUIComponent() self.right_child = GUIComponent() self.top_child = GUIComponent() self.bottom_child = GUIComponent() self.center_child = GUIComponent() def update(self): self.top_child.bbox.x = self.bbox.x self.top_child.bbox.y = self.bbox.y self.top_child.bbox.width = self.bbox.width self.top_child.set_clip_region( self.clip_region.get_intersection(self.bbox)) self.top_child.update() self.bottom_child.bbox.x = self.bbox.x self.bottom_child.bbox.y = self.bbox.y + self.bbox.height - self.bottom_child.bbox.height self.bottom_child.bbox.width = self.bbox.width self.bottom_child.set_clip_region( self.clip_region.get_intersection(self.bbox)) self.bottom_child.update() self.left_child.bbox.x = self.bbox.x self.left_child.bbox.y = self.bbox.y + self.top_child.bbox.height self.left_child.bbox.height = self.bbox.height - ( self.top_child.bbox.height + self.bottom_child.bbox.height) self.left_child.set_clip_region( self.clip_region.get_intersection(self.bbox)) self.left_child.update() self.right_child.bbox.x = self.bbox.x + self.bbox.width - self.right_child.bbox.width self.right_child.bbox.y = self.bbox.y + self.top_child.bbox.height self.right_child.bbox.height = self.bbox.height - ( self.top_child.bbox.height + self.bottom_child.bbox.height) self.right_child.set_clip_region( self.clip_region.get_intersection(self.bbox)) self.right_child.update() self.center_child.bbox.x = self.bbox.x + self.left_child.bbox.width self.center_child.bbox.y = self.bbox.y + self.top_child.bbox.height self.center_child.bbox.width = self.bbox.width - ( self.left_child.bbox.width + self.right_child.bbox.width) self.center_child.bbox.height = self.bbox.height - ( self.top_child.bbox.height + self.bottom_child.bbox.height) self.center_child.set_clip_region( self.clip_region.get_intersection(self.bbox)) self.center_child.update() # Sets the docked child def set_child_dock(self, child, dock_dir): if self.rendering: child.add_render() if dock_dir == GUIDockLayout.LEFT: self.left_child = child elif dock_dir == GUIDockLayout.RIGHT: self.right_child = child elif dock_dir == GUIDockLayout.TOP: self.top_child = child elif dock_dir == GUIDockLayout.BOTTOM: self.bottom_child = child elif dock_dir == GUIDockLayout.CENTER: self.center_child = child self.update() # Checks if this component contains a point in screen space, then propagates to children def get_selected_component(self, x, y): if self.bbox.point_inside(x, y): children = [ None if self.left_child is None else self.left_child.get_selected_component(x, y), None if self.right_child is None else self.right_child.get_selected_component(x, y), None if self.top_child is None else self.top_child.get_selected_component(x, y), None if self.bottom_child is None else self.bottom_child.get_selected_component(x, y), None if self.center_child is None else self.center_child.get_selected_component(x, y) ] for child in children: if child is not None: return child return self return None def add_render(self): self.rendering = True children = [ self.left_child, self.right_child, self.top_child, self.bottom_child, self.center_child ] for child in children: if child is not None: child.add_render() self.update() def stop_render(self): self.rendering = False children = [ self.left_child, self.right_child, self.top_child, self.bottom_child, self.center_child ] for child in children: if child is not None: child.stop_render() self.update()