Skip to content

Commit

Permalink
refactor: minor syntax change
Browse files Browse the repository at this point in the history
  • Loading branch information
louis.pontoise authored and lwouis committed Mar 10, 2020
1 parent a1b5266 commit 314801c
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions alt-tab-macos/ui/ThumbnailsPanel.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Cocoa

class ThumbnailsPanel: NSPanel, NSCollectionViewDataSource, NSCollectionViewDelegate, NSCollectionViewDelegateFlowLayout {
var backgroundView: NSVisualEffectView?
var backgroundView: NSVisualEffectView!
var collectionView: NSCollectionView!
var app: App?
let cellId = NSUserInterfaceItemIdentifier("Cell")
Expand All @@ -21,8 +21,8 @@ class ThumbnailsPanel: NSPanel, NSCollectionViewDataSource, NSCollectionViewDele
titleVisibility = .hidden
styleMask.remove(.titled)
backgroundColor = .clear
collectionView = makeCollectionView()
backgroundView = makeBackgroundView()
makeCollectionView()
makeBackgroundView()
contentView!.addSubview(backgroundView!)
// highest level possible; this allows the app to go on top of context menus
level = .screenSaver
Expand All @@ -34,28 +34,26 @@ class ThumbnailsPanel: NSPanel, NSCollectionViewDataSource, NSCollectionViewDele
makeKeyAndOrderFront(nil)
}

private func makeBackgroundView() -> NSVisualEffectView {
let backgroundView = NSVisualEffectView()
private func makeBackgroundView() {
backgroundView = NSVisualEffectView()
backgroundView.translatesAutoresizingMaskIntoConstraints = false
backgroundView.material = Preferences.windowMaterial
backgroundView.state = .active
backgroundView.wantsLayer = true
backgroundView.layer!.cornerRadius = Preferences.windowCornerRadius!
backgroundView.layer!.backgroundColor = .white
backgroundView.addSubview(collectionView)
return backgroundView
}

func makeCollectionView() -> NSCollectionView {
let collectionView_ = NSCollectionView()
collectionView_.dataSource = self
collectionView_.delegate = self
collectionView_.collectionViewLayout = CollectionViewCenterFlowLayout()
collectionView_.backgroundColors = [.yellow]
collectionView_.isSelectable = true
collectionView_.allowsMultipleSelection = false
collectionView_.register(Cell.self, forItemWithIdentifier: cellId)
return collectionView_
func makeCollectionView() {
collectionView = NSCollectionView()
collectionView.dataSource = self
collectionView.delegate = self
collectionView.collectionViewLayout = CollectionViewCenterFlowLayout()
collectionView.backgroundColors = [.yellow]
collectionView.isSelectable = true
collectionView.allowsMultipleSelection = false
collectionView.register(Cell.self, forItemWithIdentifier: cellId)
}

func collectionView(_ collectionView: NSCollectionView, numberOfItemsInSection section: Int) -> Int {
Expand Down

0 comments on commit 314801c

Please sign in to comment.