本文整理汇总了C++中GlyphArrangement::addFittedText方法的典型用法代码示例。如果您正苦于以下问题:C++ GlyphArrangement::addFittedText方法的具体用法?C++ GlyphArrangement::addFittedText怎么用?C++ GlyphArrangement::addFittedText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GlyphArrangement
的用法示例。
在下文中一共展示了GlyphArrangement::addFittedText方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: paint
void paint (Graphics& g) override
{
jassert (dynamic_cast <CodeEditorComponent*> (getParentComponent()) != nullptr);
const CodeEditorComponent& editor = *static_cast <CodeEditorComponent*> (getParentComponent());
g.fillAll (editor.findColour (CodeEditorComponent::backgroundColourId)
.overlaidWith (editor.findColour (lineNumberBackgroundId)));
const Rectangle<int> clip (g.getClipBounds());
const int lineH = editor.lineHeight;
const float lineHeightFloat = (float) lineH;
const int firstLineToDraw = jmax (0, clip.getY() / lineH);
const int lastLineToDraw = jmin (editor.lines.size(), clip.getBottom() / lineH + 1,
lastNumLines - editor.firstLineOnScreen);
const Font lineNumberFont (editor.getFont().withHeight (jmin (13.0f, lineHeightFloat * 0.8f)));
const float w = getWidth() - 2.0f;
GlyphArrangement ga;
for (int i = firstLineToDraw; i < lastLineToDraw; ++i)
ga.addFittedText (lineNumberFont, String (editor.firstLineOnScreen + i + 1),
0, (float) (lineH * i), w, lineHeightFloat,
Justification::centredRight, 1, 0.2f);
g.setColour (editor.findColour (lineNumberTextId));
ga.draw (g);
}
示例2: createTabTextLayout
void IntrojucerLookAndFeel::createTabTextLayout (const TabBarButton& button, const Rectangle<int>& textArea, GlyphArrangement& textLayout)
{
Font font (textArea.getHeight() * 0.5f);
font.setUnderline (button.hasKeyboardFocus (false));
textLayout.addFittedText (font, button.getButtonText().trim(),
(float) textArea.getX(), (float) textArea.getY(), (float) textArea.getWidth(), (float) textArea.getHeight(),
Justification::centred, 1);
}
示例3: drawTabButtonText
void CtrlrTabsLF::drawTabButtonText (TabBarButton& button, Graphics& g, bool isMouseOver, bool isMouseDown)
{
const Rectangle<float> area (button.getTextArea().toFloat());
float length = area.getWidth();
float depth = area.getHeight();
if (button.getTabbedButtonBar().isVertical())
std::swap (length, depth);
Font otherTabFont = owner.getOwner().getOwner().getOwner().getFontManager().getFontFromString (owner.getProperty(Ids::uiTabsTabFont));
Font activeTabFont = owner.getOwner().getOwner().getOwner().getFontManager().getFontFromString (owner.getProperty(Ids::uiTabsFrontTabFont));
otherTabFont.setUnderline (button.hasKeyboardFocus (false));
activeTabFont.setUnderline (button.hasKeyboardFocus (false));
GlyphArrangement textLayout;
textLayout.addFittedText (button.isFrontTab() ? activeTabFont : otherTabFont, button.getButtonText().trim(),
0.0f, 0.0f, (float) length, (float) depth,
Justification::centred,
jmax<int> (1, depth / 12));
AffineTransform t;
switch (button.getTabbedButtonBar().getOrientation())
{
case TabbedButtonBar::TabsAtLeft:
t = t.rotated (float_Pi * -0.5f).translated (area.getX(), area.getBottom());
break;
case TabbedButtonBar::TabsAtRight:
t = t.rotated (float_Pi * 0.5f).translated (area.getRight(), area.getY());
break;
case TabbedButtonBar::TabsAtTop:
case TabbedButtonBar::TabsAtBottom:
t = t.translated (area.getX(), area.getY());
break;
default:
jassertfalse;
break;
}
Colour col;
if (button.isFrontTab() && (button.isColourSpecified (TabbedButtonBar::frontTextColourId)
|| isColourSpecified (TabbedButtonBar::frontTextColourId)))
col = findColour (TabbedButtonBar::frontTextColourId);
else if (button.isColourSpecified (TabbedButtonBar::tabTextColourId)
|| isColourSpecified (TabbedButtonBar::tabTextColourId))
col = findColour (TabbedButtonBar::tabTextColourId);
else
col = button.getTabBackgroundColour().contrasting();
const float alpha = button.isEnabled() ? ((isMouseOver || isMouseDown) ? 1.0f : 0.8f) : 0.3f;
g.setColour (col.withMultipliedAlpha (alpha));
textLayout.draw (g, t);
}
示例4: getArrangementAndTransform
const AffineTransform DrawableText::getArrangementAndTransform (GlyphArrangement& glyphs) const
{
const float w = Line<float> (resolvedPoints[0], resolvedPoints[1]).getLength();
const float h = Line<float> (resolvedPoints[0], resolvedPoints[2]).getLength();
glyphs.addFittedText (scaledFont, text, 0, 0, w, h, justification, 0x100000);
return AffineTransform::fromTargetPoints (0, 0, resolvedPoints[0].getX(), resolvedPoints[0].getY(),
w, 0, resolvedPoints[1].getX(), resolvedPoints[1].getY(),
0, h, resolvedPoints[2].getX(), resolvedPoints[2].getY());
}
示例5: paint
void paint (Graphics& g) override
{
double startTime = 0.0;
{
// A ScopedSaveState will return the Graphics context to the state it was at the time of
// construction when it goes out of scope. We use it here to avoid clipping the fps text
const Graphics::ScopedSaveState state (g);
if (controls.clipToRectangle.getToggleState()) clipToRectangle (g);
if (controls.clipToPath .getToggleState()) clipToPath (g);
if (controls.clipToImage .getToggleState()) clipToImage (g);
g.setImageResamplingQuality (controls.quality.getToggleState() ? Graphics::highResamplingQuality
: Graphics::mediumResamplingQuality);
// take a note of the time before the render
startTime = Time::getMillisecondCounterHiRes();
// then let the demo draw itself..
drawDemo (g);
}
double now = Time::getMillisecondCounterHiRes();
double filtering = 0.08;
const double elapsedMs = now - startTime;
averageTimeMs += (elapsedMs - averageTimeMs) * filtering;
const double sinceLastRender = now - lastRenderStartTime;
lastRenderStartTime = now;
const double effectiveFPS = 1000.0 / averageTimeMs;
const double actualFPS = sinceLastRender > 0 ? (1000.0 / sinceLastRender) : 0;
averageActualFPS += (actualFPS - averageActualFPS) * filtering;
GlyphArrangement ga;
ga.addFittedText (displayFont,
"Time: " + String (averageTimeMs, 2)
+ " ms\nEffective FPS: " + String (effectiveFPS, 1)
+ "\nActual FPS: " + String (averageActualFPS, 1),
0, 10.0f, getWidth() - 10.0f, (float) getHeight(), Justification::topRight, 3);
g.setColour (Colours::white.withAlpha (0.5f));
g.fillRect (ga.getBoundingBox (0, ga.getNumGlyphs(), true).getSmallestIntegerContainer().expanded (4));
g.setColour (Colours::black);
ga.draw (g);
}
示例6: drawFittedText
void Graphics::drawFittedText (const String& text, const Rectangle<int>& area,
const Justification& justification,
const int maximumNumberOfLines,
const float minimumHorizontalScale) const
{
if (text.isNotEmpty() && (! area.isEmpty()) && context.clipRegionIntersects (area))
{
GlyphArrangement arr;
arr.addFittedText (context.getFont(), text,
(float) area.getX(), (float) area.getY(),
(float) area.getWidth(), (float) area.getHeight(),
justification,
maximumNumberOfLines,
minimumHorizontalScale);
arr.draw (*this);
}
}
示例7: drawFittedText
void Graphics::drawFittedText (const String& text,
const int x, const int y, const int width, const int height,
const Justification& justification,
const int maximumNumberOfLines,
const float minimumHorizontalScale) const
{
if (text.isNotEmpty()
&& width > 0 && height > 0
&& context->clipRegionIntersects (Rectangle<int> (x, y, width, height)))
{
GlyphArrangement arr;
arr.addFittedText (context->getFont(), text,
(float) x, (float) y, (float) width, (float) height,
justification,
maximumNumberOfLines,
minimumHorizontalScale);
arr.draw (*this);
}
}