]> git.r.bdr.sh - rbdr/captura/blame_incremental - Captura/Presentation/Popovers/HelpPopoverViewController.swift
Format the code
[rbdr/captura] / Captura / Presentation / Popovers / HelpPopoverViewController.swift
... / ...
CommitLineData
1/*
2 Copyright (C) 2024 Rubén Beltrán del Río
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see https://captura.tranquil.systems.
16 */
17import Cocoa
18
19class HelpPopoverViewController: NSViewController {
20
21 var labelString: String = "Captura"
22 let textField = NSTextField()
23
24 override func loadView() {
25 self.view = NSView()
26 self.view.frame = NSRect(x: 0, y: 0, width: 250, height: 40)
27
28 textField.stringValue = labelString
29 textField.font = NSFont(name: "Hiragino Mincho ProN", size: 12)
30 textField.isEditable = false
31 textField.isBezeled = false
32 textField.isSelectable = false
33 textField.backgroundColor = NSColor.clear
34 textField.sizeToFit()
35
36 let x = (view.frame.width - textField.frame.width) / 2
37 let y = (view.frame.height - textField.frame.height) / 2
38 textField.frame.origin = NSPoint(x: x, y: y)
39
40 self.view.addSubview(textField)
41 }
42
43 func updateLabel(_ newLabel: String) {
44 labelString = newLabel
45 textField.stringValue = labelString
46 textField.sizeToFit()
47
48 let x = (view.frame.width - textField.frame.width) / 2
49 let y = (view.frame.height - textField.frame.height) / 2
50 textField.frame.origin = NSPoint(x: x, y: y)
51 }
52}