Browse Source

Fix status item handler smashing against the view.

pull/113/head
Abhishek Banthia 3 years ago
parent
commit
689835c393
  1. 5
      Clocker/Panel/PanelController.swift
  2. 19
      Clocker/Preferences/Calendar/CalendarViewController.swift
  3. 1
      Clocker/Preferences/Menu Bar/StatusContainerView.swift
  4. 5
      Clocker/Preferences/Menu Bar/StatusItemHandler.swift

5
Clocker/Panel/PanelController.swift

@ -75,6 +75,8 @@ class PanelController: ParentPanelController {
updateDefaultPreferences() updateDefaultPreferences()
setupUpcomingEventViewCollectionViewIfNeccesary()
if DataStore.shared().timezones().isEmpty || DataStore.shared().shouldDisplay(.futureSlider) == false { if DataStore.shared().timezones().isEmpty || DataStore.shared().shouldDisplay(.futureSlider) == false {
futureSliderView.isHidden = true futureSliderView.isHidden = true
modernContainerView.isHidden = true modernContainerView.isHidden = true
@ -303,6 +305,9 @@ class PanelController: ParentPanelController {
window?.orderOut(nil) window?.orderOut(nil)
datasource = nil datasource = nil
upcomingEventsDataSource = nil
parentTimer?.pause()
parentTimer = nil
} }
func setActivePanel(newValue: Bool) { func setActivePanel(newValue: Bool) {

19
Clocker/Preferences/Calendar/CalendarViewController.swift

@ -5,29 +5,26 @@ import CoreLoggerKit
import EventKit import EventKit
class ClockerTextBackgroundView: NSView { class ClockerTextBackgroundView: NSView {
private var themeDidChangeNotification: NSObjectProtocol?
override func awakeFromNib() { override func awakeFromNib() {
wantsLayer = true wantsLayer = true
layer?.cornerRadius = 8.0 layer?.cornerRadius = 8.0
layer?.masksToBounds = false layer?.masksToBounds = false
layer?.backgroundColor = Themer.shared().textBackgroundColor().cgColor
themeDidChangeNotification = NotificationCenter.default.addObserver(forName: .themeDidChangeNotification, object: nil, queue: OperationQueue.main) { _ in
self.layer?.backgroundColor = Themer.shared().textBackgroundColor().cgColor
}
}
deinit { NotificationCenter.default.addObserver(self,
if let themeDidChangeNotif = themeDidChangeNotification { selector: #selector(updateBackgroundColor),
NotificationCenter.default.removeObserver(themeDidChangeNotif) name: .themeDidChangeNotification,
} object: nil)
} }
override func updateLayer() { override func updateLayer() {
super.updateLayer() super.updateLayer()
layer?.backgroundColor = Themer.shared().textBackgroundColor().cgColor layer?.backgroundColor = Themer.shared().textBackgroundColor().cgColor
} }
@objc func updateBackgroundColor() {
layer?.backgroundColor = Themer.shared().textBackgroundColor().cgColor
}
} }
class CalendarViewController: ParentViewController { class CalendarViewController: ParentViewController {

1
Clocker/Preferences/Menu Bar/StatusContainerView.swift

@ -239,6 +239,7 @@ class StatusContainerView: NSView {
// NSView move animation // NSView move animation
NSAnimationContext.runAnimationGroup({ context in NSAnimationContext.runAnimationGroup({ context in
context.duration = 0.2 context.duration = 0.2
context.timingFunction = CAMediaTimingFunction(name: CAMediaTimingFunctionName.easeIn)
let newFrame = CGRect(x: frame.origin.x, y: frame.origin.y, width: newWidth, height: frame.size.height) let newFrame = CGRect(x: frame.origin.x, y: frame.origin.y, width: newWidth, height: frame.size.height)
// The view will animate to the new origin // The view will animate to the new origin
self.animator().frame = newFrame self.animator().frame = newFrame

5
Clocker/Preferences/Menu Bar/StatusItemHandler.swift

@ -247,9 +247,8 @@ class StatusItemHandler: NSObject {
if upcomingEventView == nil { if upcomingEventView == nil {
constructCompactView(with: true) constructCompactView(with: true)
} }
} else { } else if let upcomingEventView = retrieveUpcomingEventStatusView() {
let upcomingEventView = retrieveUpcomingEventStatusView() upcomingEventView.removeFromSuperview()
upcomingEventView?.removeFromSuperview()
constructCompactView() // So that Status Container View reclaims the space constructCompactView() // So that Status Container View reclaims the space
} }
// This will internally call `statusItemViewSetNeedsDisplay` on all subviews ensuring all text in the menubar is up-to-date. // This will internally call `statusItemViewSetNeedsDisplay` on all subviews ensuring all text in the menubar is up-to-date.

Loading…
Cancel
Save