Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide/show bottom panel #374

Merged
merged 4 commits into from Apr 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 14 additions & 2 deletions studio/LonaStudio/Workspace/ComponentEditorViewController.swift
Expand Up @@ -40,6 +40,11 @@ class ComponentEditorViewController: NSSplitViewController {
set { canvasAreaView.panningEnabled = newValue }
}

public var utilitiesViewVisible: Bool {
get { return bottomItem.isCollapsed }
set { setBottomItemVisibility(to: newValue) }
}

public var onInspectLayer: ((CSLayer?) -> Void)?
public var onChangeInspectedLayer: (() -> Void)?
public var onChangeInspectedCanvas: ((Int) -> Void)?
Expand Down Expand Up @@ -110,6 +115,8 @@ class ComponentEditorViewController: NSSplitViewController {
return vc
}()

private lazy var bottomItem = NSSplitViewItem(viewController: utilitiesViewController)

private func setUpViews() {
setUpUtilities()

Expand Down Expand Up @@ -210,9 +217,8 @@ class ComponentEditorViewController: NSSplitViewController {
mainItem.minimumThickness = 300
addSplitViewItem(mainItem)

let bottomItem = NSSplitViewItem(viewController: utilitiesViewController)
bottomItem.canCollapse = false
bottomItem.minimumThickness = 0
bottomItem.minimumThickness = 200
addSplitViewItem(bottomItem)
}

Expand Down Expand Up @@ -252,4 +258,10 @@ class ComponentEditorViewController: NSSplitViewController {
onSelectLayer: { self.onInspectLayer?($0) },
selectedLayerName: selectedLayerName)
}

private func setBottomItemVisibility(to visible: Bool) {
if (visible && bottomItem.isCollapsed) || (!visible && !bottomItem.isCollapsed) {
bottomItem.animator().isCollapsed = !visible
}
}
}
22 changes: 15 additions & 7 deletions studio/LonaStudio/Workspace/WorkspaceViewController.swift
Expand Up @@ -84,7 +84,11 @@ class WorkspaceViewController: NSSplitViewController {
public var activePanes: [WorkspacePane] {
get {
return WorkspacePane.all.filter {
return !(splitViewItem(for: $0)?.isCollapsed ?? true)
if $0 == .bottom {
return !(componentEditorViewController.utilitiesViewVisible)
} else {
return !(splitViewItem(for: $0)?.isCollapsed ?? true)
}
}
}
set {
Expand Down Expand Up @@ -303,13 +307,17 @@ class WorkspaceViewController: NSSplitViewController {
}

private func setVisibility(to visible: Bool, for pane: WorkspacePane, animate: Bool) {
guard let item = splitViewItem(for: pane) else { return }
if pane == .bottom {
componentEditorViewController.utilitiesViewVisible = visible
} else {
guard let item = splitViewItem(for: pane) else { return }

if (visible && item.isCollapsed) || (!visible && !item.isCollapsed) {
if animate {
item.animator().isCollapsed = !visible
} else {
item.isCollapsed = !visible
if (visible && item.isCollapsed) || (!visible && !item.isCollapsed) {
if animate {
item.animator().isCollapsed = !visible
} else {
item.isCollapsed = !visible
}
}
}
}
Expand Down