Skip to content

Commit

Permalink
Merge branch 'develop' into uiscripting
Browse files Browse the repository at this point in the history
  • Loading branch information
scheffle committed Sep 14, 2024
2 parents 1eda02d + 17c2a7a commit af3bf1b
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 71 deletions.
92 changes: 44 additions & 48 deletions vstgui/lib/crowcolumnview.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file is part of VSTGUI. It is subject to the license terms
// This file is part of VSTGUI. It is subject to the license terms
// in the LICENSE file found in the top-level directory of this
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE

Expand Down Expand Up @@ -135,38 +135,38 @@ CPoint computeRectOffset (const CPoint& parent, const CPoint& rect, const Alignm
CRect computeGroupRect (const CRect& parent, const CRects& children, const Alignment alignment,
const Style style, double spacing)
{
CPoint maxSize;
if (style == Style::kRow)
{
for (const auto& rect : children)
{
if (maxSize.x < rect.getWidth ())
maxSize.x = rect.getWidth ();

maxSize.y = maxSize.y + rect.getHeight () + spacing;
}
// Remove the last spacing again
if (!children.empty())
maxSize.y -= spacing;
}
else
{
for (const auto& rect : children)
{
if (maxSize.y < rect.getHeight ())
maxSize.y = rect.getHeight ();

maxSize.x = maxSize.x + rect.getWidth () + spacing;
}
// Remove the last spacing again
if (!children.empty())
maxSize.x -= spacing;
}

const auto offset = computeRectOffset (parent.getSize (), maxSize, alignment);
return CRect().setSize(maxSize).offset(offset);
CPoint maxSize;
if (style == Style::kRow)
{
for (const auto& rect : children)
{
if (maxSize.x < rect.getWidth ())
maxSize.x = rect.getWidth ();

maxSize.y = maxSize.y + rect.getHeight () + spacing;
}

// Remove the last spacing again
if (!children.empty ())
maxSize.y -= spacing;
}
else
{
for (const auto& rect : children)
{
if (maxSize.y < rect.getHeight ())
maxSize.y = rect.getHeight ();

maxSize.x = maxSize.x + rect.getWidth () + spacing;
}

// Remove the last spacing again
if (!children.empty ())
maxSize.x -= spacing;
}

const auto offset = computeRectOffset (parent.getSize (), maxSize, alignment);
return CRect ().setSize (maxSize).offset (offset);
}

//--------------------------------------------------------------------------------
Expand Down Expand Up @@ -230,7 +230,8 @@ class AutoLayout
}

//--------------------------------------------------------------------------------
CRowColumnView::CRowColumnView (const CRect& size, Style style, LayoutStyle layoutStyle, CCoord spacing, const CRect& margin)
CRowColumnView::CRowColumnView (const CRect& size, Style style, LayoutStyle layoutStyle,
CCoord spacing, const CRect& margin)
: CAutoLayoutContainerView (size)
, style (style)
, layoutStyle (layoutStyle)
Expand Down Expand Up @@ -287,10 +288,7 @@ void CRowColumnView::setLayoutStyle (LayoutStyle inLayoutStyle)
}

//--------------------------------------------------------------------------------
bool CRowColumnView::isAnimateViewResizing () const
{
return hasBit (flags, kAnimateViewResizing);
}
bool CRowColumnView::isAnimateViewResizing () const { return hasBit (flags, kAnimateViewResizing); }

//--------------------------------------------------------------------------------
void CRowColumnView::setAnimateViewResizing (bool state)
Expand All @@ -299,10 +297,7 @@ void CRowColumnView::setAnimateViewResizing (bool state)
}

//--------------------------------------------------------------------------------
bool CRowColumnView::hideClippedSubviews () const
{
return hasBit (flags, kHideClippedSubViews);
}
bool CRowColumnView::hideClippedSubviews () const { return hasBit (flags, kHideClippedSubViews); }

//--------------------------------------------------------------------------------
void CRowColumnView::setHideClippedSubviews (bool state)
Expand All @@ -317,7 +312,9 @@ void CRowColumnView::resizeSubView (CView* view, const CRect& newSize)
{
if (isAttached () && isAnimateViewResizing () && viewResizeAnimationTime > 0)
{
view->addAnimation ("CRowColumnResizing", new Animation::ViewSizeAnimation (newSize, false), new Animation::LinearTimingFunction (viewResizeAnimationTime));
view->addAnimation ("CRowColumnResizing",
new Animation::ViewSizeAnimation (newSize, false),
new Animation::LinearTimingFunction (viewResizeAnimationTime));
}
else
{
Expand Down Expand Up @@ -459,8 +456,11 @@ bool CRowColumnView::sizeToFit ()
if (viewSize != getViewSize ())
{
invalid ();
auto autosizeState = getAutosizingEnabled ();
setAutosizingEnabled (false);
CViewContainer::setViewSize (viewSize);
CViewContainer::setMouseableArea (viewSize);
setAutosizingEnabled (autosizeState);
invalid ();
}
return true;
Expand All @@ -482,10 +482,7 @@ CMessageResult CRowColumnView::notify (CBaseObject* sender, IdStringPtr message)
//--------------------------------------------------------------------------------
//--------------------------------------------------------------------------------
//--------------------------------------------------------------------------------
CAutoLayoutContainerView::CAutoLayoutContainerView (const CRect& size)
: CViewContainer (size)
{
}
CAutoLayoutContainerView::CAutoLayoutContainerView (const CRect& size) : CViewContainer (size) {}

//--------------------------------------------------------------------------------
bool CAutoLayoutContainerView::attached (CView* parent)
Expand Down Expand Up @@ -543,4 +540,3 @@ bool CAutoLayoutContainerView::changeViewZOrder (CView* view, uint32_t newIndex)
}

} // VSTGUI

29 changes: 14 additions & 15 deletions vstgui/lib/platform/win32/direct2d/d2dfont.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,13 @@ struct CustomFonts
return false;
}

CustomFonts ()
CustomFonts (const UTF8String& resourceBasePath)
{
auto winFactory = getPlatformFactory ().asWin32Factory ();
if (!winFactory)
if (resourceBasePath.empty ())
return;
auto basePath = winFactory->getResourceBasePath ();
if (!basePath)
return;
*basePath += "Fonts\\*";
auto files = getDirectoryContents (*basePath);
auto basePath = resourceBasePath;
basePath += "Fonts\\*";
auto files = getDirectoryContents (basePath);
if (files.empty ())
return;
auto factory = getDWriteFactory ();
Expand Down Expand Up @@ -106,6 +103,7 @@ struct CustomFonts
return result;
}
#else
CustomFonts (const UTF8String& resourceBasePath) {}
IDWriteFontCollection* getFontCollection () { return nullptr; }
bool contains (const WCHAR*, DWRITE_FONT_WEIGHT, DWRITE_FONT_STRETCH, DWRITE_FONT_STYLE)
{
Expand All @@ -116,14 +114,9 @@ struct CustomFonts

//-----------------------------------------------------------------------------
static std::unique_ptr<CustomFonts> customFonts;
static std::once_flag customFontsOnceFlag;

//-----------------------------------------------------------------------------
static CustomFonts* getCustomFonts ()
{
std::call_once (customFontsOnceFlag, [] () { customFonts = std::make_unique<CustomFonts> (); });
return customFonts.get ();
}
static CustomFonts* getCustomFonts () { return customFonts.get (); }

//-----------------------------------------------------------------------------
static void gatherFonts (const FontFamilyCallback& callback, IDWriteFontCollection* collection)
Expand Down Expand Up @@ -198,8 +191,14 @@ bool D2DFont::getAllFontFamilies (const FontFamilyCallback& callback)
return true;
}

//------------------------------------------------------------------------
void D2DFont::initialize (const UTF8String& resourceBasePath)
{
D2DFontPrivate::customFonts = std::make_unique<D2DFontPrivate::CustomFonts> (resourceBasePath);
}

//-----------------------------------------------------------------------------
void D2DFont::terminate () { D2DFontPrivate::customFonts = nullptr; }
void D2DFont::terminate () { D2DFontPrivate::customFonts.reset (); }

//-----------------------------------------------------------------------------
D2DFont::D2DFont (const UTF8String& name, const CCoord& size, const int32_t& style)
Expand Down
1 change: 1 addition & 0 deletions vstgui/lib/platform/win32/direct2d/d2dfont.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class D2DFont final : public IPlatformFont, public IFontPainter

static bool getAllFontFamilies (const FontFamilyCallback& callback);

static void initialize (const UTF8String& resourceBasePath);
static void terminate ();

protected:
Expand Down
1 change: 1 addition & 0 deletions vstgui/lib/platform/win32/win32factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ HINSTANCE Win32Factory::getInstance () const noexcept
void Win32Factory::setResourceBasePath (const UTF8String& path) const noexcept
{
impl->setBasePath (path);
D2DFont::initialize (path);
}

//-----------------------------------------------------------------------------
Expand Down
17 changes: 11 additions & 6 deletions vstgui/plugin-bindings/vst3editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1881,6 +1881,7 @@ bool VST3Editor::enableEditing (bool state)
openUIEditorController = nullptr;
if (state)
{
editingEnabled = true;
// update uiDesc file path to absolute if possible
if (UIAttributes* attributes = description->getCustomAttributes ("VST3Editor", true))
{
Expand All @@ -1904,7 +1905,6 @@ bool VST3Editor::enableEditing (bool state)
CView* view = editController->createEditView ();
if (view)
{
editingEnabled = true;
CCoord width = view->getWidth ();
CCoord height = view->getHeight ();

Expand Down Expand Up @@ -1954,15 +1954,19 @@ bool VST3Editor::enableEditing (bool state)
CCoord width = view->getWidth () * scaleFactor;
CCoord height = view->getHeight () * scaleFactor;

if (canResize () == Steinberg::kResultTrue)
if (canResize () == Steinberg::kResultTrue && nonEditRect.isEmpty ())
{
Steinberg::ViewRect tmp;
if (getRect ().getWidth () != width)
tmp.right = getRect ().getWidth ();
if (getRect ().getHeight () != height)
tmp.bottom = getRect ().getHeight ();
if (tmp.getWidth () && tmp.getHeight ())
if (tmp.getWidth () || tmp.getHeight ())
{
if (tmp.getWidth () == 0)
tmp.right = width;
if (tmp.getHeight () == 0)
tmp.bottom = width;
checkSizeConstraint (&tmp);
nonEditRect.setWidth (tmp.getWidth ());
nonEditRect.setHeight (tmp.getHeight ());
Expand All @@ -1975,9 +1979,10 @@ bool VST3Editor::enableEditing (bool state)
getFrame ()->invalid ();
if (nonEditRect.isEmpty () == false)
{
rect.right = rect.left + (Steinberg::int32)nonEditRect.getWidth ();
rect.bottom = rect.top + (Steinberg::int32)nonEditRect.getHeight ();
plugFrame->resizeView (this, &rect);
Steinberg::ViewRect tmpRect = rect;
tmpRect.right = tmpRect.left + (Steinberg::int32)nonEditRect.getWidth ();
tmpRect.bottom = tmpRect.top + (Steinberg::int32)nonEditRect.getHeight ();
plugFrame->resizeView (this, &tmpRect);
}
else
{
Expand Down
4 changes: 2 additions & 2 deletions vstgui/plugin-bindings/vst3editor.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file is part of VSTGUI. It is subject to the license terms
// This file is part of VSTGUI. It is subject to the license terms
// in the LICENSE file found in the top-level directory of this
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE

Expand Down Expand Up @@ -217,7 +217,7 @@ class VST3Editor : public Steinberg::Vst::VSTGUIEditor,
double contentScaleFactor {1.};
double zoomFactor {1.};
std::vector<double> allowedZoomFactors;

CPoint minSize;
CPoint maxSize;
CRect nonEditRect;
Expand Down

0 comments on commit af3bf1b

Please sign in to comment.