From 214afa33f7468e0d4164f494e079d5fa5965b2d9 Mon Sep 17 00:00:00 2001 From: Andrii Nester Date: Wed, 16 Dec 2020 19:45:03 +0200 Subject: [PATCH] Vertically center text on project select button (mac) --- .../VerticallyCenteredTextFieldCell.swift | 7 +++++++ .../TimerViewController/TimerViewController.xib | 15 ++++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/ui/osx/TogglDesktop/Common/Views/TextFields/VerticallyCenteredTextFieldCell.swift b/src/ui/osx/TogglDesktop/Common/Views/TextFields/VerticallyCenteredTextFieldCell.swift index bb3b749bbf..a26b2e0940 100644 --- a/src/ui/osx/TogglDesktop/Common/Views/TextFields/VerticallyCenteredTextFieldCell.swift +++ b/src/ui/osx/TogglDesktop/Common/Views/TextFields/VerticallyCenteredTextFieldCell.swift @@ -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) @@ -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 diff --git a/src/ui/osx/TogglDesktop/Features/Timer/TimerViewController/TimerViewController.xib b/src/ui/osx/TogglDesktop/Features/Timer/TimerViewController/TimerViewController.xib index 53e68f475e..aa81fb1519 100644 --- a/src/ui/osx/TogglDesktop/Features/Timer/TimerViewController/TimerViewController.xib +++ b/src/ui/osx/TogglDesktop/Features/Timer/TimerViewController/TimerViewController.xib @@ -1,8 +1,8 @@ - + - + @@ -113,9 +113,14 @@ - + + + + + + @@ -145,7 +150,7 @@ - + @@ -177,7 +182,7 @@ - +