mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
LV2 Host: Fix some confusion between logical/physical coordinate spaces
This commit is contained in:
parent
1c2d5f69f3
commit
3bc7692868
1 changed files with 29 additions and 20 deletions
|
|
@ -376,23 +376,22 @@ private:
|
||||||
|
|
||||||
struct ViewSizeListener final : private ComponentMovementWatcher
|
struct ViewSizeListener final : private ComponentMovementWatcher
|
||||||
{
|
{
|
||||||
ViewSizeListener (Component& c, PhysicalResizeListener& l)
|
ViewSizeListener (Component& c, LogicalResizeListener& l)
|
||||||
: ComponentMovementWatcher (&c), listener (l)
|
: ComponentMovementWatcher (&c), listener (l)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void componentMovedOrResized (bool, bool wasResized) override
|
void componentMovedOrResized (bool, bool wasResized) override
|
||||||
{
|
{
|
||||||
if (wasResized)
|
if (! wasResized)
|
||||||
{
|
return;
|
||||||
const auto physicalSize = Desktop::getInstance().getDisplays()
|
|
||||||
.logicalToPhysical (getComponent()->localAreaToGlobal (getComponent()->getLocalBounds()));
|
const auto bounds = getComponent()->getLocalBounds();
|
||||||
const auto width = physicalSize.getWidth();
|
const auto width = bounds.getWidth();
|
||||||
const auto height = physicalSize.getHeight();
|
const auto height = bounds.getHeight();
|
||||||
|
|
||||||
if (width > 10 && height > 10)
|
if (width > 10 && height > 10)
|
||||||
listener.viewRequestedResizeInPhysicalPixels (width, height);
|
listener.viewRequestedResizeInLogicalPixels (width, height);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void componentPeerChanged() override {}
|
void componentPeerChanged() override {}
|
||||||
|
|
@ -401,11 +400,12 @@ struct ViewSizeListener final : private ComponentMovementWatcher
|
||||||
using ComponentMovementWatcher::componentVisibilityChanged;
|
using ComponentMovementWatcher::componentVisibilityChanged;
|
||||||
using ComponentMovementWatcher::componentMovedOrResized;
|
using ComponentMovementWatcher::componentMovedOrResized;
|
||||||
|
|
||||||
PhysicalResizeListener& listener;
|
LogicalResizeListener& listener;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ConfiguredEditorComponent final : public Component,
|
class ConfiguredEditorComponent final : public Component,
|
||||||
private PhysicalResizeListener
|
private PhysicalResizeListener,
|
||||||
|
private LogicalResizeListener
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ConfiguredEditorComponent (World& world,
|
ConfiguredEditorComponent (World& world,
|
||||||
|
|
@ -445,10 +445,11 @@ public:
|
||||||
return uiInstance->instance.getDetectedViewBounds();
|
return uiInstance->instance.getDetectedViewBounds();
|
||||||
}();
|
}();
|
||||||
|
|
||||||
|
lastPhysicalWidth = boundsToUse.getWidth();
|
||||||
|
lastPhysicalHeight = boundsToUse.getHeight();
|
||||||
|
|
||||||
const auto scaled = lv2ToComponentRect (boundsToUse);
|
const auto scaled = lv2ToComponentRect (boundsToUse);
|
||||||
lastWidth = scaled.getWidth();
|
setSize (scaled.getWidth(), scaled.getHeight());
|
||||||
lastHeight = scaled.getHeight();
|
|
||||||
setSize (lastWidth, lastHeight);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
~ConfiguredEditorComponent() override
|
~ConfiguredEditorComponent() override
|
||||||
|
|
@ -522,10 +523,18 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void viewRequestedResizeInLogicalPixels (int width, int height) override
|
||||||
|
{
|
||||||
|
const auto physical = componentToLv2Rect ({ width, height });
|
||||||
|
lastPhysicalWidth = physical.getWidth();
|
||||||
|
lastPhysicalHeight = physical.getHeight();;
|
||||||
|
resizeListener.viewRequestedResizeInLogicalPixels (width, height);
|
||||||
|
}
|
||||||
|
|
||||||
void viewRequestedResizeInPhysicalPixels (int width, int height) override
|
void viewRequestedResizeInPhysicalPixels (int width, int height) override
|
||||||
{
|
{
|
||||||
lastWidth = width;
|
lastPhysicalWidth = width;
|
||||||
lastHeight = height;
|
lastPhysicalHeight = height;
|
||||||
const auto logical = lv2ToComponentRect ({ width, height });
|
const auto logical = lv2ToComponentRect ({ width, height });
|
||||||
resizeListener.viewRequestedResizeInLogicalPixels (logical.getWidth(), logical.getHeight());
|
resizeListener.viewRequestedResizeInLogicalPixels (logical.getWidth(), logical.getHeight());
|
||||||
}
|
}
|
||||||
|
|
@ -538,7 +547,7 @@ private:
|
||||||
|
|
||||||
void applyLastRequestedPhysicalSize()
|
void applyLastRequestedPhysicalSize()
|
||||||
{
|
{
|
||||||
viewRequestedResizeInPhysicalPixels (lastWidth, lastHeight);
|
viewRequestedResizeInPhysicalPixels (lastPhysicalWidth, lastPhysicalHeight);
|
||||||
viewComponent.forceViewToSize();
|
viewComponent.forceViewToSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -574,7 +583,7 @@ private:
|
||||||
#if JUCE_LINUX || JUCE_BSD
|
#if JUCE_LINUX || JUCE_BSD
|
||||||
struct ViewComponent final : public XEmbedComponent
|
struct ViewComponent final : public XEmbedComponent
|
||||||
{
|
{
|
||||||
explicit ViewComponent (PhysicalResizeListener& l)
|
explicit ViewComponent (LogicalResizeListener& l)
|
||||||
: XEmbedComponent (true, false),
|
: XEmbedComponent (true, false),
|
||||||
listener (*this, l)
|
listener (*this, l)
|
||||||
{
|
{
|
||||||
|
|
@ -665,7 +674,7 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
LogicalResizeListener& resizeListener;
|
LogicalResizeListener& resizeListener;
|
||||||
int lastWidth = 0, lastHeight = 0;
|
int lastPhysicalWidth = 0, lastPhysicalHeight = 0;
|
||||||
float userScaleFactor = 1.0f;
|
float userScaleFactor = 1.0f;
|
||||||
NativeScaleFactorNotifier scaleNotifier { this, ScaleNotifierCallback { *this } };
|
NativeScaleFactorNotifier scaleNotifier { this, ScaleNotifierCallback { *this } };
|
||||||
ViewComponent viewComponent { *this };
|
ViewComponent viewComponent { *this };
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue