Esempio n. 1
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()
Esempio n. 2
0
 def show_subscriber_sheet(self, sender):
     self.window.sheet = Sheet((250, 107), self.window)
     self.window.sheet.name = EditText((15, 15, -15, 22),
                                       "",
                                       placeholder="Name")
     self.window.sheet.email_address = EditText((15, 43, -15, 22),
                                                "",
                                                placeholder="Email Address")
     self.window.sheet.cancel_button = Button((-190, 70, 80, 22),
                                              'Cancel',
                                              callback=self.close_sheet)
     self.window.sheet.create_button = Button(
         (-95, 70, 80, 22), 'Add', callback=self.create_subscriber)
     self.window.sheet.setDefaultButton(self.window.sheet.create_button)
     self.window.sheet.open()
Esempio n. 3
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)
Esempio n. 4
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()
Esempio n. 5
0
	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 )
Esempio n. 6
0
    def __init__(self, posSize, index, callback):
        super(LabelCtrl, self).__init__(posSize)
        self.callback = callback
        self.index = index

        self.jumpingX = 0
        self.attachButton = SquareButton((self.jumpingX, 0, self.attachButtonWidth, vanillaControlsSize['EditTextRegularHeight']),
                                         'Attach',
                                         sizeStyle='small',
                                         callback=self.attachButtonCallback)

        self.jumpingX += MARGIN_COL + self.attachButtonWidth
        self.labelNameEdit = EditText((self.jumpingX, 0, self.labelNameEditWidth, vanillaControlsSize['EditTextRegularHeight']),
                                      callback=self.labelNameEditCallback)

        self.jumpingX += MARGIN_COL + self.labelNameEditWidth
        self.plusButton = SquareButton((self.jumpingX, 0, self.plusButtonWidth, vanillaControlsSize['EditTextRegularHeight']),
                                       '+',
                                       sizeStyle='small',
                                       callback=self.plusButtonCallback)

        self.jumpingX += MARGIN_COL + self.lessButtonWidth
        self.lessButton = SquareButton((self.jumpingX, 0, self.lessButtonWidth, vanillaControlsSize['EditTextRegularHeight']),
                                       '-',
                                       sizeStyle='small',
                                       callback=self.lessButtonCallback)
Esempio n. 7
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)
Esempio n. 8
0
 def __init__(self):
     self.w = Window((550, 140), "Replace named Layer")
     self.w.editText = EditText((10, 15, -10, 22), placeholder="Layer Name", text='{170}')
     self.w.correct_path_direction = CheckBox((10, 50, -10, 18), "Correct Path Direction", value=True, sizeStyle='small')
     self.w.sync_metrics = CheckBox((210, 50, -10, 18), "Sync Metrics", value=True, sizeStyle='small')
     self.w.add_if_missing = CheckBox((10, 70, -10, 18), "Add layer if missing", value=True, sizeStyle='small')
     self.w.copybutton = Button((10, 100, -10, 17), "Replace layer", callback=self.buttonCallback)
     self.w.open()
Esempio n. 9
0
    def __init__(self):
        '''Initialize the dialog.'''
        x = y = padding = 10
        buttonHeight = 20
        windowWidth = 400

        rows = 4.5

        self.w = FloatingWindow(
            (windowWidth, buttonHeight * rows + padding * (rows)),
            "Glyph Fax Machine")

        self.fonts = {}

        # self.w.textBox = TextBox((x, y, -padding, buttonHeight), "Glyphs to Copy")

        # y += buttonHeight

        self.w.editText = EditText(
            (x, y, -padding, buttonHeight * 2 + padding),
            placeholder="Space-separated list of glyphs to copy")

        y += buttonHeight * 2 + padding * 2

        # self.w.overwriteGlyphsCheckBox = CheckBox((x, y, -padding, buttonHeight), "Overwrite Glyphs", value=False, callback=self.overwriteGlyphsOptions)

        # y += buttonHeight + padding

        self.w.overwriteNormalWidthGlyphsCheckBox = CheckBox(
            (x, y, -padding, buttonHeight),
            "Overwrite 600w Glyphs",
            value=False,
            sizeStyle="small")
        # self.w.overwriteNormalWidthGlyphsCheckBox.show(False)

        self.w.overwriteAdjustedWidthGlyphsCheckBox = CheckBox(
            (windowWidth * 0.4, y, -padding, buttonHeight),
            "Overwrite non-600w Glyphs",
            value=False,
            sizeStyle="small")
        # self.w.overwriteAdjustedWidthGlyphsCheckBox.show(False)
        self.w.colorWell = ColorWell(
            (windowWidth * 0.85, y, -padding, buttonHeight),
            color=NSColor.orangeColor())

        y += buttonHeight + padding

        self.w.sans2mono = Button(
            (x, y, windowWidth / 3 - padding / 2, buttonHeight),
            "Sans → Mono",
            callback=self.sans2monoCallback)

        self.w.mono2sans = Button(
            (windowWidth / 3 + padding, y, -padding, buttonHeight),
            "Mono → Sans",
            callback=self.mono2SansCallback)

        self.w.open()
Esempio n. 10
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)
Esempio n. 11
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)
Esempio n. 12
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)
Esempio n. 13
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)
 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)
Esempio n. 15
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()
Esempio n. 16
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()
Esempio n. 17
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)
Esempio n. 18
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)
Esempio n. 19
0
    def __init__(self):
        self.glyph = None  # Typical RoboFont function
        self.updating = False

        pad = 10
        leading = 32
        y = pad
        w = 500
        h = 500
        c1 = 150
        c2 = 200
        bh = 24  # Button height
        leading = bh + pad / 2

        self.w = Window((100, 100, w, h), 'Final tool window', minSize=(w, h))
        self.w.fontList = List((pad, pad, c2, -w / 2), [],
                               doubleClickCallback=self.openFontCallback,
                               selectionCallback=self.update)

        y = pad
        self.w.fixTabWidths = Button((-c1 - pad, y, c1, bh),
                                     'Fix tab widths',
                                     callback=self.fixTabWidthsCallback)
        self.w.fixTabWidths.enable(False)

        y += leading
        self.w.fixNegativeWidths = Button(
            (-c1 - pad, y, c1, bh),
            'Fix negative widths',
            callback=self.fixNegativeWidthsCallback)
        self.w.fixNegativeWidths.enable(False)

        y += leading
        self.w.fixMissingComponentsWidths = Button(
            (-c1 - pad, y, c1, bh),
            'Fix missing components',
            callback=self.fixMissingComponentCallback)
        self.w.fixMissingComponentsWidths.enable(False)

        self.w.selectFolder = Button((-c1 - pad, -pad - bh, c1, bh),
                                     'Select fonts',
                                     callback=self.selectFontFolder)

        self.w.canvas = Canvas((pad, -w / 2 - pad, -pad, -w / 4),
                               delegate=self)

        self.w.report = EditText((pad, -w / 4 + pad, -pad, -pad),
                                 readOnly=False)

        self.w.bind('close', self.windowCloseCallback)
        self.w.open()

        self.dirPath = self.selectFontFolder()
 def add_recipient(self, sender):
     self.window.sheet = Sheet((250, 89), self.window)
     self.window.sheet.recipient = EditText((15, 15, -15, 22),
                                            "",
                                            placeholder="Email Address")
     self.window.sheet.cancel_button = Button((-190, 52, 80, 22),
                                              'Cancel',
                                              callback=self.close_sheet)
     self.window.sheet.create_button = Button(
         (-95, 52, 80, 22), 'Add', callback=self.create_recipient)
     self.window.sheet.setDefaultButton(self.window.sheet.create_button)
     self.window.sheet.open()
Esempio n. 21
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
Esempio n. 22
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()
Esempio n. 23
0
    def __init__(self):
        self.font_order = []
        self.position = "left"
        
        L = 0  # left
        T = 0  # top
        W = 200 # width
        H = 300  # height
        p = 10 # padding
        buttonHeight = 20

        title = "☎️ Hotline Glyph"
        self.w = Window((W, H), title, minSize=(W/3, H/3))

        self.w.fileList = List(
            (L, T, -0, -(p * 3 + buttonHeight * 2)),
            self.font_order,
            columnDescriptions=[
                {"title": "✓", "width":20},
                {"title": "File name"},
                ], # files
            showColumnTitles=False,
            allowsMultipleSelection=True,
            enableDelete=True,
            otherApplicationDropSettings = dict(
                type=NSFilenamesPboardType,
                operation=NSDragOperationCopy,
                callback=self.dropCallback),
            dragSettings=dict(type="RangeType", 
                                callback=self.font_list_drag_callback),
            selfDropSettings=dict(type="RangeType", 
                                operation=NSDragOperationMove, 
                                callback=self.font_list_drop_callback)
            )

        self.w.editText = EditText((p, -(p * 2 + buttonHeight * 2), -p, buttonHeight))

        self.w.draw = CheckBox((p, -(p + buttonHeight), -p, buttonHeight), 'show', value=True, callback=self.updateViewCallback)

        self.w.toLeftbutton = SquareButton((-p*6, -(p + buttonHeight), p*2, buttonHeight), "←", sizeStyle='small', callback=self.toLeft)
        self.w.toRightbutton = SquareButton((-p*3, -(p + buttonHeight), p*2, buttonHeight), "➝", sizeStyle='small', callback=self.toRight)

        addObserver(self, "drawPreviewRef", "drawBackground")
        addObserver(self, "drawRef", "drawPreview")

        self.setUpBaseWindowBehavior() # Needed for the windowCloseCallback

        self.w.open()
Esempio n. 24
0
    def __init__(self, posSize, attachCallback, labelName=None):
        super(Label, self).__init__(posSize)
        self.labelName = labelName
        self.attachCallback = attachCallback

        self.edit = EditText((0, 0, NET_WIDTH * .7,
                              vanillaControlsSize['EditTextRegularHeight']),
                             text=self.labelName,
                             continuous=True,
                             callback=self.editCallback)

        self.button = SquareButton(
            (NET_WIDTH * .72, 0, NET_WIDTH * .28,
             vanillaControlsSize['EditTextRegularHeight']),
            'attach!',
            callback=self.buttonCallback)
    def __init__(self):
        self.filters = PenBallFiltersManager()
        self.filters.loadFiltersFromJSON('/'.join([LOCALPATH, JSONFILE]))
        self.glyphNames = []
        self.observedGlyphs = []
        self.cachedFont = RFont(showUI=False)
        self.currentFont = CurrentFont()
        filtersList = self.filters.keys()
        if len(filtersList) > 0:
            self.currentFilterName = filtersList[0]
        else:
            self.currentFilterName = None
        self.fill = True

        self.observers = [
            ('fontChanged', 'fontBecameCurrent'),
            ('fontChanged', 'fontDidOpen'),
            ('fontChanged', 'fontDidClose'),
        ]

        self.w = Window((100, 100, 800, 500), 'PenBall Wizard v{0}'.format(__version__), minSize=(500, 400))
        self.w.filtersPanel = Group((0, 0, 300, -0))
        self.w.filtersPanel.filtersList = List((0, 0, -0, -40), filtersList, selectionCallback=self.filterSelectionChanged, doubleClickCallback=self.filterEdit, allowsMultipleSelection=False, allowsEmptySelection=False, rowHeight=22)
        self.w.filtersPanel.controls = Group((0, -40, -0, 0))
        self.w.filtersPanel.addFilter = SquareButton((0, -40, 100, 40), 'Add filter', sizeStyle='small', callback=self.addFilter)
        self.w.filtersPanel.addFilterChain = SquareButton((100, -40, 100, 40), 'Add operations', sizeStyle='small', callback=self.addFilterChain)
        self.w.filtersPanel.removeFilter = SquareButton((-100, -40, 100, 40), 'Remove filter', sizeStyle='small', callback=self.removeFilter)
        self.w.textInput = EditText((300, 0, -90, 22), '', callback=self.stringInput)
        self.w.generate = SquareButton((-90, 0, 90, 22), 'Generate', callback=self.generateGlyphsToFont, sizeStyle='small')
        self.w.preview = MultiLineView((300, 22, -0, -0))
        self.w.switchFillStroke = SquareButton((-75, -40, 60, 25), 'Stroke', callback=self.switchFillStroke, sizeStyle='small')
        displayStates = self.w.preview.getDisplayStates()
        for key in ['Show Metrics','Upside Down','Stroke','Beam','Inverse','Water Fall','Multi Line']:
            displayStates[key] = False
        for key in ['Fill','Single Line']:
            displayStates[key] = True
        self.w.preview.setDisplayStates(displayStates)

        for callback, event in self.observers:
            addObserver(self, callback, event)

        self.updateControls()

        self.w.bind('close', self.end)
        self.launchWindow()
        self.w.open()
Esempio n. 26
0
    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()
Esempio n. 27
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)
    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()
Esempio n. 29
0
    def loadPlugin(self):
        self.menuName = "Italic Extremes"
        self.actionButtonLabel = 'Add Nodes'
        self.keyboardShortcut = None
        windowWidth = 300
        windowHeight = 120
        m, h, yPos = 10, 18, 10
        self.w = FloatingWindow((windowWidth, windowHeight))
        self.w.group = Group((0, 0, windowWidth, windowHeight))
        self.w.group.angle = EditText((m, yPos, -50, h),
                                      "",
                                      placeholder='Angles',
                                      sizeStyle='small',
                                      callback=self.editAngles_callback,
                                      continuous=True)
        self.w.group.refresh = Button((-40, yPos, -m, h),
                                      u"↺",
                                      callback=self.revertAngles_callback)
        yPos += m + h
        self.w.group.tabs = Tabs((m, yPos, -m, -m),
                                 ["Add slanted nodes", "Add H/V extremes"],
                                 callback=self.tab_callback)
        self.tab1 = self.w.group.tabs[0]
        self.tab1.removeV = CheckBox((m, 0, -m, h),
                                     "Delete vertical extremes",
                                     sizeStyle='small',
                                     value=False,
                                     callback=self.removeV_callback)
        yPos = h
        self.tab1.removeH = CheckBox((m, yPos, -m, h),
                                     "Delete horizontal extremes",
                                     sizeStyle='small',
                                     value=False,
                                     callback=self.removeH_callback)
        self.tab2 = self.w.group.tabs[1]
        yPos = 0
        self.tab2.removeI = CheckBox((m, yPos, -m, h),
                                     "Delete slanted nodes",
                                     sizeStyle='small',
                                     value=False,
                                     callback=self.removeI_callback)

        self.dialog = self.w.group.getNSView()
Esempio n. 30
0
	def __init__( self ):
		hori_margin = 10
		verti_margin = hori_margin
		button_width = 30
		glyphname_width = 180
		line_height = 20
		gap = 9
		dialog_height = line_height + gap + line_height + gap + line_height
		dialog_width = button_width + gap + glyphname_width + gap + button_width
		self.w = Window( ( hori_margin + dialog_width + hori_margin, verti_margin + dialog_height + verti_margin ), "insert glyph" )
		self.w.center()
		x = hori_margin
		y = verti_margin
		# glyph name
		self.w.glyphname = EditText( ( x, y, glyphname_width, line_height ), '')
		self.w.glyphname.getNSTextField().setToolTip_( u'Enter the name of the glyph to be inserted. It is sufficient to enter the beginning of the glyph name, e.g. “deg” for “degree”.' )
		# buttons
		x += glyphname_width + gap
		self.w.alignleft = Button( ( x, y, button_width, line_height ), LEFT, callback = self.buttonCallback )
		self.w.alignleft.getNSButton().setToolTip_( 'Insert the other glyph left-aligned, i.e. at its original same position. Keyboard shortcut: Enter' )
		x += button_width + gap
		self.w.alignright = Button( ( x, y, button_width, line_height ), RIGHT, callback = self.buttonCallback )
		self.w.alignright.getNSButton().setToolTip_( 'Insert the other glyph right-aligned with respect to the advance widths. Keyboard shortcut: Esc' )
		self.w.setDefaultButton( self.w.alignleft )
		self.w.alignright.bind( "\x1b", [] )
		# insert as component
		as_component_is_checked = True
		if Glyphs.defaults["com.FMX.InsertGlyphToBackground.AsCompoment"]  is not None:
			as_component_is_checked = Glyphs.defaults["com.FMX.InsertGlyphToBackground.AsCompoment"]
		y += line_height + gap
		x = hori_margin
		self.w.as_component = CheckBox( ( x, y, dialog_width, line_height ), 'Insert as component', callback=None, value=as_component_is_checked )
		self.w.as_component.getNSButton().setToolTip_( 'If checked, the other glyph is inserted to the background as a component. Otherwise, it is inserted as paths (even if the other glyph is made of components).' )
		# clear current contents
		y += line_height + gap
		clear_contents_is_checked = True
		if Glyphs.defaults["com.FMX.InsertGlyphToBackground.ClearContents"]  is not None:
			clear_contents_is_checked = Glyphs.defaults["com.FMX.InsertGlyphToBackground.ClearContents"]
		self.w.clear_contents = CheckBox( ( x, y, dialog_width, line_height ), 'Clear current contents', callback=None, value=clear_contents_is_checked )
		self.w.clear_contents.getNSButton().setToolTip_( 'Check this to clear the background before inserting the other glyph. Uncheck to keep the current contents of the background.' )
		self.w.open()