Esempio n. 1
0
    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)
Esempio n. 2
0
    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)
Esempio n. 3
0
    def __init__(self, visual=GUIDropdownVisualType.LABEL):
        GUIButton.__init__(self)
        self.bbox.height = 24
        self.padding = 2
        self.set_normal_color((0.1, 0.1, 0.1, 0))
        self.set_hover_color((1, 1, 1, 0.2))
        self.set_pressed_color((0.5, 0.5, 0.5, 1))

        if visual == GUIDropdownVisualType.LABEL:
            self.set_child(GUILabel())
        elif visual == GUIDropdownVisualType.VERTICAL:
            self.fit_width_to_content = True
            self.fit_height_to_content = True
            self.set_child(GUIFrame())
            self.child.bbox.width = 24
            self.child.bbox.height = 24
            self.child.set_bg_color((1, 1, 1, 0.9))
            self.child.set_bg_image("vertical_more.png")
        elif visual == GUIDropdownVisualType.HORIZONTAL:
            self.fit_width_to_content = True
            self.fit_height_to_content = True
            self.set_child(GUIFrame())
            self.child.bbox.width = 24
            self.child.bbox.height = 24
            self.child.set_bg_color((1, 1, 1, 0.9))
            self.child.set_bg_image("horizontal_more.png")
        self.child.receive_events = False

        self.menu = GUIContextMenu()
Esempio n. 4
0
 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
Esempio n. 5
0
 def __init__(self):
     GUIFrame.__init__(self)
     self.on_click = None
     self.on_release = None
     self.normal_color = (0, 0, 0, 0.4)
     self.pressed_color = (0, 0, 0, 1)
     self.hover_color = (1, 1, 1, 0.4)
     self.set_bg_color(self.normal_color)
     self.data = None
Esempio n. 6
0
 def __init__(self):
     GUIFrame.__init__(self)
     self.list_container = None
     self.normal_color = (0.1, 0.1, 0.1, 0)
     self.hover_color = (1, 1, 1, 0.2)
     self.active_color = (0.5, 0.5, 0.5, 1)
     self.set_bg_color(self.normal_color)
     self.select_callback = None  # called when item is selected, with the selected item as a param
     self.right_click_callback = None  # called when item is right clicked
     self.right_release_callback = None  # called when item is right released
     self.data = None  # can be used to associate GUI with objects, does nothing by itself
Esempio n. 7
0
    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()
Esempio n. 8
0
 def update(self):
     GUIFrame.update(self)
     if self.child is not None:
         if self.vertical:
             self.scroll_button.bbox.width = 10
             self.scroll_button.bbox.height = self.scroll_size
             self.child.bbox.y = self.bbox.y + self.offset
         else:
             self.scroll_button.bbox.width = self.scroll_size
             self.scroll_button.bbox.height = 10
             self.child.bbox.x = self.bbox.x + self.offset
         self.child.set_clip_region(
             self.clip_region.get_intersection(self.bbox))
         self.child.update()
Esempio n. 9
0
    def update(self):
        # This is more complicated than it should be... figure out why we can't just check for self.focused
        if self.focused and self.child is not None and len(
                self.child.children) > 0:
            # Set the text of both text boxes
            self.child.children[0].set_text(self.text[:self.cursor_pos])
            self.child.children[2].set_text(self.text[self.cursor_pos:])

        GUIFrame.update(self)

        if self.focused and self.child is not None and len(
                self.child.children) > 0:
            # Move the text boxes so the cursor is on the screen
            if self.bbox.x + self.bbox.width < self.child.children[2].bbox.x:
                self.child.bbox.x = self.bbox.x - (
                    self.child.children[0].bbox.width - self.bbox.width) - 4
            self.child.set_clip_region(
                self.clip_region.get_intersection(self.bbox))
            self.child.update()
Esempio n. 10
0
    def __init__(self):
        GUIFrame.__init__(self)
        self.cursor_pos = 0
        self.focused = False
        self.bbox.height = 20
        self.bbox.width = 100
        self.padding = 4
        self.text = ""
        self.normal_color = (1, 1, 1, 0.2)
        self.focus_color = (0.6, 0.6, 0.6, 0.2)
        self.normal_text_color = (1, 1, 1, 1)
        self.invalid_text_color = (1, 0, 0, 1)
        self.curr_text_color = self.normal_text_color
        self.set_bg_color(self.normal_color)

        self.use_single_label()

        self.on_selected = None  # Called when textbox is selected
        self.on_text_changed = None  # Called when text is changed
        self.on_lost_focus = None  # Called when textbox loses focus
        self.validate_text = None  # Called to check if text is in correct format
        self.data = None
Esempio n. 11
0
    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)
Esempio n. 12
0
    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()
Esempio n. 13
0
    def __init__(self, vertical=True):
        GUIFrame.__init__(self)
        self.set_bg_color((1, 1, 1, 0.1))
        self.start_pos = 0
        self.start_offset = 0
        self.offset = 0
        self.on_scroll = None
        self.scroll_size = 40
        self.vertical = vertical

        self.scroll_button = GUIButton()
        if self.vertical:
            self.bbox.width = 10
            self.scroll_button.bbox.width = 10
            self.scroll_button.bbox.height = self.scroll_size
        else:
            self.bbox.height = 10
            self.scroll_button.bbox.width = self.scroll_size
            self.scroll_button.bbox.height = 10

        self.scroll_button.set_normal_color((1, 1, 1, 0.8))
        self.scroll_button.set_pressed_color(self.scroll_button.hover_color)
        self.scroll_button.on_click = self.scroll_button_pressed
        self.set_child(self.scroll_button)
Esempio n. 14
0
    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)
Esempio n. 15
0
    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)