Created
January 4, 2021 05:49
-
-
Save yesmeck/82dad7155992a56cc45eb7016d3901e9 to your computer and use it in GitHub Desktop.
Kitchen toolbar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const agentView = NSStackView.alloc().init(); | |
const container = NSView.alloc().initWithFrame(NSMakeRect(0, 0, UI.TOOLBAR_DEFAULT_WIDTH, 400)); | |
container.identifier = pluginConstant.BAR_CONTAINER; | |
container.addSubview(agentView); | |
const viewsDictionary = { container, stack: agentView }; | |
const horizontalConstraints = NSLayoutConstraint.constraintsWithVisualFormat_options_metrics_views( | |
'H:|-0-[stack]-0-|', | |
0, | |
nil, | |
viewsDictionary, | |
); | |
const verticalConstraints = NSLayoutConstraint.constraintsWithVisualFormat_options_metrics_views( | |
'V:[stack]-0-|', | |
0, | |
nil, | |
viewsDictionary, | |
); | |
container.addConstraints(horizontalConstraints); | |
container.addConstraints(verticalConstraints); | |
const topAnchor = | |
util.systemVersion() >= '11.0.0' | |
? container.safeAreaLayoutGuide().topAnchor() | |
: container.topAnchor(); | |
agentView.topAnchor().constraintEqualToAnchor(topAnchor).setActive(true); | |
const viewController = NSViewController.alloc().init(); | |
viewController.view = container; | |
const toolbarView = NSSplitViewItem.splitViewItemWithViewController(viewController); | |
toolbarView.holdingPriority = NSLayoutPriorityRequired; | |
toolbarView.maximumThickness = UI.TOOLBAR_DEFAULT_WIDTH; | |
document.splitViewController().insertSplitViewItem_atIndex(toolbarView, 2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment