Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Correctly preview non-text files#1707

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Merged
Changes from1 commit
Commits
Show all changes
66 commits
Select commitHold shift + click to select a range
6f30d92
Package.resolved changed
plbstlMay 7, 2024
7113389
progress
plbstlMay 7, 2024
9a85005
minor doc change in CodeEditUI EffectView
plbstlMay 7, 2024
6749915
add WorkspacePdfFileView
plbstlMay 7, 2024
3d3893e
allow WorkspacePdfFileView to be able to send data to SwiftUI
plbstlMay 7, 2024
bd3fe37
properly name `WorkspacePdfFileView` to `WorkspacePDFView`
plbstlMay 8, 2024
a12e51c
improve WorkspacePDFView docs
plbstlMay 8, 2024
2b59534
add guards to WorkspacePDFView (makeNSView, updateNSView)
plbstlMay 8, 2024
6797552
wip
plbstlMay 8, 2024
15291c0
wip 2
plbstlMay 8, 2024
2fd13b4
correct padding
plbstlMay 8, 2024
7ae71a0
progress? not
plbstlMay 8, 2024
ff47ae8
add attachPDFDocumentToView helper in WorkspacePDFView
plbstlMay 9, 2024
d820eb9
update WorkspacePDFView docs
plbstlMay 9, 2024
b5f1614
remove WorkspaceNonTextFileView
plbstlMay 9, 2024
7ef3116
fix SwiftLint violations in WorkspacePDFView, WorkspaceCodeFileView
plbstlMay 9, 2024
6d7f7d8
add magic numbers comment to WorkspaceCodeFileView
plbstlMay 9, 2024
2192c70
update WorkspacePDFView docs
plbstlMay 9, 2024
74cd22b
before i forget
plbstlMay 9, 2024
8ef8461
progressss
plbstlMay 9, 2024
a643b43
too slow
plbstlMay 9, 2024
f583df0
wip: the best work yet
plbstlMay 9, 2024
410f62d
it really works!!
plbstlMay 9, 2024
b80dc31
add WorkspaceImageView
plbstlMay 9, 2024
a9ed5ad
add WorkspaceCannotPreviewFileView
plbstlMay 9, 2024
ff57cc8
its working very predictably but showing/hiding navigator pane isn't …
plbstlMay 9, 2024
1813416
remove the use of canPreview as it can cause unexpected behaviour
plbstlMay 9, 2024
6106b64
remove computeFrame helper in WorkspaceCodeFileView
plbstlMay 9, 2024
dc7bcad
update PDF preview's background color
plbstlMay 9, 2024
2e4dd02
add note for when PDF preview cannot create PDF document
plbstlMay 9, 2024
c2fcacc
improve docs for WorkspaceImageView & WorkspacePDFView
plbstlMay 9, 2024
2d448f6
use unnamed parameter for imageUrl in WorkspaceImageView
plbstlMay 9, 2024
f2ca164
implement `WorkspaceCannotPreviewFileView`
plbstlMay 9, 2024
c248a9d
change url variables in `WorkspaceImageView`, `WorkspacePDFView` & `W…
plbstlMay 9, 2024
82ef086
add `WorkspaceLoadingView`
plbstlMay 9, 2024
eb15141
spacing violation
plbstlMay 9, 2024
d32436a
change onAppear modifier in WorkspaceCannotPreviewFileView
plbstlMay 9, 2024
4238f2c
remove `WorkspaceCannotPreviewFileView` as it creates a bug that make…
plbstlMay 9, 2024
5c5c81b
improve docs in `WorkspacePDFView` & `WorkspaceImageView`
plbstlMay 9, 2024
752fe3b
use `WorkspaceAnyFileView` to preview GIF images
plbstlMay 9, 2024
40d52c6
add a note to the documentation for `CodeFileDocument.utType`
plbstlMay 9, 2024
b24b6ff
add `WorkspaceAnyFileView` to properly preview files of different fil…
plbstlMay 9, 2024
d2664bd
rearrange files in `CodeEdit/Features/Documents/Views`
plbstlMay 9, 2024
2fbc351
add `WorkspaceAnyFileView`, `WorkspaceLoadingView`, `WorkspaceImageVi…
plbstlMay 9, 2024
afc0a82
update docs in `WorkspaceAnyFileView`, `WorkspaceLoadingView`, `Works…
plbstlMay 9, 2024
ccc79b3
rename `CodeFileDocument.typeOfFile` to `CodeFileDocument.utType`
plbstlMay 9, 2024
6561d25
fix: allow GIF previews to play, and with their proper dimensions
plbstlMay 9, 2024
12aa788
do not return
plbstlMay 9, 2024
f039914
update docs for CodeFileDocument.utType
plbstlMay 9, 2024
b660ac7
change conformance from movie to audiovisualContent in CodeFileDocume…
plbstlMay 9, 2024
d0c2671
properly display CodeFileView contents by undo-ing the padding in its…
plbstlMay 10, 2024
1b8c8b3
remove text, image, PDF, video restrictions on `CodeFileDocument.utType`
plbstlMay 10, 2024
2ac22a7
update docs in WorkspaceImageView
plbstlMay 10, 2024
c3d31a6
WorkspaceCodeFileView: group non-text files, so they inherit modifier…
plbstlMay 10, 2024
12e0ba1
WorkspaceCodeFileView: add important note on document.utType
plbstlMay 10, 2024
8f04013
remove SwiftUI VideoPlayer view for now, it creates a bug that I can'…
plbstlMay 10, 2024
acb8a63
add `NonTextFileView` to clean up code
plbstlMay 10, 2024
9688746
remove QLPreviewItem subclass from CodeFileDocument
plbstlMay 10, 2024
425f806
rename `WorkspaceCodeFileView` to `EditorAreaFileView`
plbstlMay 10, 2024
151e345
rename `EditorView` to `EditorAreaView`
plbstlMay 10, 2024
fe1f7bb
rename 4 Workspace view files
plbstlMay 10, 2024
cb88ec2
move views for opening files to `CodeEdit/Features/Editor`
plbstlMay 10, 2024
096bb68
move `CodeFileDocument` to `CodeEdit/Features/Documents`
plbstlMay 10, 2024
cf17bc7
NSTableViewWrapper: minor change in comment
plbstlMay 10, 2024
950d7ed
move `WindowCodeFileView` to `CodeEdit/Features/Editor/Views`
plbstlMay 10, 2024
b373bb6
use `AnyFileView` to view all images
plbstlMay 10, 2024
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
PrevPrevious commit
NextNext commit
wip: the best work yet
  • Loading branch information
@plbstl
plbstl committedMay 9, 2024
commitf583df0444bad96dce9f4e65e0b80b57fc0f4727
85 changes: 45 additions & 40 deletionsCodeEdit/Features/Documents/Views/WorkspaceCodeFileView.swift
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -12,6 +12,7 @@ import AVKit
import PDFKit
import QuickLookUI
import QuickLook
import AppKit

struct WorkspaceCodeFileView: View {

Expand All@@ -32,23 +33,23 @@ struct WorkspaceCodeFileView: View {
private func computeFrame (
pixelWidth: CGFloat,
proxyWidth: CGFloat,
nsImageWidth: CGFloat,
pixelHeight: CGFloat,
proxyHeight: CGFloat,
nsImageHeight: CGFloat
proxyHeight: CGFloat
) -> (CGFloat, CGFloat) {
let aspectRatio = pixelWidth / pixelHeight
var frameWidth = min(pixelWidth, nsImageWidth)
var frameHeight = min(pixelHeight, nsImageHeight)

if frameWidth > proxyWidth {
frameHeight = min(pixelHeight, proxyHeight, nsImageHeight)
frameWidth = frameHeight * aspectRatio
} else if frameHeight > proxyHeight {
frameWidth = min(pixelWidth, proxyWidth, nsImageWidth)
var frameWidth = pixelWidth
var frameHeight = pixelHeight

if pixelWidth > proxyWidth {
frameWidth = proxyWidth
frameHeight = frameWidth / aspectRatio
}

if pixelHeight >= proxyHeight {
frameHeight = proxyHeight
frameWidth = aspectRatio * frameHeight
}

return (frameWidth, frameHeight)
}

Expand All@@ -68,40 +69,44 @@ struct WorkspaceCodeFileView: View {
var _ = print("proxy.size:", proxy.size.width, proxy.size.height)
var _ = print("pixels:", pixelWidth, pixelHeight)
var _ = print("nsImage.size:", nsImage.size.width, nsImage.size.height)
var _ = print("proxWidth rm:", proxy.size.width - 1680)
var _ = print("proxWidth:", proxy.size.width)

let (frameWidth, frameHeight) = computeFrame(
pixelWidth: pixelWidth,
proxyWidth: proxy.size.width,
nsImageWidth: nsImage.size.width,
pixelHeight: pixelHeight,
proxyHeight: proxy.size.height,
nsImageHeight: nsImage.size.height
)
// let (frameWidth, frameHeight) = computeFrame(
// pixelWidth: pixelWidth,
// proxyWidth: proxy.size.width,
// pixelHeight: pixelHeight,
// proxyHeight: proxy.size.height
// )

var _ = print("frame:", frameWidth, frameHeight)
//var _ = print("frame:", frameWidth, frameHeight)
var _ = print("----------")

// ZStack(alignment: .bottomTrailing) {
Image(nsImage: nsImage)
.resizable()
.background(.red)
.scaledToFit()
.background(.blue)
.frame( // 3328 235 - 1352.97 901.98... w/h = aspect ratio; minH * aspectRatio = maxWidth
// its width that is changing
// w/h = aspect ratio; if minW > proxyW, newW = proxyW, newH = newW/aspectRatio
maxWidth: frameWidth,
maxHeight: frameHeight
// maxWidth: min(pixelWidth, proxy.size.width, nsImage.size.width),
// maxHeight: min(pixelHeight, proxy.size.height, nsImage.size.height)
)
// .position(x: proxy.frame(in: .local).midX / 2, y: proxy.frame(in: .local).midY)
.background(.gray)
.border(.purple)
// }
ZStack {
Image(nsImage: nsImage)
.resizable()
.background(.red)
.scaledToFit()
.background(.blue)
// .frame(
// 3328 235 - 1352.97 901.98... w/h = aspect ratio; minH * aspectRatio = maxWidth
// its width that is changing
// w/h = aspect ratio; if minW > proxyW, newW = proxyW, newH = newW/aspectRatio
// maxWidth: proxy.size.width,
// maxHeight: proxy.size.height
// maxWidth: min(pixelWidth, proxy.size.width, nsImage.size.width),
// maxHeight: min(pixelHeight, proxy.size.height, nsImage.size.height)
// )
// .position(x: proxy.frame(in: .local).midX / 2, y: proxy.frame(in: .local).midY)
.background(.gray)
// .scaleEffect(0.7891589506, anchor: .leading)
.border(.purple)
.border(.orange)
}
// .padding(.leading, (proxy.size.width - pixelWidth) / 2)
// .frame(maxWidth: proxy.size.width / 2, maxHeight: proxy.size.height - 50)
// .background(.black)
.frame(width: proxy.size.width, height: proxy.size.height)
.border(.yellow)
.background(.black)

}
.padding(.top, edgeInsets.top - 1.74)
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp