示例#1
0
    def setup_method(self, method):
        self.root_layout = unserialize(StructureForEventTests)
        self.add_monkey_elem = self.root_layout.children[0]
        self.delete_all_elem = self.root_layout.children[2]
        self.add_to_ui_structure = self.root_layout.children[3]

        self.event_manager = BaseEventManager(self.root_layout, structure_keys,
                                              Events)
示例#2
0
def test_unserialize_structure_with_horizontal_layout_children_widths():
    root_layout = unserialize(StructureWithHorizontalLayoutChildrenWidths)

    assert isinstance(root_layout, HorizontalLayout)
    assert root_layout.width == 200

    child_fill_1 = root_layout.children[0]
    assert isinstance(child_fill_1, Fill)
    assert child_fill_1.width == 30

    child_fill_2 = root_layout.children[1]
    assert isinstance(child_fill_2, Fill)
    assert child_fill_2.width == 80
示例#3
0
def test_unserialize_valid_structure_with_uistructure():
    root_layout = unserialize(StructureWithUIStructure())

    assert isinstance(root_layout, VerticalLayout)
    assert root_layout.width == 300
    assert len(root_layout.children) == 2

    child_container = root_layout.children[0]

    # note that the width of root limits the width of child
    assert isinstance(child_container, VerticalLayout)
    assert child_container.width == 300

    child_element = root_layout.children[1]

    assert isinstance(child_element, Fill)
    assert child_element.width == 80
示例#4
0
def test_unserialize_structure_with_auto_width():
    root_layout = unserialize(StructureWithAutoWidth)

    assert isinstance(root_layout, VerticalLayout)
    assert root_layout.width_mode == value.AUTO
    assert root_layout.width == 0
    assert root_layout.height == 0
    assert len(root_layout.children) == 2

    child_fill = root_layout.children[0]
    assert isinstance(child_fill, Fill)
    assert child_fill.width == 0
    assert child_fill.height == 0

    another_child = root_layout.children[1]
    assert isinstance(another_child, Fill)
    assert another_child.width == 0
    assert another_child.height == 0
示例#5
0
def test_unserialize_structure_with_horizontal_layout_no_children_widths():
    root_layout = unserialize(StructureWithHorizontalLayoutNoChildrenWidths)

    assert isinstance(root_layout, HorizontalLayout)
    assert root_layout.width == 100
    assert root_layout.height == 400
    assert root_layout.default_node_height == 500

    root_layout.render()

    child_fill_1 = root_layout.children[0]
    assert isinstance(child_fill_1, Fill)
    assert child_fill_1.width == 50
    assert child_fill_1.height == 400

    child_fill_2 = root_layout.children[1]
    assert isinstance(child_fill_2, Fill)
    assert child_fill_2.width == 50
    assert child_fill_2.height == 400
示例#6
0
文件: bones.py 项目: Zildj1an/bui
 def check_bones_constraint(root_layout):
     scene = Scene.GetCurrent() 
     active = scene.objects.active     
     active_data = active.getData() 
     
     if type(active_data) == Types.ArmatureType: 
         if Window.PoseMode() == True: 
             armature_object = active 
             armature_data = armature_object.getData() 
             p = armature_object.getPose() 
             
             # check if a bone has to be added
             for bone_name in p.bones.keys(): 
                 if bone_name[:3] == "SLI":
                     bone_elem = root_layout.find_child(label=bone_name)
                     
                     if not bone_elem:
                         armature_bones_elem = root_layout.find_child(name='armature_bones')
                         new_bone = unserialize(UIStructure, UIStructure.slider_structure)
                         armature_bones_elem.append(new_bone)
                         new_bone.label = bone_name
             
             # check if a bone has been removed
             armature_bones = root_layout.find_child(name='armature_bones')
             elems_to_remove = []
             
             for armature_bone in armature_bones.children:
                 found_bone = False
                 
                 for bone_name in p.bones.keys():
                     if armature_bone.name == bone_name:
                         found_bone = True
                         break
                 
                 if not found_bone:
                     elems_to_remove.append(armature_bone)
             
             for elem in elems_to_remove:
                 armature_bones.children.remove(elem)
示例#7
0
def test_unserialize_valid_structure_with_hidden_vertical_child_container():
    root_layout = unserialize(StructureWithHiddenVerticalLayoutChild())

    assert isinstance(root_layout, VerticalLayout)
    assert root_layout.width == 200
    assert root_layout.visible == True
    assert len(root_layout.children) == 1

    child_container = root_layout.children[0]

    assert isinstance(child_container, VerticalLayout)
    assert child_container.name == 'foobar'

    # note that the width of root limits the width of child
    assert child_container.width == 200
    assert child_container.visible == False

    child_of_child = child_container.children[0]

    assert isinstance(child_of_child, Fill)
    assert child_of_child.width == 200
    assert child_of_child.visible == False
示例#8
0
def test_unserialize_structure_with_free_layout():
    root_layout = unserialize(StructureWithFreeLayout)

    assert isinstance(root_layout, FreeLayout)
    assert root_layout.width == 0
    assert root_layout.height == 0

    child_fill_1 = root_layout.children[0]
    assert isinstance(child_fill_1, Fill)
    assert child_fill_1.width == 0
    assert child_fill_1.height == 0

    child_fill_2 = root_layout.children[1]
    assert isinstance(child_fill_2, Fill)
    assert child_fill_2.width == 0
    assert child_fill_2.height == 0
    assert child_fill_2.x == 40
    assert child_fill_2.y == 500

    child_fill_3 = root_layout.children[2]
    assert isinstance(child_fill_3, Fill)
    assert child_fill_3.width == 800
    assert child_fill_3.height == 800
示例#9
0
    def __init__(self, name, label, width, height, show_fps, logging,
                 alignment, default_node_width, default_node_height, bg_color,
                 start_timers, structure_document, structure, hotkeys,
                 initializer, events):
        super(BaseWindow, self).__init__()

        self.name = name
        self.label = label
        self.width = width
        self.height = height
        self.show_fps = show_fps
        self.logging = logging
        self.alignment = alignment
        self.default_node_width = default_node_width
        self.default_node_height = default_node_height
        self.bg_color = bg_color
        self.start_timers = start_timers
        self.hotkeys = hotkeys
        self.initializer = initializer
        #self.initializer = UserInterfaceInitializer(initializer)
        self.root_layout = None  #EmptyLayout() # better to use AbstractNode instead???

        self.events = events

        # TODO: move this test to unserialize???
        if structure_document and structure:
            self.root_layout = unserialize(structure_document, structure)

            self.children.append(self.root_layout)  # XXX

            #self.root_layout.parent = self
            #self.children.append(self.root_layout)
            # could use self.append also but i think this is neater as it's explicit
            # TODO: check this out
        else:
            # TODO: should give nice warning (or just use assert?)
            print structure_document, structure
示例#10
0
 def add_to_ui_structure(elem):
     root_layout = elem.find_root_node()
     structure_root = unserialize(MinimalStructure())
     root_layout.append(structure_root)
示例#11
0
 def setup_method(self, method):
     self.root_layout = unserialize(StructureForStateEventTests)
     self.print_foo_elem = self.root_layout.children[0]
     self.event_manager = BaseEventManager(self.root_layout, structure_keys,
                                           StateEvents)
示例#12
0
def test_unserialize_valid_minimal_structure():
    root_layout = unserialize(MinimalStructure())

    assert isinstance(root_layout, VerticalLayout)
    assert root_layout.width == 400
示例#13
0
 def add_filter(elem):
     filters_container = elem.find_parent(name='filters_container')
     filters = filters_container.find_child(name='filters')
     root_structure = unserialize(UIStructure, UIStructure.filter_structure)
     filters.append(root_structure)
示例#14
0
    def add_layer(elem):
        root = elem.find_root_node()
        layers = root.find_child(name='layers')

        root_structure = unserialize(UIStructure, UIStructure.layer_structure)
        layers.append(root_structure)