Skip to content

Commit

Permalink
fix initial zoom factor for aspect ratio editor
Browse files Browse the repository at this point in the history
  • Loading branch information
scheffle committed Nov 19, 2023
1 parent 4748514 commit 73f6c10
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions vstgui/plugin-bindings/vst3editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2066,10 +2066,11 @@ double AspectRatioVST3Editor::getMinZoomFactor () const { return minZoomFactor;
//------------------------------------------------------------------------
bool PLUGIN_API AspectRatioVST3Editor::open (void* parent, const PlatformType& type)
{
calcZoomFactor = getZoomFactor ();
if (VST3Editor::open (parent, type) && getFrame ())
{
initialSize = getFrame ()->getViewSize ().getSize ();
calcZoomFactor = getZoomFactor ();
initialSize /= calcZoomFactor;
return true;
}
return false;
Expand Down Expand Up @@ -2121,7 +2122,7 @@ Steinberg::tresult PLUGIN_API AspectRatioVST3Editor::checkSizeConstraint (Steinb
Steinberg::tresult PLUGIN_API AspectRatioVST3Editor::setContentScaleFactor (ScaleFactor factor)
{
auto res = VST3Editor::setContentScaleFactor (factor);
if (res == Steinberg::kResultTrue)
if (res == Steinberg::kResultTrue && canCalculateAspectRatio ())
setZoomFactor (calcZoomFactor);
return res;
}
Expand All @@ -2131,7 +2132,7 @@ Steinberg::tresult PLUGIN_API AspectRatioVST3Editor::setContentScaleFactor (Scal
bool AspectRatioVST3Editor::canCalculateAspectRatio () const
{
auto f = getFrame ();
if (inEditMode () || (f && f->hasChildren () == false))
if (inEditMode () || f == nullptr || f->hasChildren () == false)
return false;
return true;
}
Expand Down

0 comments on commit 73f6c10

Please sign in to comment.