Added 2019-09-28: If you want to find the macro discussed in this thread, you can find it in Eskimo's blog: #14 - Macro - "Zoom to Selection Plus".
In a recent thread in the X7 section - zOOM TO SELECTION FOR TO THE NODES SELECTION - FEATURE REQUEST - there was some discussion about having the ability to zoom to selected nodes. Some VBA approaches to that were posted, and the discussion expanded to include other types of "zoom to selection" that might be useful. I've tried to address some of those with a macro.
"Zoom to Selection Plus" can, depending on the situation:
From a user standpoint, ZTSP is only one command. What happens when it is run depends on what the current selection is - or, if nothing is selected, what visible objects are present on the page.
For each of those types of zoom, to the rectangular area that bounds the selection, some "padding" can be added to the height and width. How much padding? That can be set by the user, as a percentage of the bounding dimension, with independent values for each of the types of zoom listed above. In addition to that padding, there is a user-settable "minimum view dimension" - because one might not wish to zoom "all the way in" on very small selections.
In addition to the core "Zoom to Selection Plus" capability, a "Zoom to Page Plus" capability is made available as a second command. Again, the padding for that is user-settable, so the amount of white space around the page border can be smaller (or larger) than what CorelDRAW produces with its standard "zoom to page".
Here's the .GMS file: JQ_Zoom_to_Selection_Plus_2018_09_10_0855.
With the .GMS file in place, ZTSP looks like this in the Macro Manager:
The top four subs seen there are associated with the user form that is used to access the settings. At this point, we're interested in the bottom two subs.
In this video, I've assigned F4 to "Zoom to Selection Plus" and Shift+F4 to "Zoom to Page Plus".VIDEO: Zoom To Selection Plus - Demo 01
A later post will get into the user form.
This looks fantastic!!!You are even better than Santa , I make a wish and just a few days later you bring what I wanted right down the chimney, and more!And I didn't even think about the text part but it is great.There is one thing left (if you want to enhance the text part): Zoom to selected text nodes. Thank you so much John, you are my hero!
Thanks for the kind words, Ronny. I like how this has turned out.
I really appreciate the simplicity - from a user standpoint - that comes from your suggestion to have "one Command do all of these".
The "zoom to text" part was a suggestion from pkg_sriram - and I like that, too.
Ronny Axelsson said:There is one thing left (if you want to enhance the text part): Zoom to selected text nodes.
At this point in time, I'm not aware of a way to get at that information - specifically, the locations of the selected text nodes. If I learn of a way to do that, then sure, that could be added.
For anyone who wants to know the logic that is being used by this macro - not the details of the coding, but the general "What is it thinking?" aspect of it - here is a flowchart. The image is a link to a PDF, so it can be viewed at full vector quality.
Very clever.
I noted in an earlier post that there were subs in the Macro Manager that were associated with a user form for accessing the settings. That user form looks like this:
This form allows access to the values that are used to set the "padding" for different types of zoom carried out by ZTSP, and also to the value for the minimum view size. For adjusting and testing those values, there are buttons on the form for carrying out "Zoom to Selected Plus" and "Zoom to Page" plus. When a zoom is carried out using one of those buttons, the values currently visible in the ComboBoxes are used to update the "most recently used" (MRU) lists of values for those ComboBoxes.
The label for a ComboBox offers two capabilities:
This video demonstrates how the settings for padding and minimum view size can come into play. It also demonstrates using the labels associated with ComboBoxes to (1) clear an MRU list and (2) set a ComboBox to its default value.
VIDEO: Zoom to Selection Plus - Demo 02
When a zoom is carried out within this form, and also when the form is closed, the values are written to the Registry - including the MRU lists - so the information is persistent across sessions. When the no-userform, probably-triggered-by-shortcut-keys "Zoom to Selection Plus" and "Zoom to Page Plus" subs do their thing, that is where they get their values for padding and for minimum view size.