Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NS Scroll View Magnification #37

Draft
wants to merge 20 commits into
base: master
Choose a base branch
from

Conversation

jvmespark
Copy link

Fix issue where a layout manager's NSTextStorage could be `nil` at initialization
but later set by introducing the `_setTextStorage:` method to NSTextView.

Add stubs a for missing properties in NSTextView.

Refactor `firstTextView` to properly find and return the first text view,
or `nil` if there are no text views.

Use 64-bit ready types where applicable.

Relocate unrelated code from _setTextStorage
Adds code in `initWithData` to infer document format for RTF, HTML, and plaintext documents.
Additionally refactors NSAttributedString to use the correct attribute types as described in Apple's documentation.
Add stubs for content size, frame size, and magnification size,
and add basic implementations where feasible.
Implement NSTextTab handling based on the GNUStep implementation,
with formatting and other adjustments.
@jvmespark jvmespark marked this pull request as draft February 9, 2024 22:30
Copy link

@CuriousTommy CuriousTommy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haven't checked the changes in NSView.m yet.

Comment on lines 1 to 7
{
"files.associations": {
"*.embeddedhtml": "html",
"type_traits": "cpp",
"xtr1common": "cpp"
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like you accidentally commit your .vscode/settings.json. Don't forget to remove it and rebase your changes.

AppKit/NSScrollView.m Show resolved Hide resolved
AppKit/NSScrollView.m Show resolved Hide resolved
AppKit/NSScrollView.m Outdated Show resolved Hide resolved
AppKit/NSView.m Outdated Show resolved Hide resolved
Comment on lines +666 to +656
_bounds.origin.x = _bounds.origin.x / size.width;
_bounds.origin.y = _bounds.origin.y / size.height;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Related to the above note, this would probably needs some adjustments to support negative values.

Comment on lines 1059 to 1127
// scale the content view centered at the given point
NSRect frame = [_clipView frame];
NSSize scaledSize = NSMakeSize(frame.size.width*magnification, frame.size.height*magnification);
NSPoint centeredOrigin = NSMakePoint(point.x - (newSize.width/2), point.y - (newSize.height/2));
[_clipView setFrame:NSMakeRect(centeredOrigin.x, centeredOrigin.y, scaledSize.width, scaledSize.height)];
Copy link

@CuriousTommy CuriousTommy Feb 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Were you able to verify that the contentView does indeed get updated on macOS?

I'm having trouble verifying that it's frame get updated... =/

NSScrollView *_scrollView = [[NSScrollView alloc] init];
[_scrollView setFrame: NSMakeRect(0.0, 0.0, 480, 270)];
[[_scrollView documentView] setFrame: NSMakeRect(0.0, 0.0, 500, 1200)];
printFrame(_scrollView);
[scrollView minMagnification]: 0.250000
[scrollView maxMagnification]: 4.000000
[scrollView magnification]: 1.000000
[scrollView frame]->origin.x: 0.000000
[scrollView frame]->origin.y: 0.000000
[scrollView frame]->size.width: 480.000000
[scrollView frame]->size.height: 270.000000
[[scrollView contentView] frame]->origin.x: 0.000000
[[scrollView contentView] frame]->origin.y: 0.000000
[[scrollView contentView] frame]->size.width: 480.000000
[[scrollView contentView] frame]->size.height: 270.000000
[[scrollView documentView] frame]->origin.x: 0.000000
[[scrollView documentView] frame]->origin.y: 0.000000
[[scrollView documentView] frame]->size.width: 0.000000
[[scrollView documentView] frame]->size.height: 0.000000
[_scrollView setMagnification:10.0 centeredAtPoint:NSMakePoint(50, 50)];
printFrame(_scrollView);
[scrollView minMagnification]: 0.250000
[scrollView maxMagnification]: 4.000000
[scrollView magnification]: 4.000000
[scrollView frame]->origin.x: 0.000000
[scrollView frame]->origin.y: 0.000000
[scrollView frame]->size.width: 480.000000
[scrollView frame]->size.height: 270.000000
[[scrollView contentView] frame]->origin.x: 0.000000
[[scrollView contentView] frame]->origin.y: 0.000000
[[scrollView contentView] frame]->size.width: 480.000000
[[scrollView contentView] frame]->size.height: 270.000000
[[scrollView documentView] frame]->origin.x: 0.000000
[[scrollView documentView] frame]->origin.y: 0.000000
[[scrollView documentView] frame]->size.width: 0.000000
[[scrollView documentView] frame]->size.height: 0.000000

@CKegel CKegel force-pushed the NSScrollView-Magnification branch 2 times, most recently from 1ca619e to 4ee3782 Compare February 16, 2024 21:15
@CuriousTommy
Copy link

@CKegel @jvmespark Let me know when you are ready for me to review this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants