|
|
@@ -99,6 +99,12 @@ public: |
|
|
|
|| style == RotaryHorizontalVerticalDrag;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isBar() const noexcept
|
|
|
|
{
|
|
|
|
return style == LinearBar
|
|
|
|
|| style == LinearBarVertical;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool incDecDragDirectionIsHorizontal() const noexcept
|
|
|
|
{
|
|
|
|
return incDecButtonMode == incDecButtonsDraggable_Horizontal
|
|
|
@@ -740,7 +746,7 @@ public: |
|
|
|
void handleAbsoluteDrag (const MouseEvent& e)
|
|
|
|
{
|
|
|
|
const float mousePos = (isHorizontal() || style == RotaryHorizontalDrag) ? e.position.x : e.position.y;
|
|
|
|
double newPos = (mousePos - sliderRegionStart) / (double) sliderRegionSize;
|
|
|
|
double newPos = 0;
|
|
|
|
|
|
|
|
if (style == RotaryHorizontalDrag
|
|
|
|
|| style == RotaryVerticalDrag
|
|
|
@@ -774,6 +780,8 @@ public: |
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
newPos = (mousePos - sliderRegionStart) / (double) sliderRegionSize;
|
|
|
|
|
|
|
|
if (isVertical())
|
|
|
|
newPos = 1.0 - newPos;
|
|
|
|
}
|
|
|
@@ -1120,98 +1128,34 @@ public: |
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void resized (const Rectangle<int>& localBounds, LookAndFeel& lf)
|
|
|
|
//==============================================================================
|
|
|
|
void resized (LookAndFeel& lf)
|
|
|
|
{
|
|
|
|
int minXSpace = 0;
|
|
|
|
int minYSpace = 0;
|
|
|
|
SliderLayout layout = lf.getSliderLayout (owner);
|
|
|
|
|
|
|
|
if (textBoxPos == TextBoxLeft || textBoxPos == TextBoxRight)
|
|
|
|
minXSpace = 30;
|
|
|
|
else
|
|
|
|
minYSpace = 15;
|
|
|
|
|
|
|
|
const int tbw = jmax (0, jmin (textBoxWidth, localBounds.getWidth() - minXSpace));
|
|
|
|
const int tbh = jmax (0, jmin (textBoxHeight, localBounds.getHeight() - minYSpace));
|
|
|
|
sliderRect = layout.sliderBounds;
|
|
|
|
|
|
|
|
if (style == LinearBar || style == LinearBarVertical)
|
|
|
|
{
|
|
|
|
if (valueBox != nullptr)
|
|
|
|
valueBox->setBounds (localBounds);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (textBoxPos == NoTextBox)
|
|
|
|
{
|
|
|
|
sliderRect = localBounds;
|
|
|
|
}
|
|
|
|
else if (textBoxPos == TextBoxLeft)
|
|
|
|
{
|
|
|
|
valueBox->setBounds (0, (localBounds.getHeight() - tbh) / 2, tbw, tbh);
|
|
|
|
sliderRect.setBounds (tbw, 0, localBounds.getWidth() - tbw, localBounds.getHeight());
|
|
|
|
}
|
|
|
|
else if (textBoxPos == TextBoxRight)
|
|
|
|
{
|
|
|
|
valueBox->setBounds (localBounds.getWidth() - tbw, (localBounds.getHeight() - tbh) / 2, tbw, tbh);
|
|
|
|
sliderRect.setBounds (0, 0, localBounds.getWidth() - tbw, localBounds.getHeight());
|
|
|
|
}
|
|
|
|
else if (textBoxPos == TextBoxAbove)
|
|
|
|
{
|
|
|
|
valueBox->setBounds ((localBounds.getWidth() - tbw) / 2, 0, tbw, tbh);
|
|
|
|
sliderRect.setBounds (0, tbh, localBounds.getWidth(), localBounds.getHeight() - tbh);
|
|
|
|
}
|
|
|
|
else if (textBoxPos == TextBoxBelow)
|
|
|
|
{
|
|
|
|
valueBox->setBounds ((localBounds.getWidth() - tbw) / 2, localBounds.getHeight() - tbh, tbw, tbh);
|
|
|
|
sliderRect.setBounds (0, 0, localBounds.getWidth(), localBounds.getHeight() - tbh);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const int indent = lf.getSliderThumbRadius (owner);
|
|
|
|
|
|
|
|
if (style == LinearBar)
|
|
|
|
{
|
|
|
|
const int barIndent = 1;
|
|
|
|
sliderRegionStart = barIndent;
|
|
|
|
sliderRegionSize = localBounds.getWidth() - barIndent * 2;
|
|
|
|
|
|
|
|
sliderRect.setBounds (sliderRegionStart, barIndent,
|
|
|
|
sliderRegionSize, localBounds.getHeight() - barIndent * 2);
|
|
|
|
}
|
|
|
|
else if (style == LinearBarVertical)
|
|
|
|
{
|
|
|
|
const int barIndent = 1;
|
|
|
|
sliderRegionStart = barIndent;
|
|
|
|
sliderRegionSize = localBounds.getHeight() - barIndent * 2;
|
|
|
|
if (valueBox != nullptr)
|
|
|
|
valueBox->setBounds (layout.textBoxBounds);
|
|
|
|
|
|
|
|
sliderRect.setBounds (barIndent, sliderRegionStart,
|
|
|
|
localBounds.getWidth() - barIndent * 2, sliderRegionSize);
|
|
|
|
}
|
|
|
|
else if (isHorizontal())
|
|
|
|
if (isHorizontal())
|
|
|
|
{
|
|
|
|
sliderRegionStart = sliderRect.getX() + indent;
|
|
|
|
sliderRegionSize = jmax (1, sliderRect.getWidth() - indent * 2);
|
|
|
|
|
|
|
|
sliderRect.setBounds (sliderRegionStart, sliderRect.getY(),
|
|
|
|
sliderRegionSize, sliderRect.getHeight());
|
|
|
|
sliderRegionStart = layout.sliderBounds.getX();
|
|
|
|
sliderRegionSize = layout.sliderBounds.getWidth();
|
|
|
|
}
|
|
|
|
else if (isVertical())
|
|
|
|
{
|
|
|
|
sliderRegionStart = sliderRect.getY() + indent;
|
|
|
|
sliderRegionSize = jmax (1, sliderRect.getHeight() - indent * 2);
|
|
|
|
|
|
|
|
sliderRect.setBounds (sliderRect.getX(), sliderRegionStart,
|
|
|
|
sliderRect.getWidth(), sliderRegionSize);
|
|
|
|
sliderRegionStart = layout.sliderBounds.getY();
|
|
|
|
sliderRegionSize = layout.sliderBounds.getHeight();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else if (style == IncDecButtons)
|
|
|
|
{
|
|
|
|
sliderRegionStart = 0;
|
|
|
|
sliderRegionSize = 100;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (style == IncDecButtons)
|
|
|
|
resizeIncDecButtons();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//==============================================================================
|
|
|
|
|
|
|
|
void resizeIncDecButtons()
|
|
|
|
{
|
|
|
|
Rectangle<int> buttonRect (sliderRect);
|
|
|
@@ -1582,12 +1526,13 @@ void Slider::setScrollWheelEnabled (const bool enabled) { pimpl->scrollWheel |
|
|
|
bool Slider::isHorizontal() const noexcept { return pimpl->isHorizontal(); }
|
|
|
|
bool Slider::isVertical() const noexcept { return pimpl->isVertical(); }
|
|
|
|
bool Slider::isRotary() const noexcept { return pimpl->isRotary(); }
|
|
|
|
bool Slider::isBar() const noexcept { return pimpl->isBar(); }
|
|
|
|
|
|
|
|
float Slider::getPositionOfValue (const double value) { return pimpl->getPositionOfValue (value); }
|
|
|
|
|
|
|
|
//==============================================================================
|
|
|
|
void Slider::paint (Graphics& g) { pimpl->paint (g, getLookAndFeel()); }
|
|
|
|
void Slider::resized() { pimpl->resized (getLocalBounds(), getLookAndFeel()); }
|
|
|
|
void Slider::resized() { pimpl->resized (getLookAndFeel()); }
|
|
|
|
|
|
|
|
void Slider::focusOfChildComponentChanged (FocusChangeType) { repaint(); }
|
|
|
|
|
|
|
|