1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Added an underline toggle to FontsDemo

This commit is contained in:
ed 2020-08-04 09:28:42 +01:00
parent 508d6de04e
commit a4d43c16e3
2 changed files with 20 additions and 12 deletions

View file

@ -70,6 +70,7 @@ public:
addAndMakeVisible (scaleSlider);
addAndMakeVisible (boldToggle);
addAndMakeVisible (italicToggle);
addAndMakeVisible (underlineToggle);
addAndMakeVisible (styleBox);
addAndMakeVisible (horizontalJustificationBox);
addAndMakeVisible (verticalJustificationBox);
@ -87,7 +88,8 @@ public:
scaleSlider .addListener (this);
boldToggle .onClick = [this] { refreshPreviewBoxFont(); };
italicToggle.onClick = [this] { refreshPreviewBoxFont(); };
italicToggle .onClick = [this] { refreshPreviewBoxFont(); };
underlineToggle.onClick = [this] { refreshPreviewBoxFont(); };
styleBox .onChange = [this] { refreshPreviewBoxFont(); };
Font::findFonts (fonts); // Generate the list of fonts
@ -130,6 +132,8 @@ public:
demoTextBox.setColour (TextEditor::textColourId, Colours::black);
demoTextBox.setColour (TextEditor::backgroundColourId, Colours::white);
demoTextBox.setWhitespaceUnderlined (false);
resetButton.onClick = [this] { resetToDefaultParameters(); };
setupJustificationOptions();
@ -171,8 +175,10 @@ public:
auto row = r.removeFromBottom (30);
row.removeFromLeft (labelWidth);
boldToggle.setBounds (row.removeFromLeft (row.getWidth() / 2));
italicToggle.setBounds (row);
auto toggleWidth = row.getWidth() / 3;
boldToggle .setBounds (row.removeFromLeft (toggleWidth));
italicToggle .setBounds (row.removeFromLeft (toggleWidth));
underlineToggle.setBounds (row);
r.removeFromBottom (8);
horizontalJustificationBox.setBounds (r.removeFromBottom (30).withTrimmedLeft (labelWidth * 3));
@ -231,7 +237,7 @@ private:
TextEditor demoTextBox;
const double defaultScale = 1.0, defaultHeight = 20.0, defaultKerning = 0.0;
const bool defaultBold = false, defaultItalic = false;
const bool defaultBold = false, defaultItalic = false, defaultUnderlined = false;
const int defaultStyle = 0, defaultHorizontalJustification = 0, defaultVerticalJustification = 0;
Label heightLabel { {}, "Height:" },
@ -242,7 +248,8 @@ private:
verticalJustificationLabel { {}, "Justification (vertical):" };
ToggleButton boldToggle { "Bold" },
italicToggle { "Italic" };
italicToggle { "Italic" },
underlineToggle { "Underlined" };
TextButton resetButton { "Reset" };
@ -266,7 +273,8 @@ private:
kerningSlider.setValue (defaultKerning);
boldToggle .setToggleState (defaultBold, sendNotificationSync);
italicToggle.setToggleState (defaultItalic, sendNotificationSync);
italicToggle .setToggleState (defaultItalic, sendNotificationSync);
underlineToggle.setToggleState (defaultUnderlined, sendNotificationSync);
styleBox.setSelectedItemIndex (defaultStyle);
horizontalJustificationBox.setSelectedItemIndex (defaultHorizontalJustification);
@ -315,6 +323,8 @@ private:
if (useStyle)
font = font.withTypefaceStyle (styleBox.getText());
font.setUnderline (underlineToggle.getToggleState());
demoTextBox.applyFontToAllText (font);
}

View file

@ -303,7 +303,6 @@ public:
/** Returns true if the font is underlined. */
bool isUnderlined() const noexcept;
//==============================================================================
/** Returns the font's horizontal scale.
A value of 1.0 is the normal scale, less than this will be narrower, greater
@ -464,7 +463,6 @@ public:
*/
static Font fromString (const String& fontDescription);
private:
//==============================================================================
class SharedFontInternal;