Beispiel #1
0
 def __init__(self):
     self.w = vanilla.Window((400, 400), minSize=(100, 100))
     self.w.glyphLineView = GlyphLineView((0, 0, 0, 0), pointSize=None, autohideScrollers=False, showPointSizePlacard=True)
     events.addObserver(self, "glyphChanged", "currentGlyphChanged")
     self.glyphChanged(dict(glyph=CurrentGlyph()))
     self.setUpBaseWindowBehavior()
     self.w.open()
Beispiel #2
0
    def __init__(self, font):
        if font is None:
            print("An open UFO is needed")
            return
        roboFabFont = font
        font = font.naked()
        self.font = font
        self.featureFont = None

        topHeight = 40
        left = 160

        self.w = Window((700, 400), "Feature Preview", minSize=(300, 300))

        previewGroup = Group((0, 0, -0, -0))
        self.glyphLineInputPosSize = (10, 10, -85, 22)
        self.glyphLineInputPosSizeWithSpinner = (10, 10, -106, 22)
        previewGroup.glyphNameInput = self.glyphLineInput = GlyphSequenceEditText(self.glyphLineInputPosSize, font, callback=self.glyphLineViewInputCallback)
        previewGroup.progressSpinner = self.glyphLineProgressSpinner = ProgressSpinner((-98, 13, 16, 16), sizeStyle="small")
        previewGroup.updateButton = self.glyphLineUpdateButton = Button((-75, 11, -10, 20), "Update", callback=self.updateFeatureFontCallback)

        self.w.pg = previewGroup

        # tab container
        self.w.previewTabs = Tabs((left, topHeight, -0, -0), ["Preview", "Records"], showTabs=False)
        # line view
        self.w.previewTabs[0].lineView = self.glyphLineView = GlyphLineView((0, 0, -0, -0), showPointSizePlacard=True)
        # records
        columnDescriptions = [
            dict(title="Name", width=100, minWidth=100, maxWidth=300),
            dict(title="XP", width=50),
            dict(title="YP", width=50),
            dict(title="XA", width=50),
            dict(title="YA", width=50),
            dict(title="Alternates", width=100, minWidth=100, maxWidth=300)
        ]
        self.w.previewTabs[1].recordsList = self.glyphRecordsList = List((0, 0, -0, -0), [], columnDescriptions=columnDescriptions,
                showColumnTitles=True, drawVerticalLines=True, drawFocusRing=False)
        # controls
        self.w.controlsView = self.glyphLineControls = OpenTypeControlsView((0, topHeight, left+1, 0), self.glyphLineViewControlsCallback)

        self.font.addObserver(self, "_fontChanged", "Font.Changed")

        self.w.setDefaultButton(self.glyphLineUpdateButton)
        self.w.bind("close", self.windowClose)
        self.setUpBaseWindowBehavior()

        document = roboFabFont.document()
        if document is not None:
            document.addWindowController_(self.w.getNSWindowController())

        # Somehow being attached to an NSDocument makes the vanilla.Window autosaveName argument not work.
        self.w._window.setFrameAutosaveName_("featurePreviewRoboFontExtension")

        self.w.open()

        self.updateFeatureFontCallback(None)
    def __init__(self, font):
        self.font = font
        self.glyphs = [
            font[k] for k in font.unicodeData.sortGlyphNames(
                font.keys(), glyphSortDescriptors)
        ]
        self.w = vanilla.Window((700, 500), minSize=(400, 400))

        self.w.tabs = vanilla.Tabs((10, 10, -10, -10), [
            "Window", "GlyphCollectionView", "GlyphView", "GlyphLineView",
            "Misc. Controls"
        ])
        self.windowTab = self.w.tabs[0]
        self.collectionViewTab = self.w.tabs[1]
        self.glyphViewTab = self.w.tabs[2]
        self.lineViewTab = self.w.tabs[3]
        self.controlsTab = self.w.tabs[4]

        # test various window methods
        self.windowTab.messageButton = vanilla.Button(
            (10, 10, 200, 20), "Show Message", callback=self.windowMessage)
        self.windowTab.progress1Button = vanilla.Button(
            (10, 40, 200, 20),
            "Show Progress 1",
            callback=self.windowProgress1)
        self.windowTab.progress2Button = vanilla.Button(
            (10, 70, 200, 20),
            "Show Progress 2",
            callback=self.windowProgress2)
        self.windowTab.askYesNoButton = vanilla.Button(
            (10, 100, 200, 20),
            "Show Ask Yes No",
            callback=self.windowAskYesNo)
        self.windowTab.putFileButton = vanilla.Button(
            (10, 130, 200, 20), "Show Put File", callback=self.windowPutFile)
        self.windowTab.getFileButton = vanilla.Button(
            (10, 160, 200, 20), "Show Get File", callback=self.windowGetFile)

        # test cell view
        selfDropSettings = dict(callback=self.collectionViewSelfDropCallback)
        dropSettings = dict(callback=self.collectionViewOtherDropCallback,
                            allowDropBetweenRows=False)
        self.collectionViewTab.collectionViewModifyButton = vanilla.Button(
            (10, 10, 150, 20),
            "Modify Glyphs",
            callback=self.collectionViewModify)
        self.collectionViewTab.collectionViewSizeSlider = vanilla.Slider(
            (170, 10, 150, 20),
            minValue=10,
            maxValue=100,
            value=50,
            continuous=False,
            callback=self.collectionViewResize)
        self.collectionViewTab.collectionView = GlyphCollectionView(
            (10, 40, -10, -10),
            allowDrag=True,
            selectionCallback=self.collectionViewSelectionCallback,
            doubleClickCallback=self.collectionViewDoubleClickCallback,
            deleteCallback=self.collectionViewDeleteCallback,
            selfDropSettings=selfDropSettings,
            selfApplicationDropSettings=dropSettings)
        self.collectionViewTab.collectionView.set(self.glyphs)
        self.collectionViewResize(
            self.collectionViewTab.collectionViewSizeSlider)

        # test glyph view
        self.glyphViewTab.collectionView = GlyphCollectionView(
            (10, 10, 66, -10),
            allowDrag=False,
            selectionCallback=self.glyphViewCollectionSelectionCallback,
            showModePlacard=False)
        self.glyphViewTab.glyphView = GlyphView((76, 10, -10, -10))
        self.glyphViewTab.collectionView.set(self.glyphs)
        self.glyphViewTab.collectionView.setSelection([0])

        # test line view
        self.lineViewTab.lineViewSizeSlider = vanilla.Slider(
            (-160, 11, 150, 20),
            minValue=10,
            maxValue=500,
            value=100,
            continuous=True,
            callback=self.lineViewResize)
        self.lineViewTab.textInput = GlyphSequenceEditText(
            (10, 10, -170, 22), self.font, callback=self.lineViewTextInput)
        self.lineViewTab.lineView = GlyphLineView((10, 40, -10, -10))

        # test controls
        self.controlsTab.glyphNameComboBox = GlyphNameComboBox(
            (10, 10, -10, 22), self.font)
        self.controlsTab.featureTextEditor = FeatureTextEditor(
            (10, 45, -10, -10), self.font.features.text)

        self.setUpBaseWindowBehavior()

        self.w.tabs.set(3)

        self.w.open()