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)
    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 __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()
Beispiel #4
0
class ModalDialog(_Window):

    nsWindowLevel = NSModalPanelWindowLevel

    def __init__(self, posSize, title=None, okText="OK", cancelText="Cancel", okCallback=None, cancelCallback=None):
        if title is None:
            title = ''
        super(ModalDialog, self).__init__(posSize, title, minSize=None, maxSize=None,
                textured=False, autosaveName=None, closable=False)
        self._window.standardWindowButton_(NSWindowCloseButton).setHidden_(True)
        self._window.standardWindowButton_(NSWindowZoomButton).setHidden_(True)
        self._window.standardWindowButton_(NSWindowMiniaturizeButton).setHidden_(True)
        #
        self._okCallback = okCallback
        self._cancelCallback = cancelCallback
        #
        self._bottomLine = HorizontalLine((10, -50, -10, 1))
        self._okButton = Button((-85, -35, 70, 20), okText, callback=self._internalOKCallback)
        self._cancelButton = Button((-165, -35, 70, 20), cancelText, callback=self._internalCancelCallback)
        self.setDefaultButton(self._okButton)
        self._cancelButton.bind('.', ['command'])
        if len(posSize) == 2:
            self.center()

    def open(self):
        super(ModalDialog, self).open()
        NSApp().runModalForWindow_(self.getNSWindow())

    def close(self):
        super(ModalDialog, self).close()
        NSApp().stopModal()

    @python_method
    def _internalOKCallback(self, sender):
        self.close()
        if self._okCallback is not None:
            self._okCallback(self)

    @python_method
    def _internalCancelCallback(self, sender):
        self.close()
        if self._cancelCallback is not None:
            self._cancelCallback(self)
Beispiel #5
0
    def setup(self):
        self.list = UpdateList((20, 20, -20, -60),
                               editCallback=self.update_interface,
                               refreshCallback=self.update_interface)

        self.updated_at_text = UpdatedTimeTextBox((120, -38, -20, 20),
                                                  sizeStyle="small")

        self.update_button = UpdateButton((-160, -42, 140, 20),
                                          callback=self.in_thread.install_updates)

        self.refresh_button = Button((20, -42, 90, 20), "Refresh",
                                     callback=self.in_thread.update_list)

        if env.environment == 'production':
            self.refresh_button.show(False)

        self.update_interface()
Beispiel #6
0
 def __init__(self):
     self.window = w = Window((400, 400), "Test Geometry", minSize=(100, 100))
     w.button = Button((10, 10, 120, 20), "call SetPosSize", callback=self.setFrameCallback)
     w.x = SimpleRect((10, 40, -120, -120))
     w.x.top = SimpleRect((20, 20, -20, 40))
     w.x.left = SimpleRect((40, 40, 40, -40))
     w.x.right = SimpleRect((-80, 40, 40, -40))
     w.x.lefttop = SimpleRect((10, 10, 50, 20))
     w.x.righttop = SimpleRect((-60, 10, 50, 20))
     w.x.bottom = SimpleRect((20, -60, -20, 40))
     w.x.leftbottom = SimpleRect((10, -30, 50, 20))
     w.x.rightbottom = SimpleRect((-60, -30, 50, 20))
     w.x.middle = SimpleRect((70, 70, -70, -70))
     w.x.middle.deep = SimpleRect((20, 10, -20, -10))
     w.extra = SimpleRect((-110, 10, -10, -120))
     w.y = SimpleRect((10, -110, -10, -20))
     w.y.z = SimpleRect((10, 10, -10, -10))
     w.y.z.q = SimpleRect((10, 10, -10, -10))
     w.open()
Beispiel #7
0
    def __init__(self, glyph):

        # if glyph is None, show a message
        # store the glyph and initial move values as object attributes
        self.w = FloatingWindow((200, 64), "move "+str(labelslider))
        for labelslider in BuildLabelsList(f):
            # create a floating window
            # add a slider for moving in the x axis
            self.g = glyph
            self.moveX = 0
            self.label= labelslider
            self.w.labelslider = Slider(
                    (10, 10, -10, 22),
                    value=0, maxValue=100, minValue=-100,
                    callback=self.adjust)

            # open the window
            self.w.button = Button((15, -35, -15, 20), "Done")
            self.w.open()
Beispiel #8
0
 def __init__(self):
     self.w = Window((300, 400),
                     "SliderTest",
                     autosaveName="SliderTestttt")
     # self.w.slider1 = SliderPlus((10, 10, -10, 50), "Slider 1", 0, 50, 100)
     # self.w.slider2 = SliderPlus((10, 60, -10, 50), "Slider 2", 0, 50, 100)
     info = [("abcd", "The alphabet"), ("xyz ", "The alphabet part 2"),
             ("wdth", "Width"), ("wght", "Weight")]
     self.sliderInfo = {}
     for tag, label in info:
         self.sliderInfo[tag] = (label, 0, 50, 100)
     self.w.sliderGroup = SliderGroup(300,
                                      self.sliderInfo,
                                      continuous=True,
                                      callback=self.sliderGroupCallback)
     self.w.mutateButton = Button((10, -40, 80, 20),
                                  "Mutate",
                                  callback=self.mutateCallback)
     self.w.open()
Beispiel #9
0
 def __init__(self, posSize, title=None, okText="OK", cancelText="Cancel", okCallback=None, cancelCallback=None):
     if title is None:
         title = ''
     super(ModalDialog, self).__init__(posSize, title, minSize=None, maxSize=None,
             textured=False, autosaveName=None, closable=False)
     self._window.standardWindowButton_(NSWindowCloseButton).setHidden_(True)
     self._window.standardWindowButton_(NSWindowZoomButton).setHidden_(True)
     self._window.standardWindowButton_(NSWindowMiniaturizeButton).setHidden_(True)
     #
     self._okCallback = okCallback
     self._cancelCallback = cancelCallback
     #
     self._bottomLine = HorizontalLine((10, -50, -10, 1))
     self._okButton = Button((-85, -35, 70, 20), okText, callback=self._internalOKCallback)
     self._cancelButton = Button((-165, -35, 70, 20), cancelText, callback=self._internalCancelCallback)
     self.setDefaultButton(self._okButton)
     self._cancelButton.bind('.', ['command'])
     if len(posSize) == 2:
         self.center()
Beispiel #10
0
 def __init__(self):
     NSUserDefaults.standardUserDefaults().registerDefaults_({"ToucheWindowHeight":340})
     self.windowHeight = NSUserDefaults.standardUserDefaults().integerForKey_("ToucheWindowHeight")
     self.minWindowHeight = 340
     if self.windowHeight < self.minWindowHeight:
         self.windowHeight = self.minWindowHeight
     self.closedWindowHeight = 100
     self.w = FloatingWindow((180, self.windowHeight), u'Touché!', minSize=(180,340), maxSize=(250,898))
     self.w.bind("resize", self.windowResized)
     self.isResizing = False
     p = 10
     w = 160
     
     # options
     self.w.options = Group((0, 0, 180, 220))
     
     buttons = {
         "checkSelBtn": {"text": "Check selected glyphs", "callback": self.checkSel, "y": p},
     }
     for button, data in buttons.iteritems():
         setattr(self.w.options, button, 
         Button((p, data["y"], w - 22, 22), data["text"], callback=data["callback"], sizeStyle="small"))
         
     self.w.options.zeroCheck = CheckBox((p, 35, w, 20), "Ignore zero-width glyphs", value=True, sizeStyle="small")
     self.w.options.progress = ProgressSpinner((w - 8, 13, 16, 16), sizeStyle="small")
     
     # results
     self.w.results = Group((0, 220, 180, -0))
     self.w.results.show(False)
     
     textBoxes = {"stats": -34, "result": -18}
     for box, y in textBoxes.iteritems():
         setattr(self.w.results, box, TextBox((p, y, w, 14), "", sizeStyle="small"))
         
     # list and preview 
     self.w.outputList = List((0,58,-0,-40),
         [{"left glyph": "", "right glyph": ""}], columnDescriptions=[{"title": "left glyph", "width": 90}, {"title": "right glyph"}],
         showColumnTitles=False, allowsMultipleSelection=False, enableDelete=False, selectionCallback=self.showPair)
     self.w.outputList._setColumnAutoresizing()
     self._resizeWindow(False)
     self.w.open()
Beispiel #11
0
    def buildMenu(self):
        """Builds buttons at top.

        TODO: put in a group.
        """
        x = 4
        y = 4
        w = 100
        h = 24
        self.window.proof = Button((x, y, w, h),
                                   'Proof',
                                   sizeStyle='small',
                                   callback=self.proofCallback)
        x += 110

        self.window.selectFont = PopUpButton((x, y, w, h),
                                             self.FONTS,
                                             sizeStyle='small',
                                             callback=self.setFontCallback)

        x += 110
Beispiel #12
0
    def __init__(self):
        self.doMarkGlyphs = 0
        self.doOverwrite = 1
        self.sourceFontList = AllFonts()
        self.destinationFontList = AllFonts()
        self.source_font = self.sourceFontList[0]
        self.destination_fonts = None
        self.glyphs = None
        self.mark = NSColor.redColor()

        sl = []
        for f in self.sourceFontList:
            if f.info.familyName != None:
                fn = f.info.familyName
            else:
                fn = "None"
            if f.info.styleName != None:
                fs = f.info.styleName
            else:
                fs = "None"
            sl.append(fn+" "+fs)

        ## create a window
        self.w = Window((700, 500), "Copy Glyphs", minSize=(700, 500))
        self.w.sourceTitle = TextBox((15, 20, 200, 20), "Source Font:")
        self.w.sourceFont = PopUpButton((15, 42, -410, 20), sl, callback=self.sourceCallback)
        self.w.glyphs = GlyphCollectionView((16, 70, -410, -65), initialMode="list", enableDelete=False, allowDrag=False, selectionCallback=self.glyphCallback)
        self._sortGlyphs(self.source_font)
        self.w.desTitle = TextBox((-400, 20, 200, 20), "Destination Fonts:")
        self.w.destinationFonts = FontList((-400, 42, -15, -115), self.destinationFontList, selectionCallback=self.desCallback)
        self.w.overwrite = CheckBox((-395, -105, 130, 22), "Overwrite glyphs", callback=self.overwriteCallback, value=self.doOverwrite)
        self.w.markGlyphs = CheckBox((-395, -84, 100, 22), "Mark Glyphs", callback=self.markCallback, value=self.doMarkGlyphs)
        self.w.copyButton = Button((-115, -40, 100, 20), 'Copy Glyphs', callback=self.copyCallback)
        self.w.line = HorizontalLine((10, -50, -10, 1))
        self._checkSelection()
        self._updateDest()
        ## open the window
        self.w.open()
Beispiel #13
0
    def __init__(self):
        item_height = 24.0
        margin = 10
        w_width = 350.0
        w_height = (item_height * 5) + margin
        next_y = margin
        col_1_width = w_width - (margin * 2)
        item_height = 24

        self.get_prefs('SlantComponentPositions.pref')

        self.w = Window((w_width, w_height), "Slant Angle")

        self.w.slant_angle_text = TextBox(
            (margin, next_y + 2, col_1_width, item_height),
            "Slant Angle:",
            sizeStyle='regular')
        next_y += item_height
        self.w.slant_angle = EditText(
            (margin, next_y, col_1_width, item_height),
            self.prefs.get('slant_angle', ''))
        next_y += item_height + margin

        self.w.slant_all_layers = CheckBox(
            (margin, next_y, col_1_width, item_height),
            "Slant All Layers",
            value=int(self.prefs.get('slant_all_layers')),
            sizeStyle='regular')
        next_y += item_height + margin

        self.w.makeitso = Button(
            (w_width / 4.0, next_y, col_1_width / 2.0, item_height),
            'Slant Components',
            callback=self.makeitso)
        self.w.setDefaultButton(self.w.makeitso)

        self.w.open()
        self.w.center()
Beispiel #14
0
    def _warning(self, sender, warning, prefKey):
        if self.prefs.get(prefKey):
            self.warning = Sheet((400, 140), self.w)
            self.warning.img = ImageView((10, 10, 60, 60))
            self.warning.img.setImage(imageNamed=NSImageNameCaution)
            self.warning.txt = TextBox((70, 10, -10, -40),
                                       "Warning\n" + warning)

            callback = partial(self._changePref,
                               key=prefKey,
                               value=not self.prefs.get(prefKey))
            self.warning.check = CheckBox((70, 80, -10, 20),
                                          "Always show this warning",
                                          value=self.prefs.get(prefKey),
                                          callback=callback)

            self.warning.closeButton = Button((10, 110, -10, 20),
                                              "I understand",
                                              callback=self._closeWarning)
            self.warning.setDefaultButton(self.warning.closeButton)
            self.warning.center()
            self.w.list.enable(False)
            self.warning.open()
Beispiel #15
0
    def __init__(self):
        super(VFB2UFO, self).__init__()
        self.w = FloatingWindow((PLUGIN_WIDTH, 2), PLUGIN_TITLE)
        self.jumpingY = MARGIN_VER

        # options button
        self.w.optionsPopUp = PopUpButton(
            (MARGIN_HOR, self.jumpingY, NET_WIDTH,
             vanillaControlsSize['PopUpButtonRegularHeight']),
            self.inputOptions,
            callback=self.optionsPopUpCallback)
        self.jumpingY += vanillaControlsSize[
            'PopUpButtonRegularHeight'] + MARGIN_HOR

        # suffix option
        self.w.suffixRadio = RadioGroup(
            (MARGIN_HOR, self.jumpingY, NET_WIDTH,
             vanillaControlsSize['ButtonRegularHeight'] * 2),
            ["From VFB to UFO", "From UFO to VFB"],
            callback=self.suffixRadioCallback)
        self.w.suffixRadio.set(0)
        self.w.suffixRadio.enable(False)
        self.jumpingY += vanillaControlsSize[
            'ButtonRegularHeight'] * 2 + MARGIN_HOR

        # convert button
        self.w.convertButton = Button(
            (MARGIN_HOR, self.jumpingY, NET_WIDTH,
             vanillaControlsSize['ButtonRegularHeight']),
            'Choose file and convert',
            callback=self.convertButtonCallback)
        self.jumpingY += vanillaControlsSize['ButtonRegularHeight'] + MARGIN_HOR

        self.w.resize(PLUGIN_WIDTH, self.jumpingY)
        self.setUpBaseWindowBehavior()
        self.w.open()
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
Beispiel #17
0
    def _selectionCallback(self, sender):
        try:
            if not self.w.list.getSelection():
                # Application did not finish loading yet
                pass
            else:
                # Get job name
                self.selected.clear()
                job = sender.get()[self.w.list.getSelection()[0]]
                self.selected['name'] = job['name']
                self.valueGroups = []
                # Get job path and file location
                item = self.pathList.titleOfSelectedItem()

                if 'User' in item:
                    import getpass
                    username = getpass.getuser()
                    user = username
                    path = '/Users/%s/Library/Launch' % username
                elif 'Global' in item:
                    user = '******'
                    path = '/Library/Launch'
                elif 'System' in item:
                    user = '******'
                    path = '/System/Library/Launch'
                if 'Agents' in item:
                    path += 'Agents/'
                else:
                    path += 'Daemons/'

                self.selected['path'] = path
                self.selected['file'] = str(self.selected['path'].replace(
                    ' ', '\ ')) + job['name'].replace(' ', '\ ') + '.plist'
                f = open(self.selected['file'], "r")
                self.selected['raw'] = str(f.read())
                self.selected['short'] = (
                    self.selected['name'][:32] + '…') if len(
                        self.selected['name']) > 32 else self.selected['name']
                # Get status
                if job['image'] == NSImage.imageNamed_(NSImageNameStatusNone):
                    status = None
                else:
                    status = 'Available'
                self.selected['status'] = status

                index = sender.getSelection()[0]
                relativeRect = sender.getNSTableView().rectOfRow_(index)

                self.pop = Popover((300, 100))

                self.pop.tabs = Tabs((20, 40, -20, -20),
                                     ["Editor", "Raw View"])
                self.pop.tabs._nsObject.setTabViewType_(NSNoTabsNoBorder)

                self.pop.tabBtn = SegmentedButton(
                    (10, 10, -10, 20),
                    [dict(title="Editor"),
                     dict(title="Raw View")],
                    callback=self._segmentPressed,
                    selectionStyle='one')
                self.pop.tabBtn.set(0)

                self.edit = self.pop.tabs[0]

                self.rawEdit = self.pop.tabs[1]
                self.rawEdit.editor = TextEditor((0, 0, -0, -45),
                                                 text=self.selected['raw'])

                self.selected['dict'] = launchd.plist.read(
                    self.selected['name'])

                # TODO: Add stackview to scrollview as group
                # Waiting for merge into master: https://github.com/robotools/vanilla/issues/132
                self.edit.stack = VerticalStackGroup((0, 0, -0, -45))

                for idx, (key, value) in enumerate(
                        sorted(self.selected['dict'].items())):
                    group = ValueGroup((0, 0, -0, -0),
                                       sender=self,
                                       key=key,
                                       value=value,
                                       idx=idx)
                    self.valueGroups.append(group)
                    self.edit.stack.addView(
                        self.valueGroups[idx], 300,
                        self.valueGroups[idx].getPosSize()[3])

                self.pop.save = Button((20, -50, -20, 40),
                                       "Save",
                                       callback=self._savePlist)
                self.pop.save.enable(False)
                self.pop.open(parentView=sender.getNSTableView(),
                              preferredEdge='right',
                              relativeRect=relativeRect)
        except:
            pass
Beispiel #18
0
    def __init__(self):
        self.locations = [
            'User Agents', 'Global Agents', 'Global Daemons', 'System Agents',
            'System Daemons'
        ]
        self.listItems = []
        self.selected = {}

        # Preferences
        self.homedir = os.path.expanduser('~')
        self.prefsFolder = self.homedir + "/Library/Preferences/"
        self.prefsFile = "de.nelsonfritsch.unicron.plist"

        if os.path.isfile(self.prefsFolder + self.prefsFile):
            self.prefs = self._loadPrefs(self)
        else:
            self.prefs = dict(showSystemWarning=True, windowStyle='System')
            self._savePrefs(self)

        # Preferences Window
        self.prefsWindow = Window((300, 105), 'Preferences')

        self.styles = ['System', 'Light', 'Dark']
        self.prefsWindow.styleTxt = TextBox((10, 10, -10, 20), "Window Style:")
        self.prefsWindow.style = PopUpButton((30, 35, -10, 20),
                                             self.styles,
                                             callback=self.prefsSetStyle)

        self.prefsWindow.restore = Button((10, 75, -10, 20),
                                          'Restore Warnings',
                                          callback=self.prefsRestoreWarnings)

        # Main Window
        minsize = 285
        self.w = Window((minsize, 400),
                        'Unicron',
                        closable=True,
                        fullSizeContentView=True,
                        titleVisible=False,
                        minSize=(minsize, minsize),
                        maxSize=(600, 1200),
                        autosaveName="UnicronMainWindow")

        self.pathList = NSPopUpButton.alloc().initWithFrame_(
            ((0, 0), (160, 20)))
        self.pathList.addItemsWithTitles_(self.locations)

        refreshIcon = NSImage.alloc().initWithSize_((32, 32))
        sourceImage = NSImage.imageNamed_(NSImageNameRefreshTemplate)

        w, h = sourceImage.size()

        if w > h:
            diffx = 0
            diffy = w - h
        else:
            diffx = h - w
            diffy = 0

        maxSize = max([w, h])
        refreshIcon.lockFocus()
        sourceImage.drawInRect_fromRect_operation_fraction_(
            NSMakeRect(diffx, diffy + 4, 22, 22),
            NSMakeRect(0, 0, maxSize, maxSize), NSCompositeSourceOver, 1)
        refreshIcon.unlockFocus()
        refreshIcon.setTemplate_(True)

        toolbarItems = [
            dict(itemIdentifier="Daemons",
                 label="Daemons",
                 toolTip="Daemon Group",
                 view=self.pathList,
                 callback=self.populateList),
            dict(itemIdentifier="image",
                 label="Image",
                 imageObject=refreshIcon,
                 callback=self.populateList),
        ]
        self.w.addToolbar("Unicron Toolbar",
                          toolbarItems=toolbarItems,
                          displayMode="icon")

        self.w.blend = Group((0, 0, 0, 0), blendingMode='behindWindow')

        self.listColumnDescriptions = [{
            'title': '',
            'key': 'image',
            'width': 25,
            'typingSensitive': True,
            'allowsSorting': True,
            'cell': ImageListCell()
        }, {
            'title': 'Name',
            'key': 'name',
            'typingSensitive': True,
            'allowsSorting': True,
        }]
        self.rowHeight = 20
        self.w.list = List((0, 37, -0, 0),
                           items=self.listItems,
                           columnDescriptions=self.listColumnDescriptions,
                           showColumnTitles=True,
                           allowsEmptySelection=True,
                           allowsMultipleSelection=False,
                           autohidesScrollers=True,
                           drawFocusRing=False,
                           rowHeight=self.rowHeight,
                           selectionCallback=self._selectionCallback,
                           menuCallback=self._menuCallback)

        self.w.list._nsObject.setBorderType_(NSNoBorder)

        self.w.statusbar = Group((0, -26, 0, 0), blendingMode='behindWindow')
        self.w.statusbar.border = HorizontalLine((0, 0, 0, 1))

        self.w.counter = TextBox((16, -20, -16, 15),
                                 '',
                                 alignment='center',
                                 sizeStyle='small')
        self.populateList(self)
        self.w.rowIndicator = Group((0, 0, 0, 10))

        self.prefsSetStyle(self)

        self.w.open()
Beispiel #19
0
    def __init__(self):

        self.w = FloatingWindow((self._width + 2 * self._frame, self._height),
                                self._title)

        # ----------
        # text boxes
        # ----------

        textBoxY = self._padding

        self.w.steps_label = TextBox(
            (self._col_0, textBoxY, self._col_width, self._lineHeight),
            'Steps',
            alignment='right')
        if rfVersion >= 3.4:
            self.w.steps_text = NumberEditText(
                (self._col_1, textBoxY - 2, self._col_width, self._lineHeight),
                self.steps,
                callback=self.angleCallback,
                allowFloat=False,
                allowNegative=False,
                allowEmpty=False,
                minimum=1,
                decimals=0,
                continuous=True)
        else:
            self.w.steps_text = EditText(
                (self._col_1, textBoxY - 2, self._col_width, self._lineHeight),
                self.steps,
                callback=self.angleCallback,
                continuous=True)

        textBoxY += (self._row)

        self.w.xValue_label = TextBox(
            (self._col_0, textBoxY, self._col_width, self._lineHeight),
            'x',
            alignment='right')

        if rfVersion >= 3.4:
            self.w.xValue_text = NumberEditText(
                (self._col_1, textBoxY - 2, self._col_width, self._lineHeight),
                self.xValue,
                callback=self.xCallback,
                allowFloat=True,
                decimals=0)
        else:
            self.w.xValue_text = EditText(
                (self._col_1, textBoxY - 2, self._col_width, self._lineHeight),
                self.xValue,
                callback=self.xCallback)

        textBoxY += (self._row)

        self.w.yValue_label = TextBox(
            (self._col_0, textBoxY, self._col_width, self._lineHeight),
            'y',
            alignment='right')

        if rfVersion >= 3.4:
            self.w.yValue_text = NumberEditText(
                (self._col_1, textBoxY - 2, self._col_width, self._lineHeight),
                self.yValue,
                callback=self.yCallback,
                allowFloat=True,
                decimals=0)
        else:
            self.w.yValue_text = EditText(
                (self._col_1, textBoxY - 2, self._col_width, self._lineHeight),
                self.yValue,
                callback=self.yCallback)
        textBoxY += (self._row)

        self.w.angle_label = TextBox(
            (self._col_0, textBoxY, self._col_width, self._lineHeight),
            'Angle',
            alignment='right')
        self.w.angleResult = TextBox(
            (self._col_1, textBoxY, self._col_width, self._lineHeight),
            u'%s°' % self.niceAngleString(self.angle))
        textBoxY += (self._row)

        textBoxY += (self._row * .25)
        self.w.line = HorizontalLine(
            (self._gutter, textBoxY, -self._gutter, 0.5))
        textBoxY += (self._row * .25)

        self.w.lock_checkbox = CheckBox(
            (self._col_1 - 25, textBoxY, -self._gutter, self._lineHeight),
            'Lock Center',
            value=self.lock,
            callback=self.lockCallback)
        textBoxY += (self._row)

        self.w.rounding_checkbox = CheckBox(
            (self._col_1 - 25, textBoxY, -self._gutter, self._lineHeight),
            'Round Result',
            value=self.rounding,
            callback=self.roundingCallback)
        textBoxY += (self._row)

        # -------
        # buttons
        # -------

        self.w.color = ColorWell(
            (self._col_0, textBoxY, -self._gutter, 2 * self._lineHeight),
            color=getExtensionDefaultColor(
                '%s.%s' % (rotatorDefaults, 'color'), self._color),
            callback=self.colorCallback)
        textBoxY += (self._row)

        self.w.buttonRotate = Button(
            (self._col_0, -30, -self._gutter, self._lineHeight),
            'Rotate',
            callback=self.rotateCallback)

        self.setUpBaseWindowBehavior()
        addObserver(self, 'updateOrigin', 'mouseDragged')
        addObserver(self, 'drawRotationPreview', 'drawBackground')
        addObserver(self, 'drawSolidPreview', 'drawPreview')
        self.w.setDefaultButton(self.w.buttonRotate)
        self.w.open()
    def addInterface(self, notification):
        self.window = notification['window']
        # self.cleanup(self.window)

        # CONTAINER
        xywh = (margin, -55, -margin, height)
        self.sbui = CanvasGroup(xywh, delegate=CanvasStuff(self.window))

        # LEFT
        x, y, w, h = xywh = (0, -height, dfltLwidth, height)
        this = self.sbui.L = Group(xywh)

        # text input
        xywh = (x, y + 3, width * 1.5, height * .75)
        this.Ltext = EditText(xywh,
                              placeholder='angledLeftMargin',
                              sizeStyle='mini',
                              continuous=False,
                              callback=self.setSB)
        # quick mod buttons
        xywh = (x + width * 1.5 + (gap * 1), y, width, height)
        this.Lminus = Button(xywh,
                             iconminus,
                             sizeStyle='mini',
                             callback=self.setLminus)
        this.Lminus.getNSButton().setToolTip_('Adjust LSB -' + str(unit))
        xywh = (x + width * 2.5 + (gap * 2), y, width, height)
        this.Lplus = Button(xywh,
                            iconplus,
                            sizeStyle='mini',
                            callback=self.setLplus)
        this.Lplus.getNSButton().setToolTip_('Adjust LSB +' + str(unit))
        xywh = (x + width * 3.5 + (gap * 3), y, width, height)
        this.Lround = Button(xywh,
                             iconround,
                             sizeStyle='mini',
                             callback=self.setLround)
        this.Lround.getNSButton().setToolTip_('Round LSB to ' + str(unit))
        xywh = (x + width * 4.5 + (gap * 4), y, width, height)
        this.Lright = Button(xywh,
                             iconcopyR,
                             sizeStyle='mini',
                             callback=self.setLright)
        this.Lright.getNSButton().setToolTip_('Copy Right Value')
        # stylize
        this.Ltext.getNSTextField().setBezeled_(False)
        this.Ltext.getNSTextField().setBackgroundColor_(NSColor.clearColor())
        self.flatButt(this.Lminus)
        self.flatButt(this.Lplus)
        self.flatButt(this.Lround)
        self.flatButt(this.Lright)

        # RIGHT
        x, y, w, h = xywh = (-dfltRwidth, y, dfltRwidth, h)
        this = self.sbui.R = Group(xywh)
        # text input
        xywh = (-x - width * 1.5, y + 3, width * 1.5, height * .75)
        this.Rtext = EditText(xywh,
                              placeholder='angledRightMargin',
                              sizeStyle='mini',
                              continuous=False,
                              callback=self.setSB)
        # quick mod buttons
        xywh = (-x - width * 5.5 - (gap * 4), y, width, height)
        this.Rleft = Button(xywh,
                            iconcopyL,
                            sizeStyle='mini',
                            callback=self.setRleft)
        this.Rleft.getNSButton().setToolTip_('Copy Left Value')
        xywh = (-x - width * 4.5 - (gap * 3), y, width, height)
        this.Rround = Button(xywh,
                             iconround,
                             sizeStyle='mini',
                             callback=self.setRround)
        this.Rround.getNSButton().setToolTip_('Round RSB to ' + str(unit))
        xywh = (-x - width * 3.5 - (gap * 2), y, width, height)
        this.Rminus = Button(xywh,
                             iconminus,
                             sizeStyle='mini',
                             callback=self.setRminus)
        this.Rminus.getNSButton().setToolTip_('Adjust RSB -' + str(unit))
        xywh = (-x - width * 2.5 - (gap * 1), y, width, height)
        this.Rplus = Button(xywh,
                            iconplus,
                            sizeStyle='mini',
                            callback=self.setRplus)
        this.Rplus.getNSButton().setToolTip_('Adjust RSB +' + str(unit))
        # stylize
        this.Rtext.getNSTextField().setBezeled_(False)
        this.Rtext.getNSTextField().setBackgroundColor_(NSColor.clearColor())
        this.Rtext.getNSTextField().setAlignment_(NSTextAlignmentRight)
        self.flatButt(this.Rminus)
        self.flatButt(this.Rplus)
        self.flatButt(this.Rround)
        self.flatButt(this.Rleft)

        # CENTER
        winX, winY, winW, winH = self.window.getVisibleRect()
        winW = winW - margin * 5
        x, y, w, h = xywh = ((winW / 2) - (dfltCwidth / 2), y, dfltCwidth, h)
        this = self.sbui.C = Group(xywh)
        x = 0

        # text input
        c = (dfltCwidth / 2)
        xywh = (c - (width * .75), y + 3, width * 1.5, height * .75)
        this.Ctext = EditText(xywh,
                              placeholder='width',
                              sizeStyle='mini',
                              continuous=False,
                              callback=self.setSB)
        # quick mod buttons
        xywh = (c - (width * .75) - width * 2 - (gap * 2), y, width, height)
        this.Ccenter = Button(xywh,
                              iconcenter,
                              sizeStyle='mini',
                              callback=self.setCcenter)
        this.Ccenter.getNSButton().setToolTip_('Center on Width')
        xywh = (c - (width * .75) - width - (gap * 1), y, width, height)
        this.Cround = Button(xywh,
                             iconround,
                             sizeStyle='mini',
                             callback=self.setCround)
        this.Cround.getNSButton().setToolTip_('Round Width to ' + str(unit))
        xywh = (c + (width * .75) + (gap * 1), y, width, height)
        this.Cminus = Button(xywh,
                             iconminus,
                             sizeStyle='mini',
                             callback=self.setCminus)
        this.Cminus.getNSButton().setToolTip_('Adjust Width -' + str(2 * unit))
        xywh = (c + (width * .75) + width + (gap * 2), y, width, height)
        this.Cplus = Button(xywh,
                            iconplus,
                            sizeStyle='mini',
                            callback=self.setCplus)
        this.Cplus.getNSButton().setToolTip_('Adjust Width +' + str(2 * unit))
        # stylize
        this.Ctext.getNSTextField().setBezeled_(False)
        this.Ctext.getNSTextField().setBackgroundColor_(NSColor.clearColor())
        this.Ctext.getNSTextField().setAlignment_(NSTextAlignmentCenter)
        self.flatButt(this.Cminus)
        self.flatButt(this.Cplus)
        self.flatButt(this.Cround)
        self.flatButt(this.Ccenter)

        # hide
        self.sbui.L.Lminus.show(False)
        self.sbui.L.Lround.show(False)
        self.sbui.L.Lplus.show(False)
        self.sbui.L.Lright.show(False)
        self.sbui.R.Rminus.show(False)
        self.sbui.R.Rround.show(False)
        self.sbui.R.Rplus.show(False)
        self.sbui.R.Rleft.show(False)
        self.sbui.C.Cminus.show(False)
        self.sbui.C.Cround.show(False)
        self.sbui.C.Ccenter.show(False)
        self.sbui.C.Cplus.show(False)

        # make it real
        self.sbWatcherInitialize()
        self.window.addGlyphEditorSubview(self.sbui)
        self.updateValues()
        self.buildMatchBase()
        windowViewManger[self.window] = self.sbui
    def buildMatchBase(self, notification=None):
        self.newheight = height
        try:
            g = self.window.getGlyph()
            f = g.font
            # remove old buttons
            for i in range(10):
                if hasattr(self.sbui.L, 'buttobj_%s' % i):
                    delattr(self.sbui.L, 'buttobj_%s' % i)
                    delattr(self.sbui.R, 'buttobj_%s' % i)
                    delattr(self.sbui.C, 'buttobj_%s' % i)

            # add button for each component
            self.uniquecomponents = []
            for c in g.components:
                if c.baseGlyph not in self.uniquecomponents:
                    self.uniquecomponents.append(c.baseGlyph)

            for i, c in enumerate(self.uniquecomponents):
                row = i + 1
                yy = -height * (row + 1) - 3

                xywh = (0, yy, width * 5.5 + (gap * 4), height)
                buttobj = Button(xywh,
                                 c,
                                 sizeStyle='mini',
                                 callback=self.setLmatch)
                setattr(self.sbui.L, 'buttobj_%s' % i, buttobj)
                this = getattr(self.sbui.L, 'buttobj_%s' % i)
                this.getNSButton().setAlignment_(NSTextAlignmentLeft)
                this.getNSButton().setToolTip_('Match LSB of ' + c)

                xywh = (-width * 5.5 - (gap * 4), yy, width * 5.5 + (gap * 4),
                        height)
                buttobj = Button(xywh,
                                 c,
                                 sizeStyle='mini',
                                 callback=self.setRmatch)
                setattr(self.sbui.R, 'buttobj_%s' % i, buttobj)
                this = getattr(self.sbui.R, 'buttobj_%s' % i)
                this.getNSButton().setAlignment_(NSTextAlignmentRight)
                this.getNSButton().setToolTip_('Match RSB of ' + c)

                xywh = ((dfltLwidth / 2) - (width * 2.75 + (gap * 2)), yy,
                        width * 5.5 + (gap * 4), height)
                buttobj = Button(xywh,
                                 c,
                                 sizeStyle='mini',
                                 callback=self.setCmatch)
                setattr(self.sbui.C, 'buttobj_%s' % i, buttobj)
                this = getattr(self.sbui.C, 'buttobj_%s' % i)
                this.getNSButton().setToolTip_('Match Width of ' + c)

            for i, c in enumerate(self.uniquecomponents):
                try:
                    this = getattr(self.sbui.L, 'buttobj_%s' % i)
                    # hide if hidden
                    if self.showButtons == False:
                        this.show(False)
                    # check if metrics match base glyphs
                    if int(f[c].angledLeftMargin) == int(g.angledLeftMargin):
                        self.flatButt(this, True)
                    else:
                        self.flatButt(this)

                    this = getattr(self.sbui.R, 'buttobj_%s' % i)
                    if self.showButtons == False:
                        this.show(False)
                    if int(f[c].angledRightMargin) == int(g.angledRightMargin):
                        self.flatButt(this, True)
                    else:
                        self.flatButt(this)

                    this = getattr(self.sbui.C, 'buttobj_%s' % i)
                    if self.showButtons == False:
                        this.show(False)
                    if f[c].width == g.width:
                        self.flatButt(this, True)
                    else:
                        self.flatButt(this)

                except Exception as e:
                    return

            # change height of canvas to fit buttons
            self.newheight = height * (len(self.uniquecomponents) + 2)
            newy = -55 - height * (len(self.uniquecomponents))
            self.sbui.setPosSize((margin, newy, -margin, self.newheight))
            self.sbui.L.setPosSize((0, 0, dfltLwidth, self.newheight))
            self.sbui.R.setPosSize(
                (-dfltRwidth, 0, dfltRwidth, self.newheight))
            winX, winY, winW, winH = self.window.getVisibleRect()
            winW = winW - margin * 5
            offsetcenter = (winW / 2) - (width * 2.25)
            self.sbui.C.setPosSize(
                (offsetcenter, 0, width * 5 + 12, self.newheight))

        except Exception as e:
            return
Beispiel #22
0
    def __init__(self, posSize,
                       isSidebearingsActive,
                       areGroupsShown,
                       areCollisionsShown,
                       isKerningDisplayActive,
                       areVerticalLettersDrawn,
                       isCorrectionActive,
                       isMetricsActive,
                       isColorsActive,
                       callback):

        super(GraphicsManager, self).__init__(posSize)
        self.isKerningDisplayActive = isKerningDisplayActive
        self.areVerticalLettersDrawn = areVerticalLettersDrawn
        self.areGroupsShown = areGroupsShown
        self.areCollisionsShown = areCollisionsShown
        self.isSidebearingsActive = isSidebearingsActive
        self.isCorrectionActive = isCorrectionActive
        self.isMetricsActive = isMetricsActive
        self.isColorsActive = isColorsActive
        self.callback = callback

        self.ctrlWidth, self.ctrlHeight = posSize[2], posSize[3]

        jumping_Y = 0
        self.ctrlCaption = TextBox((0, jumping_Y, self.ctrlWidth, vanillaControlsSize['TextBoxRegularHeight']),
                                   'Display options:')

        jumping_Y = vanillaControlsSize['TextBoxRegularHeight'] + MARGIN_VER/2.
        indent = 16
        self.showKerningCheck = CheckBox((indent, jumping_Y, self.ctrlWidth-indent, vanillaControlsSize['CheckBoxRegularHeight']),
                                          'show kerning',
                                          value=self.isKerningDisplayActive,
                                          callback=self.showKerningCheckCallback)

        self.showKerningHiddenButton = Button((0,self.ctrlHeight+40,0,0),
                                              'hidden kerning button',
                                              callback=self.showKerningHiddenButtonCallback)
        # self.showKerningHiddenButton.show(False)
        self.showKerningHiddenButton.bind('k', ['command'])

        jumping_Y += vanillaControlsSize['CheckBoxRegularHeight']
        self.showGroupsCheck = CheckBox((indent, jumping_Y, self.ctrlWidth-indent, vanillaControlsSize['CheckBoxRegularHeight']),
                                        'show groups',
                                        value=self.areGroupsShown,
                                        callback=self.showGroupsCheckCallback)

        jumping_Y += vanillaControlsSize['CheckBoxRegularHeight']
        self.showCollisionsCheck = CheckBox((indent, jumping_Y, self.ctrlWidth-indent, vanillaControlsSize['CheckBoxRegularHeight']),
                                        'show pair collision',
                                        value=self.areCollisionsShown,
                                        callback=self.showCollisionsCheckCallback)

        jumping_Y += vanillaControlsSize['CheckBoxRegularHeight']
        self.showSidebearingsCheck = CheckBox((indent, jumping_Y, self.ctrlWidth-indent, vanillaControlsSize['CheckBoxRegularHeight']),
                                          'show sidebearings',
                                          value=self.isSidebearingsActive,
                                          callback=self.showSidebearingsCheckCallback)

        jumping_Y += vanillaControlsSize['CheckBoxRegularHeight']
        self.showCorrectionCheck = CheckBox((indent, jumping_Y, self.ctrlWidth-indent, vanillaControlsSize['CheckBoxRegularHeight']),
                                     'show corrections amount',
                                     value=self.isCorrectionActive,
                                     callback=self.showCorrectionCheckCallback)

        jumping_Y += vanillaControlsSize['CheckBoxRegularHeight']
        self.showColorsCheck = CheckBox((indent, jumping_Y, self.ctrlWidth-indent, vanillaControlsSize['CheckBoxRegularHeight']),
                                    'show color bars',
                                    value=self.isColorsActive,
                                    callback=self.showColorsCheckCallback)

        jumping_Y += vanillaControlsSize['CheckBoxRegularHeight']
        self.showMetricsCheck = CheckBox((indent, jumping_Y, self.ctrlWidth-indent, vanillaControlsSize['CheckBoxRegularHeight']),
                                     'show metrics',
                                     value=self.isMetricsActive,
                                     callback=self.showMetricsCheckCallback)

        jumping_Y += vanillaControlsSize['CheckBoxRegularHeight']
        self.verticalLettersCheck = CheckBox((indent, jumping_Y, self.ctrlWidth-indent, vanillaControlsSize['CheckBoxRegularHeight']),
                                        'show vertical letters',
                                        value=self.areGroupsShown,
                                        callback=self.verticalLettersCheckCallback)
Beispiel #23
0
class GraphicsManager(Group):
    previousState = None

    def __init__(self, posSize,
                       isSidebearingsActive,
                       areGroupsShown,
                       areCollisionsShown,
                       isKerningDisplayActive,
                       areVerticalLettersDrawn,
                       isCorrectionActive,
                       isMetricsActive,
                       isColorsActive,
                       callback):

        super(GraphicsManager, self).__init__(posSize)
        self.isKerningDisplayActive = isKerningDisplayActive
        self.areVerticalLettersDrawn = areVerticalLettersDrawn
        self.areGroupsShown = areGroupsShown
        self.areCollisionsShown = areCollisionsShown
        self.isSidebearingsActive = isSidebearingsActive
        self.isCorrectionActive = isCorrectionActive
        self.isMetricsActive = isMetricsActive
        self.isColorsActive = isColorsActive
        self.callback = callback

        self.ctrlWidth, self.ctrlHeight = posSize[2], posSize[3]

        jumping_Y = 0
        self.ctrlCaption = TextBox((0, jumping_Y, self.ctrlWidth, vanillaControlsSize['TextBoxRegularHeight']),
                                   'Display options:')

        jumping_Y = vanillaControlsSize['TextBoxRegularHeight'] + MARGIN_VER/2.
        indent = 16
        self.showKerningCheck = CheckBox((indent, jumping_Y, self.ctrlWidth-indent, vanillaControlsSize['CheckBoxRegularHeight']),
                                          'show kerning',
                                          value=self.isKerningDisplayActive,
                                          callback=self.showKerningCheckCallback)

        self.showKerningHiddenButton = Button((0,self.ctrlHeight+40,0,0),
                                              'hidden kerning button',
                                              callback=self.showKerningHiddenButtonCallback)
        # self.showKerningHiddenButton.show(False)
        self.showKerningHiddenButton.bind('k', ['command'])

        jumping_Y += vanillaControlsSize['CheckBoxRegularHeight']
        self.showGroupsCheck = CheckBox((indent, jumping_Y, self.ctrlWidth-indent, vanillaControlsSize['CheckBoxRegularHeight']),
                                        'show groups',
                                        value=self.areGroupsShown,
                                        callback=self.showGroupsCheckCallback)

        jumping_Y += vanillaControlsSize['CheckBoxRegularHeight']
        self.showCollisionsCheck = CheckBox((indent, jumping_Y, self.ctrlWidth-indent, vanillaControlsSize['CheckBoxRegularHeight']),
                                        'show pair collision',
                                        value=self.areCollisionsShown,
                                        callback=self.showCollisionsCheckCallback)

        jumping_Y += vanillaControlsSize['CheckBoxRegularHeight']
        self.showSidebearingsCheck = CheckBox((indent, jumping_Y, self.ctrlWidth-indent, vanillaControlsSize['CheckBoxRegularHeight']),
                                          'show sidebearings',
                                          value=self.isSidebearingsActive,
                                          callback=self.showSidebearingsCheckCallback)

        jumping_Y += vanillaControlsSize['CheckBoxRegularHeight']
        self.showCorrectionCheck = CheckBox((indent, jumping_Y, self.ctrlWidth-indent, vanillaControlsSize['CheckBoxRegularHeight']),
                                     'show corrections amount',
                                     value=self.isCorrectionActive,
                                     callback=self.showCorrectionCheckCallback)

        jumping_Y += vanillaControlsSize['CheckBoxRegularHeight']
        self.showColorsCheck = CheckBox((indent, jumping_Y, self.ctrlWidth-indent, vanillaControlsSize['CheckBoxRegularHeight']),
                                    'show color bars',
                                    value=self.isColorsActive,
                                    callback=self.showColorsCheckCallback)

        jumping_Y += vanillaControlsSize['CheckBoxRegularHeight']
        self.showMetricsCheck = CheckBox((indent, jumping_Y, self.ctrlWidth-indent, vanillaControlsSize['CheckBoxRegularHeight']),
                                     'show metrics',
                                     value=self.isMetricsActive,
                                     callback=self.showMetricsCheckCallback)

        jumping_Y += vanillaControlsSize['CheckBoxRegularHeight']
        self.verticalLettersCheck = CheckBox((indent, jumping_Y, self.ctrlWidth-indent, vanillaControlsSize['CheckBoxRegularHeight']),
                                        'show vertical letters',
                                        value=self.areGroupsShown,
                                        callback=self.verticalLettersCheckCallback)

    def set(self, isKerningDisplayActive,
                  areVerticalLettersDrawn,
                  areGroupsShown,
                  areCollisionsShown,
                  isSidebearingsActive,
                  isCorrectionActive,
                  isMetricsActive,
                  isColorsActive):

        # update attributes
        self.isKerningDisplayActive = isKerningDisplayActive
        self.areVerticalLettersDrawn = areVerticalLettersDrawn
        self.areGroupsShown = areGroupsShown
        self.areCollisionsShown = areCollisionsShown
        self.isSidebearingsActive = isSidebearingsActive
        self.isCorrectionActive = isCorrectionActive
        self.isMetricsActive = isMetricsActive
        self.isColorsActive = isColorsActive

        # aligning controls
        self.showKerningCheck.set(self.isKerningDisplayActive)
        self.showGroupsCheck.set(self.areGroupsShown)
        self.showCollisionsCheck.set(self.areCollisionsShown)
        self.showSidebearingsCheck.set(self.isSidebearingsActive)
        self.showCorrectionCheck.set(self.isCorrectionActive)
        self.showColorsCheck.set(self.isColorsActive)
        self.showMetricsCheck.set(self.isMetricsActive)
        self.verticalLettersCheck.set(self.areVerticalLettersDrawn)


    def get(self):
        return (self.isKerningDisplayActive,
                self.areVerticalLettersDrawn,
                self.areGroupsShown,
                self.areCollisionsShown,
                self.isSidebearingsActive,
                self.isCorrectionActive,
                self.isMetricsActive,
                self.isColorsActive)

    def switchControls(self, value):
        self.showKerningCheck.enable(value)
        self.showSidebearingsCheck.enable(value)
        self.showGroupsCheck.enable(value)
        self.showCorrectionCheck.enable(value)
        self.showMetricsCheck.enable(value)
        self.showColorsCheck.enable(value)
        self.showCollisionsCheck.enable(value)
        self.verticalLettersCheck.enable(value)

    def showKerningCheckCallback(self, sender):
        self.isKerningDisplayActive = bool(sender.get())
        self.callback(self)

    def showGroupsCheckCallback(self, sender):
        self.areGroupsShown = bool(sender.get())
        self.callback(self)

    def verticalLettersCheckCallback(self, sender):
        self.areVerticalLettersDrawn = bool(sender.get())
        self.callback(self)

    def showCollisionsCheckCallback(self, sender):
        self.areCollisionsShown = bool(sender.get())
        self.callback(self)

    def showKerningHiddenButtonCallback(self, sender):
        self.isKerningDisplayActive = not self.isKerningDisplayActive
        self.showKerningCheck.set(self.isKerningDisplayActive)
        self.callback(self)

    def showSidebearingsCheckCallback(self, sender):
        self.isSidebearingsActive = bool(sender.get())
        self.callback(self)

    def showCorrectionCheckCallback(self, sender):
        self.isCorrectionActive = bool(sender.get())
        self.callback(self)

    def showMetricsCheckCallback(self, sender):
        self.isMetricsActive = bool(sender.get())
        self.callback(self)

    def showColorsCheckCallback(self, sender):
        self.isColorsActive = bool(sender.get())
        self.callback(self)
Beispiel #24
0
        return data

    def show(self):
        self.w.show()

    def documentWindowToFront(self, sender=None):
        self.w.makeKey()

def do(sender):
    controller = getController()
    controller.runCode() # runt je script opnieuw.
    
def getController():
    document = AppKit.NSDocumentController.sharedDocumentController().currentDocument()
    print document
    
    if not document:
        raise DrawBotError("There is no document open")
    controller = document.vanillaWindowController
    try:
        controller._variableController.buildUI(variables)
        controller._variableController.show()
    except:
        controller._variableController = VariableController(variables, controller.runCode, document)

    return controller

w = Window((978, 388, 400, 400), 'Test Vanilla in DrawBot')
w.button = Button((10, 10, 150, 30), 'Do', callback=do)
w.checkbox = CheckBox((10, 150, 150, 30), 'Check', callback=do)
w.open()
Beispiel #25
0
class UpdatesTab(BaseTab, ThreadedObject):
    title = "Updates"
    image = "toolbarScriptReload"
    identifier = "updates"

    def setup(self):
        self.list = UpdateList((20, 20, -20, -60),
                               editCallback=self.update_interface,
                               refreshCallback=self.update_interface)

        self.updated_at_text = UpdatedTimeTextBox((120, -38, -20, 20),
                                                  sizeStyle="small")

        self.update_button = UpdateButton((-160, -42, 140, 20),
                                          callback=self.in_thread.install_updates)

        self.refresh_button = Button((20, -42, 90, 20), "Refresh",
                                     callback=self.in_thread.update_list)

        if env.environment == 'production':
            self.refresh_button.show(False)

        self.update_interface()

    def activate(self):
        self.set_default_button(self.update_button)
        self.in_thread.update_list()

    @progress.each('installable')
    @progress.tick('repositoryWillDownload',
                   'Downloading {repository.repo}')
    @progress.tick('extensionWillInstall',
                   'Installing {extension.bundle.name}')
    def install_updates(self, sender=None):
        for extension in self.installable:
            extension.update()

        self.update_list(force=True)

    def update_list(self, force=False):
        if self.list.is_refreshing:
            return None

        try:
            self.update_progress = Overlay("Checking for updates...",
                                           (20, 20, -20, -60),
                                           opacity=0.6,
                                           offset=90)
            self.refresh_button.enable(False)
            self.list.refresh(force=force)
            self.enable()
        except UpdateList.ConnectionError:
            self.disable("Couldn't connect to the internet...")
        finally:
            del self.update_progress
            self.refresh_button.enable(True)

    def update_interface(self, sender=None):
        self.updated_at_text.update()
        self.update_button.update(len(self.list.selected))

    def disable(self, *args, **kwargs):
        self.list.enable(False)
        super(UpdatesTab, self).disable(*args, **kwargs)

    def enable(self, *args, **kwargs):
        self.list.enable(True)
        super(UpdatesTab, self).enable(*args, **kwargs)

    @property
    def installable(self):
        return self.list.selected
Beispiel #26
0
class ApplicantList(Group):

    columns = [{
        "title": "Name",
        "key": "name",
        "editable": False
    }, {
        "title": "Email Address",
        "key": "email_address",
        "editable": False
    }]

    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

    def open_registration_page(self, *args):
        webbrowser.open(self.applicant_roster['url'])

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

        for applicant in selected_applicants:
            token = AppStorage("accessToken").retrieve()
            Ghostlines('v1', token=token).approve_applicant(applicant["id"])

        self.after_approve()
        self.fetch()

    def enable(self, *args):
        token = AppStorage("accessToken").retrieve()
        response = Ghostlines('v1',
                              token=token).enable_applicants_v1(self.family_id)
        json = response.json()

        if response.status_code == 201:
            self.applicant_roster = json
            self.enabled = True
        else:
            ErrorMessage("Could not enable applicants", json["errors"]).open()

    def fetch(self):
        if self.enabled:
            token = AppStorage("accessToken").retrieve()
            response = Ghostlines('v1',
                                  token=token).applicant_roster(self.family_id)
            self.applicant_roster = response.json()
            self.set(self.applicant_roster["applicants"])

    def set(self, applicants):
        unapproved = [a for a in applicants if a["approved_at"] is None]
        self.list.set(unapproved)

    @property
    def enabled(self):
        return self._enabled

    @enabled.setter
    def enabled(self, value):
        self._enabled = value

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

        return self.enabled
Beispiel #27
0
 def __init__(self):
     u"""
     Initialize the window and open it.
     """
     self.w = view = Window((AppC.WINDOW_WIDTH, AppC.WINDOW_HEIGHT),
                            "Xierpa 3",
                            closable=True,
                            minSize=(200, 200),
                            maxSize=(1600, 1000))
     siteLabels = self.getSiteLabels()
     #y = len(siteLabels)*20
     y = 10
     bo = 25  # Button offset
     view.optionalSites = PopUpButton((10, y, 150, 24),
                                      siteLabels,
                                      sizeStyle='small',
                                      callback=self.selectSiteCallback)
     #view.optionalSites = RadioGroup((10, 10, 150, y), siteLabels,
     #    callback=self.selectSiteCallback, sizeStyle='small')
     self.w.optionalSites.set(0)
     y = y + 32
     view.openSite = Button((10, y, 150, 20),
                            'Open site',
                            callback=self.openSiteCallback,
                            sizeStyle='small')
     y += bo
     self.w.saveSite = Button((10, y, 150, 20),
                              'Save HTML+CSS',
                              callback=self.saveSiteCallback,
                              sizeStyle='small')
     y += bo
     view.openCss = Button((10, y, 150, 20),
                           'Open CSS',
                           callback=self.openCssCallback,
                           sizeStyle='small')
     y += bo
     #view.openSass = Button((10, y, 150, 20), 'Open SASS', callback=self.openSassCallback, sizeStyle='small')
     #y += bo
     view.openDocumentation = Button(
         (10, y, 150, 20),
         'Documentation',
         callback=self.openDocumentationCallback,
         sizeStyle='small')
     y += bo
     view.openAsPhp = Button((10, y, 150, 20),
                             'Open as PHP',
                             callback=self.openAsPhpCallback,
                             sizeStyle='small')
     #view.makeSite = Button((10, y+95, 150, 20), 'Make site', callback=self.makeSiteCallback, sizeStyle='small')
     view.forceCss = CheckBox((180, 10, 150, 20),
                              'Force make CSS',
                              sizeStyle='small',
                              value=True)
     view.doIndent = CheckBox((180, 30, 150, 20),
                              'Build indents',
                              sizeStyle='small',
                              value=True)
     view.forceCopy = CheckBox((180, 50, 150, 20),
                               'Overwrite files',
                               sizeStyle='small',
                               value=True)
     view.isOnline = CheckBox((180, 70, 150, 20),
                              'Online',
                              sizeStyle='small',
                              value=True,
                              callback=self.isOnlineCallback)
     view.console = EditText((10, -200, -10, -10), sizeStyle='small')
     # Path defaults
     y = 20
     view.mampRootLabel = TextBox((300, y, 100, 20),
                                  'MAMP folder',
                                  sizeStyle='small')
     view.mampRoot = EditText((400, y, -10, 20),
                              self.C.PATH_MAMP,
                              sizeStyle='small')
     y += bo
     view.exampleRootLabel = TextBox((300, y, 100, 20),
                                     'Root folder',
                                     sizeStyle='small')
     view.exampleRoot = EditText((400, y, -10, 20),
                                 self.C.PATH_EXAMPLES,
                                 sizeStyle='small')
     # Scripting
     y += bo
     view.script = TextEditor((300, y, -10, -240))
     view.runScript = Button((500, -230, 150, -210),
                             'Run script',
                             callback=self.runScriptCallback,
                             sizeStyle='small')
     view.script.set(self.EXAMPLE_SCRIPT)
     view.open()
Beispiel #28
0
 def __init__(self):
     
     # Preferences
     self._drawing = getExtensionDefault(self.DEFAULTKEY_DRAW, True)
     self._fill = getExtensionDefault(self.DEFAULTKEY_FILL, True)
     self._stroke = getExtensionDefault(self.DEFAULTKEY_STROKE, True)
     self._points = getExtensionDefault(self.DEFAULTKEY_POINTS, True)
     
     self._fillColor = getExtensionDefaultColor(self.DEFAULTKEY_FILLCOLOR, self.FALLBACK_FILLCOLOR)
     self._strokeColor = getExtensionDefaultColor(self.DEFAULTKEY_STROKECOLOR, self.FALLBACK_STROKECOLOR)
     self._pointsColor = getExtensionDefaultColor(self.DEFAULTKEY_POINTSCOLOR, self.FALLBACK_POINTSCOLOR)
     
     self._alignment = getExtensionDefault(self.DEFAULTKEY_ALIGNMENT, 0)
     self._kerning = getExtensionDefault(self.DEFAULTKEY_KERNING, 1)
     self._floating = getExtensionDefault(self.DEFAULTKEY_FLOATING, 1)
     
     # User preferences
     self._onCurvePointsSize = getDefault("glyphViewOncurvePointsSize") # typo, should be: OnCurve
     self._offCurvePointsSize = getDefault("glyphViewOffCurvePointsSize")
     self._strokeWidth = getDefault("glyphViewStrokeWidth")
     
     w, h = 400, 195
     x = y = 10
     
     self.initAllFonts()
     
     self.w = FloatingWindow((w, h), "Overlay UFOs")
     self.w.draw = CheckBox((x, y, 95, 18), "Draw", callback=self.drawCallback, value=self._drawing, sizeStyle="small")
     x += 60
     self.w.fill = CheckBox((x, y, 95, 18), "Fill", callback=self.fillCallback, value=self._fill, sizeStyle="small")
     x += 40
     self.w.fillColor = ColorWell((x, y, 45, 20), callback=self.fillColorCallback, color=self._fillColor)
     x += 60
     self.w.stroke = CheckBox((x, y, 95, 18), "Stroke", callback=self.strokeCallback, value=self._stroke, sizeStyle="small")
     x += 60
     self.w.strokeColor = ColorWell((x, y, 45, 20), callback=self.strokeColorCallback, color=self._strokeColor)
     x += 60
     self.w.points = CheckBox((x, y, 95, 18), "Points", callback=self.pointsCallback, value=self._points, sizeStyle="small")
     x += 60
     self.w.pointsColor = ColorWell((x, y, 45, 20), callback=self.pointsColorCallback, color=self._pointsColor)
     x, y = 10, 40
     self.w.alignText = TextBox((x, y, 250, 15), "Alignment:", sizeStyle="small")
     y += 18
     self.w.alignment = RadioGroup((x, y, 80, 55), ['Left', 'Center', 'Right'], isVertical=True, callback=self.alignmentCallback, sizeStyle="small")
     self.w.alignment.set(self._alignment)
     y += 62
     self.w.kerning = CheckBox((x, y, 100, 10), "Show kerning", callback=self.kerningCallback, value=self._kerning, sizeStyle="mini")
     y += 18
     self.w.floating = CheckBox((x, y, 100, 10), "Floating Window", callback=self.floatingCallback, value=self._floating, sizeStyle="mini")
     y += 25
     self.w.resetDefaults = Button((x, y, 85, 14), "Reset settings", callback=self.resetSettingsCallback, sizeStyle="mini")
     x, y = 110, 40
     self.w.fontList = List((x, y, 240, 55), self.getFontItems(), 
         columnDescriptions=self.getListDescriptor(), showColumnTitles=False,
         selectionCallback=None, doubleClickCallback=self.fontListCallback,
         allowsMultipleSelection=True, allowsEmptySelection=True,
         drawVerticalLines=False, drawHorizontalLines=True,
         drawFocusRing=False, rowHeight=16
     )
     y += 55
     self.w.hiddenFontList = List((x, y, 240, 55), self.getHiddenFontItems(), 
         columnDescriptions=self.getListDescriptor(), showColumnTitles=False,
         selectionCallback=None, doubleClickCallback=self.hiddenFontListCallback,
         allowsMultipleSelection=True, allowsEmptySelection=True,
         drawVerticalLines=False, drawHorizontalLines=True,
         drawFocusRing=False, rowHeight=16
     )
     self._selectionChanging = False
     self.w.fontList.setSelection([]) # unselect
     y += 65
     self.w.contextLeft = EditText((x, y, 90, 20), callback=self.contextCallback, continuous=True, placeholder="Left", sizeStyle="small")
     self.w.contextCurrent = EditText((x+95, y, 50, 20), callback=self.contextCallback, continuous=True, placeholder="?", sizeStyle="small")
     self.w.contextRight = EditText((x+150, y, 90, 20), callback=self.contextCallback, continuous=True, placeholder="Right", sizeStyle="small")
     x, y = 360, 100
     self.w.addFonts = Button((x, y, 30, 20), "+", callback=self.addHiddenFontsCallback, sizeStyle="regular")
     y += 25
     self.w.removeFonts = Button((x, y, 30, 20), unichr(8722), callback=self.removeHiddenFontsCallback, sizeStyle="regular")
             
     # Observers
     addObserver(self, "fontDidOpen", "fontDidOpen")
     addObserver(self, "fontWillClose", "fontWillClose") # fontDidClose?
     addObserver(self, "draw", "drawInactive")
     addObserver(self, "draw", "draw")
     
     # Prepare and open window
     self.setWindowLevel()
     self.setUpBaseWindowBehavior()
     self.w.open()
Beispiel #29
0
    def populateWindow(self):
        y = 10
        x = 10
        self.w.italicAngleLabel = TextBox((x, y + 4, 100, 22),
                                          'Italic Angle',
                                          sizeStyle="small")
        x += 100
        self.w.italicAngle = EditText((x, y, 40, 22),
                                      '',
                                      sizeStyle="small",
                                      callback=self.calcItalicCallback)

        y += 30
        x = 10
        self.w.crossHeightLabel = TextBox((x, y + 4, 95, 22),
                                          'Cross Height',
                                          sizeStyle="small")
        x += 100
        self.w.crossHeight = EditText((x, y, 40, 22),
                                      '',
                                      sizeStyle="small",
                                      callback=self.calcItalicCallback)
        x += 50
        self.w.crossHeightSetUC = Button((x, y, 65, 22),
                                         'Mid UC',
                                         sizeStyle="small",
                                         callback=self.calcItalicCallback)
        x += 75
        self.w.crossHeightSetLC = Button((x, y, 65, 22),
                                         'Mid LC',
                                         sizeStyle="small",
                                         callback=self.calcItalicCallback)

        y += 30
        x = 10
        self.w.italicSlantOffsetLabel = TextBox((x, y + 4, 100, 22),
                                                'Italic Slant Offset',
                                                sizeStyle="small")
        x += 100
        self.w.italicSlantOffset = EditText((x, y, 40, 22),
                                            '',
                                            sizeStyle="small",
                                            callback=self.calcItalicCallback)
        x += 60

        y += 30
        x = 10
        self.w.refresh = Button((x, y, 140, 22),
                                u'Values from Current',
                                callback=self.refresh,
                                sizeStyle="small")

        y += 30

        self.w.fontSelection = RadioGroup((x, y, 120, 35),
                                          ['Current Font', 'All Fonts'],
                                          sizeStyle="small")
        self.w.fontSelection.set(0)

        x += 160
        self.w.glyphSelection = RadioGroup(
            (x, y, 120, 55),
            ['Current Glyph', 'Selected Glyphs', 'All Glyphs'],
            sizeStyle="small")
        self.w.glyphSelection.set(0)
        y += 60
        x = 10
        self.w.setInFont = Button((x, y, 140, 22),
                                  'Set Font Italic Values',
                                  sizeStyle="small",
                                  callback=self.setInFontCallback)
        x += 160
        self.w.italicize = Button((x, y, 140, 22),
                                  'Italicize Glyphs',
                                  sizeStyle="small",
                                  callback=self.italicizeCallback)
        y += 25
        self.w.makeReferenceLayer = CheckBox(
            (x, y, 145, 22),
            'Make Reference Layer',
            value=getExtensionDefault(self.DEFAULTKEY_REFERENCE, False),
            sizeStyle="small",
            callback=self.makeReferenceLayerCallback)
        x = 10

        self.refresh()
        if self.getItalicAngle() == 0 and CurrentFont() is not None:
            self.setCrossHeight((CurrentFont().info.capHeight or 0) / 2)
    def __init__(self, font):
        self.font = font
        self.recipients = FontRecipients(self.font)
        self.applicants = []
        self.note_draft_storage = LibStorage(self.font.lib,
                                             "release_notes_draft")
        self.email_storage = LibStorage(self.font.lib,
                                        "designer_email_address")
        self.license_storage = LibStorage(self.font.lib, "license_filepath")

        self.window.banner_background = Background((0, -40, 0, 40), 1)
        self.window.upgrade_tip = TextBox(
            (15, -30, -15, 22),
            WhiteText(
                "Ghostlines is out of Beta. If you have an account, upgrade:"))
        self.window.upgrade_button = Button((-205, -31, 185, 22),
                                            "Migrate from Beta",
                                            callback=self.migrate,
                                            sizeStyle="small")

        self.window.background = Background((0, 0, -0, 235))
        self.window.attribution = AttributionText((15, 15, -15, 22), font)
        self.window.send_button = CounterButton(
            (-215, 12, 200, 24), ("Send Release to All", "Send Release to {}"),
            callback=self.send)

        self.window.notes_field_label = TextBox((15, 52, -15, 22),
                                                WhiteText("Release Notes"))
        self.window.notes_field = NotesEditor(
            (15, 75, -15, 80), draft_storage=self.note_draft_storage)

        self.window.email_address_field_label = TextBox(
            (15, 170, 270, 22), WhiteText("Contact Email Included in Release"))
        self.window.email_address_field = EmailAddressField(
            (15, 193, 270, 22), storage=self.email_storage)

        self.window.license_field_label = TextBox((-285, 170, -15, 22),
                                                  WhiteText("License"))
        self.window.license_field = FileUploadField(
            (-285, 193, -15, 22), storage=self.license_storage)

        self.window.recipients_label = TextBox((-285, 250, -15, 22),
                                               "Subscribers")
        self.window.recipients = List(
            (-285, 273, 270, -89),
            self.recipients,
            selectionCallback=self.update_send_button)
        self.window.recipients.setSelection([])

        self.window.recipients_tip = TextBox((-200, -73, 185, 14),
                                             "cmd+click to select subset",
                                             alignment="right",
                                             sizeStyle="small")

        self.window.add_recipient_button = Button((-285, -79, 30, 24),
                                                  "+",
                                                  callback=self.add_recipient)
        self.window.remove_recipient_button = Button(
            (-246, -79, 30, 24), "-", callback=self.remove_recipient)

        self.window.applicants = ApplicantList(
            (15, 250, 270, 235),
            self.font,
            self.applicants,
            self.recipients,
            after_approve=self.add_approved_applicant)

        self.window.bind("became main", self.fetch_applicants)

        self.window.setDefaultButton(self.window.send_button)
    def __init__(self, proofGroup):
        """
        Initialize inspector with proofGroup data.
        proofGroup is a dictionary passed in by ProofDrawer().
        """
        self.proofGroup = proofGroup
        self.editedProofGroup = {}

        left = 10
        row = 10
        textboxWidth = 92
        leftEditText = left + 95
        pointSizes = ["6", "8", "10", "12", "14", "18",\
                      "21", "24", "36", "48", "60", "72"]

        self.w = FloatingWindow(
            (400, 275), "Edit Proof Group: %s" % self.proofGroup["name"])

        self.w.groupName = TextBox((left, row + 2, textboxWidth, 20),
                                   "Group name:",
                                   alignment="right")

        self.w.groupNameEdit = EditText((leftEditText, row, -10, 22),
                                        self.proofGroup["name"])

        row += 33
        self.w.typeSize = TextBox((left, row + 2, textboxWidth, 20),
                                  "Type size (pt):",
                                  alignment="right")

        self.w.typeSizeEdit = ComboBox((leftEditText, row, 55, 22),
                                       pointSizes,
                                       continuous=True,
                                       callback=self._checkFloat)

        self.w.typeSizeEdit.set(self.proofGroup["typeSize"])

        self.w.leading = TextBox((leftEditText + 80, row + 2, 60, 22),
                                 "Leading:")

        self.w.leadingEdit = ComboBox((leftEditText + 139, row, 55, 22),
                                      pointSizes,
                                      continuous=True,
                                      callback=self._checkFloat)

        self.w.leadingEdit.set(self.proofGroup["leading"])

        row += 33
        self.w.contents = TextBox((left, row, textboxWidth, 20),
                                  "Contents:",
                                  alignment="right")

        self.w.contentsEdit = TextEditor(
            (leftEditText, row, -10, 150),
            "\n".join(self.proofGroup["contents"]))
        self.w.contentsEdit.getNSTextView().setFont_(monoFont)

        row += 160
        self.w.cancelButton = Button((leftEditText, row, 138, 20),
                                     "Cancel",
                                     callback=self.cancelCB)

        leftEditText += 147
        self.w.okButton = Button((leftEditText, row, 138, 20),
                                 "OK",
                                 callback=self.okCB)

        self.w.setDefaultButton(self.w.okButton)
        self.w.bind("close", self._postCloseEvent)
    def build_ui(self, useFloatingWindow=True):
        self.methods = {
            0: "balance",
            1: "free",
            2: "hobby",
        }

        self.methodNames = [
            "Balance",
            "Adjust:",
            "Hobby:",
        ]

        height = 108
        width = 200
        sliderX = 76

        if useFloatingWindow:
            self.paletteView = FloatingWindow(
                posSize=(width, height),
                title="Curve EQ",
                minSize=(width, height + 16),
                maxSize=(1000, height + 16),
            )
        else:
            self.paletteView = Window((width, height))

        self.paletteView.group = Group((0, 0, width, height))

        y = 8
        self.paletteView.group.eqMethodSelector = RadioGroup(
            (8, y, -8, -36),
            titles=self.methodNames,
            callback=self._changeMethod,
            sizeStyle="small",
        )

        y += 22
        self.paletteView.group.eqCurvatureSlider = Slider(
            (sliderX, y, -8, 17),
            callback=self._changeCurvatureFree,
            minValue=0.5,
            maxValue=1.0,
            value=0.75,  # Will be replaced by saved value
            sizeStyle="small",
        )

        y += 25
        self.paletteView.group.eqHobbyTensionSlider = Slider(
            (sliderX, y, -8, 17),
            tickMarkCount=5,
            callback=self._changeTension,
            minValue=0.5,
            maxValue=1.0,
            sizeStyle="small",
        )

        if useFloatingWindow:
            y = height - 32
            self.paletteView.group.eqSelectedButton = Button(
                (8, y, -8, 25),
                "Equalize Selected",
                callback=self._eqSelected,
                sizeStyle="small",
            )
Beispiel #33
0
 def buildUI(self, api):
     u"""Build the app UI from the api-parameters, answered the publication self._doc."""
     self.w.buildButton = Button((-100, -30, 90, 20),
                                 'Build',
                                 callback=self.build)
Beispiel #34
0
    def __init__(self, font, document=None):
        self.font = font

        self.note_draft_storage = LibStorage(self.font.lib,
                                             "releaseNotesDraft")
        self.license_storage = LibStorage(self.font.lib, "licenseFilepath")
        self.family_id_storage = LibStorage(self.font.lib, "fontFamilyId")

        self.subscribers = self.font_family["subscribers"]

        if document is not None:
            self.window.assignToDocument(document)

        self.window.background = Background((301, -52, 299, 52), alpha=0.05)

        self.window.release_info = Group((315, 15, 270, -15))

        self.window.release_info.font_name_label = TextBox((0, 0, -0, 22),
                                                           "Font Name",
                                                           sizeStyle="small")
        self.window.release_info.font_name = TextBox((0, 19, -0, 22),
                                                     self.font_family["name"])
        self.window.release_info.font_author_label = TextBox((0, 60, -0, 22),
                                                             "Designer",
                                                             sizeStyle="small")
        self.window.release_info.font_author = TextBox(
            (0, 79, -0, 22), self.font_family["designer_name"])
        self.window.release_info.version_label = TextBox((0, 120, -0, 22),
                                                         "Version Number",
                                                         sizeStyle="small")
        self.window.release_info.version = TextBox((0, 139, -0, 22),
                                                   self.font_version)

        self.window.release_info.notes_field_label = TextBox((0, 176, -0, 22),
                                                             "Release Notes",
                                                             sizeStyle="small")
        self.window.release_info.notes_field = NotesEditor(
            (0, 198, -0, 175), draft_storage=self.note_draft_storage)

        self.window.release_info.license_field_label = TextBox(
            (0, 393, -0, 22), "Attach License", sizeStyle="small")
        self.window.release_info.license_field = FileUploadField(
            (0, 410, -0, 22), storage=self.license_storage)

        self.window.release_info.send_button = CounterButton(
            (0, -24, -0, 24), ("Send Release to All", "Send Release to {}"),
            callback=self.send)

        self.window.release_subscriber_divider = VerticalLine((300, 0, 1, -0))

        self.window.subscriber_info = Group((15, 15, 270, -15))

        self.window.subscriber_info.subscribers_label = TextBox(
            (0, 0, -0, 22), "Subscribers", sizeStyle="small")
        self.window.subscriber_info.subscribers = List(
            (0, 22, -0, 205),
            self.subscribers,
            columnDescriptions=[{
                "title": "Name",
                "key": "name",
                "editable": False
            }, {
                "title": "Email Address",
                "key": "email_address",
                "editable": False
            }],
            selectionCallback=self.update_send_button)
        self.window.subscriber_info.subscribers.setSelection([])

        self.window.subscriber_info.subscribers_tip = TextBox(
            (0, 238, -0, 14),
            "cmd+click to select subset",
            alignment="right",
            sizeStyle="small")

        self.window.subscriber_info.show_subscriber_sheet_button = Button(
            (0, 233, 30, 24), "+", callback=self.show_subscriber_sheet)
        self.window.subscriber_info.remove_subscriber_button = Button(
            (40, 233, 30, 24), "-", callback=self.remove_subscriber)

        self.window.subscriber_info.applicants = \
            ApplicantList((0, 280, 270, 210),
                          self.font_family["applicant_roster"],
                          self.family_id_storage.retrieve(),
                          after_approve=self.refresh_subscribers)

        self.window.release_releases_divider = VerticalLine((600, 0, 1, -0))

        self.window.releases_info = Group((615, 15, 270, -15))

        self.window.releases_info.log_label = TextBox((0, 0, -0, 22),
                                                      "Releases",
                                                      sizeStyle="small")
        self.window.releases_info.log = \
            ReleaseLog((0, 22, -0, -0),
                       self.font_family["releases"][::-1],
                       columnDescriptions=[
                      {
                          "title": "Created",
                          "key": "created_at",
                          "editable": False
                      }, {
                          "title": "Version",
                          "key": "version",
                          "editable": False,
                          "width": 50
                      }, {
                          "title": "# subs.",
                          "key": "subscriber_count",
                          "editable": False,
                          "width": 50
                      }
                  ])

        self.resize_window_for_releases()
        self.window.bind("became main", self.fetch_applicants)
Beispiel #35
0
    script = 'fill(random(), random(), random())\nrect(10+random()*100, 10+random()*100, 200, 300)'
    newDrawing()
    namespace = DrawBotNamespace(_drawBotDrawingTool,
                                 _drawBotDrawingTool._magicVariables)
    _drawBotDrawingTool._addToNamespace(namespace)

    # Creates a new standard output, catching all print statements and tracebacks.
    stdout = StdOutput(output, outputView=outputWindow.outputView)
    stderr = StdOutput(output,
                       isError=True,
                       outputView=outputWindow.outputView)

    # Calls DrawBot's ScriptRunner with above parameters.
    ScriptRunner(script,
                 None,
                 namespace=namespace,
                 stdout=stdout,
                 stderr=stderr)
    _drawBotDrawingTool._drawInContext(context)
    pdfDocument = _drawBotDrawingTool.pdfImage()


if __name__ == '__main__':

    w = Window((10, 10, 400, 200), 'Window')
    w.button = Button((20, 20, 100, 30), 'Hit', callback=hitCallback)
    w.open()

    outputWindow = Window((500, 10, 400, 300), minSize=(1, 1), closable=True)
    outputWindow.outputView = OutPutEditor((0, 0, -0, -0), readOnly=True)
    outputWindow.open()
Beispiel #36
0
class SliderGroup(Group):

    _callback = weakrefCallbackProperty()

    def __init__(self, width, sliderInfo, continuous=True, callback=None):
        super().__init__((0, 0, width, 0))
        self._callback = callback
        self._continuous = continuous
        self._tags = []
        self.setSliderInfo(sliderInfo)

    def _breakCycles(self):
        self._callback = None
        super()._breakCycles()

    def setSliderInfo(self, sliderInfo):
        savedState = self.get()
        # clear all subviews
        for attr, value in list(self.__dict__.items()):
            if isinstance(value, VanillaBaseObject):
                delattr(self, attr)
        margin = 10
        y = margin
        self._tags = []
        self._defaultValues = {}
        for tag, (label, minValue, defaultValue,
                  maxValue) in sliderInfo.items():
            self._tags.append(tag)
            self._defaultValues[tag] = defaultValue
            attrName = f"slider_{tag}"
            slider = SliderPlus((margin, y, -margin, 40),
                                label,
                                minValue,
                                defaultValue,
                                maxValue,
                                continuous=self._continuous,
                                callback=self._sliderChanged)
            setattr(self, attrName, slider)
            y += 50

        self.resetAllButton = Button((10, y, 120, 25), "Reset all axes",
                                     self._resetAllButtonCallback)
        self.resetAllButton.enable(False)
        y += 35

        posSize = (0, 0, self.getPosSize()[2], y)
        self.setPosSize(posSize)
        self._updateState(savedState)

    def _sliderChanged(self, sender):
        self.resetAllButton.enable(True)
        callCallback(self._callback, self)

    def _resetAllButtonCallback(self, sender):
        self.resetAllButton.enable(False)
        for tag in self._tags:
            attrName = f"slider_{tag}"
            slider = getattr(self, attrName)
            slider.set(self._defaultValues[tag])
        callCallback(self._callback, self)

    def get(self):
        state = {}
        for tag in self._tags:
            attrName = f"slider_{tag}"
            slider = getattr(self, attrName)
            value = slider.get()
            if value is not None:
                if len(self._defaultValues[tag]
                       ) != 1 or value not in self._defaultValues[tag]:
                    state[tag] = value
        return state

    def _updateState(self, state):
        for tag, value in state.items():
            attrName = f"slider_{tag}"
            slider = getattr(self, attrName, None)
            if slider is not None:
                slider.set(value)

    def set(self, state):
        if state:
            self.resetAllButton.enable(True)
        for tag in self._tags:
            attrName = f"slider_{tag}"
            slider = getattr(self, attrName)
            value = state.get(tag)
            if value is None:
                value = self._defaultValues[tag]
            slider.set(value)
Beispiel #37
0
    def populateWindow(self):
        """
        The UI

        """
        self.fillColor = getExtensionDefault(DEFAULTKEY_FILLCOLOR,
                                             FALLBACK_FILLCOLOR)
        self.strokeColor = getExtensionDefault(DEFAULTKEY_STROKECOLOR,
                                               FALLBACK_STROKECOLOR)
        self.contextBefore = self.contextAfter = ""

        # Populating the view can only happen after the view is attached to the window,
        # or else the relative widths go wrong.
        self.w.add = Button((-40, 3, 30, 22), "+", callback=self.addCallback)
        self.w.reset = Button((-40, 30, 30, 22),
                              chr(8634),
                              callback=self.resetCallback)

        # Flag to see if the selection list click is in progress. We are resetting the selection
        # ourselves, using the list "buttons", but changing that selection will cause another
        # list update, that should be ignored.
        self._selectionChanging = False

        x = y = 4

        self.w.fontList = List(
            (C2, y, 250, -65),
            self._getFontItems(),
            selectionCallback=self.fontListCallback,
            drawFocusRing=False,
            enableDelete=False,
            allowsMultipleSelection=False,
            allowsEmptySelection=True,
            drawHorizontalLines=True,
            showColumnTitles=False,
            columnDescriptions=self._getPathListDescriptor(),
            rowHeight=16,
        )

        self.w.fill = CheckBox(
            (x, y, 60, 22),
            "Fill",
            sizeStyle=CONTROLS_SIZE_STYLE,
            value=True,
            callback=self.fillCallback,
        )
        y += L - 3
        self.w.stroke = CheckBox(
            (x, y, 60, 22),
            "Stroke",
            sizeStyle=CONTROLS_SIZE_STYLE,
            value=False,
            callback=self.strokeCallback,
        )
        y += L
        defaultColor = getExtensionDefault(DEFAULTKEY_FILLCOLOR,
                                           FALLBACK_FILLCOLOR)
        self.w.color = ColorWell(
            (x, y, 60, 22),
            color=NSColor.colorWithCalibratedRed_green_blue_alpha_(
                *defaultColor),
            callback=self.colorCallback,
        )
        y += LL + 5
        self.w.alignText = TextBox((x, y, 90, 50),
                                   "Alignment",
                                   sizeStyle=CONTROLS_SIZE_STYLE)
        y += L
        self.w.align = RadioGroup(
            (x, y, 90, 50),
            ["Left", "Center", "Right"],
            isVertical=True,
            sizeStyle=CONTROLS_SIZE_STYLE,
            callback=self.alignCallback,
        )
        self.w.align.set(0)

        self.w.viewCurrent = CheckBox(
            (C2, -60, 150, 22),
            "Always View Current",
            sizeStyle=CONTROLS_SIZE_STYLE,
            value=False,
            callback=self.viewCurrentCallback,
        )

        self.w.contextBefore = GlyphNamesEditText(
            (C2, -30, 85, 20),
            callback=self.contextEditCallback,
            continuous=True,
            sizeStyle="small",
            placeholder="Left Context",
        )
        self.w.contextBefore.title = "contextBefore"

        self.w.contextCurrent = GlyphNamesEditText(
            (C2 + 95, -30, 60, 20),
            callback=self.contextEditCallback,
            continuous=True,
            sizeStyle="small",
        )
        self.w.contextCurrent.title = "contextCurrent"

        self.w.contextAfter = GlyphNamesEditText(
            (C2 + 165, -30, 85, 20),
            callback=self.contextEditCallback,
            continuous=True,
            sizeStyle="small",
            placeholder="Right Context",
        )
        self.w.contextAfter.title = "contextAfter"
    def __init__(self):
        padding = 10
        lineHeight = 20
        buttonHeight = 20
        width = 123
        height = lineHeight * 6 + buttonHeight * 4 + padding * 9

        self.w = FloatingWindow((width, height), title='spacing')

        x = y = padding
        self.w.makeGroupButton = Button((x, y, -padding, buttonHeight),
                                        'make group',
                                        callback=self.makeGroupCallback,
                                        sizeStyle='small')

        y += buttonHeight + padding
        self.w.side = RadioGroup((x, y, -padding, lineHeight),
                                 ['left', 'right'],
                                 isVertical=False,
                                 callback=self.updateViewsCallback,
                                 sizeStyle='small')
        self.w.side.set(0)

        y += lineHeight + padding
        self.w.copySpacingButton = Button((x, y, -padding, buttonHeight),
                                          'copy margin',
                                          callback=self.copySpacingCallback,
                                          sizeStyle='small')

        y += buttonHeight + padding
        self.w.useBeam = CheckBox((x, y, -padding, lineHeight),
                                  'use beam',
                                  callback=self.useBeamCallback,
                                  sizeStyle='small')

        y += lineHeight
        self.w.allLayers = CheckBox((x, y, -padding, lineHeight),
                                    'all layers',
                                    callback=self.updateViewsCallback,
                                    sizeStyle='small')

        y += lineHeight + padding
        self.w.opacityLabel = TextBox((x, y, -padding, lineHeight),
                                      'opacity:',
                                      sizeStyle='small')

        y += lineHeight
        self.w.opacity = Slider((x, y, -padding, lineHeight),
                                value=0.4,
                                minValue=0.0,
                                maxValue=0.9,
                                callback=self.updateViewsCallback,
                                sizeStyle='small')

        y += lineHeight + padding
        self.w.exportButton = Button((x, y, -padding, buttonHeight),
                                     'export…',
                                     callback=self.exportCallback,
                                     sizeStyle='small')

        y += buttonHeight + padding
        self.w.importButton = Button((x, y, -padding, buttonHeight),
                                     'import…',
                                     callback=self.importCallback,
                                     sizeStyle='small')

        y += buttonHeight + padding
        self.w.verbose = CheckBox((x, y, -padding, lineHeight),
                                  'verbose',
                                  value=True,
                                  sizeStyle='small')

        self.setUpBaseWindowBehavior()

        addObserver(self, "drawGlyphsInGroup", "spaceCenterDraw")

        self.w.getNSWindow().setTitlebarAppearsTransparent_(True)
        self.w.open()