cmajor-lang / cmajor

The Cmajor public repository
https://cmajor.dev
Other
522 stars 31 forks source link

Is it possible to resize with a fixed aspect ratio? #27

Closed Tanchiky closed 9 months ago

Tanchiky commented 9 months ago

Is there any way to fix the aspect ratio in cmajor, I have looked at various documents, sources, etc. for the view item in patch file, but have not found anything specific. (something like setFixedAspectRatio in JUCE)

julianstorer commented 9 months ago

To make it easy to rescale a view without changing its aspect ratio, you can add this method to your view web component class:

e.g.

    getScaleFactorLimits()
    {
        return { minScale: 0.50,
                 maxScale: 1.25 };
    }

We've got some internal examples that use this, and will publish one soon.. But you can see the code that does the work here: https://github.com/SoundStacks/cmajor/blob/b44d5bc6a03cd67589d4f9709e958734b825a359/include/cmajor/helpers/cmaj_PatchWebView.h#L221

Tanchiky commented 9 months ago

Thank you! This worked out well!