Browse Source

Update juce stuff

Signed-off-by: falkTX <falktx@falktx.com>
tags/v2.2.0-RC1
falkTX 4 years ago
parent
commit
9a0bf93849
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
71 changed files with 591 additions and 531 deletions
  1. +4
    -4
      source/modules/juce_audio_basics/buffers/juce_AudioDataConverters.cpp
  2. +2
    -2
      source/modules/juce_audio_basics/buffers/juce_AudioDataConverters.h
  3. +3
    -3
      source/modules/juce_audio_basics/mpe/juce_MPEInstrument.cpp
  4. +1
    -1
      source/modules/juce_audio_basics/mpe/juce_MPESynthesiserBase.cpp
  5. +1
    -1
      source/modules/juce_audio_basics/utilities/juce_Interpolators.cpp
  6. +6
    -4
      source/modules/juce_audio_basics/utilities/juce_Interpolators.h
  7. +1
    -1
      source/modules/juce_audio_basics/utilities/juce_SmoothedValue.h
  8. +1
    -0
      source/modules/juce_audio_processors/format_types/juce_VST3Headers.h
  9. +10
    -8
      source/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp
  10. +1
    -1
      source/modules/juce_audio_processors/processors/juce_AudioProcessor.cpp
  11. +1
    -1
      source/modules/juce_audio_processors/processors/juce_GenericAudioProcessorEditor.cpp
  12. +1
    -1
      source/modules/juce_audio_processors/scanning/juce_PluginDirectoryScanner.cpp
  13. +1
    -1
      source/modules/juce_audio_processors/scanning/juce_PluginListComponent.cpp
  14. +1
    -1
      source/modules/juce_audio_processors/utilities/juce_AudioParameterChoice.cpp
  15. +1
    -1
      source/modules/juce_audio_processors/utilities/juce_AudioParameterFloat.cpp
  16. +2
    -2
      source/modules/juce_core/files/juce_DirectoryIterator.cpp
  17. +1
    -1
      source/modules/juce_core/files/juce_File.cpp
  18. +1
    -1
      source/modules/juce_core/javascript/juce_Javascript.cpp
  19. +2
    -1
      source/modules/juce_core/maths/juce_MathsFunctions.h
  20. +2
    -1
      source/modules/juce_core/maths/juce_Random.cpp
  21. +1
    -1
      source/modules/juce_core/native/juce_linux_SystemStats.cpp
  22. +1
    -1
      source/modules/juce_core/system/juce_PlatformDefs.h
  23. +1
    -1
      source/modules/juce_core/time/juce_PerformanceCounter.cpp
  24. +2
    -2
      source/modules/juce_core/time/juce_RelativeTime.cpp
  25. +1
    -1
      source/modules/juce_core/time/juce_Time.cpp
  26. +8
    -8
      source/modules/juce_graphics/colour/juce_Colour.cpp
  27. +5
    -5
      source/modules/juce_graphics/contexts/juce_GraphicsContext.cpp
  28. +1
    -1
      source/modules/juce_graphics/contexts/juce_LowLevelGraphicsPostScriptRenderer.cpp
  29. +5
    -5
      source/modules/juce_graphics/effects/juce_DropShadowEffect.cpp
  30. +2
    -2
      source/modules/juce_graphics/fonts/juce_Font.cpp
  31. +2
    -2
      source/modules/juce_graphics/fonts/juce_GlyphArrangement.cpp
  32. +2
    -2
      source/modules/juce_graphics/fonts/juce_TextLayout.cpp
  33. +1
    -1
      source/modules/juce_graphics/fonts/juce_Typeface.cpp
  34. +4
    -4
      source/modules/juce_graphics/geometry/juce_Path.cpp
  35. +4
    -4
      source/modules/juce_graphics/geometry/juce_Point.h
  36. +20
    -20
      source/modules/juce_graphics/geometry/juce_Rectangle.h
  37. +2
    -2
      source/modules/juce_graphics/images/juce_Image.cpp
  38. +13
    -13
      source/modules/juce_graphics/native/juce_freetype_Fonts.cpp
  39. +1
    -1
      source/modules/juce_gui_basics/buttons/juce_ArrowButton.cpp
  40. +1
    -1
      source/modules/juce_gui_basics/buttons/juce_HyperlinkButton.cpp
  41. +4
    -4
      source/modules/juce_gui_basics/buttons/juce_ImageButton.cpp
  42. +22
    -22
      source/modules/juce_gui_basics/components/juce_Component.cpp
  43. +7
    -4
      source/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.cpp
  44. +1
    -1
      source/modules/juce_gui_basics/filebrowser/juce_FileChooserDialogBox.cpp
  45. +1
    -1
      source/modules/juce_gui_basics/filebrowser/juce_FileSearchPathListComponent.cpp
  46. +2
    -2
      source/modules/juce_gui_basics/layout/juce_ComponentAnimator.cpp
  47. +6
    -6
      source/modules/juce_gui_basics/layout/juce_Grid.cpp
  48. +1
    -1
      source/modules/juce_gui_basics/layout/juce_Viewport.cpp
  49. +77
    -63
      source/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V1.cpp
  50. +176
    -148
      source/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.cpp
  51. +30
    -25
      source/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V3.cpp
  52. +58
    -58
      source/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V4.cpp
  53. +1
    -1
      source/modules/juce_gui_basics/menus/juce_PopupMenu.cpp
  54. +1
    -1
      source/modules/juce_gui_basics/mouse/juce_DragAndDropContainer.cpp
  55. +2
    -2
      source/modules/juce_gui_basics/mouse/juce_MouseInputSource.cpp
  56. +1
    -2
      source/modules/juce_gui_basics/native/juce_win32_FileChooser.cpp
  57. +5
    -4
      source/modules/juce_gui_basics/native/juce_win32_Windowing.cpp
  58. +5
    -5
      source/modules/juce_gui_basics/native/x11/juce_linux_X11_Symbols.h
  59. +1
    -1
      source/modules/juce_gui_basics/properties/juce_TextPropertyComponent.cpp
  60. +4
    -1
      source/modules/juce_gui_basics/widgets/juce_ListBox.cpp
  61. +5
    -5
      source/modules/juce_gui_basics/widgets/juce_Slider.cpp
  62. +9
    -9
      source/modules/juce_gui_basics/widgets/juce_TextEditor.cpp
  63. +17
    -17
      source/modules/juce_gui_basics/widgets/juce_Toolbar.cpp
  64. +4
    -4
      source/modules/juce_gui_basics/widgets/juce_TreeView.cpp
  65. +8
    -8
      source/modules/juce_gui_basics/windows/juce_AlertWindow.cpp
  66. +3
    -3
      source/modules/juce_gui_basics/windows/juce_CallOutBox.cpp
  67. +2
    -2
      source/modules/juce_gui_basics/windows/juce_ComponentPeer.cpp
  68. +7
    -7
      source/modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.cpp
  69. +1
    -1
      source/modules/juce_gui_extra/misc/juce_BubbleMessageComponent.cpp
  70. +7
    -7
      source/modules/juce_gui_extra/misc/juce_ColourSelector.cpp
  71. +3
    -3
      source/modules/juce_gui_extra/misc/juce_KeyMappingEditorComponent.cpp

+ 4
- 4
source/modules/juce_audio_basics/buffers/juce_AudioDataConverters.cpp View File

@@ -319,7 +319,7 @@ void AudioDataConverters::convertInt32LEToFloat (const void* source, float* dest
{
for (int i = 0; i < numSamples; ++i)
{
dest[i] = scale * (int) ByteOrder::swapIfBigEndian (*reinterpret_cast<const uint32*> (intData));
dest[i] = scale * (float) ByteOrder::swapIfBigEndian (*reinterpret_cast<const uint32*> (intData));
intData += srcBytesPerSample;
}
}
@@ -330,7 +330,7 @@ void AudioDataConverters::convertInt32LEToFloat (const void* source, float* dest
for (int i = numSamples; --i >= 0;)
{
intData -= srcBytesPerSample;
dest[i] = scale * (int) ByteOrder::swapIfBigEndian (*reinterpret_cast<const uint32*> (intData));
dest[i] = scale * (float) ByteOrder::swapIfBigEndian (*reinterpret_cast<const uint32*> (intData));
}
}
}
@@ -344,7 +344,7 @@ void AudioDataConverters::convertInt32BEToFloat (const void* source, float* dest
{
for (int i = 0; i < numSamples; ++i)
{
dest[i] = scale * (int) ByteOrder::swapIfLittleEndian (*reinterpret_cast<const uint32*> (intData));
dest[i] = scale * (float) ByteOrder::swapIfLittleEndian (*reinterpret_cast<const uint32*> (intData));
intData += srcBytesPerSample;
}
}
@@ -355,7 +355,7 @@ void AudioDataConverters::convertInt32BEToFloat (const void* source, float* dest
for (int i = numSamples; --i >= 0;)
{
intData -= srcBytesPerSample;
dest[i] = scale * (int) ByteOrder::swapIfLittleEndian (*reinterpret_cast<const uint32*> (intData));
dest[i] = scale * (float) ByteOrder::swapIfLittleEndian (*reinterpret_cast<const uint32*> (intData));
}
}
}


+ 2
- 2
source/modules/juce_audio_basics/buffers/juce_AudioDataConverters.h View File

@@ -528,8 +528,8 @@ public:
if (v < mn) mn = v;
}
return Range<float> (mn * (float) (1.0 / (1.0 + (double) Int32::maxValue)),
mx * (float) (1.0 / (1.0 + (double) Int32::maxValue)));
return Range<float> ((float) mn * (float) (1.0 / (1.0 + (double) Int32::maxValue)),
(float) mx * (float) (1.0 / (1.0 + (double) Int32::maxValue)));
}
/** Scans a block of data, returning the lowest and highest levels as floats */


+ 3
- 3
source/modules/juce_audio_basics/mpe/juce_MPEInstrument.cpp View File

@@ -491,7 +491,7 @@ void MPEInstrument::updateNoteTotalPitchbend (MPENote& note)
{
if (legacyMode.isEnabled)
{
note.totalPitchbendInSemitones = note.pitchbend.asSignedFloat() * legacyMode.pitchbendRange;
note.totalPitchbendInSemitones = note.pitchbend.asSignedFloat() * (float) legacyMode.pitchbendRange;
}
else
{
@@ -516,11 +516,11 @@ void MPEInstrument::updateNoteTotalPitchbend (MPENote& note)
auto notePitchbendInSemitones = 0.0f;
if (zone.isUsingChannelAsMemberChannel (note.midiChannel))
notePitchbendInSemitones = note.pitchbend.asSignedFloat() * zone.perNotePitchbendRange;
notePitchbendInSemitones = note.pitchbend.asSignedFloat() * (float) zone.perNotePitchbendRange;
auto masterPitchbendInSemitones = pitchbendDimension.lastValueReceivedOnChannel[zone.getMasterChannel() - 1]
.asSignedFloat()
* zone.masterPitchbendRange;
* (float) zone.masterPitchbendRange;
note.totalPitchbendInSemitones = notePitchbendInSemitones + masterPitchbendInSemitones;
}


+ 1
- 1
source/modules/juce_audio_basics/mpe/juce_MPESynthesiserBase.cpp View File

@@ -345,7 +345,7 @@ namespace
const auto& e = synth.events;
expectWithinAbsoluteError (float (e.blocks.size()),
std::ceil (float (blockSize) / subblockSize),
std::ceil ((float) blockSize / (float) subblockSize),
1.0f);
expect (e.messages.size() == blockSize);
expect (std::is_sorted (e.blocks.begin(), e.blocks.end()));


+ 1
- 1
source/modules/juce_audio_basics/utilities/juce_Interpolators.cpp View File

@@ -167,7 +167,7 @@ private:
(int) input.size(), (int) input.size());
std::vector<float> secondGaussian (doubleLengthOutput.size());
createGaussian (secondGaussian, 1.0f, expectedGaussianMidpoint + outputBufferSize, expectedGaussianWidth);
createGaussian (secondGaussian, 1.0f, expectedGaussianMidpoint + (float) outputBufferSize, expectedGaussianWidth);
FloatVectorOperations::add (expectedDoubleLengthOutput.data(), secondGaussian.data(), (int) expectedDoubleLengthOutput.size());
expectAllElementsWithin (doubleLengthOutput, expectedDoubleLengthOutput, 0.02f);


+ 6
- 4
source/modules/juce_audio_basics/utilities/juce_Interpolators.h View File

@@ -54,7 +54,8 @@ private:
static forcedinline float valueAtOffset (const float* const inputs, const float offset, int indexBuffer) noexcept
{
int numCrossings = 100;
const int numCrossings = 100;
const float floatCrossings = (float) numCrossings;
float result = 0.0f;
auto samplePosition = indexBuffer;
@@ -69,14 +70,15 @@ private:
if (i == -numCrossings || (sincPosition >= 0 && lastSincPosition < 0))
{
auto indexFloat = (sincPosition >= 0.f ? sincPosition : -sincPosition) * 100.0f;
index = (int) std::floor (indexFloat);
firstFrac = indexFloat - index;
auto indexFloored = std::floor (indexFloat);
index = (int) indexFloored;
firstFrac = indexFloat - indexFloored;
sign = (sincPosition < 0 ? -1 : 1);
}
if (sincPosition == 0.0f)
result += inputs[samplePosition];
else if (sincPosition < numCrossings && sincPosition > -numCrossings)
else if (sincPosition < floatCrossings && sincPosition > -floatCrossings)
result += inputs[samplePosition] * windowedSinc (firstFrac, index);
if (++samplePosition == numCrossings * 2)


+ 1
- 1
source/modules/juce_audio_basics/utilities/juce_SmoothedValue.h View File

@@ -369,7 +369,7 @@ private:
template <typename T = SmoothingType>
MultiplicativeVoid<T> setStepSize()
{
step = std::exp ((std::log (std::abs (this->target)) - std::log (std::abs (this->currentValue))) / this->countdown);
step = std::exp ((std::log (std::abs (this->target)) - std::log (std::abs (this->currentValue))) / (FloatType) this->countdown);
}
//==============================================================================


+ 1
- 0
source/modules/juce_audio_processors/format_types/juce_VST3Headers.h View File

@@ -52,6 +52,7 @@ JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wnon-virtual-dtor",
"-Wignored-qualifiers",
"-Wmissing-field-initializers",
"-Wformat=",
"-Wformat",
"-Wpedantic",
"-Wextra",
"-Wclass-memaccess")


+ 10
- 8
source/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp View File

@@ -1359,13 +1359,13 @@ struct VST3PluginWindow : public AudioProcessorEditor,
if (wasResized && view->canResize() == kResultTrue)
{
rect.right = (Steinberg::int32) roundToInt (getWidth() * nativeScaleFactor);
rect.bottom = (Steinberg::int32) roundToInt (getHeight() * nativeScaleFactor);
rect.right = (Steinberg::int32) roundToInt ((float) getWidth() * nativeScaleFactor);
rect.bottom = (Steinberg::int32) roundToInt ((float) getHeight() * nativeScaleFactor);
view->checkSizeConstraint (&rect);
auto w = roundToInt (rect.getWidth() / nativeScaleFactor);
auto h = roundToInt (rect.getHeight() / nativeScaleFactor);
auto w = roundToInt ((float) rect.getWidth() / nativeScaleFactor);
auto h = roundToInt ((float) rect.getHeight() / nativeScaleFactor);
setSize (w, h);
@@ -1459,10 +1459,10 @@ private:
//==============================================================================
static void resizeWithRect (Component& comp, const ViewRect& rect, float scaleFactor)
{
comp.setBounds (roundToInt (rect.left / scaleFactor),
roundToInt (rect.top / scaleFactor),
jmax (10, std::abs (roundToInt (rect.getWidth() / scaleFactor))),
jmax (10, std::abs (roundToInt (rect.getHeight() / scaleFactor))));
comp.setBounds (roundToInt ((float) rect.left / scaleFactor),
roundToInt ((float) rect.top / scaleFactor),
jmax (10, std::abs (roundToInt ((float) rect.getWidth() / scaleFactor))),
jmax (10, std::abs (roundToInt ((float) rect.getHeight() / scaleFactor))));
}
void attachPluginWindow()
@@ -2076,6 +2076,8 @@ public:
setLatencySamples (jmax (0, (int) processor->getLatencySamples()));
cachedBusLayouts = getBusesLayout();
setStateForAllMidiBuses (true);
warnOnFailure (holder->component->setActive (true));
warnOnFailureIfImplemented (processor->setProcessing (true));


+ 1
- 1
source/modules/juce_audio_processors/processors/juce_AudioProcessor.cpp View File

@@ -1549,7 +1549,7 @@ StringArray AudioProcessorParameter::getAllValueStrings() const
auto maxIndex = getNumSteps() - 1;
for (int i = 0; i < getNumSteps(); ++i)
valueStrings.add (getText ((float) i / maxIndex, 1024));
valueStrings.add (getText ((float) i / (float) maxIndex, 1024));
}
return valueStrings;


+ 1
- 1
source/modules/juce_audio_processors/processors/juce_GenericAudioProcessorEditor.cpp View File

@@ -284,7 +284,7 @@ private:
{
// The parameter is producing some unexpected text, so we'll do
// some linear interpolation.
index = roundToInt (getParameter().getValue() * (parameterValues.size() - 1));
index = roundToInt (getParameter().getValue() * (float) (parameterValues.size() - 1));
}
box.setSelectedItemIndex (index);


+ 1
- 1
source/modules/juce_audio_processors/scanning/juce_PluginDirectoryScanner.cpp View File

@@ -77,7 +77,7 @@ String PluginDirectoryScanner::getNextPluginFileThatWillBeScanned() const
void PluginDirectoryScanner::updateProgress()
{
progress = (1.0f - nextIndex.get() / (float) filesOrIdentifiersToScan.size());
progress = (1.0f - (float) nextIndex.get() / (float) filesOrIdentifiersToScan.size());
}
bool PluginDirectoryScanner::scanNextFile (bool dontRescanIfAlreadyInList,


+ 1
- 1
source/modules/juce_audio_processors/scanning/juce_PluginListComponent.cpp View File

@@ -88,7 +88,7 @@ public:
g.setColour (isBlacklisted ? Colours::red
: columnId == nameCol ? defaultTextColour
: defaultTextColour.interpolatedWith (Colours::transparentBlack, 0.3f));
g.setFont (Font (height * 0.7f, Font::bold));
g.setFont (Font ((float) height * 0.7f, Font::bold));
g.drawFittedText (text, 4, 0, width - 6, height, Justification::centredLeft, 1, 0.9f);
}
}


+ 1
- 1
source/modules/juce_audio_processors/utilities/juce_AudioParameterChoice.cpp View File

@@ -33,7 +33,7 @@ AudioParameterChoice::AudioParameterChoice (const String& idToUse, const String&
: RangedAudioParameter (idToUse, nameToUse, labelToUse), choices (c),
range ([this]
{
NormalisableRange<float> rangeWithInterval { 0.0f, choices.size() - 1.0f,
NormalisableRange<float> rangeWithInterval { 0.0f, (float) choices.size() - 1.0f,
[] (float, float end, float v) { return jlimit (0.0f, end, v * end); },
[] (float, float end, float v) { return jlimit (0.0f, 1.0f, v / end); },
[] (float start, float end, float v) { return (float) roundToInt (juce::jlimit (start, end, v)); } };


+ 1
- 1
source/modules/juce_audio_processors/utilities/juce_AudioParameterFloat.cpp View File

@@ -44,7 +44,7 @@ AudioParameterFloat::AudioParameterFloat (const String& idToUse, const String& n
if (range.interval != 0.0f)
{
if (approximatelyEqual (std::abs (range.interval - (int) range.interval), 0.0f))
if (approximatelyEqual (std::abs (range.interval - std::floor (range.interval)), 0.0f))
return 0;
auto v = std::abs (roundToInt (range.interval * pow (10, numDecimalPlaces)));


+ 2
- 2
source/modules/juce_core/files/juce_DirectoryIterator.cpp View File

@@ -159,10 +159,10 @@ float DirectoryIterator::getEstimatedProgress() const
if (totalNumFiles <= 0)
return 0.0f;
auto detailedIndex = (subIterator != nullptr) ? index + subIterator->getEstimatedProgress()
auto detailedIndex = (subIterator != nullptr) ? (float) index + subIterator->getEstimatedProgress()
: (float) index;
return jlimit (0.0f, 1.0f, detailedIndex / totalNumFiles);
return jlimit (0.0f, 1.0f, detailedIndex / (float) totalNumFiles);
}
} // namespace juce

+ 1
- 1
source/modules/juce_core/files/juce_File.cpp View File

@@ -485,7 +485,7 @@ String File::descriptionOfSizeInBytes (const int64 bytes)
else if (bytes < 1024 * 1024 * 1024) { suffix = " MB"; divisor = 1024.0 * 1024.0; }
else { suffix = " GB"; divisor = 1024.0 * 1024.0 * 1024.0; }
return (divisor > 0 ? String (bytes / divisor, 1) : String (bytes)) + suffix;
return (divisor > 0 ? String ((double) bytes / divisor, 1) : String (bytes)) + suffix;
}
//==============================================================================


+ 1
- 1
source/modules/juce_core/javascript/juce_Javascript.cpp View File

@@ -594,7 +594,7 @@ struct JavascriptEngine::RootObject : public DynamicObject
{
DivideOp (const CodeLocation& l, ExpPtr& a, ExpPtr& b) noexcept : BinaryOperator (l, a, b, TokenTypes::divide) {}
var getWithDoubles (double a, double b) const override { return b != 0 ? a / b : std::numeric_limits<double>::infinity(); }
var getWithInts (int64 a, int64 b) const override { return b != 0 ? var (a / (double) b) : var (std::numeric_limits<double>::infinity()); }
var getWithInts (int64 a, int64 b) const override { return b != 0 ? var ((double) a / (double) b) : var (std::numeric_limits<double>::infinity()); }
};
struct ModuloOp : public BinaryOperator


+ 2
- 1
source/modules/juce_core/maths/juce_MathsFunctions.h View File

@@ -521,7 +521,8 @@ template <typename FloatType>
unsigned int truncatePositiveToUnsignedInt (FloatType value) noexcept
{
jassert (value >= static_cast<FloatType> (0));
jassert (static_cast<FloatType> (value) <= std::numeric_limits<unsigned int>::max());
jassert (static_cast<FloatType> (value)
<= static_cast<FloatType> (std::numeric_limits<unsigned int>::max()));
return static_cast<unsigned int> (value);
}


+ 2
- 1
source/modules/juce_core/maths/juce_Random.cpp View File

@@ -105,7 +105,8 @@ bool Random::nextBool() noexcept
float Random::nextFloat() noexcept
{
auto result = static_cast<uint32> (nextInt()) / (std::numeric_limits<uint32>::max() + 1.0f);
auto result = static_cast<float> (static_cast<uint32> (nextInt()))
/ (static_cast<float> (std::numeric_limits<uint32>::max()) + 1.0f);
return result == 1.0f ? 1.0f - std::numeric_limits<float>::epsilon() : result;
}


+ 1
- 1
source/modules/juce_core/native/juce_linux_SystemStats.cpp View File

@@ -209,7 +209,7 @@ int64 Time::getHighResolutionTicksPerSecond() noexcept
double Time::getMillisecondCounterHiRes() noexcept
{
return getHighResolutionTicks() * 0.001;
return (double) getHighResolutionTicks() * 0.001;
}
bool Time::setSystemTimeToThisTime() const


+ 1
- 1
source/modules/juce_core/system/juce_PlatformDefs.h View File

@@ -39,7 +39,7 @@ namespace juce
#endif
/** This macro defines the C calling convention used as the standard for JUCE calls. */
#if JUCE_MSVC
#if JUCE_WINDOWS
#define JUCE_CALLTYPE __stdcall
#define JUCE_CDECL __cdecl
#else


+ 1
- 1
source/modules/juce_core/time/juce_PerformanceCounter.cpp View File

@@ -124,7 +124,7 @@ PerformanceCounter::Statistics PerformanceCounter::getStatisticsAndReset()
stats.clear();
if (s.numRuns > 0)
s.averageSeconds = s.totalSeconds / s.numRuns;
s.averageSeconds = s.totalSeconds / (float) s.numRuns;
return s;
}


+ 2
- 2
source/modules/juce_core/time/juce_RelativeTime.cpp View File

@@ -28,8 +28,8 @@ RelativeTime::RelativeTime (const RelativeTime& other) noexcept : numSeconds (
RelativeTime::~RelativeTime() noexcept {}
//==============================================================================
RelativeTime RelativeTime::milliseconds (int milliseconds) noexcept { return RelativeTime (milliseconds * 0.001); }
RelativeTime RelativeTime::milliseconds (int64 milliseconds) noexcept { return RelativeTime (milliseconds * 0.001); }
RelativeTime RelativeTime::milliseconds (int milliseconds) noexcept { return RelativeTime ((double) milliseconds * 0.001); }
RelativeTime RelativeTime::milliseconds (int64 milliseconds) noexcept { return RelativeTime ((double) milliseconds * 0.001); }
RelativeTime RelativeTime::seconds (double s) noexcept { return RelativeTime (s); }
RelativeTime RelativeTime::minutes (double numberOfMinutes) noexcept { return RelativeTime (numberOfMinutes * 60.0); }
RelativeTime RelativeTime::hours (double numberOfHours) noexcept { return RelativeTime (numberOfHours * (60.0 * 60.0)); }


+ 1
- 1
source/modules/juce_core/time/juce_Time.cpp View File

@@ -277,7 +277,7 @@ void Time::waitForMillisecondCounter (uint32 targetTime) noexcept
//==============================================================================
double Time::highResolutionTicksToSeconds (const int64 ticks) noexcept
{
return ticks / (double) getHighResolutionTicksPerSecond();
return (double) ticks / (double) getHighResolutionTicksPerSecond();
}
int64 Time::secondsToHighResolutionTicks (const double seconds) noexcept


+ 8
- 8
source/modules/juce_graphics/colour/juce_Colour.cpp View File

@@ -46,11 +46,11 @@ namespace ColourHelpers
if (hi > 0)
{
auto invDiff = 1.0f / (hi - lo);
auto invDiff = 1.0f / (float) (hi - lo);
auto red = (hi - r) * invDiff;
auto green = (hi - g) * invDiff;
auto blue = (hi - b) * invDiff;
auto red = (float) (hi - r) * invDiff;
auto green = (float) (hi - g) * invDiff;
auto blue = (float) (hi - b) * invDiff;
if (r == hi) hue = blue - green;
else if (g == hi) hue = 2.0f + red - blue;
@@ -79,12 +79,12 @@ namespace ColourHelpers
if (hi > 0)
{
lightness = ((hi + lo) / 2.0f) / 255.0f;
lightness = ((float) (hi + lo) / 2.0f) / 255.0f;
if (lightness > 0.0f)
hue = getHue (col);
saturation = (hi - lo) / (1.0f - std::abs ((2.0f * lightness) - 1.0f));
saturation = (float) (hi - lo) / (1.0f - std::abs ((2.0f * lightness) - 1.0f));
}
}
@@ -136,12 +136,12 @@ namespace ColourHelpers
if (hi > 0)
{
saturation = (hi - lo) / (float) hi;
saturation = (float) (hi - lo) / (float) hi;
if (saturation > 0.0f)
hue = getHue (col);
brightness = hi / 255.0f;
brightness = (float) hi / 255.0f;
}
}


+ 5
- 5
source/modules/juce_graphics/contexts/juce_GraphicsContext.cpp View File

@@ -532,10 +532,10 @@ void Graphics::fillCheckerBoard (Rectangle<float> area, float checkWidth, float
if (! clipped.isEmpty())
{
const int checkNumX = (int) ((clipped.getX() - area.getX()) / checkWidth);
const int checkNumY = (int) ((clipped.getY() - area.getY()) / checkHeight);
const float startX = area.getX() + checkNumX * checkWidth;
const float startY = area.getY() + checkNumY * checkHeight;
const int checkNumX = (int) (((float) clipped.getX() - area.getX()) / checkWidth);
const int checkNumY = (int) (((float) clipped.getY() - area.getY()) / checkHeight);
const float startX = area.getX() + (float) checkNumX * checkWidth;
const float startY = area.getY() + (float) checkNumY * checkHeight;
const float right = (float) clipped.getRight();
const float bottom = (float) clipped.getBottom();
@@ -666,7 +666,7 @@ void Graphics::drawImage (const Image& imageToDraw,
{
if (imageToDraw.isValid() && context.clipRegionIntersects (coordsToRectangle (dx, dy, dw, dh)))
drawImageTransformed (imageToDraw.getClippedImage (coordsToRectangle (sx, sy, sw, sh)),
AffineTransform::scale (dw / (float) sw, dh / (float) sh)
AffineTransform::scale ((float) dw / (float) sw, (float) dh / (float) sh)
.translated ((float) dx, (float) dy),
fillAlphaChannelWithCurrentBrush);
}


+ 1
- 1
source/modules/juce_graphics/contexts/juce_LowLevelGraphicsPostScriptRenderer.cpp View File

@@ -50,7 +50,7 @@ LowLevelGraphicsPostScriptRenderer::LowLevelGraphicsPostScriptRenderer (OutputSt
stateStack.add (new SavedState());
stateStack.getLast()->clip = Rectangle<int> (totalWidth_, totalHeight_);
const float scale = jmin ((520.0f / totalWidth_), (750.0f / totalHeight));
const float scale = jmin ((520.0f / (float) totalWidth_), (750.0f / (float) totalHeight));
out << "%!PS-Adobe-3.0 EPSF-3.0"
"\n%%BoundingBox: 0 0 600 824"


+ 5
- 5
source/modules/juce_graphics/effects/juce_DropShadowEffect.cpp View File

@@ -133,8 +133,8 @@ void DropShadow::drawForRectangle (Graphics& g, const Rectangle<int>& targetArea
for (float i = 0.05f; i < 1.0f; i += 0.1f)
cg.addColour (1.0 - i, colour.withMultipliedAlpha (i * i));
const float radiusInset = radius / 2.0f;
const float expandedRadius = radius + radiusInset;
const float radiusInset = (float) radius / 2.0f;
const float expandedRadius = (float) radius + radiusInset;
auto area = targetArea.toFloat().reduced (radiusInset) + offset.toFloat();
@@ -169,10 +169,10 @@ void DropShadowEffect::setShadowProperties (const DropShadow& newShadow)
void DropShadowEffect::applyEffect (Image& image, Graphics& g, float scaleFactor, float alpha)
{
DropShadow s (shadow);
s.radius = roundToInt (s.radius * scaleFactor);
s.radius = roundToInt ((float) s.radius * scaleFactor);
s.colour = s.colour.withMultipliedAlpha (alpha);
s.offset.x = roundToInt (s.offset.x * scaleFactor);
s.offset.y = roundToInt (s.offset.y * scaleFactor);
s.offset.x = roundToInt ((float) s.offset.x * scaleFactor);
s.offset.y = roundToInt ((float) s.offset.y * scaleFactor);
s.drawForImage (g, image);


+ 2
- 2
source/modules/juce_graphics/fonts/juce_Font.cpp View File

@@ -636,7 +636,7 @@ float Font::getStringWidthFloat (const String& text) const
auto w = getTypeface()->getStringWidth (text);
if (font->kerning != 0.0f)
w += font->kerning * text.length();
w += font->kerning * (float) text.length();
return w * font->height * font->horizontalScale;
}
@@ -657,7 +657,7 @@ void Font::getGlyphPositions (const String& text, Array<int>& glyphs, Array<floa
if (font->kerning != 0.0f)
{
for (int i = 0; i < num; ++i)
x[i] = (x[i] + i * font->kerning) * scale;
x[i] = (x[i] + (float) i * font->kerning) * scale;
}
else
{


+ 2
- 2
source/modules/juce_graphics/fonts/juce_GlyphArrangement.cpp View File

@@ -581,7 +581,7 @@ void GlyphArrangement::splitLines (const String& text, Font font, int startIndex
// allowing for unevenness in the lengths due to differently sized words.
const float lineLengthUnevennessAllowance = 80.0f;
if (numLines > (lineWidth + lineLengthUnevennessAllowance) / width || newFontHeight < 8.0f)
if ((float) numLines > (lineWidth + lineLengthUnevennessAllowance) / width || newFontHeight < 8.0f)
break;
}
@@ -591,7 +591,7 @@ void GlyphArrangement::splitLines (const String& text, Font font, int startIndex
int lineIndex = 0;
auto lineY = y;
auto widthPerLine = jmin (width / minimumHorizontalScale,
lineWidth / numLines);
lineWidth / (float) numLines);
while (lineY < y + height)
{


+ 2
- 2
source/modules/juce_graphics/fonts/juce_TextLayout.cpp View File

@@ -224,8 +224,8 @@ void TextLayout::draw (Graphics& g, Rectangle<float> area) const
context.saveState();
auto clip = context.getClipBounds();
auto clipTop = clip.getY() - origin.y;
auto clipBottom = clip.getBottom() - origin.y;
auto clipTop = (float) clip.getY() - origin.y;
auto clipBottom = (float) clip.getBottom() - origin.y;
for (auto& line : *this)
{


+ 1
- 1
source/modules/juce_graphics/fonts/juce_Typeface.cpp View File

@@ -242,7 +242,7 @@ private:
}
}
return num < 4 ? 0.0f : total / (num * (float) standardHeight);
return num < 4 ? 0.0f : total / ((float) num * (float) standardHeight);
}
enum { standardHeight = 100 };


+ 4
- 4
source/modules/juce_graphics/geometry/juce_Path.cpp View File

@@ -615,11 +615,11 @@ void Path::addPolygon (Point<float> centre, int numberOfSides,
if (numberOfSides > 1)
{
auto angleBetweenPoints = MathConstants<float>::twoPi / numberOfSides;
auto angleBetweenPoints = MathConstants<float>::twoPi / (float) numberOfSides;
for (int i = 0; i < numberOfSides; ++i)
{
auto angle = startAngle + i * angleBetweenPoints;
auto angle = startAngle + (float) i * angleBetweenPoints;
auto p = centre.getPointOnCircumference (radius, angle);
if (i == 0)
@@ -639,11 +639,11 @@ void Path::addStar (Point<float> centre, int numberOfPoints, float innerRadius,
if (numberOfPoints > 1)
{
auto angleBetweenPoints = MathConstants<float>::twoPi / numberOfPoints;
auto angleBetweenPoints = MathConstants<float>::twoPi / (float) numberOfPoints;
for (int i = 0; i < numberOfPoints; ++i)
{
auto angle = startAngle + i * angleBetweenPoints;
auto angle = startAngle + (float) i * angleBetweenPoints;
auto p = centre.getPointOnCircumference (outerRadius, angle);
if (i == 0)


+ 4
- 4
source/modules/juce_graphics/geometry/juce_Point.h View File

@@ -121,11 +121,11 @@ public:
/** Returns a point whose coordinates are multiplied by a given scalar value. */
template <typename FloatType>
constexpr Point operator* (FloatType multiplier) const noexcept { return Point ((ValueType) (x * multiplier), (ValueType) (y * multiplier)); }
constexpr Point operator* (FloatType multiplier) const noexcept { return Point ((ValueType) ((FloatType) x * multiplier), (ValueType) ((FloatType) y * multiplier)); }
/** Returns a point whose coordinates are divided by a given scalar value. */
template <typename FloatType>
constexpr Point operator/ (FloatType divisor) const noexcept { return Point ((ValueType) (x / divisor), (ValueType) (y / divisor)); }
constexpr Point operator/ (FloatType divisor) const noexcept { return Point ((ValueType) ((FloatType) x / divisor), (ValueType) ((FloatType) y / divisor)); }
/** Multiplies the point's coordinates by a scalar value. */
template <typename FloatType>
@@ -212,8 +212,8 @@ public:
/** Returns the position of this point, if it is transformed by a given AffineTransform. */
Point transformedBy (const AffineTransform& transform) const noexcept
{
return Point (static_cast<ValueType> (transform.mat00 * x + transform.mat01 * y + transform.mat02),
static_cast<ValueType> (transform.mat10 * x + transform.mat11 * y + transform.mat12));
return Point (static_cast<ValueType> (transform.mat00 * (float) x + transform.mat01 * (float) y + transform.mat02),
static_cast<ValueType> (transform.mat10 * (float) x + transform.mat11 * (float) y + transform.mat12));
}
//==============================================================================


+ 20
- 20
source/modules/juce_graphics/geometry/juce_Rectangle.h View File

@@ -349,10 +349,10 @@ public:
template <typename FloatType>
Rectangle operator*= (FloatType scaleFactor) noexcept
{
Rectangle<FloatType> (pos.x * scaleFactor,
pos.y * scaleFactor,
w * scaleFactor,
h * scaleFactor).copyWithRounding (*this);
Rectangle<FloatType> ((FloatType) pos.x * scaleFactor,
(FloatType) pos.y * scaleFactor,
(FloatType) w * scaleFactor,
(FloatType) h * scaleFactor).copyWithRounding (*this);
return *this;
}
@@ -364,10 +364,10 @@ public:
template <typename FloatType>
Rectangle operator*= (Point<FloatType> scaleFactor) noexcept
{
Rectangle<FloatType> (pos.x * scaleFactor.x,
pos.y * scaleFactor.y,
w * scaleFactor.x,
h * scaleFactor.y).copyWithRounding (*this);
Rectangle<FloatType> ((FloatType) pos.x * scaleFactor.x,
(FloatType) pos.y * scaleFactor.y,
(FloatType) w * scaleFactor.x,
(FloatType) h * scaleFactor.y).copyWithRounding (*this);
return *this;
}
@@ -384,10 +384,10 @@ public:
template <typename FloatType>
Rectangle operator/= (FloatType scaleFactor) noexcept
{
Rectangle<FloatType> (pos.x / scaleFactor,
pos.y / scaleFactor,
w / scaleFactor,
h / scaleFactor).copyWithRounding (*this);
Rectangle<FloatType> ((FloatType) pos.x / scaleFactor,
(FloatType) pos.y / scaleFactor,
(FloatType) w / scaleFactor,
(FloatType) h / scaleFactor).copyWithRounding (*this);
return *this;
}
@@ -395,10 +395,10 @@ public:
template <typename FloatType>
Rectangle operator/= (Point<FloatType> scaleFactor) noexcept
{
Rectangle<FloatType> (pos.x / scaleFactor.x,
pos.y / scaleFactor.y,
w / scaleFactor.x,
h / scaleFactor.y).copyWithRounding (*this);
Rectangle<FloatType> ((FloatType) pos.x / scaleFactor.x,
(FloatType) pos.y / scaleFactor.y,
(FloatType) w / scaleFactor.x,
(FloatType) h / scaleFactor.y).copyWithRounding (*this);
return *this;
}
@@ -552,22 +552,22 @@ public:
template <typename FloatType>
Point<ValueType> getRelativePoint (FloatType relativeX, FloatType relativeY) const noexcept
{
return { pos.x + static_cast<ValueType> (w * relativeX),
pos.y + static_cast<ValueType> (h * relativeY) };
return { pos.x + static_cast<ValueType> ((FloatType) w * relativeX),
pos.y + static_cast<ValueType> ((FloatType) h * relativeY) };
}
/** Returns a proportion of the width of this rectangle. */
template <typename FloatType>
ValueType proportionOfWidth (FloatType proportion) const noexcept
{
return static_cast<ValueType> (w * proportion);
return static_cast<ValueType> ((FloatType) w * proportion);
}
/** Returns a proportion of the height of this rectangle. */
template <typename FloatType>
ValueType proportionOfHeight (FloatType proportion) const noexcept
{
return static_cast<ValueType> (h * proportion);
return static_cast<ValueType> ((FloatType) h * proportion);
}
/** Returns a rectangle based on some proportional coordinates relative to this one.


+ 2
- 2
source/modules/juce_graphics/images/juce_Image.cpp View File

@@ -309,8 +309,8 @@ Image Image::rescaled (int newWidth, int newHeight, Graphics::ResamplingQuality
Graphics g (newImage);
g.setImageResamplingQuality (quality);
g.drawImageTransformed (*this, AffineTransform::scale (newWidth / (float) image->width,
newHeight / (float) image->height), false);
g.drawImageTransformed (*this, AffineTransform::scale ((float) newWidth / (float) image->width,
(float) newHeight / (float) image->height), false);
return newImage;
}


+ 13
- 13
source/modules/juce_graphics/native/juce_freetype_Fonts.cpp View File

@@ -197,7 +197,7 @@ public:
{
for (auto& path : paths)
{
for (const auto iter : RangedDirectoryIterator (File::getCurrentWorkingDirectory().getChildFile (path), true))
for (const auto& iter : RangedDirectoryIterator (File::getCurrentWorkingDirectory().getChildFile (path), true))
if (iter.getFile().hasFileExtension ("ttf;pfb;pcf;otf"))
scanFont (iter.getFile());
}
@@ -325,7 +325,7 @@ public:
if (getGlyphShape (destShape, face->glyph->outline, scale))
{
addGlyph (character, destShape, face->glyph->metrics.horiAdvance * scale);
addGlyph (character, destShape, (float) face->glyph->metrics.horiAdvance * scale);
if ((face->face_flags & FT_FACE_FLAG_KERNING) != 0)
addKerning (face, (uint32) character, glyphIndex);
@@ -355,15 +355,15 @@ private:
for (int p = startPoint; p <= endPoint; ++p)
{
auto x = scaleX * points[p].x;
auto y = scaleY * points[p].y;
auto x = scaleX * (float) points[p].x;
auto y = scaleY * (float) points[p].y;
if (p == startPoint)
{
if (FT_CURVE_TAG (tags[p]) == FT_Curve_Tag_Conic)
{
auto x2 = scaleX * points [endPoint].x;
auto y2 = scaleY * points [endPoint].y;
auto x2 = scaleX * (float) points[endPoint].x;
auto y2 = scaleY * (float) points[endPoint].y;
if (FT_CURVE_TAG (tags[endPoint]) != FT_Curve_Tag_On)
{
@@ -387,8 +387,8 @@ private:
else if (FT_CURVE_TAG (tags[p]) == FT_Curve_Tag_Conic)
{
const int nextIndex = (p == endPoint) ? startPoint : p + 1;
auto x2 = scaleX * points [nextIndex].x;
auto y2 = scaleY * points [nextIndex].y;
auto x2 = scaleX * (float) points[nextIndex].x;
auto y2 = scaleY * (float) points[nextIndex].y;
if (FT_CURVE_TAG (tags [nextIndex]) == FT_Curve_Tag_Conic)
{
@@ -412,10 +412,10 @@ private:
|| FT_CURVE_TAG (tags[next2]) != FT_Curve_Tag_On)
return false;
auto x2 = scaleX * points [next1].x;
auto y2 = scaleY * points [next1].y;
auto x3 = scaleX * points [next2].x;
auto y3 = scaleY * points [next2].y;
auto x2 = scaleX * (float) points[next1].x;
auto y2 = scaleY * (float) points[next1].y;
auto x3 = scaleX * (float) points[next2].x;
auto y3 = scaleY * (float) points[next2].y;
destShape.cubicTo (x, y, x2, y2, x3, y3);
p += 2;
@@ -441,7 +441,7 @@ private:
if (FT_Get_Kerning (face, glyphIndex, rightGlyphIndex, ft_kerning_unscaled, &kerning) == 0
&& kerning.x != 0)
addKerningPair ((juce_wchar) character, (juce_wchar) rightCharCode, kerning.x / height);
addKerningPair ((juce_wchar) character, (juce_wchar) rightCharCode, (float) kerning.x / height);
rightCharCode = FT_Get_Next_Char (face, rightCharCode, &rightGlyphIndex);
}


+ 1
- 1
source/modules/juce_gui_basics/buttons/juce_ArrowButton.cpp View File

@@ -40,7 +40,7 @@ void ArrowButton::paintButton (Graphics& g, bool /*shouldDrawButtonAsHighlighted
Path p (path);
const float offset = shouldDrawButtonAsDown ? 1.0f : 0.0f;
p.applyTransform (path.getTransformToScaleToFit (offset, offset, getWidth() - 3.0f, getHeight() - 3.0f, false));
p.applyTransform (path.getTransformToScaleToFit (offset, offset, (float) getWidth() - 3.0f, (float) getHeight() - 3.0f, false));
DropShadow (Colours::black.withAlpha (0.3f), shouldDrawButtonAsDown ? 2 : 4, Point<int>()).drawForPath (g, p);


+ 1
- 1
source/modules/juce_gui_basics/buttons/juce_HyperlinkButton.cpp View File

@@ -71,7 +71,7 @@ void HyperlinkButton::setURL (const URL& newURL) noexcept
Font HyperlinkButton::getFontToUse() const
{
if (resizeFont)
return font.withHeight (getHeight() * 0.7f);
return font.withHeight ((float) getHeight() * 0.7f);
return font;
}


+ 4
- 4
source/modules/juce_gui_basics/buttons/juce_ImageButton.cpp View File

@@ -133,18 +133,18 @@ void ImageButton::paintButton (Graphics& g,
if (preserveProportions)
{
int newW, newH;
const float imRatio = ih / (float) iw;
const float destRatio = h / (float) w;
const float imRatio = (float) ih / (float) iw;
const float destRatio = (float) h / (float) w;
if (imRatio > destRatio)
{
newW = roundToInt (h / imRatio);
newW = roundToInt ((float) h / imRatio);
newH = h;
}
else
{
newW = w;
newH = roundToInt (w * imRatio);
newH = roundToInt ((float) w * imRatio);
}
x = (w - newW) / 2;


+ 22
- 22
source/modules/juce_gui_basics/components/juce_Component.cpp View File

@@ -202,18 +202,18 @@ struct ScalingHelpers
// judder when moving windows
static Rectangle<int> unscaledScreenPosToScaled (float scale, Rectangle<int> pos) noexcept
{
return scale != 1.0f ? Rectangle<int> (roundToInt (pos.getX() / scale),
roundToInt (pos.getY() / scale),
roundToInt (pos.getWidth() / scale),
roundToInt (pos.getHeight() / scale)) : pos;
return scale != 1.0f ? Rectangle<int> (roundToInt ((float) pos.getX() / scale),
roundToInt ((float) pos.getY() / scale),
roundToInt ((float) pos.getWidth() / scale),
roundToInt ((float) pos.getHeight() / scale)) : pos;
}
static Rectangle<int> scaledScreenPosToUnscaled (float scale, Rectangle<int> pos) noexcept
{
return scale != 1.0f ? Rectangle<int> (roundToInt (pos.getX() * scale),
roundToInt (pos.getY() * scale),
roundToInt (pos.getWidth() * scale),
roundToInt (pos.getHeight() * scale)) : pos;
return scale != 1.0f ? Rectangle<int> (roundToInt ((float) pos.getX() * scale),
roundToInt ((float) pos.getY() * scale),
roundToInt ((float) pos.getWidth() * scale),
roundToInt ((float) pos.getHeight() * scale)) : pos;
}
template <typename PointOrRect>
@@ -808,8 +808,8 @@ struct StandardCachedComponentImage : public CachedComponentImage
validArea = compBounds;
g.setColour (Colours::black.withAlpha (owner.getAlpha()));
g.drawImageTransformed (image, AffineTransform::scale (compBounds.getWidth() / (float) imageBounds.getWidth(),
compBounds.getHeight() / (float) imageBounds.getHeight()), false);
g.drawImageTransformed (image, AffineTransform::scale ((float) compBounds.getWidth() / (float) imageBounds.getWidth(),
(float) compBounds.getHeight() / (float) imageBounds.getHeight()), false);
}
bool invalidateAll() override { validArea.clear(); return true; }
@@ -1026,8 +1026,8 @@ bool Component::isAlwaysOnTop() const noexcept
}
//==============================================================================
int Component::proportionOfWidth (float proportion) const noexcept { return roundToInt (proportion * boundsRelativeToParent.getWidth()); }
int Component::proportionOfHeight (float proportion) const noexcept { return roundToInt (proportion * boundsRelativeToParent.getHeight()); }
int Component::proportionOfWidth (float proportion) const noexcept { return roundToInt (proportion * (float) boundsRelativeToParent.getWidth()); }
int Component::proportionOfHeight (float proportion) const noexcept { return roundToInt (proportion * (float) boundsRelativeToParent.getHeight()); }
int Component::getParentWidth() const noexcept
{
@@ -1179,8 +1179,8 @@ void Component::setCentrePosition (int x, int y) { setCentrePosition ({ x
void Component::setCentreRelative (float x, float y)
{
setCentrePosition (roundToInt (getParentWidth() * x),
roundToInt (getParentHeight() * y));
setCentrePosition (roundToInt ((float) getParentWidth() * x),
roundToInt ((float) getParentHeight() * y));
}
void Component::setBoundsRelative (Rectangle<float> target)
@@ -1854,8 +1854,8 @@ void Component::internalRepaintUnchecked (Rectangle<int> area, bool isEntireComp
{
// Tweak the scaling so that the component's integer size exactly aligns with the peer's scaled size
auto peerBounds = peer->getBounds();
auto scaled = area * Point<float> (peerBounds.getWidth() / (float) getWidth(),
peerBounds.getHeight() / (float) getHeight());
auto scaled = area * Point<float> ((float) peerBounds.getWidth() / (float) getWidth(),
(float) peerBounds.getHeight() / (float) getHeight());
peer->repaint (affineTransform != nullptr ? scaled.transformedBy (*affineTransform) : scaled);
}
@@ -1981,8 +1981,8 @@ void Component::paintEntireComponent (Graphics& g, bool ignoreAlphaLevel)
scaledBounds.getWidth(), scaledBounds.getHeight(), ! flags.opaqueFlag);
{
Graphics g2 (effectImage);
g2.addTransform (AffineTransform::scale (scaledBounds.getWidth() / (float) getWidth(),
scaledBounds.getHeight() / (float) getHeight()));
g2.addTransform (AffineTransform::scale ((float) scaledBounds.getWidth() / (float) getWidth(),
(float) scaledBounds.getHeight() / (float) getHeight()));
paintComponentAndChildren (g2);
}
@@ -2032,16 +2032,16 @@ Image Component::createComponentSnapshot (Rectangle<int> areaToGrab,
if (r.isEmpty())
return {};
auto w = roundToInt (scaleFactor * r.getWidth());
auto h = roundToInt (scaleFactor * r.getHeight());
auto w = roundToInt (scaleFactor * (float) r.getWidth());
auto h = roundToInt (scaleFactor * (float) r.getHeight());
Image image (flags.opaqueFlag ? Image::RGB : Image::ARGB, w, h, true);
Graphics g (image);
if (w != getWidth() || h != getHeight())
g.addTransform (AffineTransform::scale (w / (float) r.getWidth(),
h / (float) r.getHeight()));
g.addTransform (AffineTransform::scale ((float) w / (float) r.getWidth(),
(float) h / (float) r.getHeight()));
g.setOrigin (-r.getPosition());
paintEntireComponent (g, true);


+ 7
- 4
source/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.cpp View File

@@ -117,10 +117,6 @@ FileBrowserComponent::FileBrowserComponent (int flags_,
lookAndFeelChanged();
addAndMakeVisible (goUpButton.get());
goUpButton->onClick = [this] { goUp(); };
goUpButton->setTooltip (TRANS ("Go up to parent directory"));
setRoot (currentRoot);
if (filename.isNotEmpty())
@@ -359,6 +355,13 @@ void FileBrowserComponent::lookAndFeelChanged()
{
goUpButton.reset (getLookAndFeel().createFileBrowserGoUpButton());
if (auto* buttonPtr = goUpButton.get())
{
addAndMakeVisible (*buttonPtr);
buttonPtr->onClick = [this] { goUp(); };
buttonPtr->setTooltip (TRANS ("Go up to parent directory"));
}
currentPathBox.setColour (ComboBox::backgroundColourId, findColour (currentPathBoxBackgroundColourId));
currentPathBox.setColour (ComboBox::textColourId, findColour (currentPathBoxTextColourId));
currentPathBox.setColour (ComboBox::arrowColourId, findColour (currentPathBoxArrowColourId));


+ 1
- 1
source/modules/juce_gui_basics/filebrowser/juce_FileChooserDialogBox.cpp View File

@@ -63,7 +63,7 @@ public:
auto area = getLocalBounds();
text.createLayout (getLookAndFeel().createFileChooserHeaderText (getName(), instructions),
getWidth() - 12.0f);
(float) getWidth() - 12.0f);
area.removeFromTop (roundToInt (text.getHeight()) + 10);


+ 1
- 1
source/modules/juce_gui_basics/filebrowser/juce_FileSearchPathListComponent.cpp View File

@@ -129,7 +129,7 @@ void FileSearchPathListComponent::paintListBoxItem (int rowNumber, Graphics& g,
g.fillAll (findColour (TextEditor::highlightColourId));
g.setColour (findColour (ListBox::textColourId));
Font f (height * 0.7f);
Font f ((float) height * 0.7f);
f.setHorizontalScale (0.9f);
g.setFont (f);


+ 2
- 2
source/modules/juce_gui_basics/layout/juce_ComponentAnimator.cpp View File

@@ -175,8 +175,8 @@ public:
void paint (Graphics& g) override
{
g.setOpacity (1.0f);
g.drawImageTransformed (image, AffineTransform::scale (getWidth() / (float) jmax (1, image.getWidth()),
getHeight() / (float) jmax (1, image.getHeight())), false);
g.drawImageTransformed (image, AffineTransform::scale ((float) getWidth() / (float) jmax (1, image.getWidth()),
(float) getHeight() / (float) jmax (1, image.getHeight())), false);
}
private:


+ 6
- 6
source/modules/juce_gui_basics/layout/juce_Grid.cpp View File

@@ -440,25 +440,25 @@ struct Grid::PlacementHelpers
if (alignContent == Grid::AlignContent::spaceBetween)
{
const auto shift = ((rowNumber - 1) * (calculation.remainingHeight / float(numberOfRows - 1)));
const auto shift = ((float) (rowNumber - 1) * (calculation.remainingHeight / float(numberOfRows - 1)));
area.setY (area.getY() + shift);
}
if (justifyContent == Grid::JustifyContent::spaceBetween)
{
const auto shift = ((columnNumber - 1) * (calculation.remainingWidth / float(numberOfColumns - 1)));
const auto shift = ((float) (columnNumber - 1) * (calculation.remainingWidth / float(numberOfColumns - 1)));
area.setX (area.getX() + shift);
}
if (alignContent == Grid::AlignContent::spaceEvenly)
{
const auto shift = (rowNumber * (calculation.remainingHeight / float(numberOfRows + 1)));
const auto shift = ((float) rowNumber * (calculation.remainingHeight / float(numberOfRows + 1)));
area.setY (area.getY() + shift);
}
if (justifyContent == Grid::JustifyContent::spaceEvenly)
{
const auto shift = (columnNumber * (calculation.remainingWidth / float(numberOfColumns + 1)));
const auto shift = ((float) columnNumber * (calculation.remainingWidth / float(numberOfColumns + 1)));
area.setX (area.getX() + shift);
}
@@ -466,7 +466,7 @@ struct Grid::PlacementHelpers
{
const auto inbetweenShift = calculation.remainingHeight / float(numberOfRows);
const auto sidesShift = inbetweenShift / 2;
auto shift = (rowNumber - 1) * inbetweenShift + sidesShift;
auto shift = (float) (rowNumber - 1) * inbetweenShift + sidesShift;
area.setY (area.getY() + shift);
}
@@ -475,7 +475,7 @@ struct Grid::PlacementHelpers
{
const auto inbetweenShift = calculation.remainingWidth / float(numberOfColumns);
const auto sidesShift = inbetweenShift / 2;
auto shift = (columnNumber - 1) * inbetweenShift + sidesShift;
auto shift = (float) (columnNumber - 1) * inbetweenShift + sidesShift;
area.setX (area.getX() + shift);
}


+ 1
- 1
source/modules/juce_gui_basics/layout/juce_Viewport.cpp View File

@@ -531,7 +531,7 @@ static int rescaleMouseWheelDistance (float distance, int singleStepSize) noexce
if (distance == 0.0f)
return 0;
distance *= 14.0f * singleStepSize;
distance *= 14.0f * (float) singleStepSize;
return roundToInt (distance < 0 ? jmin (distance, -1.0f)
: jmax (distance, 1.0f));


+ 77
- 63
source/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V1.cpp View File

@@ -57,13 +57,13 @@ void LookAndFeel_V1::drawButtonBackground (Graphics& g, Button& button, const Co
const int height = button.getHeight();
const float indent = 2.0f;
const int cornerSize = jmin (roundToInt (width * 0.4f),
roundToInt (height * 0.4f));
const int cornerSize = jmin (roundToInt ((float) width * 0.4f),
roundToInt ((float) height * 0.4f));
Path p;
p.addRoundedRectangle (indent, indent,
width - indent * 2.0f,
height - indent * 2.0f,
(float) width - indent * 2.0f,
(float) height - indent * 2.0f,
(float) cornerSize);
Colour bc (backgroundColour.withMultipliedSaturation (0.3f));
@@ -127,7 +127,7 @@ void LookAndFeel_V1::drawToggleButton (Graphics& g, ToggleButton& button, bool s
const int tickWidth = jmin (20, button.getHeight() - 4);
drawTickBox (g, button, 4.0f, (button.getHeight() - tickWidth) * 0.5f,
drawTickBox (g, button, 4.0f, (float) (button.getHeight() - tickWidth) * 0.5f,
(float) tickWidth, (float) tickWidth,
button.getToggleState(),
button.isEnabled(),
@@ -135,7 +135,7 @@ void LookAndFeel_V1::drawToggleButton (Graphics& g, ToggleButton& button, bool s
shouldDrawButtonAsDown);
g.setColour (button.findColour (ToggleButton::textColourId));
g.setFont (jmin (15.0f, button.getHeight() * 0.6f));
g.setFont (jmin (15.0f, (float) button.getHeight() * 0.6f));
if (! button.isEnabled())
g.setOpacity (0.5f);
@@ -171,7 +171,7 @@ void LookAndFeel_V1::drawProgressBar (Graphics& g, ProgressBar& progressBar,
if (textToShow.isNotEmpty())
{
g.setColour (Colour::contrasting (background, foreground));
g.setFont (height * 0.6f);
g.setFont ((float) height * 0.6f);
g.drawText (textToShow, 0, 0, width, height, Justification::centred, false);
}
@@ -191,22 +191,25 @@ void LookAndFeel_V1::drawScrollbarButton (Graphics& g, ScrollBar& bar,
Path p;
const auto w = (float) width;
const auto h = (float) height;
if (buttonDirection == 0)
p.addTriangle (width * 0.5f, height * 0.2f,
width * 0.1f, height * 0.7f,
width * 0.9f, height * 0.7f);
p.addTriangle (w * 0.5f, h * 0.2f,
w * 0.1f, h * 0.7f,
w * 0.9f, h * 0.7f);
else if (buttonDirection == 1)
p.addTriangle (width * 0.8f, height * 0.5f,
width * 0.3f, height * 0.1f,
width * 0.3f, height * 0.9f);
p.addTriangle (w * 0.8f, h * 0.5f,
w * 0.3f, h * 0.1f,
w * 0.3f, h * 0.9f);
else if (buttonDirection == 2)
p.addTriangle (width * 0.5f, height * 0.8f,
width * 0.1f, height * 0.3f,
width * 0.9f, height * 0.3f);
p.addTriangle (w * 0.5f, h * 0.8f,
w * 0.1f, h * 0.3f,
w * 0.9f, h * 0.3f);
else if (buttonDirection == 3)
p.addTriangle (width * 0.2f, height * 0.5f,
width * 0.7f, height * 0.1f,
width * 0.7f, height * 0.9f);
p.addTriangle (w * 0.2f, h * 0.5f,
w * 0.7f, h * 0.1f,
w * 0.7f, h * 0.9f);
if (shouldDrawButtonAsDown)
g.setColour (Colours::white);
@@ -231,15 +234,15 @@ void LookAndFeel_V1::drawScrollbar (Graphics& g, ScrollBar& bar,
g.setColour (bar.findColour (ScrollBar::thumbColourId)
.withAlpha ((isMouseOver || isMouseDown) ? 0.4f : 0.15f));
if (thumbSize > 0.0f)
if ((float) thumbSize > 0.0f)
{
Rectangle<int> thumb;
if (isScrollbarVertical)
{
width -= 2;
g.fillRect (x + roundToInt (width * 0.35f), y,
roundToInt (width * 0.3f), height);
g.fillRect (x + roundToInt ((float) width * 0.35f), y,
roundToInt ((float) width * 0.3f), height);
thumb.setBounds (x + 1, thumbStartPosition,
width - 2, thumbSize);
@@ -247,8 +250,8 @@ void LookAndFeel_V1::drawScrollbar (Graphics& g, ScrollBar& bar,
else
{
height -= 2;
g.fillRect (x, y + roundToInt (height * 0.35f),
width, roundToInt (height * 0.3f));
g.fillRect (x, y + roundToInt ((float) height * 0.35f),
width, roundToInt ((float) height * 0.3f));
thumb.setBounds (thumbStartPosition, y + 1,
thumbSize, height - 2);
@@ -266,20 +269,20 @@ void LookAndFeel_V1::drawScrollbar (Graphics& g, ScrollBar& bar,
{
for (int i = 3; --i >= 0;)
{
const float linePos = thumbStartPosition + thumbSize / 2 + (i - 1) * 4.0f;
const float linePos = (float) thumbStartPosition + (float) thumbSize * 0.5f + (float) (i - 1) * 4.0f;
g.setColour (Colours::black.withAlpha (0.15f));
if (isScrollbarVertical)
{
g.drawLine (x + width * 0.2f, linePos, width * 0.8f, linePos);
g.drawLine ((float) x + (float) width * 0.2f, linePos, (float) width * 0.8f, linePos);
g.setColour (Colours::white.withAlpha (0.15f));
g.drawLine (width * 0.2f, linePos - 1, width * 0.8f, linePos - 1);
g.drawLine ((float) width * 0.2f, linePos - 1.0f, (float) width * 0.8f, linePos - 1.0f);
}
else
{
g.drawLine (linePos, height * 0.2f, linePos, height * 0.8f);
g.drawLine (linePos, (float) height * 0.2f, linePos, (float) height * 0.8f);
g.setColour (Colours::white.withAlpha (0.15f));
g.drawLine (linePos - 1, height * 0.2f, linePos - 1, height * 0.8f);
g.drawLine (linePos - 1.0f, (float) height * 0.2f, linePos - 1.0f, (float) height * 0.8f);
}
}
}
@@ -335,16 +338,21 @@ void LookAndFeel_V1::drawComboBox (Graphics& g, int width, int height,
const float arrowX = 0.2f;
const float arrowH = 0.3f;
const auto x = (float) buttonX;
const auto y = (float) buttonY;
const auto w = (float) buttonW;
const auto h = (float) buttonH;
if (box.isEnabled())
{
Path p;
p.addTriangle (buttonX + buttonW * 0.5f, buttonY + buttonH * (0.45f - arrowH),
buttonX + buttonW * (1.0f - arrowX), buttonY + buttonH * 0.45f,
buttonX + buttonW * arrowX, buttonY + buttonH * 0.45f);
p.addTriangle (x + w * 0.5f, y + h * (0.45f - arrowH),
x + w * (1.0f - arrowX), y + h * 0.45f,
x + w * arrowX, y + h * 0.45f);
p.addTriangle (buttonX + buttonW * 0.5f, buttonY + buttonH * (0.55f + arrowH),
buttonX + buttonW * (1.0f - arrowX), buttonY + buttonH * 0.55f,
buttonX + buttonW * arrowX, buttonY + buttonH * 0.55f);
p.addTriangle (x + w * 0.5f, y + h * (0.55f + arrowH),
x + w * (1.0f - arrowX), y + h * 0.55f,
x + w * arrowX, y + h * 0.55f);
g.setColour (box.findColour ((isButtonDown) ? ComboBox::backgroundColourId
: ComboBox::buttonColourId));
@@ -354,7 +362,7 @@ void LookAndFeel_V1::drawComboBox (Graphics& g, int width, int height,
Font LookAndFeel_V1::getComboBoxFont (ComboBox& box)
{
Font f (jmin (15.0f, box.getHeight() * 0.85f));
Font f (jmin (15.0f, (float) box.getHeight() * 0.85f));
f.setHorizontalScale (0.9f);
return f;
}
@@ -394,13 +402,13 @@ void LookAndFeel_V1::drawLinearSlider (Graphics& g,
if (slider.isHorizontal())
{
g.fillRect (x, y + roundToInt (h * 0.6f),
w, roundToInt (h * 0.2f));
g.fillRect (x, y + roundToInt ((float) h * 0.6f),
w, roundToInt ((float) h * 0.2f));
}
else
{
g.fillRect (x + roundToInt (w * 0.5f - jmin (3.0f, w * 0.1f)), y,
jmin (4, roundToInt (w * 0.2f)), h);
g.fillRect (x + roundToInt ((float) w * 0.5f - jmin (3.0f, (float) w * 0.1f)), y,
jmin (4, roundToInt ((float) w * 0.2f)), h);
}
float alpha = 0.35f;
@@ -413,41 +421,47 @@ void LookAndFeel_V1::drawLinearSlider (Graphics& g,
if (style == Slider::TwoValueVertical || style == Slider::ThreeValueVertical)
{
drawTriangle (g, x + w * 0.5f + jmin (4.0f, w * 0.3f), minSliderPos,
x + w * 0.5f - jmin (8.0f, w * 0.4f), minSliderPos - 7.0f,
x + w * 0.5f - jmin (8.0f, w * 0.4f), minSliderPos,
drawTriangle (g,
(float) x + (float) w * 0.5f + jmin (4.0f, (float) w * 0.3f), minSliderPos,
(float) x + (float) w * 0.5f - jmin (8.0f, (float) w * 0.4f), minSliderPos - 7.0f,
(float) x + (float) w * 0.5f - jmin (8.0f, (float) w * 0.4f), minSliderPos,
fill, outline);
drawTriangle (g, x + w * 0.5f + jmin (4.0f, w * 0.3f), maxSliderPos,
x + w * 0.5f - jmin (8.0f, w * 0.4f), maxSliderPos,
x + w * 0.5f - jmin (8.0f, w * 0.4f), maxSliderPos + 7.0f,
drawTriangle (g,
(float) x + (float) w * 0.5f + jmin (4.0f, (float) w * 0.3f), maxSliderPos,
(float) x + (float) w * 0.5f - jmin (8.0f, (float) w * 0.4f), maxSliderPos,
(float) x + (float) w * 0.5f - jmin (8.0f, (float) w * 0.4f), maxSliderPos + 7.0f,
fill, outline);
}
else if (style == Slider::TwoValueHorizontal || style == Slider::ThreeValueHorizontal)
{
drawTriangle (g, minSliderPos, y + h * 0.6f - jmin (4.0f, h * 0.3f),
minSliderPos - 7.0f, y + h * 0.9f ,
minSliderPos, y + h * 0.9f,
drawTriangle (g,
minSliderPos, (float) y + (float) h * 0.6f - jmin (4.0f, (float) h * 0.3f),
minSliderPos - 7.0f, (float) y + (float) h * 0.9f,
minSliderPos, (float) y + (float) h * 0.9f,
fill, outline);
drawTriangle (g, maxSliderPos, y + h * 0.6f - jmin (4.0f, h * 0.3f),
maxSliderPos, y + h * 0.9f,
maxSliderPos + 7.0f, y + h * 0.9f,
drawTriangle (g,
maxSliderPos, (float) y + (float) h * 0.6f - jmin (4.0f, (float) h * 0.3f),
maxSliderPos, (float) y + (float) h * 0.9f,
maxSliderPos + 7.0f, (float) y + (float) h * 0.9f,
fill, outline);
}
if (style == Slider::LinearHorizontal || style == Slider::ThreeValueHorizontal)
{
drawTriangle (g, sliderPos, y + h * 0.9f,
sliderPos - 7.0f, y + h * 0.2f,
sliderPos + 7.0f, y + h * 0.2f,
drawTriangle (g,
sliderPos, (float) y + (float) h * 0.9f,
sliderPos - 7.0f, (float) y + (float) h * 0.2f,
sliderPos + 7.0f, (float) y + (float) h * 0.2f,
fill, outline);
}
else if (style == Slider::LinearVertical || style == Slider::ThreeValueVertical)
{
drawTriangle (g, x + w * 0.5f - jmin (4.0f, w * 0.3f), sliderPos,
x + w * 0.5f + jmin (8.0f, w * 0.4f), sliderPos - 7.0f,
x + w * 0.5f + jmin (8.0f, w * 0.4f), sliderPos + 7.0f,
drawTriangle (g,
(float) x + (float) w * 0.5f - jmin (4.0f, (float) w * 0.3f), sliderPos,
(float) x + (float) w * 0.5f + jmin (8.0f, (float) w * 0.4f), sliderPos - 7.0f,
(float) x + (float) w * 0.5f + jmin (8.0f, (float) w * 0.4f), sliderPos + 7.0f,
fill, outline);
}
}
@@ -477,14 +491,14 @@ void LookAndFeel_V1::drawCornerResizer (Graphics& g, int w, int h, bool isMouseO
g.setColour ((isMouseOver || isMouseDragging) ? Colours::lightgrey
: Colours::darkgrey);
const float lineThickness = jmin (w, h) * 0.1f;
const float lineThickness = (float) jmin (w, h) * 0.1f;
for (float i = 0.0f; i < 1.0f; i += 0.3f)
{
g.drawLine (w * i,
h + 1.0f,
w + 1.0f,
h * i,
g.drawLine ((float) w * i,
(float) h + 1.0f,
(float) w + 1.0f,
(float) h * i,
lineThickness);
}
}


+ 176
- 148
source/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.cpp View File

@@ -261,8 +261,8 @@ void LookAndFeel_V2::drawButtonBackground (Graphics& g,
drawGlassLozenge (g,
indentL,
indentT,
width - indentL - indentR,
height - indentT - indentB,
(float) width - indentL - indentR,
(float) height - indentT - indentB,
baseColour, outlineThickness, -1.0f,
button.isConnectedOnLeft(),
button.isConnectedOnRight(),
@@ -272,7 +272,7 @@ void LookAndFeel_V2::drawButtonBackground (Graphics& g,
Font LookAndFeel_V2::getTextButtonFont (TextButton&, int buttonHeight)
{
return Font (jmin (15.0f, buttonHeight * 0.6f));
return Font (jmin (15.0f, (float) buttonHeight * 0.6f));
}
int LookAndFeel_V2::getTextButtonWidthToFitText (TextButton& b, int buttonHeight)
@@ -344,10 +344,10 @@ void LookAndFeel_V2::drawToggleButton (Graphics& g, ToggleButton& button,
g.drawRect (0, 0, button.getWidth(), button.getHeight());
}
float fontSize = jmin (15.0f, button.getHeight() * 0.75f);
float fontSize = jmin (15.0f, (float) button.getHeight() * 0.75f);
const float tickWidth = fontSize * 1.1f;
drawTickBox (g, button, 4.0f, (button.getHeight() - tickWidth) * 0.5f,
drawTickBox (g, button, 4.0f, ((float) button.getHeight() - tickWidth) * 0.5f,
tickWidth, tickWidth,
button.getToggleState(),
button.isEnabled(),
@@ -368,7 +368,7 @@ void LookAndFeel_V2::drawToggleButton (Graphics& g, ToggleButton& button,
void LookAndFeel_V2::changeToggleButtonWidthToFitText (ToggleButton& button)
{
auto fontSize = jmin (15.0f, button.getHeight() * 0.75f);
auto fontSize = jmin (15.0f, (float) button.getHeight() * 0.75f);
auto tickWidth = fontSize * 1.1f;
Font font (fontSize);
@@ -468,7 +468,7 @@ void LookAndFeel_V2::drawAlertBox (Graphics& g, AlertWindow& alert,
colour = 0x55ff5555;
character = '!';
icon.addTriangle (iconRect.getX() + iconRect.getWidth() * 0.5f, (float) iconRect.getY(),
icon.addTriangle ((float) iconRect.getX() + (float) iconRect.getWidth() * 0.5f, (float) iconRect.getY(),
(float) iconRect.getRight(), (float) iconRect.getBottom(),
(float) iconRect.getX(), (float) iconRect.getBottom());
@@ -483,7 +483,7 @@ void LookAndFeel_V2::drawAlertBox (Graphics& g, AlertWindow& alert,
}
GlyphArrangement ga;
ga.addFittedText (Font (iconRect.getHeight() * 0.9f, Font::bold),
ga.addFittedText (Font ((float) iconRect.getHeight() * 0.9f, Font::bold),
String::charToString ((juce_wchar) (uint8) character),
(float) iconRect.getX(), (float) iconRect.getY(),
(float) iconRect.getWidth(), (float) iconRect.getHeight(),
@@ -577,11 +577,11 @@ void LookAndFeel_V2::drawProgressBar (Graphics& g, ProgressBar& progressBar,
Path p;
for (float x = (float) (- position); x < width + stripeWidth; x += stripeWidth)
for (float x = (float) (- position); x < (float) (width + stripeWidth); x += (float) stripeWidth)
p.addQuadrilateral (x, 0.0f,
x + stripeWidth * 0.5f, 0.0f,
x + (float) stripeWidth * 0.5f, 0.0f,
x, (float) height,
x - stripeWidth * 0.5f, (float) height);
x - (float) stripeWidth * 0.5f, (float) height);
Image im (Image::ARGB, width, height, true);
@@ -602,7 +602,7 @@ void LookAndFeel_V2::drawProgressBar (Graphics& g, ProgressBar& progressBar,
if (textToShow.isNotEmpty())
{
g.setColour (Colour::contrasting (background, foreground));
g.setFont (height * 0.6f);
g.setFont ((float) height * 0.6f);
g.drawText (textToShow, 0, 0, width, height, Justification::centred, false);
}
@@ -610,15 +610,15 @@ void LookAndFeel_V2::drawProgressBar (Graphics& g, ProgressBar& progressBar,
void LookAndFeel_V2::drawSpinningWaitAnimation (Graphics& g, const Colour& colour, int x, int y, int w, int h)
{
const float radius = jmin (w, h) * 0.4f;
const float radius = (float) jmin (w, h) * 0.4f;
const float thickness = radius * 0.15f;
Path p;
p.addRoundedRectangle (radius * 0.4f, thickness * -0.5f,
radius * 0.6f, thickness,
thickness * 0.5f);
const float cx = x + w * 0.5f;
const float cy = y + h * 0.5f;
const float cx = (float) x + (float) w * 0.5f;
const float cy = (float) y + (float) h * 0.5f;
const uint32 animationIndex = (Time::getMillisecondCounter() / (1000 / 10)) % 12;
@@ -626,8 +626,8 @@ void LookAndFeel_V2::drawSpinningWaitAnimation (Graphics& g, const Colour& colou
{
const uint32 n = (i + 12 - animationIndex) % 12;
g.setColour (colour.withMultipliedAlpha ((n + 1) / 12.0f));
g.fillPath (p, AffineTransform::rotation (i * (MathConstants<float>::pi / 6.0f))
g.setColour (colour.withMultipliedAlpha ((float) (n + 1) / 12.0f));
g.fillPath (p, AffineTransform::rotation ((float) i * (MathConstants<float>::pi / 6.0f))
.translated (cx, cy));
}
}
@@ -650,22 +650,25 @@ void LookAndFeel_V2::drawScrollbarButton (Graphics& g, ScrollBar& scrollbar,
{
Path p;
const auto w = (float) width;
const auto h = (float) height;
if (buttonDirection == 0)
p.addTriangle (width * 0.5f, height * 0.2f,
width * 0.1f, height * 0.7f,
width * 0.9f, height * 0.7f);
p.addTriangle (w * 0.5f, h * 0.2f,
w * 0.1f, h * 0.7f,
w * 0.9f, h * 0.7f);
else if (buttonDirection == 1)
p.addTriangle (width * 0.8f, height * 0.5f,
width * 0.3f, height * 0.1f,
width * 0.3f, height * 0.9f);
p.addTriangle (w * 0.8f, h * 0.5f,
w * 0.3f, h * 0.1f,
w * 0.3f, h * 0.9f);
else if (buttonDirection == 2)
p.addTriangle (width * 0.5f, height * 0.8f,
width * 0.1f, height * 0.3f,
width * 0.9f, height * 0.3f);
p.addTriangle (w * 0.5f, h * 0.8f,
w * 0.1f, h * 0.3f,
w * 0.9f, h * 0.3f);
else if (buttonDirection == 3)
p.addTriangle (width * 0.2f, height * 0.5f,
width * 0.7f, height * 0.1f,
width * 0.7f, height * 0.9f);
p.addTriangle (w * 0.2f, h * 0.5f,
w * 0.7f, h * 0.1f,
w * 0.7f, h * 0.9f);
if (shouldDrawButtonAsDown)
g.setColour (scrollbar.findColour (ScrollBar::thumbColourId).contrasting (0.2f));
@@ -701,37 +704,37 @@ void LookAndFeel_V2::drawScrollbar (Graphics& g,
if (isScrollbarVertical)
{
slotPath.addRoundedRectangle (x + slotIndent,
y + slotIndent,
width - slotIndentx2,
height - slotIndentx2,
(width - slotIndentx2) * 0.5f);
slotPath.addRoundedRectangle ((float) x + slotIndent,
(float) y + slotIndent,
(float) width - slotIndentx2,
(float) height - slotIndentx2,
((float) width - slotIndentx2) * 0.5f);
if (thumbSize > 0)
thumbPath.addRoundedRectangle (x + thumbIndent,
thumbStartPosition + thumbIndent,
width - thumbIndentx2,
thumbSize - thumbIndentx2,
(width - thumbIndentx2) * 0.5f);
thumbPath.addRoundedRectangle ((float) x + thumbIndent,
(float) thumbStartPosition + thumbIndent,
(float) width - thumbIndentx2,
(float) thumbSize - thumbIndentx2,
((float) width - thumbIndentx2) * 0.5f);
gx1 = (float) x;
gx2 = x + width * 0.7f;
gx2 = (float) x + (float) width * 0.7f;
}
else
{
slotPath.addRoundedRectangle (x + slotIndent,
y + slotIndent,
width - slotIndentx2,
height - slotIndentx2,
(height - slotIndentx2) * 0.5f);
slotPath.addRoundedRectangle ((float) x + slotIndent,
(float) y + slotIndent,
(float) width - slotIndentx2,
(float) height - slotIndentx2,
((float) height - slotIndentx2) * 0.5f);
if (thumbSize > 0)
thumbPath.addRoundedRectangle (thumbStartPosition + thumbIndent,
y + thumbIndent,
thumbSize - thumbIndentx2,
height - thumbIndentx2,
(height - thumbIndentx2) * 0.5f);
thumbPath.addRoundedRectangle ((float) thumbStartPosition + thumbIndent,
(float) y + thumbIndent,
(float) thumbSize - thumbIndentx2,
(float) height - thumbIndentx2,
((float) height - thumbIndentx2) * 0.5f);
gy1 = (float) y;
gy2 = y + height * 0.7f;
gy2 = (float) y + (float) height * 0.7f;
}
const Colour thumbColour (scrollbar.findColour (ScrollBar::thumbColourId));
@@ -754,13 +757,13 @@ void LookAndFeel_V2::drawScrollbar (Graphics& g,
if (isScrollbarVertical)
{
gx1 = x + width * 0.6f;
gx2 = (float) x + width;
gx1 = (float) x + (float) width * 0.6f;
gx2 = (float) x + (float) width;
}
else
{
gy1 = y + height * 0.6f;
gy2 = (float) y + height;
gy1 = (float) y + (float) height * 0.6f;
gy2 = (float) y + (float) height;
}
g.setGradientFill (ColourGradient (Colours::transparentBlack,gx1, gy1,
@@ -826,13 +829,13 @@ void LookAndFeel_V2::drawTreeviewPlusMinusBox (Graphics& g, const Rectangle<floa
g.setColour (Colour (0x80000000));
g.drawRect (boxArea);
auto size = boxSize / 2 + 1.0f;
auto size = (float) boxSize * 0.5f + 1.0f;
auto centre = (float) (boxSize / 2);
g.fillRect (x + (boxSize - size) * 0.5f, y + centre, size, 1.0f);
g.fillRect ((float) x + ((float) boxSize - size) * 0.5f, (float) y + centre, size, 1.0f);
if (! isOpen)
g.fillRect (x + centre, y + (boxSize - size) * 0.5f, 1.0f, size);
g.fillRect ((float) x + centre, (float) y + ((float) boxSize - size) * 0.5f, 1.0f, size);
}
bool LookAndFeel_V2::areLinesDrawnForTreeView (TreeView&)
@@ -879,8 +882,8 @@ void LookAndFeel_V2::getIdealPopupMenuItemSize (const String& text, const bool i
{
Font font (getPopupMenuFont());
if (standardMenuItemHeight > 0 && font.getHeight() > standardMenuItemHeight / 1.3f)
font.setHeight (standardMenuItemHeight / 1.3f);
if (standardMenuItemHeight > 0 && font.getHeight() > (float) standardMenuItemHeight / 1.3f)
font.setHeight ((float) standardMenuItemHeight / 1.3f);
idealHeight = standardMenuItemHeight > 0 ? standardMenuItemHeight : roundToInt (font.getHeight() * 1.3f);
idealWidth = font.getStringWidth (text) + idealHeight * 2;
@@ -907,17 +910,17 @@ void LookAndFeel_V2::drawPopupMenuUpDownArrow (Graphics& g, int width, int heigh
{
auto background = findColour (PopupMenu::backgroundColourId);
g.setGradientFill (ColourGradient (background, 0.0f, height * 0.5f,
g.setGradientFill (ColourGradient (background, 0.0f, (float) height * 0.5f,
background.withAlpha (0.0f),
0.0f, isScrollUpArrow ? ((float) height) : 0.0f,
false));
g.fillRect (1, 1, width - 2, height - 2);
auto hw = width * 0.5f;
auto arrowW = height * 0.3f;
auto y1 = height * (isScrollUpArrow ? 0.6f : 0.3f);
auto y2 = height * (isScrollUpArrow ? 0.3f : 0.6f);
auto hw = (float) width * 0.5f;
auto arrowW = (float) height * 0.3f;
auto y1 = (float) height * (isScrollUpArrow ? 0.6f : 0.3f);
auto y2 = (float) height * (isScrollUpArrow ? 0.3f : 0.6f);
Path p;
p.addTriangle (hw - arrowW, y1,
@@ -972,7 +975,7 @@ void LookAndFeel_V2::drawPopupMenuItem (Graphics& g, const Rectangle<int>& area,
Font font (getPopupMenuFont());
auto maxFontHeight = area.getHeight() / 1.3f;
auto maxFontHeight = (float) area.getHeight() / 1.3f;
if (font.getHeight() > maxFontHeight)
font.setHeight (maxFontHeight);
@@ -1027,7 +1030,7 @@ void LookAndFeel_V2::drawPopupMenuSectionHeader (Graphics& g, const Rectangle<in
g.setColour (findColour (PopupMenu::headerTextColourId));
g.drawFittedText (sectionName,
area.getX() + 12, area.getY(), area.getWidth() - 16, (int) (area.getHeight() * 0.8f),
area.getX() + 12, area.getY(), area.getWidth() - 16, (int) ((float) area.getHeight() * 0.8f),
Justification::bottomLeft, 1);
}
@@ -1043,7 +1046,7 @@ void LookAndFeel_V2::drawMenuBarBackground (Graphics& g, int width, int height,
false, false, false);
if (menuBar.isEnabled())
drawShinyButtonShape (g, -4.0f, 0.0f, width + 8.0f, (float) height,
drawShinyButtonShape (g, -4.0f, 0.0f, (float) width + 8.0f, (float) height,
0.0f, baseColour, 0.4f, true, true, true, true);
else
g.fillAll (baseColour);
@@ -1051,7 +1054,7 @@ void LookAndFeel_V2::drawMenuBarBackground (Graphics& g, int width, int height,
Font LookAndFeel_V2::getMenuBarFont (MenuBarComponent& menuBar, int /*itemIndex*/, const String& /*itemText*/)
{
return Font (menuBar.getHeight() * 0.7f);
return Font ((float) menuBar.getHeight() * 0.7f);
}
int LookAndFeel_V2::getMenuBarItemWidth (MenuBarComponent& menuBar, int itemIndex, const String& itemText)
@@ -1158,8 +1161,8 @@ void LookAndFeel_V2::drawComboBox (Graphics& g, int width, int height, const boo
.withMultipliedAlpha (box.isEnabled() ? 1.0f : 0.5f);
drawGlassLozenge (g,
buttonX + outlineThickness, buttonY + outlineThickness,
buttonW - outlineThickness * 2.0f, buttonH - outlineThickness * 2.0f,
(float) buttonX + outlineThickness, (float) buttonY + outlineThickness,
(float) buttonW - outlineThickness * 2.0f, (float) buttonH - outlineThickness * 2.0f,
baseColour, outlineThickness, -1.0f,
true, true, true, true);
@@ -1168,14 +1171,19 @@ void LookAndFeel_V2::drawComboBox (Graphics& g, int width, int height, const boo
const float arrowX = 0.3f;
const float arrowH = 0.2f;
const auto x = (float) buttonX;
const auto y = (float) buttonY;
const auto w = (float) buttonW;
const auto h = (float) buttonH;
Path p;
p.addTriangle (buttonX + buttonW * 0.5f, buttonY + buttonH * (0.45f - arrowH),
buttonX + buttonW * (1.0f - arrowX), buttonY + buttonH * 0.45f,
buttonX + buttonW * arrowX, buttonY + buttonH * 0.45f);
p.addTriangle (x + w * 0.5f, y + h * (0.45f - arrowH),
x + w * (1.0f - arrowX), y + h * 0.45f,
x + w * arrowX, y + h * 0.45f);
p.addTriangle (buttonX + buttonW * 0.5f, buttonY + buttonH * (0.55f + arrowH),
buttonX + buttonW * (1.0f - arrowX), buttonY + buttonH * 0.55f,
buttonX + buttonW * arrowX, buttonY + buttonH * 0.55f);
p.addTriangle (x + w * 0.5f, y + h * (0.55f + arrowH),
x + w * (1.0f - arrowX), y + h * 0.55f,
x + w * arrowX, y + h * 0.55f);
g.setColour (box.findColour (ComboBox::arrowColourId));
g.fillPath (p);
@@ -1184,7 +1192,7 @@ void LookAndFeel_V2::drawComboBox (Graphics& g, int width, int height, const boo
Font LookAndFeel_V2::getComboBoxFont (ComboBox& box)
{
return Font (jmin (15.0f, box.getHeight() * 0.85f));
return Font (jmin (15.0f, (float) box.getHeight() * 0.85f));
}
Label* LookAndFeel_V2::createComboBoxTextBox (ComboBox&)
@@ -1221,7 +1229,7 @@ void LookAndFeel_V2::drawComboBoxTextWhenNothingSelected (Graphics& g, ComboBox&
auto textArea = getLabelBorderSize (label).subtractedFrom (label.getLocalBounds());
g.drawFittedText (box.getTextWhenNothingSelected(), textArea, label.getJustificationType(),
jmax (1, (int) (textArea.getHeight() / font.getHeight())),
jmax (1, (int) ((float) textArea.getHeight() / font.getHeight())),
label.getMinimumHorizontalScale());
}
@@ -1246,7 +1254,7 @@ void LookAndFeel_V2::drawLabel (Graphics& g, Label& label)
auto textArea = getLabelBorderSize (label).subtractedFrom (label.getLocalBounds());
g.drawFittedText (label.getText(), textArea, label.getJustificationType(),
jmax (1, (int) (textArea.getHeight() / font.getHeight())),
jmax (1, (int) ((float) textArea.getHeight() / font.getHeight())),
label.getMinimumHorizontalScale());
g.setColour (label.findColour (Label::outlineColourId).withMultipliedAlpha (alpha));
@@ -1280,24 +1288,24 @@ void LookAndFeel_V2::drawLinearSliderBackground (Graphics& g, int x, int y, int
if (slider.isHorizontal())
{
const float iy = y + height * 0.5f - sliderRadius * 0.5f;
const float iy = (float) y + (float) height * 0.5f - sliderRadius * 0.5f;
const float ih = sliderRadius;
g.setGradientFill (ColourGradient::vertical (gradCol1, iy, gradCol2, iy + ih));
indent.addRoundedRectangle (x - sliderRadius * 0.5f, iy,
width + sliderRadius, ih,
indent.addRoundedRectangle ((float) x - sliderRadius * 0.5f, iy,
(float) width + sliderRadius, ih,
5.0f);
}
else
{
const float ix = x + width * 0.5f - sliderRadius * 0.5f;
const float ix = (float) x + (float) width * 0.5f - sliderRadius * 0.5f;
const float iw = sliderRadius;
g.setGradientFill (ColourGradient::horizontal (gradCol1, ix, gradCol2, ix + iw));
indent.addRoundedRectangle (ix, y - sliderRadius * 0.5f,
iw, height + sliderRadius,
indent.addRoundedRectangle (ix, (float) y - sliderRadius * 0.5f,
iw, (float) height + sliderRadius,
5.0f);
}
@@ -1326,13 +1334,13 @@ void LookAndFeel_V2::drawLinearSliderThumb (Graphics& g, int x, int y, int width
if (style == Slider::LinearVertical)
{
kx = x + width * 0.5f;
kx = (float) x + (float) width * 0.5f;
ky = sliderPos;
}
else
{
kx = sliderPos;
ky = y + height * 0.5f;
ky = (float) y + (float) height * 0.5f;
}
drawGlassSphere (g,
@@ -1345,7 +1353,7 @@ void LookAndFeel_V2::drawLinearSliderThumb (Graphics& g, int x, int y, int width
{
if (style == Slider::ThreeValueVertical)
{
drawGlassSphere (g, x + width * 0.5f - sliderRadius,
drawGlassSphere (g, (float) x + (float) width * 0.5f - sliderRadius,
sliderPos - sliderRadius,
sliderRadius * 2.0f,
knobColour, outlineThickness);
@@ -1353,33 +1361,44 @@ void LookAndFeel_V2::drawLinearSliderThumb (Graphics& g, int x, int y, int width
else if (style == Slider::ThreeValueHorizontal)
{
drawGlassSphere (g,sliderPos - sliderRadius,
y + height * 0.5f - sliderRadius,
(float) y + (float) height * 0.5f - sliderRadius,
sliderRadius * 2.0f,
knobColour, outlineThickness);
}
if (style == Slider::TwoValueVertical || style == Slider::ThreeValueVertical)
{
auto sr = jmin (sliderRadius, width * 0.4f);
auto sr = jmin (sliderRadius, (float) width * 0.4f);
drawGlassPointer (g, jmax (0.0f, x + width * 0.5f - sliderRadius * 2.0f),
drawGlassPointer (g, jmax (0.0f, (float) x + (float) width * 0.5f - sliderRadius * 2.0f),
minSliderPos - sliderRadius,
sliderRadius * 2.0f, knobColour, outlineThickness, 1);
drawGlassPointer (g, jmin (x + width - sliderRadius * 2.0f, x + width * 0.5f), maxSliderPos - sr,
sliderRadius * 2.0f, knobColour, outlineThickness, 3);
drawGlassPointer (g,
jmin ((float) x + (float) width - sliderRadius * 2.0f,
(float) x + (float) width * 0.5f),
maxSliderPos - sr,
sliderRadius * 2.0f,
knobColour,
outlineThickness,
3);
}
else if (style == Slider::TwoValueHorizontal || style == Slider::ThreeValueHorizontal)
{
auto sr = jmin (sliderRadius, height * 0.4f);
auto sr = jmin (sliderRadius, (float) height * 0.4f);
drawGlassPointer (g, minSliderPos - sr,
jmax (0.0f, y + height * 0.5f - sliderRadius * 2.0f),
jmax (0.0f, (float) y + (float) height * 0.5f - sliderRadius * 2.0f),
sliderRadius * 2.0f, knobColour, outlineThickness, 2);
drawGlassPointer (g, maxSliderPos - sliderRadius,
jmin (y + height - sliderRadius * 2.0f, y + height * 0.5f),
sliderRadius * 2.0f, knobColour, outlineThickness, 4);
drawGlassPointer (g,
maxSliderPos - sliderRadius,
jmin ((float) y + (float) height - sliderRadius * 2.0f,
(float) y + (float) height * 0.5f),
sliderRadius * 2.0f,
knobColour,
outlineThickness,
4);
}
}
}
@@ -1404,8 +1423,8 @@ void LookAndFeel_V2::drawLinearSlider (Graphics& g, int x, int y, int width, int
style == Slider::LinearBarVertical ? sliderPos
: (float) y,
style == Slider::LinearBarVertical ? (float) width
: (sliderPos - x),
style == Slider::LinearBarVertical ? (height - sliderPos)
: (sliderPos - (float) x),
style == Slider::LinearBarVertical ? ((float) height - sliderPos)
: (float) height, 0.0f,
baseColour,
slider.isEnabled() ? 0.9f : 0.3f,
@@ -1428,9 +1447,9 @@ int LookAndFeel_V2::getSliderThumbRadius (Slider& slider)
void LookAndFeel_V2::drawRotarySlider (Graphics& g, int x, int y, int width, int height, float sliderPos,
const float rotaryStartAngle, const float rotaryEndAngle, Slider& slider)
{
const float radius = jmin (width / 2, height / 2) - 2.0f;
const float centreX = x + width * 0.5f;
const float centreY = y + height * 0.5f;
const float radius = jmin ((float) width * 0.5f, (float) height * 0.5f) - 2.0f;
const float centreX = (float) x + (float) width * 0.5f;
const float centreY = (float) y + (float) height * 0.5f;
const float rx = centreX - radius;
const float ry = centreY - radius;
const float rw = radius * 2.0f;
@@ -1672,7 +1691,7 @@ void LookAndFeel_V2::drawConcertinaPanelHeader (Graphics& g, const Rectangle<int
g.drawRect (area);
g.setColour (Colours::white);
g.setFont (Font (area.getHeight() * 0.7f).boldened());
g.setFont (Font ((float) area.getHeight() * 0.7f).boldened());
g.drawFittedText (panel.getName(), 4, 0, area.getWidth() - 6, area.getHeight(), Justification::centredLeft, 1);
}
@@ -1706,24 +1725,24 @@ void LookAndFeel_V2::drawImageButton (Graphics& g, Image* image,
//==============================================================================
void LookAndFeel_V2::drawCornerResizer (Graphics& g, int w, int h, bool /*isMouseOver*/, bool /*isMouseDragging*/)
{
auto lineThickness = jmin (w, h) * 0.075f;
auto lineThickness = jmin ((float) w, (float) h) * 0.075f;
for (float i = 0.0f; i < 1.0f; i += 0.3f)
{
g.setColour (Colours::lightgrey);
g.drawLine (w * i,
h + 1.0f,
w + 1.0f,
h * i,
g.drawLine ((float) w * i,
(float) h + 1.0f,
(float) w + 1.0f,
(float) h * i,
lineThickness);
g.setColour (Colours::darkgrey);
g.drawLine (w * i + lineThickness,
h + 1.0f,
w + 1.0f,
h * i + lineThickness,
g.drawLine ((float) w * i + lineThickness,
(float) h + 1.0f,
(float) w + 1.0f,
(float) h * i + lineThickness,
lineThickness);
}
}
@@ -1772,7 +1791,7 @@ void LookAndFeel_V2::drawDocumentWindowTitleBar (DocumentWindow& window, Graphic
window.getBackgroundColour().contrasting (isActive ? 0.15f : 0.05f), (float) h));
g.fillAll();
Font font (h * 0.65f, Font::bold);
Font font ((float) h * 0.65f, Font::bold);
g.setFont (font);
int textW = font.getStringWidth (window.getName());
@@ -1836,12 +1855,12 @@ public:
if (getWidth() < getHeight())
{
diam = (float) getWidth();
y = (getHeight() - getWidth()) * 0.5f;
y = (float) (getHeight() - getWidth()) * 0.5f;
}
else
{
diam = (float) getHeight();
y = (getWidth() - getHeight()) * 0.5f;
y = (float) (getWidth() - getHeight()) * 0.5f;
}
x += diam * 0.05f;
@@ -1972,9 +1991,9 @@ void LookAndFeel_V2::drawStretchableLayoutResizerBar (Graphics& g, int w, int h,
alpha = 1.0f;
}
auto cx = w * 0.5f;
auto cy = h * 0.5f;
auto cr = jmin (w, h) * 0.4f;
auto cx = (float) w * 0.5f;
auto cy = (float) h * 0.5f;
auto cr = (float) jmin (w, h) * 0.4f;
g.setGradientFill (ColourGradient (Colours::white.withAlpha (alpha), cx + cr * 0.1f, cy + cr,
Colours::black.withAlpha (alpha), cx, cy - cr * 4.0f,
@@ -1998,12 +2017,15 @@ void LookAndFeel_V2::drawGroupComponentOutline (Graphics& g, int width, int heig
Path p;
auto x = indent;
auto y = f.getAscent() - 3.0f;
auto w = jmax (0.0f, width - x * 2.0f);
auto h = jmax (0.0f, height - y - indent);
auto w = jmax (0.0f, (float) width - x * 2.0f);
auto h = jmax (0.0f, (float) height - y - indent);
cs = jmin (cs, w * 0.5f, h * 0.5f);
auto cs2 = 2.0f * cs;
auto textW = text.isEmpty() ? 0 : jlimit (0.0f, jmax (0.0f, w - cs2 - textEdgeGap * 2), f.getStringWidth (text) + textEdgeGap * 2.0f);
auto textW = text.isEmpty() ? 0
: jlimit (0.0f,
jmax (0.0f, w - cs2 - textEdgeGap * 2),
(float) f.getStringWidth (text) + textEdgeGap * 2.0f);
auto textX = cs + textEdgeGap;
if (position.testFlags (Justification::horizontallyCentred))
@@ -2056,7 +2078,7 @@ int LookAndFeel_V2::getTabButtonSpaceAroundImage()
int LookAndFeel_V2::getTabButtonBestWidth (TabBarButton& button, int tabDepth)
{
int width = Font (tabDepth * 0.6f).getStringWidth (button.getButtonText().trim())
int width = Font ((float) tabDepth * 0.6f).getStringWidth (button.getButtonText().trim())
+ getTabButtonOverlap (tabDepth) * 2;
if (auto* extraComponent = button.getExtraComponent())
@@ -2257,26 +2279,26 @@ void LookAndFeel_V2::drawTabAreaBehindFrontButton (TabbedButtonBar& bar, Graphic
{
case TabbedButtonBar::TabsAtLeft:
gradient.point1.x = (float) w;
gradient.point2.x = w * (1.0f - shadowSize);
gradient.point2.x = (float) w * (1.0f - shadowSize);
shadowRect.setBounds ((int) gradient.point2.x, 0, w - (int) gradient.point2.x, h);
line.setBounds (w - 1, 0, 1, h);
break;
case TabbedButtonBar::TabsAtRight:
gradient.point2.x = w * shadowSize;
gradient.point2.x = (float) w * shadowSize;
shadowRect.setBounds (0, 0, (int) gradient.point2.x, h);
line.setBounds (0, 0, 1, h);
break;
case TabbedButtonBar::TabsAtTop:
gradient.point1.y = (float) h;
gradient.point2.y = h * (1.0f - shadowSize);
gradient.point2.y = (float) h * (1.0f - shadowSize);
shadowRect.setBounds (0, (int) gradient.point2.y, w, h - (int) gradient.point2.y);
line.setBounds (0, h - 1, w, 1);
break;
case TabbedButtonBar::TabsAtBottom:
gradient.point2.y = h * shadowSize;
gradient.point2.y = (float) h * shadowSize;
shadowRect.setBounds (0, 0, w, (int) gradient.point2.y);
line.setBounds (0, 0, w, 1);
break;
@@ -2381,7 +2403,7 @@ void LookAndFeel_V2::drawTableHeaderColumn (Graphics& g, TableHeaderComponent& h
}
g.setColour (header.findColour (TableHeaderComponent::textColourId));
g.setFont (Font (height * 0.5f, Font::bold));
g.setFont (Font ((float) height * 0.5f, Font::bold));
g.drawFittedText (columnName, area, Justification::centredLeft, 1);
}
@@ -2403,8 +2425,8 @@ void LookAndFeel_V2::paintToolbarBackground (Graphics& g, int w, int h, Toolbar&
g.setGradientFill (ColourGradient (background, 0.0f, 0.0f,
background.darker (0.1f),
toolbar.isVertical() ? w - 1.0f : 0.0f,
toolbar.isVertical() ? 0.0f : h - 1.0f,
toolbar.isVertical() ? (float) w - 1.0f : 0.0f,
toolbar.isVertical() ? 0.0f : (float) h - 1.0f,
false));
g.fillAll();
}
@@ -2430,7 +2452,7 @@ void LookAndFeel_V2::paintToolbarButtonLabel (Graphics& g, int x, int y, int wid
g.setColour (component.findColour (Toolbar::labelTextColourId, true)
.withAlpha (component.isEnabled() ? 1.0f : 0.25f));
auto fontHeight = jmin (14.0f, height * 0.85f);
auto fontHeight = jmin (14.0f, (float) height * 0.85f);
g.setFont (fontHeight);
g.drawFittedText (text,
@@ -2443,15 +2465,15 @@ void LookAndFeel_V2::paintToolbarButtonLabel (Graphics& g, int x, int y, int wid
void LookAndFeel_V2::drawPropertyPanelSectionHeader (Graphics& g, const String& name,
bool isOpen, int width, int height)
{
auto buttonSize = height * 0.75f;
auto buttonIndent = (height - buttonSize) * 0.5f;
auto buttonSize = (float) height * 0.75f;
auto buttonIndent = ((float) height - buttonSize) * 0.5f;
drawTreeviewPlusMinusBox (g, Rectangle<float> (buttonIndent, buttonIndent, buttonSize, buttonSize), Colours::white, isOpen, false);
auto textX = (int) (buttonIndent * 2.0f + buttonSize + 2.0f);
g.setColour (Colours::black);
g.setFont (Font (height * 0.7f, Font::bold));
g.setFont (Font ((float) height * 0.7f, Font::bold));
g.drawText (name, textX, 0, width - textX - 4, height, Justification::centredLeft, true);
}
@@ -2466,7 +2488,7 @@ void LookAndFeel_V2::drawPropertyComponentLabel (Graphics& g, int, int height, P
g.setColour (component.findColour (PropertyComponent::labelTextColourId)
.withMultipliedAlpha (component.isEnabled() ? 1.0f : 0.6f));
g.setFont (jmin (height, 24) * 0.65f);
g.setFont ((float) jmin (height, 24) * 0.65f);
auto r = getPropertyComponentContentPosition (component);
@@ -2558,7 +2580,7 @@ void LookAndFeel_V2::drawFileBrowserRow (Graphics& g, int width, int height,
{
if (auto* d = isDirectory ? getDefaultFolderImage()
: getDefaultDocumentFileImage())
d->drawWithin (g, Rectangle<float> (2.0f, 2.0f, x - 4.0f, height - 4.0f),
d->drawWithin (g, Rectangle<float> (2.0f, 2.0f, x - 4.0f, (float) height - 4.0f),
RectanglePlacement::centred | RectanglePlacement::onlyReduceInSize, 1.0f);
}
@@ -2569,18 +2591,18 @@ void LookAndFeel_V2::drawFileBrowserRow (Graphics& g, int width, int height,
g.setColour (fileListComp != nullptr ? fileListComp->findColour (DirectoryContentsDisplayComponent::textColourId)
: findColour (DirectoryContentsDisplayComponent::textColourId));
g.setFont (height * 0.7f);
g.setFont ((float) height * 0.7f);
if (width > 450 && ! isDirectory)
{
auto sizeX = roundToInt (width * 0.7f);
auto dateX = roundToInt (width * 0.8f);
auto sizeX = roundToInt ((float) width * 0.7f);
auto dateX = roundToInt ((float) width * 0.8f);
g.drawFittedText (filename,
x, 0, sizeX - x, height,
Justification::centredLeft, 1);
g.setFont (height * 0.5f);
g.setFont ((float) height * 0.5f);
g.setColour (Colours::darkgrey);
if (! isDirectory)
@@ -2746,11 +2768,11 @@ void LookAndFeel_V2::drawLevelMeter (Graphics& g, int width, int height, float l
g.setColour (Colours::white.withAlpha (0.7f));
g.fillRoundedRectangle (0.0f, 0.0f, (float) width, (float) height, 3.0f);
g.setColour (Colours::black.withAlpha (0.2f));
g.drawRoundedRectangle (1.0f, 1.0f, width - 2.0f, height - 2.0f, 3.0f, 1.0f);
g.drawRoundedRectangle (1.0f, 1.0f, (float) width - 2.0f, (float) height - 2.0f, 3.0f, 1.0f);
const int totalBlocks = 7;
const int numBlocks = roundToInt (totalBlocks * level);
auto w = (width - 6.0f) / (float) totalBlocks;
auto w = ((float) width - 6.0f) / (float) totalBlocks;
for (int i = 0; i < totalBlocks; ++i)
{
@@ -2760,7 +2782,11 @@ void LookAndFeel_V2::drawLevelMeter (Graphics& g, int width, int height, float l
g.setColour (i < totalBlocks - 1 ? Colours::blue.withAlpha (0.5f)
: Colours::red);
g.fillRoundedRectangle (3.0f + i * w + w * 0.1f, 3.0f, w * 0.8f, height - 6.0f, w * 0.4f);
g.fillRoundedRectangle (3.0f + (float) i * w + w * 0.1f,
3.0f,
(float) w * 0.8f,
(float) height - 6.0f,
(float) w * 0.4f);
}
}
@@ -2781,7 +2807,7 @@ void LookAndFeel_V2::drawKeymapChangeButton (Graphics& g, int width, int height,
}
g.setColour (textColour);
g.setFont (height * 0.6f);
g.setFont ((float) height * 0.6f);
g.drawFittedText (keyDescription,
3, 0, width - 6, height,
Justification::centred, 1);
@@ -2799,7 +2825,7 @@ void LookAndFeel_V2::drawKeymapChangeButton (Graphics& g, int width, int height,
p.setUsingNonZeroWinding (false);
g.setColour (textColour.withAlpha (button.isDown() ? 0.7f : (button.isOver() ? 0.5f : 0.3f)));
g.fillPath (p, p.getTransformToScaleToFit (2.0f, 2.0f, width - 4.0f, height - 4.0f, true));
g.fillPath (p, p.getTransformToScaleToFit (2.0f, 2.0f, (float) width - 4.0f, (float) height - 4.0f, true));
}
if (button.hasKeyboardFocus (false))
@@ -2838,7 +2864,7 @@ void LookAndFeel_V2::drawBevel (Graphics& g, const int x, const int y, const int
for (int i = bevelThickness; --i >= 0;)
{
const float op = useGradient ? (sharpEdgeOnOutside ? bevelThickness - i : i) / (float) bevelThickness
const float op = useGradient ? (float) (sharpEdgeOnOutside ? bevelThickness - i : i) / (float) bevelThickness
: 1.0f;
context.setFill (topLeftColour.withMultipliedAlpha (op));
@@ -2941,7 +2967,9 @@ void LookAndFeel_V2::drawGlassPointer (Graphics& g,
p.lineTo (x, y + diameter * 0.6f);
p.closeSubPath();
p.applyTransform (AffineTransform::rotation (direction * MathConstants<float>::halfPi, x + diameter * 0.5f, y + diameter * 0.5f));
p.applyTransform (AffineTransform::rotation ((float) direction * MathConstants<float>::halfPi,
x + diameter * 0.5f,
y + diameter * 0.5f));
{
ColourGradient cg (Colours::white.overlaidWith (colour.withMultipliedAlpha (0.3f)), 0, y,


+ 30
- 25
source/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V3.cpp View File

@@ -64,15 +64,15 @@ void LookAndFeel_V3::drawScrollbar (Graphics& g, ScrollBar& scrollbar, int x, in
if (thumbSize > 0)
{
const float thumbIndent = (isScrollbarVertical ? width : height) * 0.25f;
const float thumbIndent = (float) (isScrollbarVertical ? width : height) * 0.25f;
const float thumbIndentx2 = thumbIndent * 2.0f;
if (isScrollbarVertical)
thumbPath.addRoundedRectangle (x + thumbIndent, thumbStartPosition + thumbIndent,
width - thumbIndentx2, thumbSize - thumbIndentx2, (width - thumbIndentx2) * 0.5f);
thumbPath.addRoundedRectangle ((float) x + thumbIndent, (float) thumbStartPosition + thumbIndent,
(float) width - thumbIndentx2, (float) thumbSize - thumbIndentx2, ((float) width - thumbIndentx2) * 0.5f);
else
thumbPath.addRoundedRectangle (thumbStartPosition + thumbIndent, y + thumbIndent,
thumbSize - thumbIndentx2, height - thumbIndentx2, (height - thumbIndentx2) * 0.5f);
thumbPath.addRoundedRectangle ((float) thumbStartPosition + thumbIndent, (float) y + thumbIndent,
(float) thumbSize - thumbIndentx2, (float) height - thumbIndentx2, ((float) height - thumbIndentx2) * 0.5f);
}
Colour thumbCol (scrollbar.findColour (ScrollBar::thumbColourId, true));
@@ -102,7 +102,7 @@ void LookAndFeel_V3::drawConcertinaPanelHeader (Graphics& g, const Rectangle<int
g.fillRect (area.withTop (area.getBottom() - 1));
g.setColour (bkg.contrasting());
g.setFont (Font (area.getHeight() * 0.6f).boldened());
g.setFont (Font ((float) area.getHeight() * 0.6f).boldened());
g.drawFittedText (panel.getName(), 4, 0, area.getWidth() - 6, area.getHeight(), Justification::centredLeft, 1);
}
@@ -137,8 +137,8 @@ void LookAndFeel_V3::drawButtonBackground (Graphics& g, Button& button, const Co
const bool flatOnTop = button.isConnectedOnTop();
const bool flatOnBottom = button.isConnectedOnBottom();
const float width = button.getWidth() - 1.0f;
const float height = button.getHeight() - 1.0f;
const float width = (float) button.getWidth() - 1.0f;
const float height = (float) button.getHeight() - 1.0f;
if (width > 0 && height > 0)
{
@@ -281,26 +281,26 @@ void LookAndFeel_V3::drawTabAreaBehindFrontButton (TabbedButtonBar& bar, Graphic
{
case TabbedButtonBar::TabsAtLeft:
gradient.point1.x = (float) w;
gradient.point2.x = w * (1.0f - shadowSize);
gradient.point2.x = (float) w * (1.0f - shadowSize);
shadowRect.setBounds ((int) gradient.point2.x, 0, w - (int) gradient.point2.x, h);
line.setBounds (w - 1, 0, 1, h);
break;
case TabbedButtonBar::TabsAtRight:
gradient.point2.x = w * shadowSize;
gradient.point2.x = (float) w * shadowSize;
shadowRect.setBounds (0, 0, (int) gradient.point2.x, h);
line.setBounds (0, 0, 1, h);
break;
case TabbedButtonBar::TabsAtTop:
gradient.point1.y = (float) h;
gradient.point2.y = h * (1.0f - shadowSize);
gradient.point2.y = (float) h * (1.0f - shadowSize);
shadowRect.setBounds (0, (int) gradient.point2.y, w, h - (int) gradient.point2.y);
line.setBounds (0, h - 1, w, 1);
break;
case TabbedButtonBar::TabsAtBottom:
gradient.point2.y = h * shadowSize;
gradient.point2.y = (float) h * shadowSize;
shadowRect.setBounds (0, 0, w, (int) gradient.point2.y);
line.setBounds (0, 0, w, 1);
break;
@@ -371,14 +371,19 @@ void LookAndFeel_V3::drawComboBox (Graphics& g, int width, int height, const boo
const float arrowX = 0.3f;
const float arrowH = 0.2f;
const auto x = (float) buttonX;
const auto y = (float) buttonY;
const auto w = (float) buttonW;
const auto h = (float) buttonH;
Path p;
p.addTriangle (buttonX + buttonW * 0.5f, buttonY + buttonH * (0.45f - arrowH),
buttonX + buttonW * (1.0f - arrowX), buttonY + buttonH * 0.45f,
buttonX + buttonW * arrowX, buttonY + buttonH * 0.45f);
p.addTriangle (x + w * 0.5f, y + h * (0.45f - arrowH),
x + w * (1.0f - arrowX), y + h * 0.45f,
x + w * arrowX, y + h * 0.45f);
p.addTriangle (buttonX + buttonW * 0.5f, buttonY + buttonH * (0.55f + arrowH),
buttonX + buttonW * (1.0f - arrowX), buttonY + buttonH * 0.55f,
buttonX + buttonW * arrowX, buttonY + buttonH * 0.55f);
p.addTriangle (x + w * 0.5f, y + h * (0.55f + arrowH),
x + w * (1.0f - arrowX), y + h * 0.55f,
x + w * arrowX, y + h * 0.55f);
g.setColour (box.findColour (ComboBox::arrowColourId).withMultipliedAlpha (box.isEnabled() ? 1.0f : 0.3f));
g.fillPath (p);
@@ -438,19 +443,19 @@ void LookAndFeel_V3::drawLinearSliderBackground (Graphics& g, int x, int y, int
if (slider.isHorizontal())
{
auto iy = y + height * 0.5f - sliderRadius * 0.5f;
auto iy = (float) y + (float) height * 0.5f - sliderRadius * 0.5f;
g.setGradientFill (ColourGradient::vertical (gradCol1, iy, gradCol2, iy + sliderRadius));
indent.addRoundedRectangle (x - sliderRadius * 0.5f, iy, width + sliderRadius, sliderRadius, 5.0f);
indent.addRoundedRectangle ((float) x - sliderRadius * 0.5f, iy, (float) width + sliderRadius, sliderRadius, 5.0f);
}
else
{
auto ix = x + width * 0.5f - sliderRadius * 0.5f;
auto ix = (float) x + (float) width * 0.5f - sliderRadius * 0.5f;
g.setGradientFill (ColourGradient::horizontal (gradCol1, ix, gradCol2, ix + sliderRadius));
indent.addRoundedRectangle (ix, y - sliderRadius * 0.5f, sliderRadius, height + sliderRadius, 5.0f);
indent.addRoundedRectangle (ix, (float) y - sliderRadius * 0.5f, sliderRadius, (float) height + sliderRadius, 5.0f);
}
g.fillPath (indent);
@@ -500,7 +505,7 @@ void LookAndFeel_V3::drawKeymapChangeButton (Graphics& g, int width, int height,
}
g.setColour (textColour);
g.setFont (height * 0.6f);
g.setFont ((float) height * 0.6f);
g.drawFittedText (keyDescription, 4, 0, width - 8, height, Justification::centred, 1);
}
else
@@ -516,7 +521,7 @@ void LookAndFeel_V3::drawKeymapChangeButton (Graphics& g, int width, int height,
p.setUsingNonZeroWinding (false);
g.setColour (textColour.darker(0.1f).withAlpha (button.isDown() ? 0.7f : (button.isOver() ? 0.5f : 0.3f)));
g.fillPath (p, p.getTransformToScaleToFit (2.0f, 2.0f, width - 4.0f, height - 4.0f, true));
g.fillPath (p, p.getTransformToScaleToFit (2.0f, 2.0f, (float) width - 4.0f, (float) height - 4.0f, true));
}
if (button.hasKeyboardFocus (false))
@@ -542,7 +547,7 @@ public:
if (ResizableWindow* rw = findParentComponentOfClass<ResizableWindow>())
background = rw->getBackgroundColour();
const float cx = getWidth() * 0.5f, cy = getHeight() * 0.5f;
const float cx = (float) getWidth() * 0.5f, cy = (float) getHeight() * 0.5f;
const float diam = jmin (cx, cy) * (shouldDrawButtonAsDown ? 0.60f : 0.65f);
g.setColour (background);


+ 58
- 58
source/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V4.cpp View File

@@ -138,7 +138,7 @@ public:
auto reducedRect = Justification (Justification::centred)
.appliedToRectangle (Rectangle<int> (getHeight(), getHeight()), getLocalBounds())
.toFloat()
.reduced (getHeight() * 0.3f);
.reduced ((float) getHeight() * 0.3f);
g.fillPath (p, p.getTransformToScaleToFit (reducedRect, true));
}
@@ -237,7 +237,7 @@ void LookAndFeel_V4::drawDocumentWindowTitleBar (DocumentWindow& window, Graphic
g.setColour (getCurrentColourScheme().getUIColour (ColourScheme::widgetBackground));
g.fillAll();
Font font (h * 0.65f, Font::plain);
Font font ((float) h * 0.65f, Font::plain);
g.setFont (font);
auto textW = font.getStringWidth (window.getName());
@@ -277,7 +277,7 @@ void LookAndFeel_V4::drawDocumentWindowTitleBar (DocumentWindow& window, Graphic
//==============================================================================
Font LookAndFeel_V4::getTextButtonFont (TextButton&, int buttonHeight)
{
return { jmin (16.0f, buttonHeight * 0.6f) };
return { jmin (16.0f, (float) buttonHeight * 0.6f) };
}
void LookAndFeel_V4::drawButtonBackground (Graphics& g,
@@ -330,10 +330,10 @@ void LookAndFeel_V4::drawButtonBackground (Graphics& g,
void LookAndFeel_V4::drawToggleButton (Graphics& g, ToggleButton& button,
bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown)
{
auto fontSize = jmin (15.0f, button.getHeight() * 0.75f);
auto fontSize = jmin (15.0f, (float) button.getHeight() * 0.75f);
auto tickWidth = fontSize * 1.1f;
drawTickBox (g, button, 4.0f, (button.getHeight() - tickWidth) * 0.5f,
drawTickBox (g, button, 4.0f, ((float) button.getHeight() - tickWidth) * 0.5f,
tickWidth, tickWidth,
button.getToggleState(),
button.isEnabled(),
@@ -376,7 +376,7 @@ void LookAndFeel_V4::drawTickBox (Graphics& g, Component& component,
void LookAndFeel_V4::changeToggleButtonWidthToFitText (ToggleButton& button)
{
auto fontSize = jmin (15.0f, button.getHeight() * 0.75f);
auto fontSize = jmin (15.0f, (float) button.getHeight() * 0.75f);
auto tickWidth = fontSize * 1.1f;
Font font (fontSize);
@@ -441,7 +441,7 @@ void LookAndFeel_V4::drawAlertBox (Graphics& g, AlertWindow& alert,
{
character = '!';
icon.addTriangle (iconRect.getX() + iconRect.getWidth() * 0.5f, (float) iconRect.getY(),
icon.addTriangle ((float) iconRect.getX() + (float) iconRect.getWidth() * 0.5f, (float) iconRect.getY(),
static_cast<float> (iconRect.getRight()), static_cast<float> (iconRect.getBottom()),
static_cast<float> (iconRect.getX()), static_cast<float> (iconRect.getBottom()));
@@ -457,7 +457,7 @@ void LookAndFeel_V4::drawAlertBox (Graphics& g, AlertWindow& alert,
}
GlyphArrangement ga;
ga.addFittedText ({ iconRect.getHeight() * 0.9f, Font::bold },
ga.addFittedText ({ (float) iconRect.getHeight() * 0.9f, Font::bold },
String::charToString ((juce_wchar) (uint8) character),
static_cast<float> (iconRect.getX()), static_cast<float> (iconRect.getY()),
static_cast<float> (iconRect.getWidth()), static_cast<float> (iconRect.getHeight()),
@@ -504,17 +504,17 @@ void LookAndFeel_V4::drawLinearProgressBar (Graphics& g, ProgressBar& progressBa
auto barBounds = progressBar.getLocalBounds().toFloat();
g.setColour (background);
g.fillRoundedRectangle (barBounds, progressBar.getHeight() * 0.5f);
g.fillRoundedRectangle (barBounds, (float) progressBar.getHeight() * 0.5f);
if (progress >= 0.0f && progress <= 1.0f)
{
Path p;
p.addRoundedRectangle (barBounds, progressBar.getHeight() * 0.5f);
p.addRoundedRectangle (barBounds, (float) progressBar.getHeight() * 0.5f);
g.reduceClipRegion (p);
barBounds.setWidth (barBounds.getWidth() * (float) progress);
g.setColour (foreground);
g.fillRoundedRectangle (barBounds, progressBar.getHeight() * 0.5f);
g.fillRoundedRectangle (barBounds, (float) progressBar.getHeight() * 0.5f);
}
else
{
@@ -526,18 +526,18 @@ void LookAndFeel_V4::drawLinearProgressBar (Graphics& g, ProgressBar& progressBa
Path p;
for (auto x = static_cast<float> (-position); x < width + stripeWidth; x += stripeWidth)
for (auto x = static_cast<float> (-position); x < (float) (width + stripeWidth); x += (float) stripeWidth)
p.addQuadrilateral (x, 0.0f,
x + stripeWidth * 0.5f, 0.0f,
x + (float) stripeWidth * 0.5f, 0.0f,
x, static_cast<float> (height),
x - stripeWidth * 0.5f, static_cast<float> (height));
x - (float) stripeWidth * 0.5f, static_cast<float> (height));
Image im (Image::ARGB, width, height, true);
{
Graphics g2 (im);
g2.setColour (foreground);
g2.fillRoundedRectangle (barBounds, progressBar.getHeight() * 0.5f);
g2.fillRoundedRectangle (barBounds, (float) progressBar.getHeight() * 0.5f);
}
g.setTiledImageFill (im, 0, 0, 0.85f);
@@ -547,7 +547,7 @@ void LookAndFeel_V4::drawLinearProgressBar (Graphics& g, ProgressBar& progressBa
if (textToShow.isNotEmpty())
{
g.setColour (Colour::contrasting (background, foreground));
g.setFont (height * 0.6f);
g.setFont ((float) height * 0.6f);
g.drawText (textToShow, 0, 0, width, height, Justification::centred, false);
}
@@ -770,7 +770,7 @@ void LookAndFeel_V4::drawPopupMenuItem (Graphics& g, const Rectangle<int>& area,
if (isSeparator)
{
auto r = area.reduced (5, 0);
r.removeFromTop (roundToInt ((r.getHeight() * 0.5f) - 0.5f));
r.removeFromTop (roundToInt (((float) r.getHeight() * 0.5f) - 0.5f));
g.setColour (findColour (PopupMenu::textColourId).withAlpha (0.3f));
g.fillRect (r.removeFromTop (1));
@@ -798,7 +798,7 @@ void LookAndFeel_V4::drawPopupMenuItem (Graphics& g, const Rectangle<int>& area,
auto font = getPopupMenuFont();
auto maxFontHeight = r.getHeight() / 1.3f;
auto maxFontHeight = (float) r.getHeight() / 1.3f;
if (font.getHeight() > maxFontHeight)
font.setHeight (maxFontHeight);
@@ -860,8 +860,8 @@ void LookAndFeel_V4::getIdealPopupMenuItemSize (const String& text, const bool i
{
auto font = getPopupMenuFont();
if (standardMenuItemHeight > 0 && font.getHeight() > standardMenuItemHeight / 1.3f)
font.setHeight (standardMenuItemHeight / 1.3f);
if (standardMenuItemHeight > 0 && font.getHeight() > (float) standardMenuItemHeight / 1.3f)
font.setHeight ((float) standardMenuItemHeight / 1.3f);
idealHeight = standardMenuItemHeight > 0 ? standardMenuItemHeight : roundToInt (font.getHeight() * 1.3f);
idealWidth = font.getStringWidth (text) + idealHeight * 2;
@@ -922,9 +922,9 @@ void LookAndFeel_V4::drawComboBox (Graphics& g, int width, int height, bool,
Rectangle<int> arrowZone (width - 30, 0, 20, height);
Path path;
path.startNewSubPath (arrowZone.getX() + 3.0f, arrowZone.getCentreY() - 2.0f);
path.lineTo (static_cast<float> (arrowZone.getCentreX()), arrowZone.getCentreY() + 3.0f);
path.lineTo (arrowZone.getRight() - 3.0f, arrowZone.getCentreY() - 2.0f);
path.startNewSubPath ((float) arrowZone.getX() + 3.0f, (float) arrowZone.getCentreY() - 2.0f);
path.lineTo ((float) arrowZone.getCentreX(), (float) arrowZone.getCentreY() + 3.0f);
path.lineTo ((float) arrowZone.getRight() - 3.0f, (float) arrowZone.getCentreY() - 2.0f);
g.setColour (box.findColour (ComboBox::arrowColourId).withAlpha ((box.isEnabled() ? 0.9f : 0.2f)));
g.strokePath (path, PathStrokeType (2.0f));
@@ -932,7 +932,7 @@ void LookAndFeel_V4::drawComboBox (Graphics& g, int width, int height, bool,
Font LookAndFeel_V4::getComboBoxFont (ComboBox& box)
{
return { jmin (16.0f, box.getHeight() * 0.85f) };
return { jmin (16.0f, (float) box.getHeight() * 0.85f) };
}
void LookAndFeel_V4::positionComboBoxText (ComboBox& box, Label& label)
@@ -947,8 +947,8 @@ void LookAndFeel_V4::positionComboBoxText (ComboBox& box, Label& label)
//==============================================================================
int LookAndFeel_V4::getSliderThumbRadius (Slider& slider)
{
return jmin (12, slider.isHorizontal() ? static_cast<int> (slider.getHeight() * 0.5f)
: static_cast<int> (slider.getWidth() * 0.5f));
return jmin (12, slider.isHorizontal() ? static_cast<int> ((float) slider.getHeight() * 0.5f)
: static_cast<int> ((float) slider.getWidth() * 0.5f));
}
void LookAndFeel_V4::drawLinearSlider (Graphics& g, int x, int y, int width, int height,
@@ -960,21 +960,21 @@ void LookAndFeel_V4::drawLinearSlider (Graphics& g, int x, int y, int width, int
if (slider.isBar())
{
g.setColour (slider.findColour (Slider::trackColourId));
g.fillRect (slider.isHorizontal() ? Rectangle<float> (static_cast<float> (x), y + 0.5f, sliderPos - x, height - 1.0f)
: Rectangle<float> (x + 0.5f, sliderPos, width - 1.0f, y + (height - sliderPos)));
g.fillRect (slider.isHorizontal() ? Rectangle<float> (static_cast<float> (x), (float) y + 0.5f, sliderPos - (float) x, (float) height - 1.0f)
: Rectangle<float> ((float) x + 0.5f, sliderPos, (float) width - 1.0f, (float) y + ((float) height - sliderPos)));
}
else
{
auto isTwoVal = (style == Slider::SliderStyle::TwoValueVertical || style == Slider::SliderStyle::TwoValueHorizontal);
auto isThreeVal = (style == Slider::SliderStyle::ThreeValueVertical || style == Slider::SliderStyle::ThreeValueHorizontal);
auto trackWidth = jmin (6.0f, slider.isHorizontal() ? height * 0.25f : width * 0.25f);
auto trackWidth = jmin (6.0f, slider.isHorizontal() ? (float) height * 0.25f : (float) width * 0.25f);
Point<float> startPoint (slider.isHorizontal() ? x : x + width * 0.5f,
slider.isHorizontal() ? y + height * 0.5f : height + y);
Point<float> startPoint (slider.isHorizontal() ? (float) x : (float) x + (float) width * 0.5f,
slider.isHorizontal() ? (float) y + (float) height * 0.5f : (float) (height + y));
Point<float> endPoint (slider.isHorizontal() ? width + x : startPoint.x,
slider.isHorizontal() ? startPoint.y : y);
Point<float> endPoint (slider.isHorizontal() ? (float) (width + x) : startPoint.x,
slider.isHorizontal() ? startPoint.y : (float) y);
Path backgroundTrack;
backgroundTrack.startNewSubPath (startPoint);
@@ -987,20 +987,20 @@ void LookAndFeel_V4::drawLinearSlider (Graphics& g, int x, int y, int width, int
if (isTwoVal || isThreeVal)
{
minPoint = { slider.isHorizontal() ? minSliderPos : width * 0.5f,
slider.isHorizontal() ? height * 0.5f : minSliderPos };
minPoint = { slider.isHorizontal() ? minSliderPos : (float) width * 0.5f,
slider.isHorizontal() ? (float) height * 0.5f : minSliderPos };
if (isThreeVal)
thumbPoint = { slider.isHorizontal() ? sliderPos : width * 0.5f,
slider.isHorizontal() ? height * 0.5f : sliderPos };
thumbPoint = { slider.isHorizontal() ? sliderPos : (float) width * 0.5f,
slider.isHorizontal() ? (float) height * 0.5f : sliderPos };
maxPoint = { slider.isHorizontal() ? maxSliderPos : width * 0.5f,
slider.isHorizontal() ? height * 0.5f : maxSliderPos };
maxPoint = { slider.isHorizontal() ? maxSliderPos : (float) width * 0.5f,
slider.isHorizontal() ? (float) height * 0.5f : maxSliderPos };
}
else
{
auto kx = slider.isHorizontal() ? sliderPos : (x + width * 0.5f);
auto ky = slider.isHorizontal() ? (y + height * 0.5f) : sliderPos;
auto kx = slider.isHorizontal() ? sliderPos : ((float) x + (float) width * 0.5f);
auto ky = slider.isHorizontal() ? ((float) y + (float) height * 0.5f) : sliderPos;
minPoint = startPoint;
maxPoint = { kx, ky };
@@ -1021,26 +1021,26 @@ void LookAndFeel_V4::drawLinearSlider (Graphics& g, int x, int y, int width, int
if (isTwoVal || isThreeVal)
{
auto sr = jmin (trackWidth, (slider.isHorizontal() ? height : width) * 0.4f);
auto sr = jmin (trackWidth, (slider.isHorizontal() ? (float) height : (float) width) * 0.4f);
auto pointerColour = slider.findColour (Slider::thumbColourId);
if (slider.isHorizontal())
{
drawPointer (g, minSliderPos - sr,
jmax (0.0f, y + height * 0.5f - trackWidth * 2.0f),
jmax (0.0f, (float) y + (float) height * 0.5f - trackWidth * 2.0f),
trackWidth * 2.0f, pointerColour, 2);
drawPointer (g, maxSliderPos - trackWidth,
jmin (y + height - trackWidth * 2.0f, y + height * 0.5f),
jmin ((float) (y + height) - trackWidth * 2.0f, (float) y + (float) height * 0.5f),
trackWidth * 2.0f, pointerColour, 4);
}
else
{
drawPointer (g, jmax (0.0f, x + width * 0.5f - trackWidth * 2.0f),
drawPointer (g, jmax (0.0f, (float) x + (float) width * 0.5f - trackWidth * 2.0f),
minSliderPos - trackWidth,
trackWidth * 2.0f, pointerColour, 1);
drawPointer (g, jmin (x + width - trackWidth * 2.0f, x + width * 0.5f), maxSliderPos - sr,
drawPointer (g, jmin ((float) (x + width) - trackWidth * 2.0f, (float) x + (float) width * 0.5f), maxSliderPos - sr,
trackWidth * 2.0f, pointerColour, 3);
}
}
@@ -1108,7 +1108,7 @@ void LookAndFeel_V4::drawPointer (Graphics& g, const float x, const float y, con
p.lineTo (x, y + diameter * 0.6f);
p.closeSubPath();
p.applyTransform (AffineTransform::rotation (direction * MathConstants<float>::halfPi,
p.applyTransform (AffineTransform::rotation ((float) direction * MathConstants<float>::halfPi,
x + diameter * 0.5f, y + diameter * 0.5f));
g.setColour (colour);
g.fillPath (p);
@@ -1173,10 +1173,10 @@ void LookAndFeel_V4::drawLevelMeter (Graphics& g, int width, int height, float l
g.fillRoundedRectangle (0.0f, 0.0f, static_cast<float> (width), static_cast<float> (height), outerCornerSize);
auto doubleOuterBorderWidth = 2.0f * outerBorderWidth;
auto numBlocks = roundToInt (totalBlocks * level);
auto numBlocks = roundToInt ((float) totalBlocks * level);
auto blockWidth = (width - doubleOuterBorderWidth) / static_cast<float> (totalBlocks);
auto blockHeight = height - doubleOuterBorderWidth;
auto blockWidth = ((float) width - doubleOuterBorderWidth) / static_cast<float> (totalBlocks);
auto blockHeight = (float) height - doubleOuterBorderWidth;
auto blockRectWidth = (1.0f - 2.0f * spacingFraction) * blockWidth;
auto blockRectSpacing = spacingFraction * blockWidth;
@@ -1192,7 +1192,7 @@ void LookAndFeel_V4::drawLevelMeter (Graphics& g, int width, int height, float l
else
g.setColour (i < totalBlocks - 1 ? c : Colours::red);
g.fillRoundedRectangle (outerBorderWidth + (i * blockWidth) + blockRectSpacing,
g.fillRoundedRectangle (outerBorderWidth + ((float) i * blockWidth) + blockRectSpacing,
outerBorderWidth,
blockRectWidth,
blockHeight,
@@ -1207,8 +1207,8 @@ void LookAndFeel_V4::paintToolbarBackground (Graphics& g, int w, int h, Toolbar&
g.setGradientFill ({ background, 0.0f, 0.0f,
background.darker (0.2f),
toolbar.isVertical() ? w - 1.0f : 0.0f,
toolbar.isVertical() ? 0.0f : h - 1.0f,
toolbar.isVertical() ? (float) w - 1.0f : 0.0f,
toolbar.isVertical() ? 0.0f : (float) h - 1.0f,
false });
g.fillAll();
}
@@ -1222,7 +1222,7 @@ void LookAndFeel_V4::paintToolbarButtonLabel (Graphics& g, int x, int y, int wid
g.setColour (baseTextColour.withAlpha (component.isEnabled() ? 1.0f : 0.25f));
auto fontHeight = jmin (14.0f, height * 0.85f);
auto fontHeight = jmin (14.0f, (float) height * 0.85f);
g.setFont (fontHeight);
g.drawFittedText (text,
@@ -1235,8 +1235,8 @@ void LookAndFeel_V4::paintToolbarButtonLabel (Graphics& g, int x, int y, int wid
void LookAndFeel_V4::drawPropertyPanelSectionHeader (Graphics& g, const String& name,
bool isOpen, int width, int height)
{
auto buttonSize = height * 0.75f;
auto buttonIndent = (height - buttonSize) * 0.5f;
auto buttonSize = (float) height * 0.75f;
auto buttonIndent = ((float) height - buttonSize) * 0.5f;
drawTreeviewPlusMinusBox (g, { buttonIndent, buttonIndent, buttonSize, buttonSize },
findColour (ResizableWindow::backgroundColourId), isOpen, false);
@@ -1245,7 +1245,7 @@ void LookAndFeel_V4::drawPropertyPanelSectionHeader (Graphics& g, const String&
g.setColour (findColour (PropertyComponent::labelTextColourId));
g.setFont ({ height * 0.7f, Font::bold });
g.setFont ({ (float) height * 0.7f, Font::bold });
g.drawText (name, textX, 0, width - textX - 4, height, Justification::centredLeft, true);
}
@@ -1264,7 +1264,7 @@ void LookAndFeel_V4::drawPropertyComponentLabel (Graphics& g, int width, int hei
g.setColour (component.findColour (PropertyComponent::labelTextColourId)
.withMultipliedAlpha (component.isEnabled() ? 1.0f : 0.6f));
g.setFont (jmin (height, 24) * 0.65f);
g.setFont ((float) jmin (height, 24) * 0.65f);
auto r = getPropertyComponentContentPosition (component);


+ 1
- 1
source/modules/juce_gui_basics/menus/juce_PopupMenu.cpp View File

@@ -1177,7 +1177,7 @@ private:
else
{
oldGlobalPos += Point<int> (2, 0);
subX += itemScreenBounds.getWidth();
subX += (float) itemScreenBounds.getWidth();
}
Path areaTowardsSubMenu;


+ 1
- 1
source/modules/juce_gui_basics/mouse/juce_DragAndDropContainer.cpp View File

@@ -438,7 +438,7 @@ void DragAndDropContainer::startDragging (const var& sourceDescription,
if (distance > lo)
{
auto alpha = (distance > hi) ? 0
: (hi - distance) / (float) (hi - lo)
: (float) (hi - distance) / (float) (hi - lo)
+ random.nextFloat() * 0.008f;
dragImage.multiplyAlphaAt (x, y, alpha);


+ 2
- 2
source/modules/juce_gui_basics/mouse/juce_MouseInputSource.cpp View File

@@ -538,8 +538,8 @@ private:
bool canBePartOfMultipleClickWith (const RecentMouseDown& other, int maxTimeBetweenMs) const noexcept
{
return time - other.time < RelativeTime::milliseconds (maxTimeBetweenMs)
&& std::abs (position.x - other.position.x) < getPositionToleranceForInputType()
&& std::abs (position.y - other.position.y) < getPositionToleranceForInputType()
&& std::abs (position.x - other.position.x) < (float) getPositionToleranceForInputType()
&& std::abs (position.y - other.position.y) < (float) getPositionToleranceForInputType()
&& buttons == other.buttons
&& peerID == other.peerID;
}


+ 1
- 2
source/modules/juce_gui_basics/native/juce_win32_FileChooser.cpp View File

@@ -48,7 +48,6 @@ public:
: Thread ("Native Win32 FileChooser"),
owner (parent), title (titleToUse), filtersString (filtersToUse),
selectsDirectories ((flags & FileBrowserComponent::canSelectDirectories) != 0),
selectsFiles ((flags & FileBrowserComponent::canSelectFiles) != 0),
isSave ((flags & FileBrowserComponent::saveMode) != 0),
warnAboutOverwrite ((flags & FileBrowserComponent::warnAboutOverwriting) != 0),
selectMultiple ((flags & FileBrowserComponent::canSelectMultipleItems) != 0),
@@ -160,7 +159,7 @@ private:
WaitableEvent threadHasReference;
CriticalSection deletingDialog;
bool selectsDirectories, selectsFiles, isSave, warnAboutOverwrite, selectMultiple;
bool selectsDirectories, isSave, warnAboutOverwrite, selectMultiple;
HeapBlock<WCHAR> files;
HeapBlock<WCHAR> filters;


+ 5
- 4
source/modules/juce_gui_basics/native/juce_win32_Windowing.cpp View File

@@ -1780,16 +1780,17 @@ public:
private:
Point<float> getMousePos (POINTL mousePos) const
{
Point<float> screenPos;
auto screenPos = pointFromPOINT ({ mousePos.x, mousePos.y }).toFloat();
#if JUCE_WIN_PER_MONITOR_DPI_AWARE
auto h = (HWND) peer.getNativeHandle();
if (isPerMonitorDPIAwareWindow (h))
screenPos = convertPhysicalScreenPointToLogical (pointFromPOINT ({ mousePos.x, mousePos.y }), h).toFloat();
else
screenPos = convertPhysicalScreenPointToLogical (screenPos.roundToInt(), h).toFloat();
#else
if (JUCEApplication::isStandaloneApp())
screenPos /= static_cast<float> (getGlobalDPI() / USER_DEFAULT_SCREEN_DPI);
#endif
screenPos = pointFromPOINT ({ mousePos.x, mousePos.y }).toFloat() / static_cast<float> (getGlobalDPI() / USER_DEFAULT_SCREEN_DPI);
return peer.getComponent().getLocalPoint (nullptr, screenPos);
}


+ 5
- 5
source/modules/juce_gui_basics/native/x11/juce_linux_X11_Symbols.h View File

@@ -578,19 +578,19 @@ private:
}
//==============================================================================
DynamicLibrary xLib { "libX11.so" }, xextLib { "libXext.so" };
DynamicLibrary xLib { "libX11.so.6" }, xextLib { "libXext.so.6" };
#if JUCE_USE_XCURSOR
DynamicLibrary xcursorLib { "libXcursor.so" };
DynamicLibrary xcursorLib { "libXcursor.so.1" };
#endif
#if JUCE_USE_XINERAMA
DynamicLibrary xineramaLib { "libXinerama.so" };
DynamicLibrary xineramaLib { "libXinerama.so.1" };
#endif
#if JUCE_USE_XRENDER
DynamicLibrary xrenderLib { "libXrender.so" };
DynamicLibrary xrenderLib { "libXrender.so.1" };
#endif
#if JUCE_USE_XRANDR
DynamicLibrary xrandrLib { "libXrandr.so" };
DynamicLibrary xrandrLib { "libXrandr.so.2" };
#endif
//==============================================================================


+ 1
- 1
source/modules/juce_gui_basics/properties/juce_TextPropertyComponent.cpp View File

@@ -103,7 +103,7 @@ public:
g.setFont (labelFont);
g.drawFittedText (textToDisplayWhenEmpty, textArea, getJustificationType(),
jmax (1, (int) (textArea.getHeight() / labelFont.getHeight())),
jmax (1, (int) ((float) textArea.getHeight() / labelFont.getHeight())),
getMinimumHorizontalScale());
}
}


+ 4
- 1
source/modules/juce_gui_basics/widgets/juce_ListBox.cpp View File

@@ -890,7 +890,10 @@ Image ListBox::createSnapshotOfRows (const SparseSet<int>& rows, int& imageX, in
imageY = imageArea.getY();
auto listScale = Component::getApproximateScaleFactorForComponent (this);
Image snapshot (Image::ARGB, roundToInt (imageArea.getWidth() * listScale), roundToInt (imageArea.getHeight() * listScale), true);
Image snapshot (Image::ARGB,
roundToInt ((float) imageArea.getWidth() * listScale),
roundToInt ((float) imageArea.getHeight() * listScale),
true);
for (int i = getNumRowsOnScreen() + 2; --i >= 0;)
{


+ 5
- 5
source/modules/juce_gui_basics/widgets/juce_Slider.cpp View File

@@ -685,8 +685,8 @@ public:
//==============================================================================
void handleRotaryDrag (const MouseEvent& e)
{
auto dx = e.position.x - sliderRect.getCentreX();
auto dy = e.position.y - sliderRect.getCentreY();
auto dx = e.position.x - (float) sliderRect.getCentreX();
auto dy = e.position.y - (float) sliderRect.getCentreY();
if (dx * dx + dy * dy > 25.0f)
{
@@ -768,7 +768,7 @@ public:
}
else
{
newPos = (mousePos - sliderRegionStart) / (double) sliderRegionSize;
newPos = (mousePos - (float) sliderRegionStart) / (double) sliderRegionSize;
if (isVertical())
newPos = 1.0 - newPos;
@@ -1140,8 +1140,8 @@ public:
{
auto pixelPos = (float) getLinearSliderPos (pos);
mousePos = owner.localPointToGlobal (Point<float> (isHorizontal() ? pixelPos : (owner.getWidth() / 2.0f),
isVertical() ? pixelPos : (owner.getHeight() / 2.0f)));
mousePos = owner.localPointToGlobal (Point<float> (isHorizontal() ? pixelPos : ((float) owner.getWidth() / 2.0f),
isVertical() ? pixelPos : ((float) owner.getHeight() / 2.0f)));
}
const_cast <MouseInputSource&> (ms).setScreenPosition (mousePos);


+ 9
- 9
source/modules/juce_gui_basics/widgets/juce_TextEditor.cpp View File

@@ -547,7 +547,7 @@ struct TextEditor::Iterator
Graphics::ScopedSaveState state (g);
g.reduceClipRegion ({ startX, baselineY, endX - startX, 1 });
g.fillCheckerBoard ({ (float) endX, baselineY + 1.0f }, 3.0f, 1.0f, colour, Colours::transparentBlack);
g.fillCheckerBoard ({ (float) endX, (float) baselineY + 1.0f }, 3.0f, 1.0f, colour, Colours::transparentBlack);
}
void drawSelectedText (Graphics& g, Range<int> selected, Colour selectedTextColour) const
@@ -1584,9 +1584,9 @@ void TextEditor::drawContent (Graphics& g)
Iterator i2 (i);
RectangleList<float> selectionArea;
while (i2.next() && i2.lineY < clip.getBottom())
while (i2.next() && i2.lineY < (float) clip.getBottom())
{
if (i2.lineY + i2.lineHeight >= clip.getY()
if (i2.lineY + i2.lineHeight >= (float) clip.getY()
&& selection.intersects ({ i2.indexInText, i2.indexInText + i2.atom->numChars }))
{
i2.addSelection (selectionArea, selection);
@@ -1601,9 +1601,9 @@ void TextEditor::drawContent (Graphics& g)
const UniformTextSection* lastSection = nullptr;
while (i.next() && i.lineY < clip.getBottom())
while (i.next() && i.lineY < (float) clip.getBottom())
{
if (i.lineY + i.lineHeight >= clip.getY())
if (i.lineY + i.lineHeight >= (float) clip.getY())
{
if (selection.intersects ({ i.indexInText, i.indexInText + i.atom->numChars }))
{
@@ -1621,9 +1621,9 @@ void TextEditor::drawContent (Graphics& g)
{
Iterator i2 (*this);
while (i2.next() && i2.lineY < clip.getBottom())
while (i2.next() && i2.lineY < (float) clip.getBottom())
{
if (i2.lineY + i2.lineHeight >= clip.getY()
if (i2.lineY + i2.lineHeight >= (float) clip.getY()
&& underlinedSection.intersects ({ i2.indexInText, i2.indexInText + i2.atom->numChars }))
{
i2.drawUnderline (g, underlinedSection, findColour (textColourId));
@@ -1883,7 +1883,7 @@ bool TextEditor::pageUp (bool selecting)
return moveCaretToStartOfLine (selecting);
auto caretPos = getCaretRectangleFloat();
return moveCaretWithTransaction (indexAtPosition (caretPos.getX(), caretPos.getY() - viewport->getViewHeight()), selecting);
return moveCaretWithTransaction (indexAtPosition (caretPos.getX(), caretPos.getY() - (float) viewport->getViewHeight()), selecting);
}
bool TextEditor::pageDown (bool selecting)
@@ -1892,7 +1892,7 @@ bool TextEditor::pageDown (bool selecting)
return moveCaretToEndOfLine (selecting);
auto caretPos = getCaretRectangleFloat();
return moveCaretWithTransaction (indexAtPosition (caretPos.getX(), caretPos.getBottom() + viewport->getViewHeight()), selecting);
return moveCaretWithTransaction (indexAtPosition (caretPos.getX(), caretPos.getBottom() + (float) viewport->getViewHeight()), selecting);
}
void TextEditor::scrollByLines (int deltaLines)


+ 17
- 17
source/modules/juce_gui_basics/widgets/juce_Toolbar.cpp View File

@@ -51,7 +51,7 @@ public:
}
else
{
maxSize = roundToInt (toolbarThickness * fixedSize);
maxSize = roundToInt ((float) toolbarThickness * fixedSize);
minSize = drawBar ? maxSize : jmin (4, maxSize);
preferredSize = maxSize;
@@ -87,9 +87,9 @@ public:
auto thickness = 0.2f;
if (isToolbarVertical())
g.fillRect (w * 0.1f, h * (0.5f - thickness * 0.5f), w * 0.8f, h * thickness);
g.fillRect ((float) w * 0.1f, (float) h * (0.5f - thickness * 0.5f), (float) w * 0.8f, (float) h * thickness);
else
g.fillRect (w * (0.5f - thickness * 0.5f), h * 0.1f, w * thickness, h * 0.8f);
g.fillRect ((float) w * (0.5f - thickness * 0.5f), (float) h * 0.1f, (float) w * thickness, (float) h * 0.8f);
}
if (getEditingMode() != normalMode && ! drawBar)
@@ -106,33 +106,33 @@ public:
if (isToolbarVertical())
{
x1 = w * 0.5f;
y1 = h * 0.4f;
x1 = (float) w * 0.5f;
y1 = (float) h * 0.4f;
x2 = x1;
y2 = indentX * 2.0f;
y2 = (float) indentX * 2.0f;
x3 = x1;
y3 = h * 0.6f;
y3 = (float) h * 0.6f;
x4 = x1;
y4 = h - y2;
y4 = (float) h - y2;
hw = w * 0.15f;
hl = w * 0.2f;
hw = (float) w * 0.15f;
hl = (float) w * 0.2f;
}
else
{
x1 = w * 0.4f;
y1 = h * 0.5f;
x2 = indentX * 2.0f;
x1 = (float) w * 0.4f;
y1 = (float) h * 0.5f;
x2 = (float) indentX * 2.0f;
y2 = y1;
x3 = w * 0.6f;
x3 = (float) w * 0.6f;
y3 = y1;
x4 = w - x2;
x4 = (float) w - x2;
y4 = y1;
hw = h * 0.15f;
hl = h * 0.2f;
hw = (float) h * 0.15f;
hl = (float) h * 0.2f;
}
Path p;


+ 4
- 4
source/modules/juce_gui_basics/widgets/juce_TreeView.cpp View File

@@ -993,7 +993,7 @@ public:
void paint (Graphics& g) override
{
g.setColour (findColour (TreeView::dragAndDropIndicatorColourId, true));
g.drawRoundedRectangle (1.0f, 1.0f, getWidth() - 2.0f, getHeight() - 2.0f, 3.0f, 2.0f);
g.drawRoundedRectangle (1.0f, 1.0f, (float) getWidth() - 2.0f, (float) getHeight() - 2.0f, 3.0f, 2.0f);
}
private:
@@ -1552,13 +1552,13 @@ void TreeViewItem::paintRecursively (Graphics& g, int width)
}
}
auto halfH = itemHeight * 0.5f;
auto halfH = (float) itemHeight * 0.5f;
auto indentWidth = ownerView->getIndentSize();
auto depth = TreeViewHelpers::calculateDepth (this, ownerView->rootItemVisible);
if (depth >= 0 && ownerView->openCloseButtonsVisible)
{
auto x = (depth + 0.5f) * indentWidth;
auto x = ((float) depth + 0.5f) * (float) indentWidth;
const bool parentLinesDrawn = parentItem != nullptr && parentItem->areLinesDrawn();
@@ -1566,7 +1566,7 @@ void TreeViewItem::paintRecursively (Graphics& g, int width)
paintVerticalConnectingLine (g, Line<float> (x, 0, x, isLastOfSiblings() ? halfH : (float) itemHeight));
if (parentLinesDrawn || (parentItem == nullptr && areLinesDrawn()))
paintHorizontalConnectingLine (g, Line<float> (x, halfH, x + indentWidth / 2, halfH));
paintHorizontalConnectingLine (g, Line<float> (x, halfH, x + (float) indentWidth * 0.5f, halfH));
{
auto* p = parentItem;


+ 8
- 8
source/modules/juce_gui_basics/windows/juce_AlertWindow.cpp View File

@@ -239,7 +239,7 @@ public:
setFont (font);
setText (message, false);
bestWidth = 2 * (int) std::sqrt (font.getHeight() * font.getStringWidth (message));
bestWidth = 2 * (int) std::sqrt (font.getHeight() * (float) font.getStringWidth (message));
}
void updateLayout (const int width)
@@ -249,7 +249,7 @@ public:
s.append (getText(), getFont());
TextLayout text;
text.createLayoutWithBalancedLineLengths (s, width - 8.0f);
text.createLayoutWithBalancedLineLengths (s, (float) width - 8.0f);
setSize (width, jmin (width, (int) (text.getHeight() + getFont().getHeight())));
}
@@ -355,8 +355,8 @@ void AlertWindow::updateLayout (const bool onlyIncreaseSize)
auto wid = jmax (messageFont.getStringWidth (text),
messageFont.getStringWidth (getName()));
auto sw = (int) std::sqrt (messageFont.getHeight() * wid);
auto w = jmin (300 + sw * 2, (int) (getParentWidth() * 0.7f));
auto sw = (int) std::sqrt (messageFont.getHeight() * (float) wid);
auto w = jmin (300 + sw * 2, (int) ((float) getParentWidth() * 0.7f));
const int edgeGap = 10;
const int labelHeight = 18;
int iconSpace = 0;
@@ -382,7 +382,7 @@ void AlertWindow::updateLayout (const bool onlyIncreaseSize)
}
w = jmax (350, (int) textLayout.getWidth() + iconSpace + edgeGap * 4);
w = jmin (w, (int) (getParentWidth() * 0.7f));
w = jmin (w, (int) ((float) getParentWidth() * 0.7f));
auto textLayoutH = (int) textLayout.getHeight();
auto textBottom = 16 + titleH + textLayoutH;
@@ -412,12 +412,12 @@ void AlertWindow::updateLayout (const bool onlyIncreaseSize)
for (auto* tb : textBlocks)
w = jmax (w, static_cast<const AlertTextComp*> (tb)->bestWidth);
w = jmin (w, (int) (getParentWidth() * 0.7f));
w = jmin (w, (int) ((float) getParentWidth() * 0.7f));
for (auto* tb : textBlocks)
{
auto* ac = static_cast<AlertTextComp*> (tb);
ac->updateLayout ((int) (w * 0.8f));
ac->updateLayout ((int) ((float) w * 0.8f));
h += ac->getHeight() + 10;
}
@@ -443,7 +443,7 @@ void AlertWindow::updateLayout (const bool onlyIncreaseSize)
totalWidth += b->getWidth() + spacer;
auto x = (w - totalWidth) / 2;
auto y = (int) (getHeight() * 0.95f);
auto y = (int) ((float) getHeight() * 0.95f);
for (auto* c : buttons)
{


+ 3
- 3
source/modules/juce_gui_basics/windows/juce_CallOutBox.cpp View File

@@ -201,7 +201,7 @@ void CallOutBox::updatePosition (const Rectangle<int>& newAreaToPointTo, const R
auto hh = newBounds.getHeight() / 2;
auto hwReduced = (float) (hw - borderSpace * 2);
auto hhReduced = (float) (hh - borderSpace * 2);
auto arrowIndent = borderSpace - arrowSize;
auto arrowIndent = (float) borderSpace - arrowSize;
Point<float> targets[4] = { { (float) targetArea.getCentreX(), (float) targetArea.getBottom() },
{ (float) targetArea.getRight(), (float) targetArea.getCentreY() },
@@ -234,8 +234,8 @@ void CallOutBox::updatePosition (const Rectangle<int>& newAreaToPointTo, const R
nearest = distanceFromCentre;
targetPoint = targets[i];
newBounds.setPosition ((int) (centre.x - hw),
(int) (centre.y - hh));
newBounds.setPosition ((int) (centre.x - (float) hw),
(int) (centre.y - (float) hh));
}
}


+ 2
- 2
source/modules/juce_gui_basics/windows/juce_ComponentPeer.cpp View File

@@ -115,8 +115,8 @@ void ComponentPeer::handlePaint (LowLevelGraphicsContext& contextToPaintTo)
if (peerBounds.getWidth() != componentBounds.getWidth() || peerBounds.getHeight() != componentBounds.getHeight())
// Tweak the scaling so that the component's integer size exactly aligns with the peer's scaled size
g.addTransform (AffineTransform::scale (peerBounds.getWidth() / (float) componentBounds.getWidth(),
peerBounds.getHeight() / (float) componentBounds.getHeight()));
g.addTransform (AffineTransform::scale ((float) peerBounds.getWidth() / (float) componentBounds.getWidth(),
(float) peerBounds.getHeight() / (float) componentBounds.getHeight()));
#if JUCE_ENABLE_REPAINT_DEBUGGING
#ifdef JUCE_IS_REPAINT_DEBUGGING_ACTIVE


+ 7
- 7
source/modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.cpp View File

@@ -85,8 +85,8 @@ public:
void getHighlightArea (RectangleList<float>& area, float x, int y, int lineH, float characterWidth) const
{
if (highlightColumnStart < highlightColumnEnd)
area.add (Rectangle<float> (x + highlightColumnStart * characterWidth - 1.0f, y - 0.5f,
(highlightColumnEnd - highlightColumnStart) * characterWidth + 1.5f, lineH + 1.0f));
area.add (Rectangle<float> (x + (float) highlightColumnStart * characterWidth - 1.0f, (float) y - 0.5f,
(float) (highlightColumnEnd - highlightColumnStart) * characterWidth + 1.5f, (float) lineH + 1.0f));
}
void draw (CodeEditorComponent& owner, Graphics& g, const Font& fontToUse,
@@ -100,7 +100,7 @@ public:
for (auto& token : tokens)
{
const float tokenX = x + column * characterWidth;
const float tokenX = x + (float) column * characterWidth;
if (tokenX > rightClip)
break;
@@ -108,7 +108,7 @@ public:
column += token.length;
}
as.draw (g, { x, (float) y, column * characterWidth + 10.0f, (float) lineH });
as.draw (g, { x, (float) y, (float) column * characterWidth + 10.0f, (float) lineH });
}
private:
@@ -301,7 +301,7 @@ public:
lastNumLines - editor.firstLineOnScreen);
auto lineNumberFont = editor.getFont().withHeight (jmin (13.0f, lineHeightFloat * 0.8f));
auto w = getWidth() - 2.0f;
auto w = (float) getWidth() - 2.0f;
GlyphArrangement ga;
for (int i = firstLineToDraw; i < lastLineToDraw; ++i)
@@ -443,7 +443,7 @@ void CodeEditorComponent::resized()
{
auto visibleWidth = getWidth() - scrollbarThickness - getGutterSize();
linesOnScreen = jmax (1, (getHeight() - scrollbarThickness) / lineHeight);
columnsOnScreen = jmax (1, (int) (visibleWidth / charWidth));
columnsOnScreen = jmax (1, (int) ((float) visibleWidth / charWidth));
lines.clear();
rebuildLineTokens();
updateCaretPosition();
@@ -737,7 +737,7 @@ void CodeEditorComponent::scrollToKeepCaretOnScreen()
Rectangle<int> CodeEditorComponent::getCharacterBounds (const CodeDocument::Position& pos) const
{
return { roundToInt ((getGutterSize() - xOffset * charWidth) + indexToColumn (pos.getLineNumber(), pos.getIndexInLine()) * charWidth),
return { roundToInt ((getGutterSize() - xOffset * charWidth) + (float) indexToColumn (pos.getLineNumber(), pos.getIndexInLine()) * charWidth),
(pos.getLineNumber() - firstLineOnScreen) * lineHeight,
roundToInt (charWidth),
lineHeight };


+ 1
- 1
source/modules/juce_gui_extra/misc/juce_BubbleMessageComponent.cpp View File

@@ -97,7 +97,7 @@ void BubbleMessageComponent::paintContent (Graphics& g, int w, int h)
g.setColour (findColour (TooltipWindow::textColourId));
textLayout.draw (g, Rectangle<float> (bubblePaddingX / 2.0f, bubblePaddingY / 2.0f,
w - bubblePaddingX, h - bubblePaddingY));
(float) w - bubblePaddingX, (float) h - bubblePaddingY));
}
void BubbleMessageComponent::timerCallback()


+ 7
- 7
source/modules/juce_gui_extra/misc/juce_ColourSelector.cpp View File

@@ -67,11 +67,11 @@ public:
for (int y = 0; y < height; ++y)
{
auto val = 1.0f - y / (float) height;
auto val = 1.0f - (float) y / (float) height;
for (int x = 0; x < width; ++x)
{
auto sat = x / (float) width;
auto sat = (float) x / (float) width;
pixels.setPixelColour (x, y, Colour (h, sat, val, 1.0f));
}
}
@@ -92,8 +92,8 @@ public:
void mouseDrag (const MouseEvent& e) override
{
auto sat = (e.x - edge) / (float) (getWidth() - edge * 2);
auto val = 1.0f - (e.y - edge) / (float) (getHeight() - edge * 2);
auto sat = (float) (e.x - edge) / (float) (getWidth() - edge * 2);
auto val = 1.0f - (float) (e.y - edge) / (float) (getHeight() - edge * 2);
owner.setSV (sat, val);
}
@@ -135,9 +135,9 @@ private:
void paint (Graphics& g) override
{
g.setColour (Colour::greyLevel (0.1f));
g.drawEllipse (1.0f, 1.0f, getWidth() - 2.0f, getHeight() - 2.0f, 1.0f);
g.drawEllipse (1.0f, 1.0f, (float) getWidth() - 2.0f, (float) getHeight() - 2.0f, 1.0f);
g.setColour (Colour::greyLevel (0.9f));
g.drawEllipse (2.0f, 2.0f, getWidth() - 4.0f, getHeight() - 4.0f, 1.0f);
g.drawEllipse (2.0f, 2.0f, (float) getWidth() - 4.0f, (float) getHeight() - 4.0f, 1.0f);
}
};
@@ -195,7 +195,7 @@ public:
void mouseDrag (const MouseEvent& e) override
{
owner.setHue ((e.y - edge) / (float) (getHeight() - edge * 2));
owner.setHue ((float) (e.y - edge) / (float) (getHeight() - edge * 2));
}
void updateIfNeeded()


+ 3
- 3
source/modules/juce_gui_extra/misc/juce_KeyMappingEditorComponent.cpp View File

@@ -88,7 +88,7 @@ public:
if (keyNum < 0)
setSize (h, h);
else
setSize (jlimit (h * 4, h * 8, 6 + Font (h * 0.6f).getStringWidth (getName())), h);
setSize (jlimit (h * 4, h * 8, 6 + Font ((float) h * 0.6f).getStringWidth (getName())), h);
}
//==============================================================================
@@ -240,7 +240,7 @@ public:
void paint (Graphics& g) override
{
g.setFont (getHeight() * 0.7f);
g.setFont ((float) getHeight() * 0.7f);
g.setColour (owner.findColour (KeyMappingEditorComponent::textColourId));
g.drawFittedText (TRANS (owner.getCommandManager().getNameOfCommand (commandID)),
@@ -307,7 +307,7 @@ public:
void paintItem (Graphics& g, int width, int height) override
{
g.setFont (Font (height * 0.7f, Font::bold));
g.setFont (Font ((float) height * 0.7f, Font::bold));
g.setColour (owner.findColour (KeyMappingEditorComponent::textColourId));
g.drawText (TRANS (categoryName), 2, 0, width - 2, height, Justification::centredLeft, true);


Loading…
Cancel
Save