本文整理汇总了C++中ProgressBar::getLocalBounds方法的典型用法代码示例。如果您正苦于以下问题:C++ ProgressBar::getLocalBounds方法的具体用法?C++ ProgressBar::getLocalBounds怎么用?C++ ProgressBar::getLocalBounds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProgressBar
的用法示例。
在下文中一共展示了ProgressBar::getLocalBounds方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawProgressBar
void ProjucerLookAndFeel::drawProgressBar (Graphics& g, ProgressBar& progressBar,
int width, int height, double progress, const String& textToShow)
{
ignoreUnused (width, height, progress);
const auto background = progressBar.findColour (ProgressBar::backgroundColourId);
const auto foreground = progressBar.findColour (defaultButtonBackgroundColourId);
const auto sideLength = jmin (width, height);
auto barBounds = progressBar.getLocalBounds().withSizeKeepingCentre (sideLength, sideLength).reduced (1).toFloat();
auto rotationInDegrees = static_cast<float> ((Time::getMillisecondCounter() / 10) % 360);
auto normalisedRotation = rotationInDegrees / 360.0f;
const auto rotationOffset = 22.5f;
const auto maxRotation = 315.0f;
auto startInDegrees = rotationInDegrees;
auto endInDegrees = startInDegrees + rotationOffset;
if (normalisedRotation >= 0.25f && normalisedRotation < 0.5f)
{
const auto rescaledRotation = (normalisedRotation * 4.0f) - 1.0f;
endInDegrees = startInDegrees + rotationOffset + (maxRotation * rescaledRotation);
}
else if (normalisedRotation >= 0.5f && normalisedRotation <= 1.0f)
{
endInDegrees = startInDegrees + rotationOffset + maxRotation;
const auto rescaledRotation = 1.0f - ((normalisedRotation * 2.0f) - 1.0f);
startInDegrees = endInDegrees - rotationOffset - (maxRotation * rescaledRotation);
}
g.setColour (background);
Path arcPath2;
arcPath2.addCentredArc (barBounds.getCentreX(),
barBounds.getCentreY(),
barBounds.getWidth() * 0.5f,
barBounds.getHeight() * 0.5f, 0.0f,
0.0f,
2.0f * float_Pi,
true);
g.strokePath (arcPath2, PathStrokeType (2.0f));
g.setColour (foreground);
Path arcPath;
arcPath.addCentredArc (barBounds.getCentreX(),
barBounds.getCentreY(),
barBounds.getWidth() * 0.5f,
barBounds.getHeight() * 0.5f,
0.0f,
degreesToRadians (startInDegrees),
degreesToRadians (endInDegrees),
true);
arcPath.applyTransform (AffineTransform::rotation (normalisedRotation * float_Pi * 2.25f, barBounds.getCentreX(), barBounds.getCentreY()));
g.strokePath (arcPath, PathStrokeType (2.0f));
if (textToShow.isNotEmpty())
{
g.setColour (progressBar.findColour (TextButton::textColourOffId));
g.setFont (Font (12.0f, 2));
g.drawText (textToShow, barBounds, Justification::centred, false);
}
}