|
|
@@ -25,7 +25,10 @@ private final class TitlebarIconButton: NSButton {
|
|
|
private func commonInit() {
|
|
|
wantsLayer = true
|
|
|
layer?.cornerRadius = 5
|
|
|
- layer?.masksToBounds = true
|
|
|
+ // Do not mask the button’s bounds to the rounded rect: on a ~10×10 pt control,
|
|
|
+ // cornerRadius 5 + masksToBounds clips to a *circle* and cuts off corner-heavy
|
|
|
+ // bitmap icons (e.g. layout grid). SF Symbols stay fine due to built-in padding.
|
|
|
+ layer?.masksToBounds = false
|
|
|
}
|
|
|
|
|
|
override func updateTrackingAreas() {
|
|
|
@@ -87,6 +90,26 @@ private final class TitlebarIconButton: NSButton {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+/// Scales a bundled template image to a logical point size for the titlebar (SF Symbols here use 12pt; bitmap icons often need ~14pt to read the same optically).
|
|
|
+private func makeTitlebarSizedTemplateImage(named name: String, pointSize: CGFloat, layoutMarginFraction: CGFloat = 0) -> NSImage? {
|
|
|
+ guard let source = NSImage(named: name) else { return nil }
|
|
|
+ let logicalSize = NSSize(width: pointSize, height: pointSize)
|
|
|
+ let image = NSImage(size: logicalSize, flipped: false) { rect in
|
|
|
+ NSGraphicsContext.current?.imageInterpolation = .high
|
|
|
+ let inset = min(rect.width, rect.height) * layoutMarginFraction
|
|
|
+ let drawRect = rect.insetBy(dx: inset, dy: inset)
|
|
|
+ source.draw(
|
|
|
+ in: drawRect,
|
|
|
+ from: NSRect(origin: .zero, size: source.size),
|
|
|
+ operation: .sourceOver,
|
|
|
+ fraction: 1.0
|
|
|
+ )
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ image.isTemplate = true
|
|
|
+ return image
|
|
|
+}
|
|
|
+
|
|
|
final class InAppBrowserWindowManager {
|
|
|
static let shared = InAppBrowserWindowManager()
|
|
|
|
|
|
@@ -232,6 +255,9 @@ final class InAppBrowserWindowController: NSWindowController, NSWindowDelegate {
|
|
|
fallbackSymbolName: "square.on.square"
|
|
|
)
|
|
|
|
|
|
+ // Bundled PNG: 1x = layout-fluid-3, 2x = layout-fluid-4 @ 48px — slightly larger than 12pt symbols so the full glyph reads clearly.
|
|
|
+ widgetButton.image = makeTitlebarSizedTemplateImage(named: "widget_custom_icon", pointSize: 14, layoutMarginFraction: 0)
|
|
|
+
|
|
|
// Center site identity (logo + app/site name).
|
|
|
siteIconView = NSImageView()
|
|
|
siteIconView.translatesAutoresizingMaskIntoConstraints = false
|