Skip to content
This repository has been archived by the owner on Feb 24, 2025. It is now read-only.

Zoom improvements #3810

Merged
merged 16 commits into from
Feb 12, 2025
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
323 changes: 16 additions & 307 deletions DuckDuckGo-macOS.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@
{
"identity" : "trackerradarkit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/duckduckgo/TrackerRadarKit.git",
"location" : "https://github.com/duckduckgo/TrackerRadarKit",
"state" : {
"revision" : "5de0a610a7927b638a5fd463a53032c9934a2c3b",
"version" : "3.0.0"
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"images" : [
{
"filename" : "Zoom-Page-Increase-16D.svg",
"filename" : "Union.pdf",
"idiom" : "universal"
}
],
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"images" : [
{
"filename" : "Shape 1.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"preserves-vector-representation" : true,
"template-rendering-intent" : "template"
}
}
Binary file not shown.
16 changes: 16 additions & 0 deletions DuckDuckGo/Assets.xcassets/Images/ZoomIn.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"images" : [
{
"filename" : "Shape 2.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"preserves-vector-representation" : true,
"template-rendering-intent" : "template"
}
}
Binary file not shown.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"images" : [
{
"filename" : "OptionsButtonMenuZoom.pdf",
"filename" : "Shape.pdf",
"idiom" : "universal"
}
],
Expand All @@ -10,6 +10,7 @@
"version" : 1
},
"properties" : {
"preserves-vector-representation" : true,
"template-rendering-intent" : "template"
}
}
Binary file not shown.
2 changes: 0 additions & 2 deletions DuckDuckGo/BookmarksBar/View/BookmarksBarMenuPopover.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ final class BookmarksBarMenuPopover: NSPopover {
private(set) var rootFolder: BookmarkFolder?

private(set) var preferredEdge: NSRectEdge?
private(set) weak var positioningView: NSView?

private var bookmarksMenuPopoverDelegate: BookmarksBarMenuPopoverDelegate? {
delegate as? BookmarksBarMenuPopoverDelegate
Expand Down Expand Up @@ -85,7 +84,6 @@ final class BookmarksBarMenuPopover: NSPopover {
tableView.addSubview(v)
}

self.positioningView = positioningView
self.preferredEdge = preferredEdge
viewController.adjustPreferredContentSize(positionedRelativeTo: positioningRect, of: positioningView, at: preferredEdge)
super.show(relativeTo: positioningRect, of: positioningView, preferredEdge: preferredEdge)
Expand Down
17 changes: 17 additions & 0 deletions DuckDuckGo/Common/Extensions/NSPopoverExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,22 @@ extension NSPopover {
self.contentViewController?.view.window?.parent ?? Self.mainWindow
}

private static let positioningViewKey = UnsafeRawPointer(bitPattern: "positioningViewKey".hashValue)!
private final class WeakPositioningViewRef: NSObject {
weak var view: NSView?
init(_ view: NSView? = nil) {
self.view = view
}
}
@nonobjc var positioningView: NSView? {
get {
(objc_getAssociatedObject(self, Self.positioningViewKey) as? WeakPositioningViewRef)?.view
}
set {
objc_setAssociatedObject(self, Self.positioningViewKey, newValue.map { WeakPositioningViewRef($0) }, .OBJC_ASSOCIATION_RETAIN)
}
}

/// prefferred bounding box for the popover positioning
@objc var boundingFrame: NSRect {
guard let mainWindow else { return .infinite }
Expand All @@ -65,6 +81,7 @@ extension NSPopover {
/// Shows the popover below the specified rect inside the view bounds with the popover's pin positioned in the middle of the rect
public func show(positionedBelow positioningRect: NSRect, in positioningView: NSView) {
assert(!positioningView.isHidden && positioningView.alphaValue > 0)
self.positioningView = positioningView

// We tap into `_currentFrameOnScreenWithContentSize:outAnchorEdge:` to adjust popover position
// inside bounds of its owner Main Window.
Expand Down
10 changes: 10 additions & 0 deletions DuckDuckGo/Common/View/AppKit/MouseOverButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,16 @@ internal class MouseOverButton: NSButton, Hoverable {
}
}

@IBInspectable var horizontalPadding: CGFloat = 0
@IBInspectable var verticalPadding: CGFloat = 0

override var intrinsicContentSize: NSSize {
var size = super.intrinsicContentSize
size.width += self.horizontalPadding
size.height += self.verticalPadding
return size
}

var normalTintColor: NSColor? {
didSet {
updateTintColor()
Expand Down
3 changes: 2 additions & 1 deletion DuckDuckGo/Menus/MainMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,9 @@ final class MainMenu: NSMenu {
toggleFullscreenMenuItem
NSMenuItem.separator()

actualSizeMenuItem
zoomInMenuItem
zoomOutMenuItem
actualSizeMenuItem
NSMenuItem.separator()

NSMenuItem(title: UserText.mainMenuDeveloper) {
Expand Down Expand Up @@ -766,6 +766,7 @@ final class MainMenu: NSMenu {

NSMenuItem(title: "Logging").submenu(setupLoggingMenu())
NSMenuItem(title: "AI Chat").submenu(AIChatDebugMenu())
NSMenuItem(title: "Zoom UI popover").submenu(ZoomPopoverDebugMenu())

if #available(macOS 14.4, *) {
NSMenuItem.separator()
Expand Down
3 changes: 3 additions & 0 deletions DuckDuckGo/Menus/MainMenuActions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -465,14 +465,17 @@ extension MainViewController {

@objc func zoomIn(_ sender: Any) {
getActiveTabAndIndex()?.tab.webView.zoomIn()
navigationBarViewController.addressBarViewController?.addressBarButtonsViewController?.openZoomPopover(source: .menu)
}

@objc func zoomOut(_ sender: Any) {
getActiveTabAndIndex()?.tab.webView.zoomOut()
navigationBarViewController.addressBarViewController?.addressBarButtonsViewController?.openZoomPopover(source: .menu)
}

@objc func actualSize(_ sender: Any) {
getActiveTabAndIndex()?.tab.webView.resetZoomLevel()
navigationBarViewController.addressBarViewController?.addressBarButtonsViewController?.openZoomPopover(source: .menu)
}

@objc func toggleDownloads(_ sender: Any) {
Expand Down
Loading
Loading