Exemple #1
0
    def __init__(self, tabbedEditor):
        """
        :param tabbedEditor: LookNFeelTabbedEditor
        :return:
        """
        super(LookNFeelVisualEditing, self).__init__()

        self.tabbedEditor = tabbedEditor
        self.rootWindow = None

        self.lookNFeelHierarchyDockWidget = LookNFeelHierarchyDockWidget(
            self, tabbedEditor)
        self.lookNFeelWidgetLookSelectorWidget = LookNFeelWidgetLookSelectorWidget(
            self, tabbedEditor)
        self.falagardElementEditorDockWidget = LookNFeelFalagardElementEditorDockWidget(
            self, tabbedEditor)

        looknfeel = QtGui.QVBoxLayout(self)
        looknfeel.setContentsMargins(0, 0, 0, 0)
        self.setLayout(looknfeel)

        self.scene = EditingScene(self)

        self.setupActions()
        self.setupToolBar()
        self.lookNFeelHierarchyDockWidget.treeView.setupContextMenu()
Exemple #2
0
    def __init__(self, tabbedEditor):
        """
        :param tabbedEditor: LookNFeelTabbedEditor
        :return:
        """
        super(LookNFeelVisualEditing, self).__init__()

        self.tabbedEditor = tabbedEditor
        self.rootWindow = None

        self.lookNFeelHierarchyDockWidget = LookNFeelHierarchyDockWidget(self, tabbedEditor)
        self.lookNFeelWidgetLookSelectorWidget = LookNFeelWidgetLookSelectorWidget(self, tabbedEditor)
        self.falagardElementEditorDockWidget = LookNFeelFalagardElementEditorDockWidget(self, tabbedEditor)

        looknfeel = QtGui.QVBoxLayout(self)
        looknfeel.setContentsMargins(0, 0, 0, 0)
        self.setLayout(looknfeel)

        self.scene = EditingScene(self)

        self.setupActions()
        self.setupToolBar()
        self.lookNFeelHierarchyDockWidget.treeView.setupContextMenu()
Exemple #3
0
class LookNFeelVisualEditing(QtGui.QWidget, multi.EditMode):
    """This is the default visual editing mode

    see ceed.editors.multi.EditMode
    """

    def __init__(self, tabbedEditor):
        """
        :param tabbedEditor: LookNFeelTabbedEditor
        :return:
        """
        super(LookNFeelVisualEditing, self).__init__()

        self.tabbedEditor = tabbedEditor
        self.rootWindow = None

        self.lookNFeelHierarchyDockWidget = LookNFeelHierarchyDockWidget(self, tabbedEditor)
        self.lookNFeelWidgetLookSelectorWidget = LookNFeelWidgetLookSelectorWidget(self, tabbedEditor)
        self.falagardElementEditorDockWidget = LookNFeelFalagardElementEditorDockWidget(self, tabbedEditor)

        looknfeel = QtGui.QVBoxLayout(self)
        looknfeel.setContentsMargins(0, 0, 0, 0)
        self.setLayout(looknfeel)

        self.scene = EditingScene(self)

        self.setupActions()
        self.setupToolBar()
        self.lookNFeelHierarchyDockWidget.treeView.setupContextMenu()

    def initialise(self):
        propertyMap = mainwindow.MainWindow.instance.project.propertyMap
        widgetLookPropertyManager = FalagardElementAttributesManager(propertyMap, self)
        self.falagardElementEditorDockWidget.inspector.setPropertyManager(widgetLookPropertyManager)

        self.rootWindow = PyCEGUI.WindowManager.getSingleton().createWindow("DefaultWindow", "LookNFeelEditorRoot")
        PyCEGUI.System.getSingleton().getDefaultGUIContext().setRootWindow(self.rootWindow)

    def destroy(self):
        # Remove the widget with the previous WidgetLook from the scene
        self.destroyCurrentPreviewWidget()

    def setupActions(self):
        self.connectionGroup = action.ConnectionGroup(action.ActionManager.instance)

    def setupToolBar(self):
        self.toolBar = QtGui.QToolBar("looknfeel")
        self.toolBar.setObjectName("looknfeelToolbar")
        self.toolBar.setIconSize(QtCore.QSize(32, 32))

    def rebuildEditorMenu(self, editorMenu):
        """Adds actions to the editor menu"""

    def destroyCurrentPreviewWidget(self):
        """
        Destroys all child windows of the root, which means that all preview windows of the selected WidgetLookFeel should be destroyed
        :return:
        """

        if self.rootWindow is None:
            return

        # Remove the widget with the previous WidgetLook from the scene
        while self.rootWindow.getChildCount() != 0:
            PyCEGUI.WindowManager.getSingleton().destroyWindow(self.rootWindow.getChildAtIdx(0))

        # TODO (Ident) :
        # Fix the window pool cleanup issues in CEGUI default and remove this later in the CEED default branch
        # for more info see: http://cegui.org.uk/wiki/The_Lederhosen_project_-_The_Second_Coming
        PyCEGUI.WindowManager.getSingleton().cleanDeadPool()

    def updateWidgetLookPreview(self):
        self.destroyCurrentPreviewWidget()

        if self.tabbedEditor.targetWidgetLook:

            # Add new widget representing the new WidgetLook to the scene, if the factory is registered
            factoryPresent = PyCEGUI.WindowFactoryManager.getSingleton().isFactoryPresent(self.tabbedEditor.targetWidgetLook)
            if factoryPresent:
                widgetLookWindow = PyCEGUI.WindowManager.getSingleton().createWindow(self.tabbedEditor.targetWidgetLook, "WidgetLookWindow")
                self.rootWindow.addChild(widgetLookWindow)
            else:
                self.tabbedEditor.targetWidgetLook = ""

        #Refresh the drawing of the preview
        self.scene.update()

    def updateToNewTargetWidgetLook(self):
        self.updateWidgetLookPreview()

        self.falagardElementEditorDockWidget.inspector.setSource(None)

        self.lookNFeelHierarchyDockWidget.updateToNewWidgetLook(self.tabbedEditor.targetWidgetLook)

    def showEvent(self, event):
        mainwindow.MainWindow.instance.ceguiContainerWidget.activate(self, self.scene)
        mainwindow.MainWindow.instance.ceguiContainerWidget.setViewFeatures(wheelZoom = True,
                                                                            middleButtonScroll = True,
                                                                            continuousRendering = settings.getEntry("looknfeel/visual/continuous_rendering").value)

        self.lookNFeelHierarchyDockWidget.setEnabled(True)
        self.lookNFeelWidgetLookSelectorWidget.setEnabled(True)
        self.falagardElementEditorDockWidget.setEnabled(True)

        PyCEGUI.System.getSingleton().getDefaultGUIContext().setRootWindow(self.rootWindow)

        self.toolBar.setEnabled(True)
        if self.tabbedEditor.editorMenu() is not None:
            self.tabbedEditor.editorMenu().menuAction().setEnabled(True)

        # connect all our actions
        self.connectionGroup.connectAll()

        super(LookNFeelVisualEditing, self).showEvent(event)

    def hideEvent(self, event):
        # disconnected all our actions
        self.connectionGroup.disconnectAll()

        self.lookNFeelHierarchyDockWidget.setEnabled(False)
        self.lookNFeelWidgetLookSelectorWidget.setEnabled(False)
        self.falagardElementEditorDockWidget.setEnabled(False)

        self.toolBar.setEnabled(False)
        if self.tabbedEditor.editorMenu() is not None:
            self.tabbedEditor.editorMenu().menuAction().setEnabled(False)

        mainwindow.MainWindow.instance.ceguiContainerWidget.deactivate(self)

        super(LookNFeelVisualEditing, self).hideEvent(event)

    def focusPropertyInspectorFilterBox(self):
        """Focuses into property set inspector filter

        This potentially allows the user to just press a shortcut to find properties to edit,
        instead of having to reach for a mouse.
        """

        filterBox = self.propertiesDockWidget.inspector.filterBox
        # selects all contents of the filter so that user can replace that with their search phrase
        filterBox.selectAll()
        # sets focus so that typing puts text into the filter box without clicking
        filterBox.setFocus()

    def performCut(self):
        ret = self.performCopy()
        self.scene.deleteSelectedWidgets()

        return ret
Exemple #4
0
class LookNFeelVisualEditing(QtGui.QWidget, multi.EditMode):
    """This is the default visual editing mode

    see ceed.editors.multi.EditMode
    """
    def __init__(self, tabbedEditor):
        """
        :param tabbedEditor: LookNFeelTabbedEditor
        :return:
        """
        super(LookNFeelVisualEditing, self).__init__()

        self.tabbedEditor = tabbedEditor
        self.rootWindow = None

        self.lookNFeelHierarchyDockWidget = LookNFeelHierarchyDockWidget(
            self, tabbedEditor)
        self.lookNFeelWidgetLookSelectorWidget = LookNFeelWidgetLookSelectorWidget(
            self, tabbedEditor)
        self.falagardElementEditorDockWidget = LookNFeelFalagardElementEditorDockWidget(
            self, tabbedEditor)

        looknfeel = QtGui.QVBoxLayout(self)
        looknfeel.setContentsMargins(0, 0, 0, 0)
        self.setLayout(looknfeel)

        self.scene = EditingScene(self)

        self.setupActions()
        self.setupToolBar()
        self.lookNFeelHierarchyDockWidget.treeView.setupContextMenu()

    def initialise(self):
        propertyMap = mainwindow.MainWindow.instance.project.propertyMap
        widgetLookPropertyManager = FalagardElementAttributesManager(
            propertyMap, self)
        self.falagardElementEditorDockWidget.inspector.setPropertyManager(
            widgetLookPropertyManager)

        self.rootWindow = PyCEGUI.WindowManager.getSingleton().createWindow(
            "DefaultWindow", "LookNFeelEditorRoot")
        PyCEGUI.System.getSingleton().getDefaultGUIContext().setRootWindow(
            self.rootWindow)

    def destroy(self):
        # Remove the widget with the previous WidgetLook from the scene
        self.destroyCurrentPreviewWidget()

    def setupActions(self):
        self.connectionGroup = action.ConnectionGroup(
            action.ActionManager.instance)

    def setupToolBar(self):
        self.toolBar = QtGui.QToolBar("looknfeel")
        self.toolBar.setObjectName("looknfeelToolbar")
        self.toolBar.setIconSize(QtCore.QSize(32, 32))

    def rebuildEditorMenu(self, editorMenu):
        """Adds actions to the editor menu"""

    def destroyCurrentPreviewWidget(self):
        """
        Destroys all child windows of the root, which means that all preview windows of the selected WidgetLookFeel should be destroyed
        :return:
        """

        if self.rootWindow is None:
            return

        # Remove the widget with the previous WidgetLook from the scene
        while self.rootWindow.getChildCount() != 0:
            PyCEGUI.WindowManager.getSingleton().destroyWindow(
                self.rootWindow.getChildAtIdx(0))

        # TODO (Ident) :
        # Fix the window pool cleanup issues in CEGUI default and remove this later in the CEED default branch
        # for more info see: http://cegui.org.uk/wiki/The_Lederhosen_project_-_The_Second_Coming
        PyCEGUI.WindowManager.getSingleton().cleanDeadPool()

    def updateWidgetLookPreview(self):
        self.destroyCurrentPreviewWidget()

        if self.tabbedEditor.targetWidgetLook:

            # Add new widget representing the new WidgetLook to the scene, if the factory is registered
            factoryPresent = PyCEGUI.WindowFactoryManager.getSingleton(
            ).isFactoryPresent(self.tabbedEditor.targetWidgetLook)
            if factoryPresent:
                widgetLookWindow = PyCEGUI.WindowManager.getSingleton(
                ).createWindow(self.tabbedEditor.targetWidgetLook,
                               "WidgetLookWindow")
                self.rootWindow.addChild(widgetLookWindow)
            else:
                self.tabbedEditor.targetWidgetLook = ""

        #Refresh the drawing of the preview
        self.scene.update()

    def updateToNewTargetWidgetLook(self):
        self.updateWidgetLookPreview()

        self.falagardElementEditorDockWidget.inspector.setSource(None)

        self.lookNFeelHierarchyDockWidget.updateToNewWidgetLook(
            self.tabbedEditor.targetWidgetLook)

    def showEvent(self, event):
        mainwindow.MainWindow.instance.ceguiContainerWidget.activate(
            self, self.scene)
        mainwindow.MainWindow.instance.ceguiContainerWidget.setViewFeatures(
            wheelZoom=True,
            middleButtonScroll=True,
            continuousRendering=settings.getEntry(
                "looknfeel/visual/continuous_rendering").value)

        self.lookNFeelHierarchyDockWidget.setEnabled(True)
        self.lookNFeelWidgetLookSelectorWidget.setEnabled(True)
        self.falagardElementEditorDockWidget.setEnabled(True)

        PyCEGUI.System.getSingleton().getDefaultGUIContext().setRootWindow(
            self.rootWindow)

        self.toolBar.setEnabled(True)
        if self.tabbedEditor.editorMenu() is not None:
            self.tabbedEditor.editorMenu().menuAction().setEnabled(True)

        # connect all our actions
        self.connectionGroup.connectAll()

        super(LookNFeelVisualEditing, self).showEvent(event)

    def hideEvent(self, event):
        # disconnected all our actions
        self.connectionGroup.disconnectAll()

        self.lookNFeelHierarchyDockWidget.setEnabled(False)
        self.lookNFeelWidgetLookSelectorWidget.setEnabled(False)
        self.falagardElementEditorDockWidget.setEnabled(False)

        self.toolBar.setEnabled(False)
        if self.tabbedEditor.editorMenu() is not None:
            self.tabbedEditor.editorMenu().menuAction().setEnabled(False)

        mainwindow.MainWindow.instance.ceguiContainerWidget.deactivate(self)

        super(LookNFeelVisualEditing, self).hideEvent(event)

    def focusPropertyInspectorFilterBox(self):
        """Focuses into property set inspector filter

        This potentially allows the user to just press a shortcut to find properties to edit,
        instead of having to reach for a mouse.
        """

        filterBox = self.propertiesDockWidget.inspector.filterBox
        # selects all contents of the filter so that user can replace that with their search phrase
        filterBox.selectAll()
        # sets focus so that typing puts text into the filter box without clicking
        filterBox.setFocus()

    def performCut(self):
        ret = self.performCopy()
        self.scene.deleteSelectedWidgets()

        return ret