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 8 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
36 changes: 18 additions & 18 deletions DuckDuckGo-macOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8326,22 +8326,22 @@
isa = PBXGroup;
children = (
31F7F2A4288AD299001C0D64 /* BadgeAnimations */,
AA3439732754D55100B241FA /* trackers-1.json */,
AA3439742754D55100B241FA /* trackers-2.json */,
AA3439752754D55100B241FA /* trackers-3.json */,
AA34396A2754D4E200B241FA /* shield.json */,
AA34396B2754D4E300B241FA /* shield-dot.json */,
AA7EB6E027E7D05500036718 /* flame-mouse-over.json */,
AA7EB6E627E8809D00036718 /* shield-mouse-over.json */,
AA7EB6E827E880A600036718 /* shield-dot-mouse-over.json */,
AA3439762754D55100B241FA /* dark-trackers-1.json */,
AA3439722754D55100B241FA /* dark-trackers-2.json */,
AA3439772754D55100B241FA /* dark-trackers-3.json */,
AA7EB6E127E7D05500036718 /* dark-flame-mouse-over.json */,
AA34396F2754D4E900B241FA /* dark-shield.json */,
AA34396E2754D4E900B241FA /* dark-shield-dot.json */,
AA7EB6E127E7D05500036718 /* dark-flame-mouse-over.json */,
AA7EB6EA27E880AE00036718 /* dark-shield-mouse-over.json */,
AA7EB6EC27E880B600036718 /* dark-shield-dot-mouse-over.json */,
AA7EB6EA27E880AE00036718 /* dark-shield-mouse-over.json */,
AA3439762754D55100B241FA /* dark-trackers-1.json */,
AA3439722754D55100B241FA /* dark-trackers-2.json */,
AA3439772754D55100B241FA /* dark-trackers-3.json */,
AA7EB6E027E7D05500036718 /* flame-mouse-over.json */,
AA34396A2754D4E200B241FA /* shield.json */,
AA34396B2754D4E300B241FA /* shield-dot.json */,
AA7EB6E827E880A600036718 /* shield-dot-mouse-over.json */,
AA7EB6E627E8809D00036718 /* shield-mouse-over.json */,
AA3439732754D55100B241FA /* trackers-1.json */,
AA3439742754D55100B241FA /* trackers-2.json */,
AA3439752754D55100B241FA /* trackers-3.json */,
);
path = Animations;
sourceTree = "<group>";
Expand Down Expand Up @@ -8428,23 +8428,23 @@
AA86491624D8339A001BABEE /* View */ = {
isa = PBXGroup;
children = (
BBB9314C2D1F0F1700D50AC1 /* ShowToolbarsOnFullScreenMenuCoordinator.swift */,
AA7EB6EE27E880EA00036718 /* Animations */,
AAC5E4F025D6BF10007F5990 /* AddressBarButton.swift */,
AAC5E4F525D6BF2C007F5990 /* AddressBarButtonsViewController.swift */,
5614B3A02BBD639D009B5031 /* ZoomPopover.swift */,
AABEE6AE24AD22B90043105B /* AddressBarTextField.swift */,
B6676BE02AA986A700525A21 /* AddressBarTextEditor.swift */,
AABEE6AE24AD22B90043105B /* AddressBarTextField.swift */,
B60D64482AAF1B7C00B26F50 /* AddressBarTextSelectionNavigation.swift */,
14D9B8F924F7E089000D4D13 /* AddressBarViewController.swift */,
D64A5FF72AEA5C2B00B6D6E7 /* HomeButtonMenuFactory.swift */,
AAA0CC462533833C0079BC96 /* MoreOptionsMenu.swift */,
1DEDB3632C19934C006B6D1B /* MoreOptionsMenuButton.swift */,
85589E8C27BBBB870038AD11 /* NavigationBar.storyboard */,
AAA0CC32252F181A0079BC96 /* NavigationButtonMenuDelegate.swift */,
85012B0129133F9F003D0DCC /* NavigationBarPopovers.swift */,
AA68C3D22490ED62001B8783 /* NavigationBarViewController.swift */,
AAA0CC32252F181A0079BC96 /* NavigationButtonMenuDelegate.swift */,
B60293E52BA19ECD0033186B /* NetPPopoverManagerMock.swift */,
D64A5FF72AEA5C2B00B6D6E7 /* HomeButtonMenuFactory.swift */,
BBB9314C2D1F0F1700D50AC1 /* ShowToolbarsOnFullScreenMenuCoordinator.swift */,
5614B3A02BBD639D009B5031 /* ZoomPopover.swift */,
);
path = View;
sourceTree = "<group>";
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
9 changes: 9 additions & 0 deletions DuckDuckGo/Common/Extensions/NSPopoverExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ extension NSPopover {
self.contentViewController?.view.window?.parent ?? Self.mainWindow
}

@nonobjc var positioningView: NSView? {
guard self.responds(to: Selector.positioningView) else { return nil }
return self.perform(Selector.positioningView).takeUnretainedValue() as? NSView
}

/// prefferred bounding box for the popover positioning
@objc var boundingFrame: NSRect {
guard let mainWindow else { return .infinite }
Expand Down Expand Up @@ -122,4 +127,8 @@ extension NSPopover {
return nil
}

enum Selector {
static let positioningView = NSSelectorFromString("positioningView")
}

}
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 @@ -297,9 +297,9 @@ final class MainMenu: NSMenu {
toggleFullscreenMenuItem
NSMenuItem.separator()

actualSizeMenuItem
zoomInMenuItem
zoomOutMenuItem
actualSizeMenuItem
NSMenuItem.separator()

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

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

}
debugMenu.addItem(internalUserItem)
Expand Down
3 changes: 3 additions & 0 deletions DuckDuckGo/Menus/MainMenuActions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -459,14 +459,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