|
| 1 | +import AppKit |
| 2 | +import TGUIKit |
| 3 | +import ColorPalette |
| 4 | + |
| 5 | +_ = NSApplication.shared |
| 6 | +NSApp.setActivationPolicy(.accessory) |
| 7 | +let images = ["Icon_SearchField", "Icon_SearchClear", "Icon_Quote", "Icon_Quote_Collapse", "Icon_Quote_Expand"].map { name in |
| 8 | + let image = NSImage(size: NSSize(width: 16, height: 16), flipped: false) { _ in true } |
| 9 | + image.setName(name) |
| 10 | + return image |
| 11 | +} |
| 12 | +let initial = PresentationTheme.current |
| 13 | +System.updateScaleFactor(2) |
| 14 | +System.liquidGlass = true |
| 15 | +let window = Window(contentRect: NSMakeRect(150, 150, 620, 220), styleMask: [.borderless], backing: .buffered, defer: false) |
| 16 | +window.level = .floating |
| 17 | +window.isReleasedWhenClosed = false |
| 18 | +window.isOpaque = true |
| 19 | +window.hasShadow = false |
| 20 | +window.makeKeyAndOrderFront(nil) |
| 21 | +for (name, palette) in [("dark", nightAccentPalette), ("light", whitePalette)] { |
| 22 | + let theme = PresentationTheme(colors: palette, search: initial.search, inputTheme: initial.inputTheme) |
| 23 | + updateTheme(theme) |
| 24 | + for (phase, title) in [("before", __BEFORE__), ("after", __AFTER__)] { |
| 25 | + let root = View(frame: NSMakeRect(0, 0, 620, 220)) |
| 26 | + root.backgroundColor = palette.listBackground |
| 27 | + window.backgroundColor = palette.listBackground |
| 28 | + window.contentView = root |
| 29 | + for (text, y, size) in [("Recent Actions", CGFloat(20), CGFloat(17)), ("Alex joined the channel", CGFloat(84), CGFloat(14))] { |
| 30 | + let label = NSTextField(labelWithString: text) |
| 31 | + label.font = .systemFont(ofSize: size) |
| 32 | + label.textColor = size == 17 ? palette.text : palette.grayText |
| 33 | + label.frame = NSMakeRect(20, y, 580, 24) |
| 34 | + label.alignment = .center |
| 35 | + root.addSubview(label) |
| 36 | + } |
| 37 | + let settings = TextButton() |
| 38 | + __SETUP__ |
| 39 | + __STYLE__ |
| 40 | + settings.setFrameOrigin(NSMakePoint((root.frame.width - settings.frame.width) / 2, root.frame.height - settings.frame.height - 12)) |
| 41 | + root.addSubview(settings) |
| 42 | + root.layoutSubtreeIfNeeded() |
| 43 | + precondition(settings.frame.width >= settings.textSize.width + 30) |
| 44 | + precondition(root.bounds.contains(settings.frame)) |
| 45 | + RunLoop.main.run(until: Date(timeIntervalSinceNow: 0.25)) |
| 46 | + let capture = Process() |
| 47 | + capture.executableURL = URL(fileURLWithPath: "/usr/sbin/screencapture") |
| 48 | + capture.arguments = ["-x", "-o", "-l", String(window.windowNumber), __SNAPSHOTS__ + "/\(phase)-\(name).png"] |
| 49 | + try! capture.run() |
| 50 | + capture.waitUntilExit() |
| 51 | + precondition(capture.terminationStatus == 0) |
| 52 | + } |
| 53 | +} |
| 54 | +window.orderOut(nil) |
| 55 | +print("Native Recent Actions label captures saved; button fits and stays centered in both appearances.") |
0 commit comments