Skip to content

OrionTabbedLocationViewController

Corban Amouzou edited this page Jan 12, 2022 · 2 revisions

OrionTabbedLocationViewController

This hold all of our OrionSearchTabFields and connects them up by receiving their events and forwarding them to each-other. As this is like a controlled proxy service however, raw events are not completely forwarded, but translated into the events needed to allow all of the tabs to update synchronously.

class OrionTabbedLocationViewController: NSViewController 

Inheritance

NSViewController, OrionSearchFieldControllerDelegate, OrionWindowResizeDelegate, WKNavigationDelegate

Initializers

init(_:_:_:)

Creates a OrionTabbedLocationViewController with a specified delegate to manage it

init(
        _ delegate: OrionTabbedLocationViewControllerDelegate?,
        _ mockup: Bool,
        _ window: NSWindow? = nil
    ) 

Parameters

  • delegate: The owner of this class that manages the current tabs webview

init?(coder:)

required init?(coder: NSCoder) 

Properties

tabCount

var tabCount: Int 

mockup

A value determining if the view gets set up normally on creation or if only the UI properties are set and the delegation is not needed.

let mockup: Bool

stackView

Centralized tab collection

let stackView: NSStackView 

tabs

The list of all the tabs open in the window

var tabs: [OrionSearchFieldController] 

currentTab

The tab with focused context. Will not be nil

var currentTab: OrionSearchFieldController?

delegate

The delegate responsible for using the current tabs webview

weak var delegate: OrionTabbedLocationViewControllerDelegate?

userContentController

The content controller for all the tabs. Not recommended to share this among all of the webviews.

lazy var userContentController: OrionUserContentController 

Methods

tabWillClose(sender:)

func tabWillClose(sender: OrionSearchFieldController) 

tabWantsForeground(tab:)

func tabWantsForeground(tab: OrionSearchFieldController) 

updateAllTabs(_:_:)

Calls OrionSearchField.updateProperties(tabCount:​) on all of the tab search fields

func updateAllTabs(_ sender: OrionSearchFieldController?, _ windowSize: NSSize? = nil) 

Parameters

  • sender: Optional sender to directly control which tab has focus. If not supplied the focus is assumed to be the current tab.
  • windowSize: Optional size to update the width of the tabs with. Defaults to nil.

windowWillResize(toSize:)

A wrapper for all the tabs to update them without adding them all to the window resize observers

func windowWillResize(toSize: NSSize) 

webView(_:decidePolicyFor:decisionHandler:)

func webView(
        _ webView: WKWebView,
        decidePolicyFor navigationAction: WKNavigationAction,
        decisionHandler: @escaping (WKNavigationActionPolicy) -> Void
    ) 

webView(_:didFinish:)

func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) 

webView(_:didStartProvisionalNavigation:)

func webView(_ webView: WKWebView, didStartProvisionalNavigation navigation: WKNavigation!) 

webView(_:didFailProvisionalNavigation:withError:)

func webView(_ webView: WKWebView, didFailProvisionalNavigation navigation: WKNavigation!, withError error: Error) 

setupStackView(window:)

Sets up the stackView and makes it stretch across the entire toolbar

func setupStackView(window: NSWindow?) 

addTab()

Creates and adds a new tab the stackView and gives it foreground context

func addTab() 

removeTab(tab:)

Removes a tab and gives foreground context to the last tab in the tab array

func removeTab(tab: OrionSearchFieldController) 

Parameters

  • tab: The tab to remove from the window
Clone this wiki locally