Esempio n. 1
0
	def settings(self):
		self.name = Glyphs.localize({
			'en': 'Alignment',
			'de': 'Ausrichtung',
			'es': 'Alineación',
			'fr': 'Alignement',
			'pt': 'Alinhamento',
		})
		width = 150
		self.marginTop = 7
		self.marginLeft = 7
		self.lineSpacing = 21
		smallSize = NSFont.systemFontSizeForControlSize_( NSFont.smallSystemFontSize() )
		textFieldHeight = smallSize + 7
		textFieldWidth = 50
		# lockHeight = textFieldHeight
		innerWidth = width - 2 * self.marginLeft
		height = ( MAX_ZONES + 4 ) * self.lineSpacing + self.marginTop * 3
		self.posx_TextField = width - textFieldWidth - self.marginLeft

		# Create Vanilla window and group with controls
		self.paletteView = Window( (width, height), minSize=(width, height - 10), maxSize=(width, height + 200 ) )
		self.paletteView.group = Group( (0, 0, width, height ) )

		posy = self.marginTop
		# set up fields for center
		headlineBbox = NSAttributedString.alloc().initWithString_attributes_( 'Bounding box', { NSFontAttributeName:NSFont.boldSystemFontOfSize_( smallSize ) } )
		self.paletteView.group.headlineBbox = TextBox( ( 10, posy, innerWidth, 18 ), headlineBbox, sizeStyle='small' )
		posy += self.lineSpacing
		self.paletteView.group.centerXLabel = TextBox( ( 10, posy + 3, innerWidth, 18 ), 'center x', sizeStyle='small' )
		self.posy_centerX = posy
		# self.paletteView.group.lockX = ImageButton( ( self.posx_TextField - lockHeight - 5, posy, lockHeight, lockHeight ), imageNamed='GSLockUnlockedTemplate', bordered=False, imagePosition='top', callback=self.lockCallback, sizeStyle='regular' )
		# self.lockXlocked = False
		self.paletteView.group.centerX = ArrowEditText( ( self.posx_TextField, posy, textFieldWidth, textFieldHeight ), callback=self.editTextCallback, continuous=False, readOnly=False, formatter=None, placeholder='multiple', sizeStyle='small' )
		posy += self.lineSpacing
		self.paletteView.group.centerYLabel = TextBox( ( 10, posy + 3, innerWidth, 18 ), 'center y', sizeStyle='small' )
		self.posy_centerY = posy
		# self.paletteView.group.lockY = ImageButton( ( self.posx_TextField - lockHeight - 5, posy, lockHeight, lockHeight ), imageNamed='GSLockUnlockedTemplate', bordered=False, imagePosition='top', callback=self.lockCallback, sizeStyle='regular' )
		# self.lockYlocked = False
		self.paletteView.group.centerY = ArrowEditText( ( self.posx_TextField, posy, textFieldWidth, textFieldHeight ), callback=self.editTextCallback, continuous=False, readOnly=False, formatter=None, placeholder='multiple', sizeStyle='small' )
		posy += self.lineSpacing + self.marginTop
		# set up fields for overshoot
		headlineOvershoot = NSAttributedString.alloc().initWithString_attributes_( 'Overshoot', { NSFontAttributeName:NSFont.boldSystemFontOfSize_( NSFont.systemFontSizeForControlSize_( smallSize ) ) } )
		self.paletteView.group.headlineOvershoot = TextBox( ( 10, posy, innerWidth, 18 ), headlineOvershoot, sizeStyle='small' )
		posy += self.lineSpacing
		self.paletteView.group, 'lineAbove', HorizontalLine( ( self.marginLeft, posy - 3, innerWidth, 1 ) )
		for i in range( MAX_ZONES ):
			setattr( self.paletteView.group, 'name' + str( i ), TextBox( ( 10, posy, innerWidth, 18 ), '', sizeStyle='small' ) )
			setattr( self.paletteView.group, 'value' + str( i ), TextBox( ( self.posx_TextField, posy, textFieldWidth - 3, textFieldHeight ), '', sizeStyle='small', alignment='right' ) )
			posy += self.lineSpacing
			setattr( self.paletteView.group, 'line' + str( i ), HorizontalLine( ( self.marginLeft, posy - 3, innerWidth, 1 ) ) )
		# set dialog to NSView
		self.dialog = self.paletteView.group.getNSView()
		# set self.font
		self.font = None
		windowController = self.windowController()
		if windowController:
			self.font = windowController.document().font
Esempio n. 2
0
 def initWithDropboxApp_initialIgnoreList_takeAction_callback_remote_(self, dropbox_app, initial_ignore_list, take_action, callback, remote):
     self = super(SelectiveSyncView, self).initWithFrame_(NSZeroRect)
     if self is None:
         return
     self._initial_ignore_list = initial_ignore_list
     self._callback = callback
     self._take_action = take_action
     self._remote = remote
     self.setAutoresizingMask_(NSViewWidthSizable | NSViewHeightSizable)
     self._dropbox_app = dropbox_app
     self.initBrowser(self._remote)
     self.initButtons()
     f = NSFont.systemFontOfSize_(NSFont.smallSystemFontSize())
     self.infoLabel = NSTextField.createLabelWithText_font_(selsync_strings.info, f)
     self.addSubview_(self.infoLabel)
     self.reloadInvalidState()
     self.layoutForWidth_(DEFAULT_ADVANCED_WIDTH if self.forest.advanced_view else DEFAULT_SIMPLE_WIDTH)
     return self
Esempio n. 3
0
	def __init__( self ):
		# Window 'self.w':
		windowWidth  = 350
		windowHeight = 140
		windowWidthResize  = 100 # user can resize width by this value
		windowHeightResize = 0   # user can resize height by this value
		self.w = vanilla.FloatingWindow(
			( windowWidth, windowHeight ), # default window size
			"Set Family Alignment Zones", # window title
			minSize = ( windowWidth, windowHeight ), # minimum size (for resizing)
			maxSize = ( windowWidth + windowWidthResize, windowHeight + windowHeightResize ), # maximum size (for resizing)
			autosaveName = "com.mekkablue.SetFamilyAlignmentZones.mainwindow" # stores last window position and size
		)
		
		# UI elements:
		linePos, inset, lineHeight = 12, 15, 22
		
		self.w.descriptionText = vanilla.TextBox( (inset, linePos+2, -inset, lineHeight*2), u"Choose an instance (typically the Regular), and insert its zones as PostScript Family Alignment Zones.", sizeStyle='small', selectable=True )
		linePos += lineHeight*2
		
		self.w.instanceText = vanilla.TextBox( (inset, linePos+2, inset+55, 14), u"Instance:", sizeStyle='small', selectable=True )
		
		self.w.instancePicker = vanilla.PopUpButton( (inset+55, linePos, -inset-25, 17), (), sizeStyle='small' )
		self.w.instancePicker.getNSPopUpButton().setToolTip_("Inactive instances are marked.")
		# set font to tabular figures:
		popUpFont = NSFont.monospacedDigitSystemFontOfSize_weight_(NSFont.smallSystemFontSize(), 0.0)
		self.w.instancePicker.getNSPopUpButton().setFont_(popUpFont)
		
		self.w.updateButton = vanilla.SquareButton( (-inset-20, linePos, -inset, 18), u"↺", sizeStyle='small', callback=self.updateInstancePicker )
		self.w.updateButton.getNSButton().setToolTip_("Click to update the menu with the instances of the current font.")
		linePos += lineHeight
		
		# Run Button:
		self.w.runButton = vanilla.Button( (-110-inset, -20-inset, -inset, -inset), "Insert FAZ", sizeStyle='regular', callback=self.SetFamilyAlignmentZonesMain )
		self.w.setDefaultButton( self.w.runButton )
		
		
		# Open window and focus on it:
		self.updateInstancePicker()
		self.w.open()
		self.w.makeKey()
Esempio n. 4
0
    def __init__(self):
        # Window 'self.w':
        windowWidth = 350
        windowHeight = 240
        windowWidthResize = 1000  # user can resize width by this value
        windowHeightResize = 1000  # user can resize height by this value
        self.w = vanilla.FloatingWindow(
            (windowWidth, windowHeight),  # default window size
            "Metrics Key Manager",  # window title
            minSize=(windowWidth,
                     windowHeight - 100),  # minimum size (for resizing)
            maxSize=(windowWidth + windowWidthResize, windowHeight +
                     windowHeightResize),  # maximum size (for resizing)
            autosaveName=
            "com.mekkablue.MetricsKeyManager.mainwindow"  # stores last window position and size
        )

        # UI elements:
        linePos, inset, lineHeight, boxHeight = self.getMeasurements()

        self.w.LeftMetricsKeysText = vanilla.TextBox(
            (inset, linePos + 2, 70, 14),
            u"Left Keys:",
            sizeStyle='small',
            selectable=True)
        self.w.LeftMetricsKeys = vanilla.TextEditor(
            (inset + 70, linePos, -inset, boxHeight),
            "",
            callback=self.SavePreferences)  #, sizeStyle='small' )

        linePos += boxHeight + 10
        self.w.RightMetricsKeysText = vanilla.TextBox(
            (inset, linePos + 2, 70, 14),
            u"Right Keys:",
            sizeStyle='small',
            selectable=True)
        self.w.RightMetricsKeys = vanilla.TextEditor(
            (inset + 70, linePos, -inset, boxHeight),
            "",
            callback=self.SavePreferences)  #, sizeStyle='small' )

        editFont = NSFont.legibileFontOfSize_(NSFont.smallSystemFontSize())

        for editField in (self.w.LeftMetricsKeys, self.w.RightMetricsKeys):
            editField.getNSTextView().setToolTip_(
                u"Enter a metrics key like '=H', followed by a colon (:), followed by glyph names, spearated by space, comma, or any other separator that cannot be part of a glyph name. (Glyph names can contain A-Z, a-z, 0-9, period, underscore and hyphen.)\nExample: ‘=H: B D E F’."
            )
            editField.getNSTextView().setFont_(editFont)
            editField.getNSScrollView().setHasVerticalScroller_(1)
            editField.getNSScrollView().setRulersVisible_(1)

        # Buttons:
        self.w.resetButton = vanilla.Button(
            (-280 - inset, -20 - inset, -inset - 190, -inset),
            u"⟲ Reset",
            sizeStyle='regular',
            callback=self.SetDefaults)
        self.w.resetButton.getNSButton().setToolTip_(
            u"Resets the contents of the L+R Keys to their (currently only Latin) defaults."
        )

        self.w.scanButton = vanilla.Button(
            (-180 - inset, -20 - inset, -inset - 90, -inset),
            u"↑ Extract",
            sizeStyle='regular',
            callback=self.ScanFontForKeys)
        self.w.scanButton.getNSButton().setToolTip_(
            u"Scans the current font for all metrics keys and lists them here. Normalizes the preceding equals sign (=). No matter whether you typed them with or without an equals sign, they will show up here with one."
        )

        self.w.runButton = vanilla.Button(
            (-80 - inset, -20 - inset, -inset, -inset),
            u"↓ Apply",
            sizeStyle='regular',
            callback=self.MetricsKeyManagerMain)
        self.w.runButton.getNSButton().setToolTip_(
            u"Parses the current content of the window and will attempt to set the metrics keys of the respective glyphs in the frontmost font."
        )
        self.w.setDefaultButton(self.w.runButton)

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

        # Bind resizing method:
        self.w.bind("resize", self.windowResize)

        # Open window and focus on it:
        self.w.open()
        self.w.makeKey()
Esempio n. 5
0
    def layout(self):
        self._thumbnail = ThumbnailBoxView.alloc().initWithFrame_(NSZeroRect)
        self._thumbnail.setImage_(Images.Box64)
        self._thumbnail.setImageAlignment_(NSImageAlignCenter)
        self._thumbnail.setImageScaling_(NSScaleToFit)
        self._thumbnail.setFrameSize_(self.THUMBNAIL_SIZE)
        self._thumbnail.setFrameOrigin_(self.THUMBNAIL_ORIGIN)
        self._thumbnail.setShadowOffset_(self.SHADOW_OFFSET)
        self._thumbnail.setShadowBlurRadius_(self.SHADOW_BLUR)
        self._thumbnail.setShadowColor_(NSColor.blackColor().colorWithAlphaComponent_(0.3))
        self._label = NSTextField.createLabelWithText_font_('', NSFont.boldSystemFontOfSize_(13))
        self._label.setFrameOrigin_(self.LABEL_ORIGIN)
        self._progress_bar = NSProgressIndicator.alloc().initWithFrame_(NSRect(self.PROGRESS_ORIGIN, self.PROGRESS_SIZE))
        self._progress_bar.setStyle_(NSProgressIndicatorBarStyle)
        self._progress_bar.setIndeterminate_(YES)
        self._progress_bar.setFrameOrigin_(self.PROGRESS_ORIGIN)
        self._estimate = NSTextField.createLabelWithText_font_('', NSFont.systemFontOfSize_(NSFont.smallSystemFontSize()))
        self._estimate.setFrameOrigin_(self.ESTIMATE_ORIGIN)
        self._hide_button = self.addNormalRoundButtonWithTitle_action_(MiscStrings.hide_button, self.handleHideButton_)
        self._hide_button.setKeyEquivalent_(ENTER_KEY)
        self._hide_button.alignRightInSuperview()
        self._hide_button.alignBottomInSuperview()
        self._cancel_button = self.addNormalRoundButtonWithTitle_action_(MiscStrings.cancel_button, self.handleCancelButton_)
        self._cancel_button.placeLeftOfButton_(self._hide_button)
        self.addSubview_(self._thumbnail)
        self.addSubview_(self._label)
        self.addSubview_(self._progress_bar)
        self.addSubview_(self._estimate)

        @message_sender(AppHelper.callAfter)
        def handleMessage(message):
            self._label.setStringValue_(message)
            self._label.sizeToFit()

        @message_sender(AppHelper.callAfter)
        def handleTotalBytes(total_bytes):
            self._progress_bar.setIndeterminate_(YES if total_bytes == 0 else NO)
            self._progress_bar.setMinValue_(0.0)
            self._progress_bar.setMaxValue_(total_bytes)
            self._progress_bar.setDoubleValue_(self.ui.cur_bytes.get())

        @message_sender(AppHelper.callAfter)
        def handleCurBytes(cur_bytes):
            self._progress_bar.setDoubleValue_(cur_bytes)
            self._estimate.setStringValue_(self.ui.get_remaining_message())
            self._estimate.sizeToFit()

        @message_sender(AppHelper.callAfter)
        def handleLastPhoto(path):
            if path:
                if time.time() - self.last_photo_time > self.THUMBNAIL_TIMEOUT:
                    image = NSImage.alloc().initByReferencingFile_(unicode(path))
                    if image.isValid():
                        self._thumbnail.setBorder_(True)
                        self._thumbnail.setImage_(image)
                        self.last_photo_time = time.time()
            else:
                self._thumbnail.setBorder_(False)
                self._thumbnail.setImage_(Images.Box64)

        handleMessage(self.ui.message.get())
        handleTotalBytes(self.ui.total_bytes.get())
        handleCurBytes(self.ui.cur_bytes.get())
        handleLastPhoto(self.ui.last_photo.get())
        self.ui.message.register(handleMessage)
        self.ui.total_bytes.register(handleTotalBytes)
        self.ui.cur_bytes.register(handleCurBytes)
        self.ui.last_photo.register(handleLastPhoto)