コード例 #1
0
    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()
コード例 #2
0
    def __init__(self):
        # Window 'self.w':
        editX = 180
        editY = 22
        textY = 17
        spaceX = 10
        spaceY = 10
        buttonSizeX = 60
        windowWidth = spaceX * 3 + editX * 2 + 85
        windowHeight = 260
        self.w = vanilla.FloatingWindow(
            (windowWidth, windowHeight),  # default window size
            "Copy Kerning Pairs",  # window title
            autosaveName=
            "com.Tosche.CopyKerningPairs.mainwindow"  # stores last window position and size
        )

        # UI elements:
        self.w.tabs = vanilla.Tabs((10, 10, -10, -20 - 30), ["Pair", "Preset"])
        tab1 = self.w.tabs[0]
        tab1.text0 = vanilla.TextBox((spaceX, 0, 260, textY),
                                     "Copy the kerning pair between...",
                                     sizeStyle='regular')
        tab1.editL0 = vanilla.EditText((spaceX, spaceY + textY, editX, editY),
                                       "",
                                       sizeStyle='regular',
                                       callback=self.checkField)
        tab1.editR0 = vanilla.EditText(
            (spaceX * 3 + editX + 20, spaceY + textY, editX, editY),
            "",
            sizeStyle='regular',
            callback=self.checkField)
        tab1.checkL0 = vanilla.TextBox(
            (spaceX + editX + 5, spaceY + textY + 2, 40, textY),
            u"Any",
            sizeStyle='regular')
        tab1.checkR0 = vanilla.TextBox(
            (spaceX * 3 + editX * 2 + 25, spaceY + textY + 2, 40, textY),
            u"Any",
            sizeStyle='regular')
        tab1.text1 = vanilla.TextBox(
            (spaceX, spaceY * 2 + textY + editY, 200, textY),
            "...to this pair",
            sizeStyle='regular')
        tab1.editL1 = vanilla.EditText(
            (spaceX, spaceY * 3 + textY * 2 + editY, editX, editY),
            "",
            sizeStyle='regular',
            callback=self.checkField)
        tab1.editR1 = vanilla.EditText(
            (spaceX * 3 + editX + 20, spaceY * 3 + textY * 2 + editY, editX,
             editY),
            "",
            sizeStyle='regular',
            callback=self.checkField)
        tab1.checkL1 = vanilla.TextBox(
            (spaceX + editX + 5, spaceY * 3 + textY * 2 + editY + 2, 40,
             textY),
            u"Any",
            sizeStyle='regular')
        tab1.checkR1 = vanilla.TextBox(
            (spaceX * 3 + editX * 2 + 25, spaceY * 3 + textY * 2 + editY + 2,
             40, textY),
            u"Any",
            sizeStyle='regular')
        tab1.text2 = vanilla.TextBox(
            (spaceX, spaceY * 5 + textY * 3 + editY, 400, textY * 2),
            "Groups will be automatically detected.\nYou can also type group name with @ prefix (e.g. @A)",
            sizeStyle='regular')

        tab2 = self.w.tabs[1]
        tab2.radio = vanilla.RadioGroup((spaceX, 2, 80, 78),
                                        ["Letter", "Numeral"],
                                        isVertical=True,
                                        sizeStyle='regular',
                                        callback=self.checkRadio)
        tab2.popLetter = vanilla.PopUpButton((spaceX + 100, spaceY, 320, 20), [
            "Caps to Small Caps", "Caps & Lowercase to Superscript",
            "Caps & Lowercase to Subscript", "Cap to Lowercase",
            "Punctuation to Small Caps"
        ],
                                             sizeStyle='regular')
        tab2.popNum1 = vanilla.PopUpButton(
            (spaceX + 100, spaceY + 40, 140, 20), [
                "Lining Proportional", "Small Cap", "Numerator", "Denominator",
                "Superscript", "Subscript", "Default"
            ],
            sizeStyle='regular')
        tab2.popNum2 = vanilla.PopUpButton(
            (spaceX + 100 + 180, spaceY + 40, 140, 20), [
                "Lining Proportional", "Small Cap", "Numerator", "Denominator",
                "Superscript", "Subscript", "Default"
            ],
            sizeStyle='regular')
        tab2.textTo = vanilla.TextBox(
            (spaceX + 100 + 151, spaceY + 40, 20, textY),
            "to",
            sizeStyle='regular')
        tab2.textScale = vanilla.TextBox((spaceX, spaceY + 80, 100, textY),
                                         "Scale\t\t%",
                                         sizeStyle='regular')
        tab2.editScale = vanilla.EditText(
            (spaceX + 40, spaceY + 77, 40, editY), '100', sizeStyle='regular')
        tab2.textSkip = vanilla.TextBox(
            (spaceX + 120, spaceY + 80, 400, textY),
            "Ignore pair values smaller than         units",
            sizeStyle='regular')
        tab2.editSkip = vanilla.EditText(
            (spaceX + 321, spaceY + 77, 30, editY), '10', sizeStyle='regular')
        tab2.textNote = vanilla.TextBox(
            (spaceX, spaceY * 3 + textY + 76, 360, textY * 2),
            "It only copies pairs between the groups.\nBut regular punctuations and symbols are taken care of.",
            sizeStyle='regular')

        # Common:
        self.w.allMaster = vanilla.CheckBox((spaceX, -20 - 15, 100, -15),
                                            "All masters",
                                            sizeStyle='regular')
        self.w.runButton = vanilla.Button((-80 - 15, -20 - 15, -15, -15),
                                          "Run",
                                          sizeStyle='regular',
                                          callback=self.CopyKerningPairsMain)

        # Load Settings:
        if not self.LoadPreferences():
            print "Note: 'Copy Kerning Pairs' could not load preferences. Will resort to defaults"

        # Open window and focus on it:
        self.w.open()
        tab2.radio.set(0)
        tab2.popNum1.enable(False)
        tab2.popNum2.enable(False)
        self.w.makeKey()
コード例 #3
0
	def __init__( self ):
		windowWidth  = 600
		windowHeight = 260
		self.w = vanilla.FloatingWindow(
			( windowWidth, windowHeight ), # default window size
			"BubbleKern", # window title
			minSize = ( windowWidth, windowHeight ), # minimum size (for resizing)
			autosaveName = "com.Tosche.BubbleKern.mainwindow" # stores last window position and size
		)

		self.w.tabs = vanilla.Tabs((spX, spY, -spX, -spY*2-btnY), ["Pair List Builder", "Flat Text"])
		tab0 = self.w.tabs[0]
		tab0.options = vanilla.PopUpButton((spX, 0, 200, btnY), tab0options, callback=self.optionTasks )
		tab0.options._nsObject.menu().setAutoenablesItems_(False)
		emptyPermutation = [{" ":"", "Left":"", "Right":"", "Add Flipped":"", "Pair Count":"0" }]
		GroupColumnWidth = int((self.w.getPosSize()[2]-180-spX*5-prevX)/2+1)
		tab0.permList = vanilla.List((spX, spY+btnY, -prevX-spX*2, -spY*3), emptyPermutation,
			columnDescriptions=[
				{"title":" ", "width":20},
				{"title":"Left", "width":GroupColumnWidth},
				{"title":"Right", "width":GroupColumnWidth},
				{"title":"Add Flipped","cell":vanilla.CheckBoxListCell(), "width":70},
				{"title":"Pair Count", "width":90}
			],
		#	dragSettings = dict( type=NSString, callback=self.dragCallback ), # WHY DOES THIS THING NOT WORK?
			selfDropSettings=dict(type=toolOrderDragType, operation=NSDragOperationMove, callback=self.dropListSelfCallback),
			allowsMultipleSelection = False,
			selectionCallback = self.permListSelected,
			doubleClickCallback= self.permListDoubleClick,
		)

		tableView = tab0.permList._tableView
		tableView.setAllowsColumnReordering_(False)
		tableView.unbind_("sortDescriptors") # Disables sorting by clicking the title bar
		tableView.tableColumns()[0].setResizingMask_(0)
		tableView.tableColumns()[1].setResizingMask_(1)
		tableView.tableColumns()[2].setResizingMask_(1)
		tableView.tableColumns()[3].setResizingMask_(0)
		tableView.tableColumns()[4].setResizingMask_(0)
		tableView.setColumnAutoresizingStyle_(1)
# setResizingMask_() 0=Fixed, 1=Auto-Resizable (Not user-resizable). There may be more options?
# setColumnAutoresizingStyle accepts value from 0 to 5.
# For detail,see: http://api.monobjc.net/html/T_Monobjc_AppKit_NSTableViewColumnAutoresizingStyle.htm

		tab0.sectionPreview = vanilla.TextBox((-prevX-spX, spY+btnY-2, -spX, txY), "Section Preview", sizeStyle = "small")
		tab0.preview = vanilla.TextEditor((-prevX-spX, spY+btnY+txY, -spX, -spY*3), "", readOnly=True)
		tab0.preview._textView.setFont_( Menlo12 )
		tab0.total = vanilla.TextBox((-prevX-spX*2-75, -spY-txY, 100, txY), "", sizeStyle = "small")
		# Add & Delete Buttons:
		tab0.add = vanilla.SquareButton((spX, -spY*3-1, 30, 20), "+", sizeStyle = 'regular', callback=self.addButton)
		tab0.delete = vanilla.SquareButton((spX+29, -spY*3-1, 30, 20), u"–", sizeStyle = 'regular', callback=self.delButton)

		tab1 = self.w.tabs[1]
		tab1.loadButton = vanilla.Button((spX, 0, 160, btnY), "Load a Text File", callback=self.loadFile)

		tab1.flatPairs = vanilla.TextEditor((spX, spY+btnY, -spX, -spY*3), "", callback=self.refreshPairNum)
		tab1.flatPairs._textView.setFont_( Menlo12 )
		tab1.pairNum = vanilla.TextBox((10, -spY-txY, -10, txY), "", sizeStyle = "small")

		self.w.allButton = vanilla.Button((-spX*2-btnX*2-60, -btnY-spY, btnX, btnY), "Kern All Pairs", sizeStyle='regular', callback=self.BubbleKernMain)
		self.w.selButton = vanilla.Button((-spX-btnX-60, -btnY-spY, btnX+60, btnY), "Kern Pairs with Selected Glyphs", sizeStyle='regular', callback=self.BubbleKernMain )

		# Load Settings:
		if not self.LoadPreferences():
			print "Note: 'BubbleKern' could not load preferences. Will resort to defaults"

		self.refreshTotal()
		self.refreshSectionPreview(0)
		self.refreshPairNum(self.w)
		# Open window and focus on it:
		self.w.open()
		self.w.makeKey()