From c946c0ea4806f5355e98418d95fe3cdd3ce1baf8 Mon Sep 17 00:00:00 2001 From: Roopesh Chander Date: Wed, 2 Jan 2019 18:57:09 +0530 Subject: macOS: Manage tunnels: Add a filler button Signed-off-by: Roopesh Chander --- .../TunnelsListTableViewController.swift | 30 +++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'WireGuard/WireGuard/UI') diff --git a/WireGuard/WireGuard/UI/macOS/ViewController/TunnelsListTableViewController.swift b/WireGuard/WireGuard/UI/macOS/ViewController/TunnelsListTableViewController.swift index 7a4cdfa..05aabbe 100644 --- a/WireGuard/WireGuard/UI/macOS/ViewController/TunnelsListTableViewController.swift +++ b/WireGuard/WireGuard/UI/macOS/ViewController/TunnelsListTableViewController.swift @@ -65,11 +65,15 @@ class TunnelsListTableViewController: NSViewController { clipView.documentView = tableView scrollView.contentView = clipView + let fillerButton = FillerButton() + let containerView = NSView() containerView.addSubview(scrollView) containerView.addSubview(buttonBar) + containerView.addSubview(fillerButton) scrollView.translatesAutoresizingMaskIntoConstraints = false buttonBar.translatesAutoresizingMaskIntoConstraints = false + fillerButton.translatesAutoresizingMaskIntoConstraints = false NSLayoutConstraint.activate([ containerView.topAnchor.constraint(equalTo: scrollView.topAnchor), @@ -77,7 +81,11 @@ class TunnelsListTableViewController: NSViewController { containerView.trailingAnchor.constraint(equalTo: scrollView.trailingAnchor), scrollView.bottomAnchor.constraint(equalTo: buttonBar.topAnchor, constant: 1), containerView.leadingAnchor.constraint(equalTo: buttonBar.leadingAnchor), - containerView.bottomAnchor.constraint(equalTo: buttonBar.bottomAnchor) + containerView.bottomAnchor.constraint(equalTo: buttonBar.bottomAnchor), + scrollView.bottomAnchor.constraint(equalTo: fillerButton.topAnchor, constant: 1), + containerView.bottomAnchor.constraint(equalTo: fillerButton.bottomAnchor), + buttonBar.trailingAnchor.constraint(equalTo: fillerButton.leadingAnchor, constant: 1), + fillerButton.trailingAnchor.constraint(equalTo: containerView.trailingAnchor) ]) NSLayoutConstraint.activate([ @@ -141,3 +149,23 @@ extension TunnelsListTableViewController: NSTableViewDelegate { return cell } } + +class FillerButton: NSButton { + override var intrinsicContentSize: NSSize { + return NSSize(width: NSView.noIntrinsicMetric, height: NSView.noIntrinsicMetric) + } + + init() { + super.init(frame: CGRect.zero) + title = "" + bezelStyle = .smallSquare + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + override func mouseDown(with event: NSEvent) { + // Eat mouseDown event, so that the button looks enabled but is unresponsive + } +} -- cgit v1.2.3-59-g8ed1b