The open-source Arc replacement for macOS. Spaces, pinned tabs, split view, Little Windows and Arc's shortcuts on Chromium, with your Arc sidebar imported in one go.
A tab dropped on a pinned tab offers a split view, like Arc
Victor1f3c3d3610d9
diff --git a/Sources/Cra/App/AppDelegate.swift b/Sources/Cra/App/AppDelegate.swiftindex eb6802e..75a2ab1 100644--- a/Sources/Cra/App/AppDelegate.swift+++ b/Sources/Cra/App/AppDelegate.swift@@ -769,7 +769,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuItemValidation {if let c = dict["combine"], let content = main.window?.contentView {let tabs = store.children(of: store.focusedSpace.todayContainerID).filter { $0.tab != nil }guard tabs.count > 1 else { return }- let kind: CombineDropPreview.Kind = c == "folder" ? .folder : .split(leading: c == "leading")+ let kind = CombineDropPreview.Kind.split(leading: c == "leading")let pal = store.focusedSpace.theme.palettelet v = CombineDropPreview(kind: kind, target: tabs[0], dragged: tabs[1], depth: 0, palette: pal, favicons: favicons)v.frame = NSRect(x: 10, y: content.bounds.height - 420, width: 300, height: CraMetrics.rowHeight)diff --git a/Sources/Cra/UI/Sidebar/List/SpaceListView.swift b/Sources/Cra/UI/Sidebar/List/SpaceListView.swiftindex c992692..6fbd30c 100644--- a/Sources/Cra/UI/Sidebar/List/SpaceListView.swift+++ b/Sources/Cra/UI/Sidebar/List/SpaceListView.swift@@ -240,9 +240,6 @@ final class SpaceListView: NSView, NSDraggingSource {case .split(let t, let leading)? where t == id:d.combine = .split(leading: leading)d.combineDragged = drop.draggedID- case .newFolder(let t)? where t == id:- d.combine = .folder- d.combineDragged = drop.draggedIDdefault: break}return d@@ -379,7 +376,6 @@ final class SpaceListView: NSView, NSDraggingSource {switch target {case .insert(let parent, _): lands = isPinnedList(parent) ? .pinned : .todaycase .into(let id): lands = isPinnedList(id) ? .pinned : .today- case .newFolder: lands = .pinnedcase .split: lands = .today}return lands == (isPinnedList(drop.draggedID) ? .pinned : .today) ? nil : lands@@ -922,7 +918,7 @@ final class SpaceListView: NSView, NSDraggingSource {ui.listDrop = drop// A tick when a row starts offering to combine, so the change of meaning is felt as well as seen.switch drop.target {- case .split?, .newFolder?:+ case .split?:if store.settings.hapticFeedbackOnReorder { NSHapticFeedbackManager.defaultPerformer.perform(.generic, performanceTime: .now) }default: break}@@ -971,8 +967,6 @@ final class SpaceListView: NSView, NSDraggingSource {switch drop.target {case .insert(let parent, let index)?:store.moveItems(group, to: parent, index: index)- case .newFolder(let tab)?:- if let folder = store.createFolder(combining: tab, with: group) { ui.renamingID = folder.id }case .split(let tab, let leading)?:store.createSplit(with: leading ? [id, tab] : [tab, id], at: tab)case .into(let target)?:@@ -1022,9 +1016,9 @@ final class SpaceListView: NSView, NSDraggingSource {else if f >= 0.75 { target = store.isExpanded(rid) ? .insert(parent: rid, index: 0) : after }else { target = .into(rid) }} else if middle && isTab && item.isTab {- target = isInside(rid, space.todayContainerID)- ? .split(with: rid, leading: p.x < r.frame.midX)- : .newFolder(with: rid)+ // Arc combines two tabs into a split wherever the target sits (#191): a pinned+ // one stays pinned and the split opens in Today with a copy of it.+ target = .split(with: rid, leading: p.x < r.frame.midX)} else if middle && isTab && item.isSplit {target = .into(rid)} else {@@ -1054,7 +1048,7 @@ final class SpaceListView: NSView, NSDraggingSource {switch target {case .into(let f)? where store.item(f)?.isLiveFolder == true: target = nilcase .insert(let parent, _)? where store.item(parent)?.isLiveFolder == true && store.item(id)?.parentID != parent: target = nil- case .newFolder(let tab)? where store.item(store.item(tab)?.parentID ?? tab)?.isLiveFolder == true: target = nil+ case .split(let tab, _)? where store.item(store.item(tab)?.parentID ?? tab)?.isLiveFolder == true: target = nildefault: break}diff --git a/Sources/Cra/UI/Sidebar/SidebarListDrop.swift b/Sources/Cra/UI/Sidebar/SidebarListDrop.swiftindex 2968b5c..5ed886e 100644--- a/Sources/Cra/UI/Sidebar/SidebarListDrop.swift+++ b/Sources/Cra/UI/Sidebar/SidebarListDrop.swift@@ -7,10 +7,8 @@ struct SidebarListDrop: Equatable {enum Target: Equatable {/// Before the child at `index` of `parent` (`index == count` appends).case insert(parent: UUID, index: Int)- /// A new folder holding this tab and the dragged one (a pinned tab).- case newFolder(with: UUID)- /// A split of this tab and the dragged one (a Today tab); the dragged- /// tab takes the left pane when `leading`, else the right.+ /// A split of this tab and the dragged one (Arc's drag-to-combine, pinned or Today, #191);+ /// the dragged tab takes the left pane when `leading`, else the right.case split(with: UUID, leading: Bool)/// Into a folder or a split row.case into(UUID)@@ -89,16 +87,12 @@ final class DragAutoscroller {}}-/// A tab row while another tab hovers over its middle, drawn as the row the-/// drop makes: in Today the row splits open and the dragged tab slides into a-/// dashed pane on the side it will take (the split row's own layout), moving-/// across when the pointer crosses the row's middle; in Pinned it becomes a-/// "New Folder" row with both tabs' icons dropping into a stack.-/// What dropping a row onto another would make, drawn over the target row: a split with the-/// dragged tab sliding in beside it under a dashed outline, or a new folder with both icons.+/// A tab row while another tab hovers over its middle, drawn as the split the drop makes:+/// the row splits open and the dragged tab slides into a dashed pane on the side it will take+/// (the split row's own layout), moving across when the pointer crosses the row's middle.@MainActorfinal class CombineDropPreview: NSView {- enum Kind: Equatable { case split(leading: Bool), folder }+ enum Kind: Equatable { case split(leading: Bool) }private let kind: Kindprivate let target: SidebarItem@@ -168,7 +162,6 @@ final class CombineDropPreview: NSView {}switch kind {case .split(let leading): buildSplit(leading: leading)- case .folder: buildFolder()}CATransaction.commit()}@@ -232,70 +225,4 @@ final class CombineDropPreview: NSView {addSubview(line)Self.spring(line.layer, "opacity", from: 0.0, to: 1.0)}-- // MARK: Folder-- private func buildFolder() {- let x0 = CraMetrics.rowLeading + CGFloat(depth) * CraMetrics.indent- let h = bounds.height- let tones = palette.folderColors(nil)- // The folder: its outline over its fill, popping from 40%.- let folder = CALayer()- folder.frame = NSRect(x: x0, y: (h - 16) / 2, width: CraMetrics.favicon, height: 16)- for (name, color) in [("folder.fill", NSColor(tones.fill)), ("folder", NSColor(tones.tint))] {- let l = CALayer()- l.frame = folder.bounds- l.contentsGravity = .center- l.contentsScale = window?.backingScaleFactor ?? 2- l.contents = NSImage(systemSymbolName: name, accessibilityDescription: nil)?- .withSymbolConfiguration(.init(pointSize: 15, weight: .regular).applying(.init(paletteColors: [color])))- folder.addSublayer(l)- }- layer?.addSublayer(folder)- Self.spring(folder, "transform.scale", from: 0.4, to: 1.0)- Self.spring(folder, "opacity", from: 0.0, to: 1.0)- let label = NSTextField.sidebarLabel(size: 14, weight: .medium)- label.stringValue = "New Folder"- label.textColor = colors.textPrimary- let lx = x0 + CraMetrics.favicon + 11- label.frame = NSRect(x: lx - SidebarText.inset, y: (h - 17) / 2, width: max(0, bounds.width - lx - 60) + 2 * SidebarText.inset, height: 17)- addSubview(label)- // Both icons stacked 14 pt from the trailing edge, fanning out.- let cx = bounds.width - 6 - 14 - 10- let back = stackedIcon(target, centre: CGPoint(x: cx, y: h / 2))- let front = stackedIcon(dragged, centre: CGPoint(x: cx, y: h / 2))- // SwiftUI's angles and offsets as they are: this view is flipped, y grows down like SwiftUI's.- back.transform = CATransform3DConcat(CATransform3DMakeRotation(-6 * .pi / 180, 0, 0, 1), CATransform3DMakeTranslation(-5, 0, 0))- front.transform = CATransform3DConcat(CATransform3DMakeRotation(7 * .pi / 180, 0, 0, 1), CATransform3DMakeTranslation(6, 0, 0))- Self.spring(back, "transform", from: CATransform3DIdentity, to: back.transform)- Self.spring(front, "transform", from: CATransform3DMakeTranslation(22, -8, 0), to: front.transform)- Self.spring(front, "opacity", from: 0.0, to: 1.0)- }-- private func stackedIcon(_ item: SidebarItem, centre: CGPoint) -> CALayer {- let l = CALayer()- l.bounds = CGRect(x: 0, y: 0, width: 20, height: 20)- l.position = centre- l.cornerRadius = 5- l.cornerCurve = .continuous- l.backgroundColor = (palette.isDark ? NSColor(white: 0.22, alpha: 1) : .white).cgColor- l.shadowColor = NSColor.black.cgColor- l.shadowOpacity = 0.15- l.shadowRadius = 1.5- l.shadowOffset = CGSize(width: 0, height: 0.5)- let icon = SidebarFaviconView(size: 14)- icon.show(favicons.image(forKey: item.tab?.iconKey), flip: favicons.glyphIsDark(forKey: item.tab?.iconKey) == palette.isDark, colors: colors)- let face = CALayer()- face.frame = CGRect(x: 3, y: 3, width: 14, height: 14)- face.contentsGravity = .resizeAspect- face.contentsScale = window?.backingScaleFactor ?? 2- face.cornerRadius = 14 * 0.22- face.masksToBounds = true- if let image = icon.image {- face.contents = image.layerContents(forContentsScale: face.contentsScale)- }- l.addSublayer(face)- layer?.addSublayer(l)- return l- }}