Browse Source

Truncated time widths!

pull/92/head
Abhishek 5 years ago
parent
commit
3ebdba307d
  1. 14
      Clocker/Menu Bar/StatusContainerView.swift
  2. 3
      Clocker/Menu Bar/StatusItemHandler.swift

14
Clocker/Menu Bar/StatusContainerView.swift

@ -125,10 +125,24 @@ class StatusContainerView: NSView {
assertionFailure("Subviews count should > 0") assertionFailure("Subviews count should > 0")
} }
// See if frame's width needs any adjustment
var newWidth: CGFloat = 0
subviews.forEach { subviews.forEach {
if let statusItem = $0 as? StatusItemView { if let statusItem = $0 as? StatusItemView {
// Determine what's the best width required to display the current string.
let newBestWidth = CGFloat(bestWidth(for: statusItem.dataObject))
// Let's note if the current width is too small/correct
newWidth += statusItem.frame.size.width != newBestWidth ? newBestWidth : statusItem.frame.size.width
statusItem.updateTimeInMenubar() statusItem.updateTimeInMenubar()
} }
} }
if newWidth != frame.size.width {
print("Correcting our width to \(newWidth) and the previous width was \(frame.size.width)")
frame = CGRect(x: frame.origin.x, y: frame.origin.y, width: newWidth, height: frame.size.height)
}
} }
} }

3
Clocker/Menu Bar/StatusItemHandler.swift

@ -35,9 +35,6 @@ class StatusItemHandler: NSObject {
// TODO: Make sure it's set just once. // TODO: Make sure it's set just once.
private var currentState: MenubarState = .standardText { private var currentState: MenubarState = .standardText {
didSet { didSet {
if oldValue == currentState {
assert(oldValue == currentState, "We have the same status bar state")
}
// Do some cleanup // Do some cleanup
switch oldValue { switch oldValue {
case .compactText: case .compactText:

Loading…
Cancel
Save