Skip to content
This repository has been archived by the owner on Feb 13, 2024. It is now read-only.

Commit

Permalink
Merge pull request #4763 from toggl-open-source/fix/project-select-bu…
Browse files Browse the repository at this point in the history
…tton-center

Vertically center text on project select button (mac)
  • Loading branch information
skel35 authored Dec 17, 2020
2 parents b48ba94 + 214afa3 commit d980f79
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ final class VerticallyCenteredButtonCell: NSButtonCell {

@IBInspectable var focusRingCornerRadius: CGFloat = 0
@IBInspectable var leftPadding: CGFloat = 0
@IBInspectable var verticalTitleOffset: CGFloat = 0

override func drawingRect(forBounds theRect: NSRect) -> NSRect {
var newRect = super.drawingRect(forBounds: theRect)
Expand All @@ -101,6 +102,12 @@ final class VerticallyCenteredButtonCell: NSButtonCell {
return newRect
}

override func titleRect(forBounds rect: NSRect) -> NSRect {
var titleFrame = super.titleRect(forBounds: rect)
titleFrame.origin.y += verticalTitleOffset
return titleFrame
}

override func drawFocusRingMask(withFrame cellFrame: NSRect, in controlView: NSView) {

// Draw default
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="17506" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="17701" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="17506"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="17701"/>
<capability name="Named colors" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
Expand Down Expand Up @@ -113,9 +113,14 @@
<constraints>
<constraint firstAttribute="height" constant="24" id="aos-pz-lzF"/>
</constraints>
<buttonCell key="cell" type="roundRect" bezelStyle="roundedRect" image="project-button" imagePosition="only" alignment="center" lineBreakMode="truncatingTail" imageScaling="proportionallyDown" inset="2" id="XiJ-UQ-fKx">
<buttonCell key="cell" type="roundRect" bezelStyle="roundedRect" image="project-button" imagePosition="only" alignment="center" lineBreakMode="truncatingTail" imageScaling="proportionallyDown" inset="2" id="XiJ-UQ-fKx" customClass="VerticallyCenteredButtonCell" customModule="Toggl_Track" customModuleProvider="target">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" size="12" name="HelveticaNeue"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="number" keyPath="verticalTitleOffset">
<real key="value" value="-1"/>
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
</buttonCell>
<color key="contentTintColor" name="lighter-grey-color"/>
<userDefinedRuntimeAttributes>
Expand Down Expand Up @@ -145,7 +150,7 @@
<constraint firstAttribute="width" constant="24" id="K6L-TG-EPU"/>
<constraint firstAttribute="height" constant="24" id="hHI-j8-8eD"/>
</constraints>
<buttonCell key="cell" type="roundRect" bezelStyle="roundedRect" image="tag-button" imagePosition="only" alignment="center" imageScaling="proportionallyDown" inset="2" id="gdT-xR-BDt">
<buttonCell key="cell" type="roundRect" bezelStyle="roundedRect" image="tag-button" imagePosition="only" alignment="center" imageScaling="proportionallyDown" inset="2" id="gdT-xR-BDt" customClass="VerticallyCenteredButtonCell" customModule="Toggl_Track" customModuleProvider="target">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" size="12" name="HelveticaNeue"/>
</buttonCell>
Expand Down Expand Up @@ -177,7 +182,7 @@
<constraint firstAttribute="width" constant="24" id="1aZ-p7-qEl"/>
<constraint firstAttribute="height" constant="24" id="MD6-2y-exy"/>
</constraints>
<buttonCell key="cell" type="roundRect" bezelStyle="roundedRect" image="billable-button" imagePosition="only" alignment="center" enabled="NO" imageScaling="proportionallyDown" inset="2" id="im8-is-hrS">
<buttonCell key="cell" type="roundRect" bezelStyle="roundedRect" image="billable-button" imagePosition="only" alignment="center" enabled="NO" imageScaling="proportionallyDown" inset="2" id="im8-is-hrS" customClass="VerticallyCenteredButtonCell" customModule="Toggl_Track" customModuleProvider="target">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" size="12" name="HelveticaNeue"/>
</buttonCell>
Expand Down

0 comments on commit d980f79

Please sign in to comment.