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

WPF ZoomIn/Out Functionality #306

Merged
merged 3 commits into from
Apr 14, 2014
Merged

WPF ZoomIn/Out Functionality #306

merged 3 commits into from
Apr 14, 2014

Conversation

amaitland
Copy link
Member

Added GetZoomLevel and SetZoomLevel methods to ManagedCefBrowserAdapater
Currently unable to get GetZoomLevel to return any value other than 0,
comment in source says "This method can only be called on the UI
thread", so need to investigate that further. SetZoomLevel works as
expected.
Added WPF Commands for ZoomIn, ZoomOut and ZoomReset.
Added Dependency properties for ZoomLevel and ZoomLevelIncrement
Added content menu items for ZoomIn, ZoomOut and ZoomReset to Wpf
Example

Added GetZoomLevel and SetZoomLevel methods to ManagedCefBrowserAdapater
Currently unable to get GetZoomLevel to return any value other than 0,
comment in source says "This method can only be called on the UI
thread", so need to investigate that further. SetZoomLevel works as
expected.
Added WPF Commands for ZoomIn, ZoomOut and ZoomReset.
Added Dependency properties for ZoomLevel and ZoomLevelIncrement
Added content menu items for ZoomIn, ZoomOut and ZoomReset to Wpf
Example
{
auto cefHost = _renderClientAdapter->TryGetCefHost();

if (cefHost != nullptr)
Copy link
Member

Choose a reason for hiding this comment

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

The whitespace here is quite messed up. Could you take a look at it?

Copy link
Member Author

Choose a reason for hiding this comment

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

Interesting! The code looks fine in visual studio, I can see the formatting of the patch is clearly all over the place. I'm fairly new to the world of Git, so if you have any insights they would be greatly appreciated, otherwise I'll take a look at the issue shortly.

Copy link
Contributor

Choose a reason for hiding this comment

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

@amaitland we use spaces for whitespace here - not tabs. I guess that's the problem ... Take a look at your Visual Studio settings (don't know if it's configurable per solution/project). Otherwise I can reccomend the PowerCommands aka "Productivity Power Tools" VS add-in. It complains if a file has mixed tabs/spaces - and you just click a button to fix it in either direction.

Copy link
Member

Choose a reason for hiding this comment

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

But be very careful to not commit a lot of whitespace changes along with other changes (which is easy if you click the "fix tabs/spaces" button 😃). Please fix as needed, but as separate pull requests.

Copy link
Member Author

Choose a reason for hiding this comment

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

Makes perfect sense, thank you both for the prompt reply's. I've just committed the formatting changes.

Fix indentation from previous commit (change from tabs to spaces)
@perlun
Copy link
Member

perlun commented Apr 10, 2014

This is good, except for the whitespace mixup (should be space, not tab) and commented out code (which should be deleted or included, but not commented out). I suggest you make a new branch off of the current master (i.e. master@cefsharp/CefSharp) and cherrypick this specific commit over, and then fix it. (The easiest way is probably to just enforce your VC++ to use spaces and not tabs in the IDE settings.)

Let's start with that and I can then give the code a further review, once these more trivial settings are done.


protected virtual void OnZoomLevelChanged(double oldValue, double newValue)
{
if (!Cef.IsInitialized && !Cef.Initialize())
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if it's a good idea to implicitly initialize CEF when the zoom level is changed? Could it have "bad" implications?

Copy link
Member Author

Choose a reason for hiding this comment

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

TBH that was copied from one of the other property change handlers. Just the check for IsInitialized should be enough, I'll update.

@perlun
Copy link
Member

perlun commented Apr 10, 2014

Gha, don't write comments about old, no-more-relevant changesets... 😄 I think this is all good, except for the commented out code. Please add a commit (to your master branch) that removed that part and I'll merge it. Thanks a lot! 😄

@amaitland
Copy link
Member Author

I'll remove the commented out code and also the call to Cef.Initialize() in on OnZoomLevelChanged.

Sorry about the whitespace problems, checking that sort of stuff is a total waste of your time, so my appologies, I'll look at sorting this issue out going forward!

Remove call to Cef.Initialize() in OnZoomLevelChanged
@amaitland
Copy link
Member Author

Changes made, let me know if there is anything else.

@amaitland
Copy link
Member Author

Anything else required before this one can be merged?

@@ -55,5 +69,11 @@ public interface IWpfWebBrowser : IWebBrowser
/// <returns><c>true</c> if keyboard focus and logical focus were set to this element; <c>false</c> if only logical focus
/// was set to this element, or if the call to this method did not force the focus to change.</returns>
bool Focus();

/// <summary>
/// The zoom level at which the browser control is currently displaying. Can be set to 0 to clear the zoom level(resets to default zoom level)
Copy link
Member

Choose a reason for hiding this comment

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

I lack a space here, but since this is such a minor change I'll fix it myself.

perlun added a commit that referenced this pull request Apr 14, 2014
WPF ZoomIn/Out Functionality
@perlun perlun merged commit 69afa79 into cefsharp:master Apr 14, 2014
@perlun
Copy link
Member

perlun commented Apr 14, 2014

Looks good, merging.

@perlun perlun added this to the 31.0.0 milestone Apr 14, 2014
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