示例#1
0
    def createSettingsForFalagardElement(self, falagardElement):
        """
        Creates a list of settings for any type of Falagard Element (except the WidgetLookFeel itself)
        :param falagardElement:
        :return:
        """

        settings = []

        if falagardElement is None:
            return settings

        from falagard_element_interface import FalagardElementInterface

        attributeList = FalagardElementInterface.getListOfAttributes(
            falagardElement)

        for attributeName in attributeList:
            attributeValue, attributeCeguiType = FalagardElementInterface.getAttributeValue(
                falagardElement, attributeName, self.visual.tabbedEditor)
            newSetting = self.createPropertyForFalagardElement(
                falagardElement, attributeName, attributeValue,
                attributeCeguiType, "")
            settings.append(newSetting)

        return settings
示例#2
0
    def redo(self):
        # We set the value using the setter callback
        from falagard_element_interface import FalagardElementInterface
        FalagardElementInterface.setAttributeValue(self.falagardElement, self.attributeName, self.newValue)

        from ceed.propertytree.properties import Property
        #TODO Ident: Refresh the property view afterwards instead
        #self.falagardProperty.setValue(self.newValue, reason=Property.ChangeValueReason.InnerValueChanged)

        self.visual.destroyCurrentPreviewWidget()

        self.visual.tabbedEditor.removeOwnedWidgetLookFalagardMappings()
        self.visual.tabbedEditor.addMappedWidgetLookFalagardMappings()

        self.visual.updateWidgetLookPreview()

        """
        # We add every WidgetLookFeel name of this Look N' Feel to a StringSet
        nameSet = self.visual.tabbedEditor.getStringSetOfWidgetLookFeelNames()
        # We parse all WidgetLookFeels as XML to a string
        import PyCEGUI
        lookAndFeelString = PyCEGUI.WidgetLookManager.getSingleton().getWidgetLookSetAsString(nameSet)

        lookAndFeelString = self.visual.tabbedEditor.unmapWidgetLookReferences(lookAndFeelString)

        self.visual.tabbedEditor.tryUpdatingWidgetLookFeel(lookAndFeelString)
        self.visual.updateToNewTargetWidgetLook()
        """

        super(FalagardElementAttributeEdit, self).redo()
示例#3
0
    def redo(self):
        # We set the value using the setter callback
        from falagard_element_interface import FalagardElementInterface
        FalagardElementInterface.setAttributeValue(self.falagardElement,
                                                   self.attributeName,
                                                   self.newValue)

        from ceed.propertytree.properties import Property
        #TODO Ident: Refresh the property view afterwards instead
        #self.falagardProperty.setValue(self.newValue, reason=Property.ChangeValueReason.InnerValueChanged)

        self.visual.destroyCurrentPreviewWidget()

        self.visual.tabbedEditor.removeOwnedWidgetLookFalagardMappings()
        self.visual.tabbedEditor.addMappedWidgetLookFalagardMappings()

        self.visual.updateWidgetLookPreview()
        """
        # We add every WidgetLookFeel name of this Look N' Feel to a StringSet
        nameSet = self.visual.tabbedEditor.getStringSetOfWidgetLookFeelNames()
        # We parse all WidgetLookFeels as XML to a string
        import PyCEGUI
        lookAndFeelString = PyCEGUI.WidgetLookManager.getSingleton().getWidgetLookSetAsString(nameSet)

        lookAndFeelString = self.visual.tabbedEditor.unmapWidgetLookReferences(lookAndFeelString)

        self.visual.tabbedEditor.tryUpdatingWidgetLookFeel(lookAndFeelString)
        self.visual.updateToNewTargetWidgetLook()
        """

        super(FalagardElementAttributeEdit, self).redo()
示例#4
0
    def undo(self):
        super(FalagardElementAttributeEdit, self).undo()

        # We set the value using the setter callback
        from falagard_element_interface import FalagardElementInterface
        FalagardElementInterface.setAttributeValue(self.falagardElement, self.attributeName, self.oldValue)

        from ceed.propertytree.properties import Property
        #TODO Ident: Refresh the property view afterwards instead
        # self.falagardProperty.setValue(self.oldValue, reason=Property.ChangeValueReason.InnerValueChanged)

        self.visual.updateWidgetLookPreview()
示例#5
0
    def undo(self):
        super(FalagardElementAttributeEdit, self).undo()

        # We set the value using the setter callback
        from falagard_element_interface import FalagardElementInterface
        FalagardElementInterface.setAttributeValue(self.falagardElement,
                                                   self.attributeName,
                                                   self.oldValue)

        from ceed.propertytree.properties import Property
        #TODO Ident: Refresh the property view afterwards instead
        # self.falagardProperty.setValue(self.oldValue, reason=Property.ChangeValueReason.InnerValueChanged)

        self.visual.updateWidgetLookPreview()
    def createPropertyForFalagardElement(self, falagardElement, attributeName, attributeValue, attributeCeguiType, helpText):
        """
        Create a FalagardElementEditorProperty based on a type-specific property for the FalagardElement's attribute
        """

        from ceed.editors.looknfeel.falagard_element_interface import FalagardElementInterface
        falagardElementTypeStr = FalagardElementInterface.getFalagardElementTypeAsString(falagardElement)

        # Get the python type representing the cegui type and also the editor options
        pythonDataType, editorOptions = self.getPythonCeguiTypeAndEditorOptions(self.propertyMap, falagardElementTypeStr, attributeName, attributeCeguiType)

        # Get the pythonised type of the value and also its editor-propertytype
        pythonTypeValue, propertyType = self.getEditorPropertyTypeAndValue(pythonDataType, attributeValue)

        # Unmap the reference in case we reference to the WidgetLookFeel
        if attributeName == "look" and falagardElementTypeStr == "SectionSpecification" and pythonTypeValue:
            from ceed.editors.looknfeel.tabbed_editor import LookNFeelTabbedEditor
            pythonTypeValue, _ = LookNFeelTabbedEditor.unmapMappedNameIntoOriginalParts(pythonTypeValue)

        typedProperty = propertyType(name=attributeName,
                                     category=falagardElementTypeStr,
                                     helpText=helpText,
                                     value=pythonTypeValue,
                                     defaultValue=pythonTypeValue,
                                     readOnly=False,
                                     editorOptions=editorOptions,
                                     createComponents=True
                                     )

        # create and return the multi wrapper
        return FalagardElementEditorProperty(typedProperty, falagardElement, attributeName, self.visual)
示例#7
0
    def __init__(self,
                 falagardProperty,
                 visual,
                 falagardElement,
                 attributeName,
                 newValue,
                 ignoreNextCallback=False):
        super(FalagardElementAttributeEdit, self).__init__()

        self.visual = visual
        """ :type : LookNFeelVisualEditing """

        self.falagardElement = falagardElement
        self.attributeName = attributeName

        self.falagardProperty = falagardProperty
        """ :type : FalagardElementEditorProperty"""

        # We retrieve the momentary value using the getter callback and store it as old value
        from falagard_element_interface import FalagardElementInterface
        self.oldValue, ceguiType = FalagardElementInterface.getAttributeValue(
            falagardElement, attributeName, visual.tabbedEditor)
        self.oldValueAsString = unicode(self.oldValue)

        # If the value is a subtype of
        from ceed.cegui import ceguitypes
        newValueType = type(newValue)
        if issubclass(newValueType, ceguitypes.Base):
            # if it is a subclass of our ceguitypes, do some special handling
            self.newValueAsString = unicode(newValue)
            self.newValue = newValueType.toCeguiType(self.newValueAsString)
        elif newValueType is bool or newValueType is unicode:
            self.newValue = newValue
            self.newValueAsString = unicode(newValue)
        else:
            raise Exception("Unexpected type encountered")

        # Get the Falagard element's type as string so we can display better info
        from ceed.editors.looknfeel.falagard_element_interface import FalagardElementInterface
        self.falagardElementName = FalagardElementInterface.getFalagardElementTypeAsString(
            falagardElement)

        self.refreshText()

        self.ignoreNextCall = ignoreNextCallback
    def createSettingsForFalagardElement(self, falagardElement):
        """
        Creates a list of settings for any type of Falagard Element (except the WidgetLookFeel itself)
        :param falagardElement:
        :return:
        """

        settings = []

        if falagardElement is None:
            return settings

        from falagard_element_interface import FalagardElementInterface

        attributeList = FalagardElementInterface.getListOfAttributes(falagardElement)

        for attributeName in attributeList:
            attributeValue, attributeCeguiType = FalagardElementInterface.getAttributeValue(falagardElement, attributeName, self.visual.tabbedEditor)
            newSetting = self.createPropertyForFalagardElement(falagardElement, attributeName, attributeValue, attributeCeguiType, "")
            settings.append(newSetting)

        return settings
示例#9
0
    def __init__(self, falagardProperty, visual, falagardElement, attributeName, newValue, ignoreNextCallback=False):
        super(FalagardElementAttributeEdit, self).__init__()

        self.visual = visual
        """ :type : LookNFeelVisualEditing """

        self.falagardElement = falagardElement
        self.attributeName = attributeName

        self.falagardProperty = falagardProperty
        """ :type : FalagardElementEditorProperty"""

        # We retrieve the momentary value using the getter callback and store it as old value
        from falagard_element_interface import FalagardElementInterface
        self.oldValue, ceguiType = FalagardElementInterface.getAttributeValue(falagardElement, attributeName, visual.tabbedEditor)
        self.oldValueAsString = unicode(self.oldValue)

        # If the value is a subtype of
        from ceed.cegui import ceguitypes
        newValueType = type(newValue)
        if issubclass(newValueType, ceguitypes.Base):
            # if it is a subclass of our ceguitypes, do some special handling
            self.newValueAsString = unicode(newValue)
            self.newValue = newValueType.toCeguiType(self.newValueAsString)
        elif newValueType is bool or newValueType is unicode:
            self.newValue = newValue
            self.newValueAsString = unicode(newValue)
        else:
            raise Exception("Unexpected type encountered")

        # Get the Falagard element's type as string so we can display better info
        from ceed.editors.looknfeel.falagard_element_interface import FalagardElementInterface
        self.falagardElementName = FalagardElementInterface.getFalagardElementTypeAsString(falagardElement)

        self.refreshText()

        self.ignoreNextCall = ignoreNextCallback
示例#10
0
    def createPropertyForFalagardElement(self, falagardElement, attributeName,
                                         attributeValue, attributeCeguiType,
                                         helpText):
        """
        Create a FalagardElementEditorProperty based on a type-specific property for the FalagardElement's attribute
        """

        from ceed.editors.looknfeel.falagard_element_interface import FalagardElementInterface
        falagardElementTypeStr = FalagardElementInterface.getFalagardElementTypeAsString(
            falagardElement)

        # Get the python type representing the cegui type and also the editor options
        pythonDataType, editorOptions = self.getPythonCeguiTypeAndEditorOptions(
            self.propertyMap, falagardElementTypeStr, attributeName,
            attributeCeguiType)

        # Get the pythonised type of the value and also its editor-propertytype
        pythonTypeValue, propertyType = self.getEditorPropertyTypeAndValue(
            pythonDataType, attributeValue)

        # Unmap the reference in case we reference to the WidgetLookFeel
        if attributeName == "look" and falagardElementTypeStr == "SectionSpecification" and pythonTypeValue:
            from ceed.editors.looknfeel.tabbed_editor import LookNFeelTabbedEditor
            pythonTypeValue, _ = LookNFeelTabbedEditor.unmapMappedNameIntoOriginalParts(
                pythonTypeValue)

        typedProperty = propertyType(name=attributeName,
                                     category=falagardElementTypeStr,
                                     helpText=helpText,
                                     value=pythonTypeValue,
                                     defaultValue=pythonTypeValue,
                                     readOnly=False,
                                     editorOptions=editorOptions,
                                     createComponents=True)

        # create and return the multi wrapper
        return FalagardElementEditorProperty(typedProperty, falagardElement,
                                             attributeName, self.visual)