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

Update NSView with setShadow:/shadow methods #229

Merged
merged 11 commits into from
Dec 27, 2023

Conversation

gcasa
Copy link
Member

@gcasa gcasa commented Dec 24, 2023

Please see the bug here: #217

@gcasa
Copy link
Member Author

gcasa commented Dec 24, 2023

I think that this might give some clue as to how to do this in the backend. I am not sure that shadows necessarily need layers to work.
https://stackoverflow.com/questions/30630280/how-do-i-create-a-circular-shadow-effect-with-cairo

@gcasa
Copy link
Member Author

gcasa commented Dec 24, 2023

Also of interest MIGHT be... https://github.com/rcairo/rcairo/blob/master/lib/cairo/context/blur.rb

I know these examples are in different languages, but they are both using cairo, so I wanted to note them here.

@gcasa
Copy link
Member Author

gcasa commented Dec 24, 2023

It seems as though the keys being used are these...

[heron@nomad Base.lproj] % strings MainMenu.nib | grep -i shadow                                     [0]
NSShadowHoriz
IBNSShadowedSymbolConfiguration
NSShadowVert
NSViewShadow
NSShadowBlurRadius
NSShadowColor
NSShadow_Test
NSShadow_Test
Quit NSShadow_Test
Quit NSShadow_Test
About NSShadow_Test
About NSShadow_Test
NSShadow_Test Help
NSShadow_Test Help
Hide NSShadow_Test
Hide NSShadow_Test
NSShadow_Test
NSShadow_Test
NSShadow

The new NIBArchive format is proving to be a menace at analyzing nib files for keys... but since we can read xib files it is not a problem, but it is a format we might want to consider looking at in the future. GC

@gcasa
Copy link
Member Author

gcasa commented Dec 25, 2023

Yet more info about blur... https://discourse.gnome.org/t/cairo-gaussian-blur-for-shadows/2174

Source/NSView.m Outdated Show resolved Hide resolved
@gcasa
Copy link
Member Author

gcasa commented Dec 26, 2023

Okay, so now I have got everything decoding for the NSShadow from the XIB properly. I am going to work on the backend now. Some changes might be needed in libs-gui, but I doubt it.

@fredkiefer
Copy link
Member

Let me try to explain this once more:

  • You should start off by implementing direct drawing of the shadow. For this you will need to add a setShadow: method on the GSGraphicsContext class to be called from [NSShadow set]. After that you just need to implement that method or rather the actual handling of the shadow while drawing in the Cairo graphics context in the backend.
  • Implementing the shadow drawing for a view requires more changes in gui. When drawing a view we always clip to the frame of the view. This means, when drawing the shadow from the view drawing code, it would never be visible. Most likely we need to draw it from the super view context somewhere in the whole view hierarchy drawing code. But this is only part of the problem. You also need to figure out what parts of the screen need to be invalidated when a view with a shadow requires a redraw. Please take your time here. A complete day just trying to understand the existing code would be well spend. Then figure out what extensions will be required and before implementing them, let us discuss your approach.

I would suggest to merge this PR here separately and not wait until you have the complete implementation in place.

@gcasa
Copy link
Member Author

gcasa commented Dec 26, 2023

Okay. Thank you for the great input. I will change this PR to ready and if you find it suitable, then please approve.

@gcasa gcasa marked this pull request as ready for review December 26, 2023 19:14
@gcasa
Copy link
Member Author

gcasa commented Dec 26, 2023

I will open another PR for the shadow work in GSGraphicsContext.

@gcasa
Copy link
Member Author

gcasa commented Dec 27, 2023

@fredkiefer please approve if it's okay to merge. I am in the process of looking at what is involved on the backend.

@gcasa
Copy link
Member Author

gcasa commented Dec 27, 2023

#232 PR for set method on libs-gui

Source/NSView.m Outdated Show resolved Hide resolved
Source/NSView.m Outdated Show resolved Hide resolved
Copy link
Member

@fredkiefer fredkiefer left a comment

Choose a reason for hiding this comment

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

Looks mostly OK, but the RETAIN issue needs to be resolved. You could also use the setter instead.

@gcasa
Copy link
Member Author

gcasa commented Dec 27, 2023

Looks mostly OK, but the RETAIN issue needs to be resolved. You could also use the setter instead.

I added both retains, I think using the setter is cleaner. I am going to go ahead and make that change. Give me a moment.

@gcasa
Copy link
Member Author

gcasa commented Dec 27, 2023

I changed the code to use the setter, thanks. :). Merging.

@gcasa gcasa merged commit 79fd2c8 into master Dec 27, 2023
4 checks passed
@gcasa gcasa deleted the NSShadow_implementation_issue217 branch December 27, 2023 17:26
@gcasa
Copy link
Member Author

gcasa commented Dec 27, 2023

Forgot to add the NSView.m file to the commit... I will correct it on master. Sorry.

@gcasa
Copy link
Member Author

gcasa commented Dec 27, 2023

Oh... it got them. :). Nevermind.

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

Successfully merging this pull request may close these issues.

2 participants