mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Scaling: Ensured that the Slider's PopupDisplayComponent will have the same transform applied as the Slider itself
This commit is contained in:
parent
b632360518
commit
8377a6406b
2 changed files with 23 additions and 3 deletions
|
|
@ -145,7 +145,8 @@ void BubbleComponent::setPosition (Rectangle<int> rectangleToPointTo,
|
|||
}
|
||||
}
|
||||
|
||||
setBounds (targetX - arrowTip.x, targetY - arrowTip.y, totalW, totalH);
|
||||
auto origin = Point<int> (targetX - arrowTip.x, targetY - arrowTip.y).transformedBy (getTransform().inverted());
|
||||
setBounds (origin.getX(), origin.getY(), totalW, totalH);
|
||||
}
|
||||
|
||||
} // namespace juce
|
||||
|
|
|
|||
|
|
@ -990,7 +990,7 @@ public:
|
|||
|
||||
if (popupDisplay == nullptr)
|
||||
{
|
||||
popupDisplay.reset (new PopupDisplayComponent (owner));
|
||||
popupDisplay.reset (new PopupDisplayComponent (owner, parentForPopupDisplay == nullptr));
|
||||
|
||||
if (parentForPopupDisplay != nullptr)
|
||||
parentForPopupDisplay->addChildComponent (popupDisplay.get());
|
||||
|
|
@ -1275,10 +1275,13 @@ public:
|
|||
struct PopupDisplayComponent : public BubbleComponent,
|
||||
public Timer
|
||||
{
|
||||
PopupDisplayComponent (Slider& s)
|
||||
PopupDisplayComponent (Slider& s, bool isOnDesktop)
|
||||
: owner (s),
|
||||
font (s.getLookAndFeel().getSliderPopupFont (s))
|
||||
{
|
||||
if (isOnDesktop)
|
||||
setTransform (AffineTransform::scale (getApproximateScaleFactor (&s)));
|
||||
|
||||
setAlwaysOnTop (true);
|
||||
setAllowedPlacement (owner.getLookAndFeel().getSliderPopupPlacement (s));
|
||||
setLookAndFeel (&s.getLookAndFeel());
|
||||
|
|
@ -1316,6 +1319,22 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
static float getApproximateScaleFactor (Component* targetComponent)
|
||||
{
|
||||
AffineTransform transform;
|
||||
|
||||
for (Component* target = targetComponent; target != nullptr; target = target->getParentComponent())
|
||||
{
|
||||
transform = transform.followedBy (target->getTransform());
|
||||
|
||||
if (target->isOnDesktop())
|
||||
transform = transform.scaled (target->getDesktopScaleFactor());
|
||||
}
|
||||
|
||||
return (transform.getScaleFactor() / Desktop::getInstance().getGlobalScaleFactor());
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
Slider& owner;
|
||||
Font font;
|
||||
String text;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue