aboutsummaryrefslogtreecommitdiff
path: root/Sources/phbar/Views
diff options
context:
space:
mode:
authorTommaso Negri <me@tommasongr.com>2026-08-09 23:58:42 +0200
committerTommaso Negri <me@tommasongr.com>2026-08-09 23:58:44 +0200
commitd59b22e557fa5d69ea6be725a7e5bcd829588225 (patch)
tree618e20ef2b648e46eac3d51e14b8e0fcc1faba3c /Sources/phbar/Views
parent62ce97dcb63d61c8db739c1b32bd387042ca66a0 (diff)
downloadbar-d59b22e557fa5d69ea6be725a7e5bcd829588225.tar.gz
bar-d59b22e557fa5d69ea6be725a7e5bcd829588225.zip
rename project and add documentation guides
Diffstat (limited to 'Sources/phbar/Views')
-rw-r--r--Sources/phbar/Views/BarView.swift29
-rw-r--r--Sources/phbar/Views/BarWindow.swift32
-rw-r--r--Sources/phbar/Views/BlockView.swift60
-rw-r--r--Sources/phbar/Views/CellView.swift11
4 files changed, 0 insertions, 132 deletions
diff --git a/Sources/phbar/Views/BarView.swift b/Sources/phbar/Views/BarView.swift
deleted file mode 100644
index 7ad7c4c..0000000
--- a/Sources/phbar/Views/BarView.swift
+++ /dev/null
@@ -1,29 +0,0 @@
-import SwiftUI
-
-struct BarView: View {
- private let left: [Block]
- private let right: [Block]
-
- init(blocks: [Block]) {
- self.left = blocks.filter { $0.placement == .left }
- self.right = blocks.filter { $0.placement == .right }
- }
-
- var body: some View {
- HStack(spacing: 0) {
- ForEach(left) { block in
- BlockView(block: block)
- }
-
- Spacer()
-
- ForEach(right) { block in
- BlockView(block: block)
- }
- }
- .font(Config.font)
- .foregroundStyle(Config.foreground)
- .frame(maxWidth: .infinity, maxHeight: Config.height)
- .background(Config.background)
- }
-}
diff --git a/Sources/phbar/Views/BarWindow.swift b/Sources/phbar/Views/BarWindow.swift
deleted file mode 100644
index ce65432..0000000
--- a/Sources/phbar/Views/BarWindow.swift
+++ /dev/null
@@ -1,32 +0,0 @@
-import AppKit
-
-final class BarWindow: NSPanel {
- init(contentRect: NSRect) {
- super.init(
- contentRect: contentRect,
- styleMask: [.nonactivatingPanel, .borderless],
- backing: .buffered,
- defer: false
- )
-
- animationBehavior = .none
- backgroundColor = .clear
- becomesKeyOnlyIfNeeded = true
- collectionBehavior = [
- .canJoinAllSpaces,
- .fullScreenAuxiliary,
- .fullScreenNone,
- .stationary,
- ]
- hasShadow = false
- hidesOnDeactivate = false
- isFloatingPanel = true
- isMovable = false
- isOpaque = false
- isReleasedWhenClosed = false
- level = .floating
- }
-
- override var canBecomeMain: Bool { false }
- override var canBecomeKey: Bool { true }
-}
diff --git a/Sources/phbar/Views/BlockView.swift b/Sources/phbar/Views/BlockView.swift
deleted file mode 100644
index 85d6e6e..0000000
--- a/Sources/phbar/Views/BlockView.swift
+++ /dev/null
@@ -1,60 +0,0 @@
-import SwiftUI
-
-struct BlockView: View {
- @ObservedObject var block: Block
-
- @State private var hovering = false
-
- var body: some View {
- HStack(spacing: 0) {
- ForEach(block.cells) { cell in
- CellView(cell: cell)
- }
- }
- .onHover { hovering = $0 }
- .onAppear {
- NSEvent.addLocalMonitorForEvents(matching: [
- .leftMouseDown,
- .rightMouseDown,
- .otherMouseDown,
- .scrollWheel,
- ]) { event in
- handle(event: event)
- }
- }
- }
-
- private func handle(event: NSEvent) -> NSEvent {
- guard hovering else { return event }
-
- switch event.type {
- case .leftMouseDown, .rightMouseDown, .otherMouseDown:
- block.runScript(env: ["BUTTON": String(event.buttonNumber)])
- break
- case .scrollWheel:
- if event.scrollingDeltaY > 0 {
- block.runScript(env: ["SCROLL": "UP"])
- break
- }
-
- if event.scrollingDeltaY < 0 {
- block.runScript(env: ["SCROLL": "DOWN"])
- break
- }
-
- if event.scrollingDeltaX > 0 {
- block.runScript(env: ["SCROLL": "RIGHT"])
- break
- }
-
- if event.scrollingDeltaX < 0 {
- block.runScript(env: ["SCROLL": "LEFT"])
- break
- }
- default:
- break
- }
-
- return event
- }
-}
diff --git a/Sources/phbar/Views/CellView.swift b/Sources/phbar/Views/CellView.swift
deleted file mode 100644
index 6b39eb1..0000000
--- a/Sources/phbar/Views/CellView.swift
+++ /dev/null
@@ -1,11 +0,0 @@
-import SwiftUI
-
-struct CellView: View {
- var cell: Cell
-
- var body: some View {
- Text(cell.rawValue)
- .frame(height: Config.height)
- .background(cell.background)
- }
-}