Example #1
0
    def _build_ui(self):
        columnDescriptions = [
            {
                "title": "Delete",
                "cell": vanilla.CheckBoxListCell(),
                "width": 40
            },
            {
                "title": "Description",
                "typingSensitive": True,
                "editable": False,
                "width": 210
            },
            {
                "title": "Size",
                "typingSensitive": True,
                "editable": False,
                "width": 60
            },
            {
                "title": "Key",
                "typingSensitive": True,
                "editable": True,
                "width": 220
            },
            {
                "title": "Location",
                "typingSensitive": True,
                "editable": False,
                "width": 40
            },
        ]
        self._width = 640
        self._height = 300

        self.w = vanilla.Window((self._width, self._height), "UFO Cleaner",
                                (self._width, self._height))
        self.w.key_list = vanilla.List(
            (10, 9, -10, -40),
            self._libkeys,
            columnDescriptions=columnDescriptions,
            drawFocusRing=True,
            #editCallback=self._setDecompose,
            doubleClickCallback=self._open_sheet,
        )
        #self.w.xml = CodeEditor((10, -130, -10, -40), "", lexer="xml")

        self.w.total_size = vanilla.TextBox((10, -30, 240, 20), "")
        self._update_total_size_display()

        self.w.action_button = vanilla.Button(
            (-200, -30, -10, 20),
            "Delete checked items from UFO",
            callback=self._clean_ufo,
            sizeStyle="small",
        )

        self._sheet = False
        self.setUpBaseWindowBehavior()
        self.w.open()
    def __init__(self):
        self.fullMetadata = getExtensionDefault("%s.scriptMetadata" %
                                                KEYPREFIX,
                                                fallback={})
        if not len(self.fullMetadata.keys()):
            # "Restart" window
            self.w = vanilla.Window((500, 160), "Andy’s RoboFont Hacks")
            self.w.hr = vanilla.HorizontalLine((10, -50, -10, 1))
            self.w.restartText = vanilla.TextBox(
                (20, 20, -20, -45),
                text_Bold(
                    "Installed and updated.\nRestart RoboFont to refresh the list of my RoboFont hacks.\n\n    — Andy Clymer"
                ))
            self.w.okButton = vanilla.Button((-120, -35, 100, 20),
                                             "OK",
                                             callback=self.cancelCallback)
            self.w.open()

        else:
            # Full window
            self.w = vanilla.Window((750, 300), "Andy’s RoboFont Hacks")
            columnDescriptions = [{
                "title": "state",
                "width": 20,
                "cell": vanilla.CheckBoxListCell()
            }, {
                "title": "longName"
            }]
            self.w.scriptList = vanilla.List(
                (10, 10, 300, -60), [],
                allowsMultipleSelection=False,
                showColumnTitles=False,
                selectionCallback=self.listSelectionChanged,
                columnDescriptions=columnDescriptions)

            self.defaultTitle = "Andy’s RoboFont Hacks"
            self.defaultText = "A selection of extras that make RoboFont work the way I like it. \n\nEverything is optional, click on one of the names on the left for a description of what the add-on does. Select as many as you like by checking the box to the left of the name, and restart RoboFont to activate.\n\n    — Andy Clymer"
            self.w.descriptionBox = vanilla.Box((320, 10, -10, -60))
            self.w.descriptionBox.title = vanilla.TextBox((5, 5, -10, 25),
                                                          self.defaultTitle)
            self.w.descriptionBox.text = vanilla.TextBox((5, 38, -10, -10),
                                                         self.defaultText)
            #self.w.webView = WebView.alloc().initWithFrame_(((0, 0), (320, 1000)))
            #self.w.scroll = vanilla.ScrollView((320, 10, -10, -60), self.w.webView, hasHorizontalScroller=False, hasVerticalScroller=False)
            #self.w.webView.setMainFrameURL_(self.htmlPath)

            self.w.hr = vanilla.HorizontalLine((10, -50, -10, 1))
            self.w.changeNote = vanilla.TextBox(
                (20, -32, -230, 25),
                text_SmallGray("Any change will require restarting RoboFont."),
                sizeStyle="small")
            self.w.cancelButton = vanilla.Button((-230, -35, 100, 20),
                                                 "Cancel",
                                                 callback=self.cancelCallback)
            self.w.applyButton = vanilla.Button((-120, -35, 100, 20),
                                                "Apply",
                                                callback=self.applyCallback)
            self.populateList()
            self.w.open()
Example #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()
Example #4
0
def get_ui(window_controller, title):

    glyph_column_descriptions = [
        {
            "title": "Layers",
            "cell": vanilla.CheckBoxListCell(),
            "width": 35,
            "editable": False,
        },
        {
            "title": "Name",
            "typingSensitive": True,
            "editable": False,
        },
    ]

    layer_column_descriptions = [
        {
            "title": "Index",
            "key": "layer_index",
            "width": 45,
            "editable": True,
        },
        {
            "title": "ColorIndex",
            "key": "layer_color_index",
            "width": 45,
            "editable": True,
        },
        # {
        #     "title": "Color",
        #     "binding": "selectedValue",
        #     "cell": vanilla.PopUpButtonListCell([]),
        #     "width": 30,
        #     "editable": True,
        # },
        {
            "title": "Layer Glyph",
            "typingSensitive": True,
            "editable": True,
        },
    ]

    palette_column_descriptions = [
        {
            "title": "Index",
            # "cell": IntType, #TODO
            "width": 60,
            "typingSensitive": True,
        },
        {
            "title":
            "Color",
            "cell":
            RFColorCell.alloc().initWithDoubleClickCallback_(
                window_controller.paletteEditColorCell),
            "typingSensitive":
            False,
            "editable":
            False,
        },
    ]

    layer_drop_settings = {
        "type": NSColorPboardType,
        "allowDropBetweenRows": False,
        "allowDropOnRow": True,
        "callback": window_controller._callback_layer_drop,
    }

    col2 = int(round(window_width / 2))
    y = 10

    w = vanilla.Window((window_width, 496), "%s - RoboChrome" % title)
    w.preview = Canvas(
        (10, y, 320, 200),
        canvasSize=(318, 200),
        hasHorizontalScroller=False,
        hasVerticalScroller=False,
        delegate=window_controller,
    )
    w.paletteswitch = vanilla.PopUpButton(
        (340, y, -10, 20),
        [],
        callback=window_controller._paletteSwitchCallback,
    )
    w.colorpalette = vanilla.List(
        (340, y + 30, -10, 170),
        [],
        columnDescriptions=palette_column_descriptions,
        drawFocusRing=True,
        editCallback=window_controller.paletteEdit,
        selectionCallback=window_controller._callback_color_select_in_palette,
        allowsMultipleSelection=False,
        enableDelete=True,
    )
    w.addPalette = vanilla.GradientButton(
        (340, 215, 24, 24),
        imagePath="../resources/iconColorFontPalette.pdf",
        callback=window_controller.paletteDuplicate,
    )
    w.deletePalette = vanilla.GradientButton(
        (363, 215, 24, 24),
        imagePath="../resources/iconColorFontPaletteMinus.pdf",
        callback=window_controller.paletteDelete,
    )
    w.addColorToPalette = vanilla.GradientButton(
        (410, 215, 24, 24),
        imagePath="../resources/iconColorFontPlus.pdf",
        callback=window_controller.addColorToPalette,
    )
    y += 210
    w.glyph_list_label = vanilla.TextBox((10, y, 120, 20),
                                         "Glyphs with layers:",
                                         sizeStyle="small")
    w.glyph_list_search_box = vanilla.SearchBox(
        (118, y - 3, 114, 20),
        placeholder="Filter glyphs",
        callback=window_controller._callback_update_ui_glyph_list,
        sizeStyle="small",
    )
    w.colorChooser = vanilla.ColorWell(
        (240, y - 4, 40, 22),
        callback=window_controller._callback_color_changed_foreground,
        color=window_controller.color,
    )
    w.colorbgChooser = vanilla.ColorWell(
        (290, y - 4, 40, 22),
        color=window_controller.colorbg,
        callback=window_controller._callback_color_changed_background)
    w.colorPaletteColorChooser = vanilla.ColorWell(
        (450, y - 4, 40, 22),
        callback=window_controller._callback_color_changed_layer,
        color=window_controller.color,
    )
    y += 25
    w.glyph_list = vanilla.List(
        (10, y, col2 - 10, 150),
        [],
        columnDescriptions=glyph_column_descriptions,
        drawFocusRing=True,
        #editCallback=None,
        doubleClickCallback=window_controller._callback_goto_glyph,
        selectionCallback=window_controller._callback_ui_glyph_list_selection,
        allowsMultipleSelection=False,
    )
    w.layer_list = vanilla.List(
        (col2 + 10, y, -10, 150),
        [],
        columnDescriptions=layer_column_descriptions,
        drawFocusRing=True,
        editCallback=window_controller._callback_layer_edit,
        enableDelete=True,
        selectionCallback=window_controller._callback_layer_select,
        allowsMultipleSelection=False,
        otherApplicationDropSettings=layer_drop_settings,
    )
    y += 160
    w.show_only_glyphs_with_layers = vanilla.CheckBox(
        (10, y, 176, 20),
        "Show only glyphs with layers",
        callback=window_controller._callback_set_show_only_glyphs_with_layers,
        value=window_controller.show_only_glyphs_with_layers,
        sizeStyle="small")
    w.add_layer_button = vanilla.GradientButton(
        (col2 + 10, y - 10, 24, 24),
        imagePath="../resources/iconColorFontPlus.pdf",
        callback=window_controller._callback_layer_add,
    )
    # w.add_svg_button = vanilla.Button(
    #     (col2+43, y-10, 60, 24),
    #     "Add SVG",
    #     callback=window_controller._choose_svg_to_import,
    #     sizeStyle="small"
    # )
    y += 28
    w.selectButton = vanilla.Button(
        (10, y, col2 - 10, 20),
        "Select glyphs with layers",
        callback=window_controller._callback_select_glyphs_in_font_window,
    )
    w.auto_palette_button = vanilla.Button(
        (col2 + 10, y, 110, 20),
        "Mix palette",
        callback=window_controller._callback_auto_palette,
    )
    w.png_button = vanilla.Button(
        (380, y, 110, 20),
        "Export PNG",
        callback=window_controller._choose_png_to_export,
    )
    y += 31
    w.toggleSettingsButton = vanilla.Button(
        (10, y, 115, 20),
        "Settings...",
        callback=window_controller._callback_toggle_settings,
    )
    w.auto_layer_button = vanilla.Button(
        (135, y, 115, 20),
        "Auto layers",
        callback=window_controller._callback_auto_layers,
    )
    w.import_button = vanilla.Button(
        (col2 + 10, y, 110, 20),
        "Import font",
        callback=window_controller._choose_file_to_import,
    )
    w.export_button = vanilla.Button(
        (380, y, 110, 20),
        "Export to font",
        callback=window_controller._choose_file_to_export,
    )

    return w
    def __init__(self):
        self.fontAnchors = FontAnchors(CurrentFont())
        self.showPreview = getExtensionDefault(
            "%s.%s" % (extensionID, "preview"), True)
        nscolor = getDefaultColor("glyphViewPreviewFillColor")
        self.preview_color = (nscolor.redComponent(), nscolor.greenComponent(),
                              nscolor.blueComponent(),
                              nscolor.alphaComponent())

        columnDescriptions = [
            {
                "title": "Show",
                "cell": vanilla.CheckBoxListCell(),
                "width": 35
            },
            {
                "title": "Name",
                "typingSensitive": True,
                "editable": False
            },
        ]

        self.w = vanilla.FloatingWindow((170, 490),
                                        "Anchor Overlay",
                                        closable=False)

        y = 10
        self.w.showAnchors_label = vanilla.TextBox((10, y, -10, 20),
                                                   "Show anchors:",
                                                   sizeStyle="small")
        y += 25
        self.w.showAnchors = vanilla.List(
            (10, y, -10, 150),
            self.fontAnchors.getAnchorNames(),
            columnDescriptions=columnDescriptions,
            drawFocusRing=True,
            editCallback=self.updateAnchorVisibility,
            doubleClickCallback=self.selectGlyphsWithAnchorName,
            selectionCallback=self.updateAnchoredGlyphsList,
        )
        y += 160
        self.w.markAnchors_label = vanilla.TextBox((10, y, 150, 20),
                                                   "Show mark glyphs:",
                                                   sizeStyle="small")
        y += 25
        self.w.markAnchors = vanilla.List(
            (10, y, 150, 180),
            [],  #self.fontAnchors.anchorGlyphs.keys(),
            columnDescriptions=columnDescriptions,
            editCallback=self.updateMarkVisibility,
            doubleClickCallback=self.gotoGlyph,
            allowsMultipleSelection=False,
            allowsEmptySelection=False,
        )
        y += 188
        #self.w.drawPreview = vanilla.CheckBox((10, y, -10, -10), "Show in preview mode",
        #    callback=self.setShowPreview,
        #    value=self.showPreview,
        #    sizeStyle="small"
        #)

        #self.w.displayAnchors = vanilla.CheckBox((10, y+25, -10, -10), "Show anchors",
        #    callback=self.setShowAnchors,
        #    value=getGlyphViewDisplaySettings()["Anchors"],
        #    sizeStyle="small"
        #)

        y += 2
        self.w.alignAnchors_label = vanilla.TextBox((10, y, -10, -10),
                                                    "Align selected anchors:",
                                                    sizeStyle="small")

        y += 21
        self.w.centerXButton = vanilla.Button(
            (10, y, 72, 25),
            "Points X",
            callback=self.centerAnchorX,
            sizeStyle="small",
        )
        self.w.centerYButton = vanilla.Button(
            (88, y, 72, 25),
            "Points Y",
            callback=self.centerAnchorY,
            sizeStyle="small",
        )

        y += 26
        self.w.baselineButton = vanilla.Button(
            (10, y, 46, 25),
            "base",
            callback=self.moveAnchorBaseline,
            sizeStyle="small",
        )
        self.w.xheightButton = vanilla.Button(
            (62, y, 46, 25),
            "x",
            callback=self.moveAnchorXheight,
            sizeStyle="small",
        )
        self.w.capheightButton = vanilla.Button(
            (114, y, 46, 25),
            "cap",
            callback=self.moveAnchorCapheight,
            sizeStyle="small",
        )

        self.setUpBaseWindowBehavior()
        self.addObservers()

        self.w.showAnchors.setSelection([])
        self.w.open()
Example #6
0
    def __init__(self, font):
        self.font = font
        self.w = vanilla.Sheet((700, 300), parentWindow=CurrentFontWindow().w, minSize=(200, 200))
        self.originalConstructions = ConstructionsLoader(font.defaultLayer).constructions
        columnDescriptions = [
            dict(
                title="Name",
                key="name",
                editable=False,
                width=100
            ),
            dict(
                title="Construction",
                key="construction",
                editable=True
            ),
            dict(
                title="Decompose",
                key="decompose",
                editable=True,
                cell=vanilla.CheckBoxListCell(),
                width=80
            )
        ]
        self.w.constructionList = vanilla.List(
            "auto",
            [],
            columnDescriptions=columnDescriptions
        )
        self.w.showExistingGlyphsCheckBox = vanilla.CheckBox(
            "auto",
            "Show Existing Glyphs",
            callback=self.showExistingGlyphsCheckBoxCallback
        )
        self.w.flex = vanilla.Group("auto")
        self.w.buildInAllFontsButton = vanilla.Button(
            "auto",
            "Build In All Fonts",
            callback=self.buildInAllFontsButtonCallback
        )
        self.w.cancelButton = vanilla.Button(
            "auto",
            "Cancel",
            callback=self.cancelButtonCallback
        )
        self.w.buildButton = vanilla.Button(
            "auto",
            "Build",
            callback=self.buildButtonCallback
        )

        metrics = dict(
            margin=15,
            padding=10,
            buttonWidth=80
        )
        rules = [
            "H:|[constructionList]|",
            "H:|-margin-[showExistingGlyphsCheckBox][flex(>=100)]-[buildInAllFontsButton]-padding-[cancelButton(==buttonWidth)]-padding-[buildButton(==buttonWidth)]-margin-|",
            "V:|"
                "[constructionList]"
                "-padding-"
                "[showExistingGlyphsCheckBox]"
                "-margin-"
            "|",
            "V:|"
                "[constructionList]"
                "-padding-"
                "[flex]"
                "-margin-"
            "|",
            "V:|"
                "[constructionList]"
                "-padding-"
                "[buildInAllFontsButton]"
                "-margin-"
            "|",
            "V:|"
                "[constructionList]"
                "-padding-"
                "[cancelButton]"
                "-margin-"
            "|",
            "V:|"
                "[constructionList]"
                "-padding-"
                "[buildButton]"
                "-margin-"
            "|"
        ]
        self.w.addAutoPosSizeRules(rules, metrics)

        self.populateConstructionList()
        self.w.setDefaultButton(self.w.buildButton)
        self.w.cancelButton.bind(".", ["command"])
        self.w.open()