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, component=None): GUIFrame.__init__(self) self.component = component if self.component is not None: self.component.component_update_callback = self.component_change_handler self.envedit_data = None self.property_fields = {} # GUI settings self.fit_height_to_content = True self.padding = 10 self.set_bg_color((1, 1, 1, 0.2)) layout = GUIStackLayout() self.set_child(layout) title_layout = GUIDockLayout() title_layout.bbox.height = 30 layout.add_child(title_layout) self.title = GUILabel() self.title.text_size = 15 self.title.set_text(self.component.name) title_layout.set_child_dock(self.title, GUIDockLayout.LEFT) options_dropdown = GUIDropdown(GUIDropdownVisualType.VERTICAL) title_layout.set_child_dock(options_dropdown, GUIDockLayout.RIGHT) move_up_option = GUIMenuItem() move_up_option.child.set_text("Move Component Up") move_up_option.data = self.component move_up_option.on_release = self.move_up_option_handler options_dropdown.menu.child.add_child(move_up_option) move_down_option = GUIMenuItem() move_down_option.child.set_text("Move Component Down") move_down_option.data = self.component move_down_option.on_release = self.move_down_option_handler options_dropdown.menu.child.add_child(move_down_option) del_option = GUIMenuItem() del_option.child.set_text("Delete Component") del_option.data = self.component del_option.on_release = self.del_option_handler options_dropdown.menu.child.add_child(del_option) self.properties_layout = GUIStackLayout() layout.add_child(self.properties_layout) self.setup_drawer()
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 __init__(self, use_int=False, step=.1): GUIFrame.__init__(self) self.use_int = use_int self.step = step if self.use_int: self.step = 1 self.bbox.height = 20 self.bbox.width = 100 self.data = None layout = GUIDockLayout() self.set_child(layout) self.text_box = GUITextBox() self.text_box.validate_text = self.validate_text layout.set_child_dock(self.text_box, GUIDockLayout.CENTER) button_layout = GUIStackLayout() button_layout.bbox.width = 10 layout.set_child_dock(button_layout, GUIDockLayout.RIGHT) up_button = GUIButton() up_button.bbox.height = 10 up_button.bbox.width = 10 up_button.set_normal_color((0.8, 0.8, 0.8, 0.9)) up_button.set_pressed_color((0, 0, 0, 0.9)) up_button.on_click = self.up_arrow_pressed up_button.set_bg_image("up_arrow.png") button_layout.add_child(up_button) down_button = GUIButton() down_button.bbox.height = 10 down_button.bbox.width = 10 down_button.set_normal_color((0.8, 0.8, 0.8, 0.9)) down_button.set_pressed_color((0, 0, 0, 0.9)) down_button.on_click = self.down_arrow_pressed down_button.set_bg_image("down_arrow.png") button_layout.add_child(down_button)
def use_stacked_labels(self): if self.child is not None: self.remove_child() self.set_child(GUIStackLayout(vertical=False)) self.child.bbox.height = self.bbox.height first_label = GUILabel() first_label.set_text_color(self.curr_text_color) first_label.receive_events = False self.child.add_child(first_label) cursor = GUIFrame() cursor.bbox.width = 1 cursor.set_bg_color((1, 1, 1, 1)) cursor.receive_events = False self.child.add_child(cursor) second_label = GUILabel() second_label.set_text_color(self.curr_text_color) second_label.receive_events = False self.child.add_child(second_label) self.update()
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) self.child = GUIStackLayout() self.selected_item = None
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)