def __init__(self):
        """
        Use "accuracy" in UI because it's easier to understand,
        but convert to "tolerance" because it's easier to use
        in parallel slope math later.
        """
        self.maxValue = 5
        self.w = ShowHideWindow((150, 60), "Set Accuracy")
        self.w.accuracySlider = Slider(
            (10, 9, -10, 23),
            minValue=0,
            maxValue=self.maxValue,
            value=self.maxValue - hf.readSetting(settingDir),
            sizeStyle="small",
            callback=self.accuracySliderCB)
        self.w.lessText = TextBox((10, 30, -10, 12),
                                  text="Less",
                                  sizeStyle="small")
        self.w.moreText = TextBox((10, 30, -10, 12),
                                  text="More",
                                  alignment="right",
                                  sizeStyle="small")

        self.w.center()
        self.w.makeKey()
class FileUploadField(Group):

    def __init__(self, dimensions, storage=NullStorage()):
        self.storage = storage

        super(FileUploadField, self).__init__(dimensions)

        self.choose_file_button = Button((0, 3, 100, 17), "Choose File", sizeStyle="small", callback=self.choose_file)
        self.remove_file_button = Button((-60, 3, 60, 17), "Remove", sizeStyle="small", callback=self.remove_file)
        self.filepath_label = TextBox((18, 3, -70, 20), "")
        self.filepath_button = ImageButton((0, 3, -70, 20), "", callback=self.reveal_file)
        self.filepath_button.getNSButton().setTransparent_(True)
        self.filetype_image = ImageView((0, 4, 16, 16))

        self.filepath = self.storage.retrieve()

    def choose_file(self, sender):
        filepath = getFile("Choose a .txt or .pdf document to use as a license",
                           "Select License",
                           fileTypes=("txt", "md", "pdf"))

        if filepath is not None:
            self.storage.store(filepath[0])
            self.filepath = filepath[0]

    def remove_file(self, sender):
        self.storage.store(None)
        self.filepath = None

    def reveal_file(self, sender):
        workspace = NSWorkspace.sharedWorkspace()
        workspace.selectFile_inFileViewerRootedAtPath_(self.filepath,
                                                       os.path.dirname(self.filepath))

    @property
    def filename(self):
        if self.filepath is not None:
            return os.path.basename(self.filepath)
        else:
            return ""

    @property
    def filepath(self):
        return self._filepath

    @filepath.setter
    def filepath(self, value):
        self._filepath = value

        selected = value is not None and value is not ''

        icon = NSWorkspace.sharedWorkspace().iconForFile_(self._filepath)

        self.choose_file_button.show(not selected)
        self.remove_file_button.show(selected)
        self.filepath_label.show(selected)
        self.filepath_label.set(WhiteText(self.filename))
        self.filepath_button.show(selected)
        self.filetype_image.show(selected)
        self.filetype_image.setImage(imageObject=icon)
Example #3
0
    def __init__(self,
                 dimensions,
                 applicant_roster,
                 font_family_id,
                 after_approve=None):
        super(ApplicantList, self).__init__(dimensions)

        _, _, width, height = self.getPosSize()

        self.applicant_roster = applicant_roster
        self.family_id = font_family_id
        self.after_approve = after_approve

        self.border = DashedRectangle((0, 0, width, height))
        self.enable_registry_button = CenteredButton(width,
                                                     height,
                                                     190,
                                                     24,
                                                     "Create Application Form",
                                                     callback=self.enable)

        self.label = TextBox((0, 0, -0, 22), "Applicants", sizeStyle="small")
        self.list = List((0, 23, 0, -34), [], columnDescriptions=self.columns)
        self.approve_applicant_button = Button((0, -24, 90, 24),
                                               "Approve",
                                               callback=self.approve_applicant)
        self.open_registration_page_button = Button(
            (-150, -20, 150, 17),
            "Open Application Form",
            callback=self.open_registration_page,
            sizeStyle="small")

        self.enabled = self.applicant_roster is not None
Example #4
0
class FileUploadField(Group):

    def __init__(self, dimensions, storage=NullStorage()):
        self.storage = storage

        super(FileUploadField, self).__init__(dimensions)

        self.choose_file_button = Button((0, 3, 100, 17), "Choose File", sizeStyle="small", callback=self.choose_file)
        self.remove_file_button = Button((-60, 3, 60, 17), "Remove", sizeStyle="small", callback=self.remove_file)
        self.filepath_label = TextBox((18, 3, -70, 20), "")
        self.filepath_button = ImageButton((0, 3, -70, 20), "", callback=self.reveal_file)
        self.filepath_button.getNSButton().setTransparent_(True)
        self.filetype_image = ImageView((0, 4, 16, 16))

        self.filepath = self.storage.retrieve()

    def choose_file(self, sender):
        filepath = getFile("Choose a .txt or .pdf document to use as a license",
                           "Select License",
                           fileTypes=("txt", "md", "pdf"))

        if filepath is not None:
            self.storage.store(filepath[0])
            self.filepath = filepath[0]

    def remove_file(self, sender):
        self.storage.store(None)
        self.filepath = None

    def reveal_file(self, sender):
        workspace = NSWorkspace.sharedWorkspace()
        workspace.selectFile_inFileViewerRootedAtPath_(self.filepath,
                                                       os.path.dirname(self.filepath))

    @property
    def filename(self):
        if self.filepath is not None:
            return os.path.basename(self.filepath)
        else:
            return ""

    @property
    def filepath(self):
        return self._filepath

    @filepath.setter
    def filepath(self, value):
        self._filepath = value

        selected = value is not None and value is not ''

        icon = NSWorkspace.sharedWorkspace().iconForFile_(self._filepath)

        self.choose_file_button.show(not selected)
        self.remove_file_button.show(selected)
        self.filepath_label.show(selected)
        self.filepath_label.set(self.filename)
        self.filepath_button.show(selected)
        self.filetype_image.show(selected)
        self.filetype_image.setImage(imageObject=icon)
Example #5
0
    def __init__(self, posSize, index, aFont, isTop, isBottom,
                 directionCallback, displayedCallback):
        super(FontRow, self).__init__(posSize)
        self.directionCallback = directionCallback
        self.displayedCallback = displayedCallback
        self.index = index
        self.ctrlFont = aFont

        squareButtonSide = FONT_ROW_HEIGHT - 6

        self.check = CheckBox(
            (0, 0, 16, vanillaControlsSize['CheckBoxRegularHeight']),
            '',
            value=self.isDisplayed,
            callback=self.checkCallback)

        self.caption = TextBox(
            (18, 2, 120, vanillaControlsSize['TextBoxRegularHeight']),
            '{}'.format(self.ctrlFont.info.styleName))

        self.buttonUp = SquareButton((-(squareButtonSide * 2 + MARGIN_COL), 0,
                                      squareButtonSide, squareButtonSide),
                                     u'↑',
                                     callback=self.buttonUpCallback)
        if isTop is True:
            self.buttonUp.show(False)

        self.buttonDw = SquareButton(
            (-squareButtonSide, 0, squareButtonSide, squareButtonSide),
            u'↓',
            callback=self.buttonDwCallback)
        if isBottom is True:
            self.buttonDw.show(False)
Example #6
0
    def __init__(self, posSize, callback):
        super(WordListController, self).__init__(posSize)
        x, y, self.ctrlWidth, self.ctrlHeight = posSize
        self.callback = callback

        # handling kerning words
        self.kerningWordsDB = loadKerningTexts(STANDARD_KERNING_TEXT_FOLDER)
        self.kerningTextBaseNames = self.kerningWordsDB.keys()
        self.activeKerningTextBaseName = self.kerningTextBaseNames[0]
        # this is the list used for data manipulation
        self.wordsWorkingList = self.kerningWordsDB[self.activeKerningTextBaseName]
        # this list instead is used for data visualization in the ctrl
        self._makeWordsDisplayList(self.activeKerningTextBaseName)
        self.activeWord = self.wordsWorkingList[0]['word']
        self.wordFilter = ''

        jumping_Y = 0
        self.kerningVocabularyPopUp = PopUpButton((0, jumping_Y, self.ctrlWidth*.6, vanillaControlsSize['PopUpButtonRegularHeight']),
                                                  self.kerningTextBaseNames,
                                                  callback=self.kerningVocabularyPopUpCallback)

        self.openTextsFolderButton = SquareButton((self.ctrlWidth*.62, jumping_Y, self.ctrlWidth*.38, vanillaControlsSize['PopUpButtonRegularHeight']+1),
                                                  'Load texts...',
                                                  sizeStyle='small',
                                                  callback=self.openTextsFolderButtonCallback)

        wordsColumnDescriptors = [
            {'title': '#', 'width': 30, 'editable': False},
            {'title': 'word', 'width': self.ctrlWidth-80, 'editable': False},
            {'title': 'done?', 'width': 35, 'cell': CheckBoxListCell(), 'editable': False}]

        jumping_Y += self.openTextsFolderButton.getPosSize()[3] + MARGIN_VER
        self.wordsListCtrl = List((0, jumping_Y, self.ctrlWidth, 170),
                                  self.wordsDisplayList,
                                  enableDelete=False,
                                  allowsMultipleSelection=False,
                                  columnDescriptions=wordsColumnDescriptors,
                                  selectionCallback=self.wordsListCtrlSelectionCallback,
                                  doubleClickCallback=self.wordsListCtrlDoubleClickCallback)

        jumping_Y += self.wordsListCtrl.getPosSize()[3] + MARGIN_VER
        self.wordsFilterCtrl = EditText((-70, jumping_Y-1, 70, vanillaControlsSize['EditTextRegularHeight']),
                                        placeholder='filter...',
                                        callback=self.wordsFilterCtrlCallback)

        self.wordsDone = len([row['done?'] for row in self.wordsWorkingList if row['done?'] != 0])
        self.infoCaption = TextBox((0, jumping_Y+2, self.ctrlWidth-self.wordsFilterCtrl.getPosSize()[2], vanillaControlsSize['TextBoxRegularHeight']),
                                   'done: {:d}/{:d}'.format(self.wordsDone, len(self.wordsWorkingList)))

        jumping_Y += self.wordsFilterCtrl.getPosSize()[3] + MARGIN_VER
        self.loadStatus = SquareButton((0, jumping_Y, 90, vanillaControlsSize['ButtonRegularHeight']+2),
                                       'Load status',
                                       callback=self.loadStatusCallback)

        self.saveButton = SquareButton((-90, jumping_Y, 90, vanillaControlsSize['ButtonRegularHeight']+2),
                                       'Save status',
                                       callback=self.saveButtonCallback)
 def __init__(self, parameter, posSize, text='', callback=None, continuous=False, showRelativeValue=False):
     super(ParameterTextInput, self).__init__(posSize)
     self.parameter = parameter
     rel = self._relValue()
     self.callback = callback
     self.textInput = EditText((0, 0, -40, -0), text=text, callback=self._valueInput, continuous=continuous)
     self.relInfo = TextBox((-35, 5, -0, -0), rel, alignment='left', sizeStyle='small')
     self.showRelativeValue(showRelativeValue)
     self.vanillaInputs = [self.textInput]
     self.parameter.bind(self)
Example #8
0
    def __init__(self):
        self.font = Glyphs.font  # Returns the current that is open in GlyphsApp
        self.currentGlyphName = 'H'
        self.glyph = self.font[self.currentGlyphName].layers[0]
        lsb = int(round(self.glyph.LSB))
        rsb = int(round(self.glyph.RSB))

        pad = 10
        leading = 32
        y = pad
        w = 300
        h = 400
        buttonWidth = 100
        buttonHeight = 48

        self.w = Window((100, 100, w, h), 'DemoWindowTool')
        self.w.doDraw = CheckBox((pad, y, 100, 24),
                                 'Draw',
                                 callback=self.doDrawCallback)

        y += leading
        self.w.leftMarginLabel = TextBox((pad, y, -pad, 24), 'Left margin')
        y += leading / 2
        self.w.leftMarginSlider = Slider(
            (pad, y, -pad - 60, 24),
            minValue=MIN_LSB,
            maxValue=MAX_LSB,
            value=lsb,
            tickMarkCount=10,
            callback=self.leftMarginSliderCallback)
        self.w.leftMarginBox = EditText((-pad - 60 + pad, y, -pad, 24),
                                        callback=self.leftMarginBoxCallback)
        self.w.leftMarginBox.set(str(lsb))

        y += leading
        self.w.rightMarginLabel = TextBox((pad, y, -pad, 24), 'Right margin')
        y += leading / 2
        self.w.rightMarginSlider = Slider(
            (pad, y, -pad - 60, 24),
            minValue=MIN_RSB,
            maxValue=MAX_RSB,
            value=rsb,
            tickMarkCount=10,
            callback=self.rightMarginSliderCallback)
        self.w.rightMarginBox = EditText((-pad - 60 + pad, y, -pad, 24),
                                         callback=self.rightMarginBoxCallback)
        self.w.rightMarginBox.set(str(rsb))

        y = self.w.saveFont = Button((-buttonWidth - pad, -buttonHeight - pad,
                                      buttonWidth, buttonHeight),
                                     'Save',
                                     callback=self.saveFontCallback)

        self.w.open()
Example #9
0
 def __init__(self, success_window):
     self.success_window = success_window
     
     self.window.introduction = TextBox((15, 15, -15, 22), 'Sign in with your Ghostlines account.', sizeStyle='small')
     self.window.email_label = TextBox((15, 44, -15, 22), 'Email:', sizeStyle='small')
     self.window.email_field = EditText((15, 61, -15, 22))
     self.window.password_label = TextBox((15, 101, -15, 22), 'Password:'******'small')
     self.window.password_field = SecureEditText((15, 119, -15, 22))
     self.window.need_account_button = Button((15, -35, 110, 17), 'Need Account?', callback=self.make_account, sizeStyle="small")
     self.window.sign_in_button = Button((175, -38, 110, 22), 'Sign In', callback=self.sign_in)
     self.window.setDefaultButton(self.window.sign_in_button)
Example #10
0
    def __init__(self, dimensions, storage=NullStorage()):
        self.storage = storage

        super(FileUploadField, self).__init__(dimensions)

        self.choose_file_button = Button((0, 3, 100, 17), "Choose File", sizeStyle="small", callback=self.choose_file)
        self.remove_file_button = Button((-60, 3, 60, 17), "Remove", sizeStyle="small", callback=self.remove_file)
        self.filepath_label = TextBox((18, 3, -70, 20), "")
        self.filepath_button = ImageButton((0, 3, -70, 20), "", callback=self.reveal_file)
        self.filepath_button.getNSButton().setTransparent_(True)
        self.filetype_image = ImageView((0, 4, 16, 16))

        self.filepath = self.storage.retrieve()
Example #11
0
    def __init__(self):
        self.valuesPrefsKey = prefsKey + ".delta." + basename(
            Glyphs.font.filepath)
        # UI metrics
        spacing = 8
        height = 22
        # calculate window height
        minWinSize = (220,
                      120 + (len(Glyphs.font.masters) * (height + spacing)))
        # create UI window
        self.w = FloatingWindow(minWinSize,
                                "Adjust sidebearings",
                                minSize=minWinSize,
                                maxSize=(500, 500),
                                autosaveName=prefsKey + ".win")
        # layout UI controls
        y = 16
        self.w.label = TextBox((16, y, -16, height),
                               "Sidebearing delta adjustment:")
        y += height + spacing

        inputWidth = 64
        for master in Glyphs.font.masters:
            setattr(self.w, "deltaLabel%s" % master.id,
                    TextBox((16, y, -16 - inputWidth, height), master.name))
            setattr(self.w, "deltaInput%s" % master.id,
                    EditText((-16 - inputWidth, y, -16, height), "16"))
            # print("self.w.deltaInputs[master.id]", getattr(self.w, "deltaInput%s" % master.id))
            y += height + spacing

        self.w.submitButton = Button((16, -16 - height, -16, height),
                                     "Adjust all sidebearings",
                                     callback=self.onSubmit)
        # finalize UI
        self.w.setDefaultButton(self.w.submitButton)
        self.loadPreferences()
        self.w.bind("close", self.savePreferences)

        # make sure window is large enough to show all masters
        x, y, w, h = self.w.getPosSize()
        if w < minWinSize[0] and h < minWinSize[1]:
            self.w.setPosSize((x, y, minWinSize[0], minWinSize[1]),
                              animate=False)
        elif w < minWinSize[0]:
            self.w.setPosSize((x, y, minWinSize[0], h), animate=False)
        elif h < minWinSize[1]:
            self.w.setPosSize((x, y, w, minWinSize[1]), animate=False)

        self.w.open()
        self.w.makeKey()
Example #12
0
 def __init__(self, posSize, text, minValue, maxValue, value, callback):
     Group.__init__(self, posSize)
     self.text = TextBox((0, 0, -0, 20), text)
     self.slider = Slider((2, 20, -60, 17),
                          minValue=minValue,
                          maxValue=maxValue,
                          value=value,
                          sizeStyle="small",
                          callback=self.sliderChanged)
     self.edit = EditText((-40, 15, -0, 22),
                          text=str(value),
                          placeholder=str(value),
                          callback=self.editChanged)
     self.callback = callback
    def __init__(self, logout_window, account=None):
        self.logout_window = logout_window

        if account is not None:
            self.account = account

        self.window.email_label = TextBox((15, 15, -15, 22),
                                          'Account Email:',
                                          sizeStyle='small')
        self.window.account_email = TextBox((15, 40, -15, 22),
                                            self.account['email_address'],
                                            alignment='center')
        self.window.sign_out_button = Button((175, -38, 110, 22),
                                             'Sign Out',
                                             callback=self.sign_out)
Example #14
0
    def __init__(self):
        self.master_names = [m.name for m in Glyphs.font.masters][1:]

        item_height = 24.0
        w_width = 350.0
        w_height = item_height * 5
        margin = 10
        next_y = margin
        col_1_width = w_width - (margin * 2)
        item_height = 24

        self.w = Window((w_width, w_height), "Convert Master to Brace Layers")

        next_y = margin
        self.w.master_names_label = TextBox((margin, next_y + 2, col_1_width, item_height), "Master to Convert (Cannot be the first Master)", sizeStyle='regular')
        next_y += item_height
        self.w.master_names = PopUpButton((margin, next_y, col_1_width, item_height), self.master_names)
        next_y += item_height + margin
        selected_master_index = Glyphs.font.masters.index(Glyphs.font.selectedFontMaster)
        self.w.master_names.set(selected_master_index - 1)

        self.w.gobutton = Button((margin + (col_1_width / 4), next_y, col_1_width / 2, item_height), 'Add Brace Layers', callback=self.makeitso)

        self.w.setDefaultButton(self.w.gobutton)

        self.w.open()
Example #15
0
 def __init__(self, parameter, posSize, title=None, callback=None):
     super(ParameterSliderTextInput, self).__init__(posSize)
     self.parameter = parameter
     self.callback = callback
     editTextPosSize = (-65, 0, 40, 22)
     if title is None:
         sliderPosSize = (5, 3, -80, 15)
     elif title is not None:
         title = title.capitalize()
         sliderPosSize = (70, 3, -80, 15)
         self.title = TextBox((0, 3, 65, 30), title, sizeStyle='small')
     if parameter.dissociable:
         editTextPosSize = (-65, 0, 40, 22)
         self.checkBox = CheckBox((-22, 5, 22, 25),
                                  u'∞',
                                  callback=self.setFree,
                                  value=True,
                                  sizeStyle='mini')
     self.slider = Slider(sliderPosSize,
                          minValue=parameter.limits[0],
                          maxValue=parameter.limits[1],
                          value=parameter.value,
                          callback=self.valueInput,
                          sizeStyle='small')
     self.textInput = EditText(editTextPosSize,
                               str(parameter.value),
                               callback=self.valueInput,
                               continuous=False,
                               sizeStyle='small')
     self.parameter.bind(self)
Example #16
0
    def __init__(self):
        self.searchResults = []
        self.selectedChars = ""

        self.w = FloatingWindow((300, 400), "Unicode Picker", minSize=(250, 300),
                                autosaveName="UnicodePicker")
        y = 15
        self.w.searchField = EditText((20, y, -20, 25),
                                      placeholder="Search Unicode name or value",
                                      callback=self.searchTextChanged_)

        y += 40
        columnDescriptions = [
            dict(title="char", width=40,
                 cell=makeTextCell(align="center", font=AppKit.NSFont.systemFontOfSize_(14))),
            dict(title="unicode", width=60, cell=makeTextCell(align="right")),
            dict(title="name"),
        ]
        self.w.unicodeList = List((0, y, 0, -100), [], columnDescriptions=columnDescriptions,
                                  rowHeight=18,
                                  selectionCallback=self.listSelectionChanged_,
                                  doubleClickCallback=self.listDoubleClickCallback_)

        y = -95
        self.w.unicodeText = TextBox((20, y, -10, 55), "")
        self.w.unicodeText._nsObject.cell().setFont_(AppKit.NSFont.systemFontOfSize_(36))
        self.w.unicodeText._nsObject.cell().setLineBreakMode_(AppKit.NSLineBreakByTruncatingMiddle)
        y += 55
        self.w.copyButton = Button((20, y, 120, 25), "Copy", callback=self.copy_)
        self.w.copyButton.enable(False)

        self.w.open()
        self.w._window.setWindowController_(self)
        self.w._window.setBecomesKeyOnlyIfNeeded_(False)
        self.w._window.makeKeyWindow()
	def __init__( self ):
		# Window 'self.w':
		w  = 300
		h = 300
		windowWidthResize  = 200 # user can resize width by this value
		windowHeightResize = 500   # user can resize height by this value
		self.w = vanilla.FloatingWindow(
			(w, h ), # default window size
			"Dimensions", # window title
			minSize = ( w, h-100 ), # minimum size (for resizing)
			maxSize = ( w + windowWidthResize, h + windowHeightResize ), # maximum size (for resizing)
			autosaveName = "com.typetr.Dimensions.mainwindow" # stores last window position and size
		)
		M = 10
		y = 30
		# UI elements we'll use later
		self.w.tabWidth = EditText( (M, y, w/4-M-M, 20), "650", sizeStyle='small' )
		self.w.tabWidthLabel = TextBox( (w/4, y+4, w/2, 20), "Tab width", sizeStyle='small' )
		
		y += 30
		# Checkbox to flag if any drawing should be done by this tools
		self.w.doDraw = CheckBox((M, y, -M, 24), "Fix errors", value=False, sizeStyle='regular' )
					   
		# Open window and focus on it:
		self.w.bind('close', self.windowCloseCallback) # Make bind in case the window is closed
		self.w.open()
		self.w.makeKey()
		
		# Establish callbacks that we need for this tool
		Glyphs.addCallback( self.drawforeground, DRAWFOREGROUND )
		Glyphs.addCallback( self.drawbackground, DRAWBACKGROUND )
Example #18
0
    def showWindow_(self, sender):
        try:
            from vanilla import Group, Slider, TextBox, Window
            self.windowWidth = 300
            self.windowHeight = 240

            self.w = Window((self.windowWidth, self.windowWidth),
                            "Rotate View",
                            minSize=(self.windowWidth, self.windowWidth + 20))

            self.w.Preview = RoatatePreview((0, 0, -0, -60))
            self.w.controlBox = Group((0, -60, -0, -0))
            self.w.controlBox.slider = Slider((10, 6, -10, 23),
                                              tickMarkCount=17,
                                              callback=self.sliderCallback,
                                              value=0,
                                              minValue=-360,
                                              maxValue=360)
            self.w.controlBox.textBox = TextBox((10, -25, -10, 22),
                                                text="0.00°",
                                                alignment="center")
            self.w.controlBox.slider.getNSSlider().setEnabled_(False)

            self.w.open()
            self.changeGlyph_(None)
            Glyphs.addCallback(
                self.changeGlyph_, UPDATEINTERFACE
            )  #will be called on ever change to the interface
        except:
            print(traceback.format_exc())
    def __init__(self, dimensions, font, applicants, recipients, after_approve=None):
        super(ApplicantList, self).__init__(dimensions)

        _, _, width, height = self.getPosSize()

        self.recipients = recipients
        self.applicants = applicants
        self.font = font
        self.after_approve = after_approve

        self.border = DashedRectangle((0, 0, width, height))
        self.activate_registry_button = CenteredButton(width, height, 190, 24,
                                                       "Activate Registration Page",
                                                       callback=self.activate)

        self.label = TextBox((0, 0, -0, 22), "Applicants")
        self.list = List((0, 23, 0, -34), applicants)
        self.approve_applicant_button = Button((0, -24, 90, 24),
                                               "Approve",
                                               callback=self.approve_applicant)
        self.open_registration_page_button = Button((-150, -20, 150, 17),
                                                    "Open Registration Page",
                                                    callback=self.open_registration_page,
                                                    sizeStyle="small")

        self.activated = font.lib.has_key('pm.ghostlines.ghostlines.registry_token')
Example #20
0
    def __init__(self, callback):
        super(JumpToLineWindow, self).__init__()
        self.callback = callback

        # init the window
        self.w = FloatingWindow((WINDOW_WIDTH, 0), 'Jump to line')

        # edit text caption
        jumpingY = MARGIN_TOP
        self.w.caption = TextBox((MARGIN_LFT, jumpingY + 3, NET_WIDTH * .6,
                                  vanillaControlsSize['TextBoxRegularHeight']),
                                 'Jump to line:')

        self.w.lineEdit = EditText(
            (MARGIN_LFT + NET_WIDTH * .6, jumpingY, -MARGIN_RGT,
             vanillaControlsSize['EditTextRegularHeight']),
            continuous=False)

        jumpingY += vanillaControlsSize['EditTextRegularHeight'] + MARGIN_INT
        self.w.cancelButton = Button(
            (-(BUTTON_WIDTH * 2 + MARGIN_INT + MARGIN_RGT), jumpingY,
             BUTTON_WIDTH, vanillaControlsSize['ButtonRegularHeight']),
            'Cancel',
            callback=self.cancelButtonCallback)

        self.w.okButton = Button(
            (-(BUTTON_WIDTH + MARGIN_RGT), jumpingY, BUTTON_WIDTH,
             vanillaControlsSize['ButtonRegularHeight']),
            'Ok',
            callback=self.okButtonCallback)

        jumpingY += vanillaControlsSize['ButtonRegularHeight'] + MARGIN_BTM
        self.setUpBaseWindowBehavior()
        self.w.resize(WINDOW_WIDTH, jumpingY)
    def __init__(self):
        self.f = CurrentFont()
        self.u = getKerningPairsFromUFO.UFOkernReader(self.f)
        self.absKerning = int(self.u.absoluteKerning)
        self.amountOfPairs = len(self.u.allKerningPairs)

        self.textString = ('The font has %s flat kerning pairs.\n'
                           'Set at %s points, the absolute amount\n'
                           'of kerning would cover the distance of\n%s.')

        wWidth = 300
        wHeight = 250

        if self.amountOfPairs:
            message = u'CONGRATULATIONS! \U0001F600'
        else:
            message = u'Bummer. \U0001F622'

        self.w = Window((wWidth, wHeight), message)

        self.w.measurementSystem = RadioGroup((20, 15, -10, 20),
                                              ["Metric", "Imperial"],
                                              callback=self.parametersChanged,
                                              isVertical=False)

        self.w._pointSize = TextBox((20, 145, -30, 17), 'Point size:')

        self.w.pointSize = Slider((100, 145, -30, 17),
                                  minValue=0,
                                  maxValue=1000,
                                  callback=self.parametersChanged,
                                  value=12)

        pointSize = int(self.w.pointSize.get())
        absKerning = int(self.absKerning *
                         (pointSize / self.f.info.unitsPerEm))

        self.w.text = TextBox(
            (20, 45, -20, 85),
            self.textString % (self.amountOfPairs, int(
                self.w.pointSize.get()), self.convertToMetric(absKerning)))

        self.w.button = Button((20, -40, -30, 20),
                               "Copy kerning pairs to clipboard",
                               callback=self.button)

        self.w.open()
    def __init__(self):
        item_height = 24.0
        w_width = 300.0
        w_height = item_height * 8
        margin = 10
        next_y = margin
        col_1_width = w_width - (margin * 2)
        item_height = 24

        self.messages = []
        self.interpolated_fonts = dict()
        self.current_glyph = None

        self.all_kern_groups = self.get_all_kern_groups()
        self.w = Window((w_width, w_height), "Rename Kern Groups")

        self.w.text_1 = TextBox((margin, next_y, w_width, item_height),
                                "Rename:",
                                sizeStyle='small')
        next_y += item_height
        self.w.nameFind = PopUpButton(
            (margin, next_y, w_width - (margin * 2), item_height),
            self.all_kern_groups,
            sizeStyle='regular')
        next_y += item_height + item_height

        self.w.text_2 = TextBox((margin, next_y, w_width, item_height),
                                "To:",
                                sizeStyle='small')
        next_y += item_height
        self.w.nameReplace = EditText(
            (margin, next_y, w_width - (margin * 2), item_height),
            "",
            sizeStyle='regular')
        next_y += item_height + margin

        self.w.gobutton = Button(
            (margin + (col_1_width / 4), next_y, col_1_width / 2, item_height),
            'Rename',
            callback=self.makeitso)

        self.w.setDefaultButton(self.w.gobutton)
        self.w.center()
        self.w.open()
Example #23
0
    def __init__(self,
                 posSize,
                 sender=None,
                 blenderMode=None,
                 key=None,
                 value=None,
                 idx=0):
        super().__init__(posSize)
        self._setupView(self.nsViewClass, posSize)
        self.sender, self.key, self.value, self.idx = sender, key, value, idx

        if self.idx > 0:
            self.separator = HorizontalLine((0, 0, -0, 1))

        self.help = HelpButton((0, 10, 21, 20), callback=self._helpCallback)
        try:
            docstring[self.key]
        except:
            self.help.enable(False)

        description = TextBox((60, 10, -0, 20), str(self.key))

        if isinstance(value, dict):
            self.description = description
            # TODO: Recursive evaluation of nested dicts
            pass

        elif isinstance(self.value, str) or (isinstance(value, int)
                                             and not isinstance(value, bool)):
            self.description = description
            self.edit = EditText((10, 40, -0, 20),
                                 text=self.value,
                                 callback=self._dummyCallback)
            self.resize(self.getPosSize()[2], 80)

        elif isinstance(self.value, bool):
            self.check = CheckBox((60, 10, -0, 20),
                                  key,
                                  callback=self._dummyCallback,
                                  value=self.value)
            self.resize(self.getPosSize()[2], 40)

        elif isinstance(self.value, list):
            values = self.getValues(self.value)

            self.description = description
            self.list = List((10, 40, -0, 80),
                             items=self.value,
                             columnDescriptions=None,
                             showColumnTitles=False,
                             allowsEmptySelection=False,
                             allowsMultipleSelection=False,
                             autohidesScrollers=True,
                             drawFocusRing=False)
            self.list._nsObject.setBorderType_(NSNoBorder)
            self.resize(self.getPosSize()[2], 120)
Example #24
0
    def __init__(self, posSize, index, isVertical, isHorizontal, step,
                 gridColor, callback):
        Group.__init__(self, posSize)

        # from arguments to attributes
        self.ctrlX, self.ctrlY, self.ctrlWidth, self.ctrlHeight = posSize
        self.index = index
        self.isVertical = isVertical
        self.isHorizontal = isHorizontal
        self.step = step
        self.gridColor = gridColor
        self.callback = callback

        # ctrls
        jumpin_X = 12
        self.indexText = TextBox(
            (jumpin_X, 0, 16, vanillaControlsSize['TextBoxRegularHeight']),
            '{:d})'.format(index))
        jumpin_X += self.indexText.getPosSize()[2]

        self.stepCtrl = EditText(
            (jumpin_X, 0, 38, vanillaControlsSize['EditTextRegularHeight']),
            callback=self.stepCtrlCallback)
        jumpin_X += self.stepCtrl.getPosSize()[2] + 16

        self.isHorizontalCheck = CheckBox(
            (jumpin_X, 0, 32, vanillaControlsSize['CheckBoxRegularHeight']),
            "H",
            value=self.isHorizontal,
            callback=self.isHorizontalCheckCallback)
        jumpin_X += self.isHorizontalCheck.getPosSize()[2] + 2

        self.isVerticalCheck = CheckBox(
            (jumpin_X, 0, 32, vanillaControlsSize['CheckBoxRegularHeight']),
            "V",
            value=self.isVertical,
            callback=self.isVerticalCheckCallback)
        jumpin_X += self.isVerticalCheck.getPosSize()[2] + 10

        self.whichColorWell = ColorWell(
            (jumpin_X, 0, 46, self.ctrlHeight),
            color=NSColor.colorWithCalibratedRed_green_blue_alpha_(*gridColor),
            callback=self.whichColorWellCallback)
Example #25
0
 def show_notification_sheet(self, text, size=(300, 80)):
     self.w.notification = Sheet(size, self.parent.w)
     self.w.notification.text = TextBox((15, 15, -50, -15), text)
     self.w.notification.closeButton = Button(
         (-115, -37, 100, 22),
         'Close',
         callback=self.close_notification_sheet)
     self.w.notification.setDefaultButton(
         self.parent.w.notification.closeButton)
     self.w.notification.open()
Example #26
0
    def __init__(self, position, label, placeholder=""):
        super(TextField, self).__init__(
            (position[0], position[1], position[2], 22))

        self.label = TextBox((0, 3, self.indent - 10, 22),
                             "{0}:".format(label),
                             alignment="right")

        self.text = EditText((self.indent, 0, 500 - 40 - self.indent, 22),
                             placeholder=placeholder)
    def __init__(self):
        self.file_name = 'CustomFilter Project Glyph Sets.plist'
        folder_path = os.path.dirname(Glyphs.font.filepath)
        self.file_path = os.path.join(folder_path, self.file_name)

        self.charsets = OrderedDict()
        self.parse_plist()

        self.basic_xml = """<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.08">
<array>
{charsets}
</array>
</plist>"""

        item_height = 24.0
        w_width = 350.0
        w_height = item_height * 7
        margin = 10
        next_y = margin
        col_1_width = w_width - (margin * 2)
        item_height = 24

        self.w = Window((w_width, w_height), "Insert a font as brace layers")

        next_y = margin
        self.w.charset_name_label = TextBox((margin, next_y + 2, col_1_width, item_height), "Character Set Name:", sizeStyle='regular')
        next_y += item_height
        self.w.charset_name = EditText((margin, next_y, col_1_width, item_height), callback=self.check_extant_charsets)
        next_y += item_height + 2
        self.w.extant_warning = TextBox((margin, next_y + 2, col_1_width, item_height), "The Character Set already exists and will be overwritten!", sizeStyle='small')
        self.w.extant_warning.show(False)
        next_y += (item_height * 0.7) + margin

        self.w.reopen = CheckBox((margin, next_y, col_1_width, item_height), "Close and Reopen current file", value=True)
        next_y += item_height + margin

        self.w.gobutton = Button((margin + (col_1_width / 4), next_y, col_1_width / 2, item_height), 'Make Character Set', callback=self.makeitso)

        self.w.setDefaultButton(self.w.gobutton)

        self.w.open()
Example #28
0
    def __init__(self, font, success_window):
        self.font = font
        self.success_window = success_window

        self.window.family_name_label = TextBox((15, 15, -15, 22),
                                                'Family Name',
                                                sizeStyle='small')
        self.window.family_name = EditText((15, 40, -15, 22),
                                           font.info.familyName)

        self.window.designer_name_label = TextBox((15, 81, -15, 22),
                                                  'Designer',
                                                  sizeStyle='small')
        self.window.designer_name = EditText((15, 106, -15, 22),
                                             font.info.openTypeNameDesigner)

        self.window.create_button = Button((175, -38, 110, 22),
                                           'Add Font',
                                           callback=self.create)
Example #29
0
 def setTags(self, tagGroups, stylisticSetNames):
     # clear all subviews
     for attr, value in list(self.__dict__.items()):
         if isinstance(value, VanillaBaseObject):
             delattr(self, attr)
     self._titles = list(tagGroups)
     self._tagIdentifiers = defaultdict(list)
     margin = 10
     tagWidth = 60
     y = margin
     tagCounter = 0
     for title, tags in tagGroups.items():
         titleLabel = TextBox((margin, y, -margin, 20), title)
         setattr(self, f"label_{title}", titleLabel)
         y += 24
         for tag in sorted(tags):
             tagView = TagView((margin, y, tagWidth, 20),
                               tag,
                               None,
                               callback=self._tagStateChanged)
             names = stylisticSetNames.get(tag)
             if names:
                 if len(names) == 1:
                     description = next(iter(names))
                 else:
                     description = "<multiple names>"
             else:
                 description = features.get(tag, ["<unknown>"])[0]
             friendlyName = TextBox(
                 (margin + tagWidth + 6, y + 1, -margin, 20), description)
             friendlyName._nsObject.cell().setLineBreakMode_(
                 AppKit.NSLineBreakByTruncatingTail)
             tagIdentifier = f"tag_{title}_{tag}"
             self._tagIdentifiers[tag].append(tagIdentifier)
             setattr(self, tagIdentifier, tagView)
             setattr(self, f"friendlyName_{title}_{tag}", friendlyName)
             tagCounter += 1
             y += 26
         y += 6
     posSize = (0, 0, self.getPosSize()[2], y)
     self.setPosSize(posSize)
     self._updateState()
Example #30
0
 def enterAlternateNumber_(self, sender):
     self.popover = Popover((140, 80))
     self.popover.open(parentView=self, preferredEdge='right')
     self.popover.label = TextBox((20, 10, -20, 20), "Enter an Alt nr.:")
     if self.state:
         value = str(int(self.state))
     else:
         value = ""
     self.popover.altNumber = EditText((20, 35, -20, 25), value, continuous=False,
                                       callback=self.textEnteredCallback_)
     self.window().makeFirstResponder_(self.popover.altNumber._nsObject)
Example #31
0
    def __init__(self):
        self.fontTarget = FONT_TARGET_OPTIONS[0]
        self.glyphTarget = GLYPH_TARGET_OPTIONS[0]
        self.gridSize = 4

        self.w = FloatingWindow((0, 0, PLUGIN_WIDTH, 400), PLUGIN_TITLE)
        jumpingY = MARGIN_VER

        # font target
        self.w.fontTargetPopUp = PopUpButton(
            (MARGIN_HOR, jumpingY, NET_WIDTH,
             vanillaControlsSize['PopUpButtonRegularHeight']),
            FONT_TARGET_OPTIONS,
            callback=self.fontTargetPopUpCallback)
        jumpingY += vanillaControlsSize['PopUpButtonRegularHeight'] + MARGIN_VER

        # glyph target
        self.w.glyphTargetPopUp = PopUpButton(
            (MARGIN_HOR, jumpingY, NET_WIDTH,
             vanillaControlsSize['PopUpButtonRegularHeight']),
            GLYPH_TARGET_OPTIONS,
            callback=self.glyphTargetPopUpCallback)
        jumpingY += vanillaControlsSize['PopUpButtonRegularHeight'] + MARGIN_VER

        # grid size captions
        self.w.gridSizeCaption = TextBox(
            (MARGIN_HOR, jumpingY + 2, NET_WIDTH * .32,
             vanillaControlsSize['TextBoxRegularHeight']), 'Grid Size:')

        # grid size edit
        self.w.gridSizeEdit = EditText(
            (MARGIN_HOR + NET_WIDTH * .32, jumpingY, NET_WIDTH * .3,
             vanillaControlsSize['EditTextRegularHeight']),
            text='{:d}'.format(self.gridSize),
            callback=self.gridSizeEditCallback)
        jumpingY += vanillaControlsSize['EditTextRegularHeight'] + MARGIN_VER

        self.w.moveBcpHandlesCheck = CheckBox(
            (MARGIN_HOR, jumpingY, NET_WIDTH,
             vanillaControlsSize['CheckBoxRegularHeight']),
            'move bcp handles',
            value=self.bcpHandlesFit,
            callback=self.moveBcpHandlesCheckCallback)
        jumpingY += vanillaControlsSize['CheckBoxRegularHeight'] + MARGIN_VER

        # fit button
        self.w.fitButton = Button((MARGIN_HOR, jumpingY, NET_WIDTH,
                                   vanillaControlsSize['ButtonRegularHeight']),
                                  'Fit!',
                                  callback=self.fitButtonCallback)
        jumpingY += vanillaControlsSize['ButtonRegularHeight'] + MARGIN_VER

        self.w.setPosSize((0, 0, PLUGIN_WIDTH, jumpingY))
        self.w.open()
Example #32
0
    def __init__(self):
        self.transferList = NAME_2_GLYPHLIST[GLYPHLISTS_OPTIONS[0]]
        self.target = TARGET_OPTIONS[0]

        self.w = FloatingWindow((0, 0, PLUGIN_WIDTH, 400), PLUGIN_TITLE)
        jumpingY = MARGIN_VER

        # target fonts
        self.w.targetFontsPopUp = PopUpButton(
            (MARGIN_HOR, jumpingY, NET_WIDTH,
             vanillaControlsSize['PopUpButtonRegularHeight']),
            TARGET_OPTIONS,
            callback=self.targetFontsPopUpCallback)
        jumpingY += vanillaControlsSize['PopUpButtonRegularHeight'] + MARGIN_VER

        # transfer lists pop up
        self.w.glyphListPopUp = PopUpButton(
            (MARGIN_HOR, jumpingY, NET_WIDTH,
             vanillaControlsSize['PopUpButtonRegularHeight']),
            GLYPHLISTS_OPTIONS,
            callback=self.glyphListPopUpCallback)
        jumpingY += vanillaControlsSize['PopUpButtonRegularHeight'] + MARGIN_VER

        # offset caption
        self.w.offsetCaption = TextBox(
            (MARGIN_HOR, jumpingY + 2, NET_WIDTH * .22,
             vanillaControlsSize['TextBoxRegularHeight']), 'Offset:')

        # offset edit text
        self.w.offsetEdit = EditText(
            (MARGIN_HOR + NET_WIDTH * .25, jumpingY, NET_WIDTH * .35,
             vanillaControlsSize['EditTextRegularHeight']),
            continuous=False,
            callback=self.offsetEditCallback)
        self.w.offsetEdit.set('%d' % self.verticalOffset)
        jumpingY += vanillaControlsSize['EditTextRegularHeight'] + MARGIN_VER

        # clean button
        self.w.cleanButton = Button(
            (MARGIN_HOR, jumpingY, NET_WIDTH * .45,
             vanillaControlsSize['ButtonRegularHeight']),
            'Clean',
            callback=self.cleanButtonCallback)

        # run button
        self.w.runButton = Button(
            (MARGIN_HOR + NET_WIDTH * .55, jumpingY, NET_WIDTH * .45,
             vanillaControlsSize['ButtonRegularHeight']),
            'Run!',
            callback=self.runButtonCallback)
        jumpingY += vanillaControlsSize['ButtonRegularHeight'] + MARGIN_VER

        self.w.setPosSize((0, 0, PLUGIN_WIDTH, jumpingY))
        self.w.open()
    def __init__(self, dimensions, storage=NullStorage()):
        self.storage = storage

        super(FileUploadField, self).__init__(dimensions)

        self.choose_file_button = Button((0, 3, 100, 17), "Choose File", sizeStyle="small", callback=self.choose_file)
        self.remove_file_button = Button((-60, 3, 60, 17), "Remove", sizeStyle="small", callback=self.remove_file)
        self.filepath_label = TextBox((18, 3, -70, 20), "")
        self.filepath_button = ImageButton((0, 3, -70, 20), "", callback=self.reveal_file)
        self.filepath_button.getNSButton().setTransparent_(True)
        self.filetype_image = ImageView((0, 4, 16, 16))

        self.filepath = self.storage.retrieve()
class ApplicantList(Group):

    def __init__(self, dimensions, font, applicants, recipients, after_approve=None):
        super(ApplicantList, self).__init__(dimensions)

        _, _, width, height = self.getPosSize()

        self.recipients = recipients
        self.applicants = applicants
        self.font = font
        self.after_approve = after_approve

        self.border = DashedRectangle((0, 0, width, height))
        self.activate_registry_button = CenteredButton(width, height, 190, 24,
                                                       "Activate Registration Page",
                                                       callback=self.activate)

        self.label = TextBox((0, 0, -0, 22), "Applicants")
        self.list = List((0, 23, 0, -34), applicants)
        self.approve_applicant_button = Button((0, -24, 90, 24),
                                               "Approve",
                                               callback=self.approve_applicant)
        self.open_registration_page_button = Button((-150, -20, 150, 17),
                                                    "Open Registration Page",
                                                    callback=self.open_registration_page,
                                                    sizeStyle="small")

        self.activated = font.lib.has_key('pm.ghostlines.ghostlines.registry_token')

    def open_registration_page(self, *args):
        response = Ghostlines('v0.1').registry(self.font.lib['pm.ghostlines.ghostlines.registry_token'])
        registry = response.json()
        webbrowser.open(registry['url'])

    def approve_applicant(self, *args):
        selected_applicants = [self.list[i] for i in self.list.getSelection()]

        for applicant in selected_applicants:
            Ghostlines('v0.1').approve(self.font.lib['pm.ghostlines.ghostlines.registry_token'], applicant)
            self.after_approve(applicant)

        self.fetch()

    def activate(self, *args):
        response = Ghostlines('v0.1').enable_applicants({
            'font_name': self.font.info.familyName,
            'designer': self.font.info.designer
        })

        registry = response.json()

        self.font.lib['pm.ghostlines.ghostlines.registry_token'] = registry['token']
        self.activated = True

    def fetch(self):
        if self.font.lib.has_key('pm.ghostlines.ghostlines.registry_token'):
            response = Ghostlines('v0.1').registry(self.font.lib['pm.ghostlines.ghostlines.registry_token'])
            registry = response.json()
            applicant_emails = [r['email_address'] for r in registry['applicants'] if not r['approved_at']]

            self.list.set(applicant_emails)

    @property
    def activated(self):
        return self._activated

    @activated.setter
    def activated(self, value):
        self._activated = value

        self.label.show(value)
        self.list.show(value)
        self.approve_applicant_button.show(value)
        self.border.show(not value)
        self.activate_registry_button.show(not value)
        self.open_registration_page_button.show(value)

        return self.activated
class ParameterTextInput(Group):

    def __init__(self, parameter, posSize, text='', callback=None, continuous=False, showRelativeValue=False):
        super(ParameterTextInput, self).__init__(posSize)
        self.parameter = parameter
        rel = self._relValue()
        self.callback = callback
        self.textInput = EditText((0, 0, -40, -0), text=text, callback=self._valueInput, continuous=continuous)
        self.relInfo = TextBox((-35, 5, -0, -0), rel, alignment='left', sizeStyle='small')
        self.showRelativeValue(showRelativeValue)
        self.vanillaInputs = [self.textInput]
        self.parameter.bind(self)

    def get(self):
        return self.parameter.get()

    def enable(self, value):
        for item in self.vanillaInputs:
            item.enable(value)

    def _valueInput(self, sender):
        value = sender.get()
        parameter = self.parameter
        if value == 'R' and parameter.hasMaster:
            parameter.reset()
            parameter.update()
            if self.callback is not None:
                self.callback(parameter)
            return
        elif value != '*':
            parameter.setInput(value, sender=sender)
            parameter.update()
            if self.callback is not None:
                self.callback(parameter)
        rel = self._relValue()
        self.relInfo.set(rel)

    def showRelativeValue(self, b):
        self.relInfo.show(b)

    def setFree(self, sender):
        value = bool(sender.get())
        self.parameter.setFree(value)

    def update(self, sender):
        value = self.parameter.get()
        self.textInput.set(str(value))
        self._updateRelValue()

    def _updateRelValue(self):
        rel = self._relValue()
        self.relInfo.set(rel)

    def _relValue(self):
        parameter = self.parameter
        rel = '-'
        if parameter.hasMaster:
            if parameter.mode == 'ratio':
                rel = '%s' % (parameter.getRatio())
            elif parameter.mode == 'offset':
                offsetValue = int(parameter.getOffset())
                sign = '+' if offsetValue >= 0 else ''
                rel = '%s%s' % (sign, offsetValue)
        return rel