I’m finally trying to get my Eneroth Viewport Resizer to work on Mac. However I have no Mac to try on myself, and have no idea what APIs there are. Is there a way to get and set the size of the SketchUp window, similarly to how you can do with Win32Api or the User32 dll on Windows?
This is what my low level Windows window module looks like, that I’m trying to recreate for Mac.
I struggle a bit to follow this code. Am I correct that the model has to be closed and re-open to apply the new window size? Id there any API on Mac for directly changing the size of an existing window?
no, I written hundreds of versions over the years using Applesricpt, ossascript, objc, cocoa, and ruby, but they all require specific user permissions to function…
people are just not happy to allow the level of ‘control’ needed…
I’ll PM you what I use as I believe it’s cross platform…
I’d prefer special permissions, like SketchUp having to run as administrator, over hacks that makes assumptions of where the data is stored or the like. Also getting and setting the current value of the existing window is an absolute requirement for how the extension is built. This versions updates the fields live when the window is resized and changes the window when the fields are changed.
Unless there is an API contract stating where the PLIST file is located and what format it has, accessing it is based on numerous assumptions. Also the PLIST hack doesn’t appear to be live.
that old one of mine uses SU plist which only stores those when ‘closed’…
earlier versions used the ‘live’ System window position dameon [not plist] but every version of mac OS restricted access further and further, until it wasn’t worth pursuing…
SU.app would have to ‘allow access’ to the doc window and expose it in the API for us to seamlessly use it…
I’ve had the need for this myself for writing reliable tests. I’ve also only gotten Windows working with Win32. But I’m thinking it could be worth adding some utility to the SketchUp API for this. Not sure what a sane API would be for this that is able to cater for Macs MDI…
I actually started writing on an API FR but deleted it thinking this was quite far outside the scope of the API. Typically this would be done with OS API, but maybe there are reasons to add support in the SU API.
I don’t know what API design would be good either, and if the window position should be exposed in addition to the size. The multi document interface also raises some questions. Perhaps there could be an optional argument taking the Model object, but defaulting to the active one.
Main reason I can think of is testing. It’s come up enough times where a reliable viewport size is useful.
Maybe a method on the Sketchup::View object? Probably where it makes the most sense.
Perhaps there could be a new Window class that also has a set_position and a bring_to_front method and some other methods HtmlDialog has. I don’t know what other people need. Even if no other functionality is added to start with, a new class gives more possibilities without cluttering the existing classes.
Maybe Model can have a window method returning this object. The method name active_view suggest a model can have multiple views, like one for each scene, but I don’t know if this is true. If it is all these views would use the same window, but if not the getter is maybe better suited in the View class.
model.active_view.get_size(x, y, w, h) # rounds the circle for resizing
# for dialog positioning
model.active_view.center_offset # position on client screen...
# use case
offset = model.active_view.center_offset
dialog.set_postion(offset)
# this could also be a HtmlDialog method to position them relative
# to the active model window.
dialog.center # we have
# missing
dialog.top_left
dialog.top_right
dialog.bottom_left
dialog.bottom_right