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:
parent
508d6de04e
commit
a4d43c16e3
2 changed files with 20 additions and 12 deletions
|
|
@ -70,6 +70,7 @@ public:
|
|||
addAndMakeVisible (scaleSlider);
|
||||
addAndMakeVisible (boldToggle);
|
||||
addAndMakeVisible (italicToggle);
|
||||
addAndMakeVisible (underlineToggle);
|
||||
addAndMakeVisible (styleBox);
|
||||
addAndMakeVisible (horizontalJustificationBox);
|
||||
addAndMakeVisible (verticalJustificationBox);
|
||||
|
|
@ -86,9 +87,10 @@ public:
|
|||
kerningSlider.addListener (this);
|
||||
scaleSlider .addListener (this);
|
||||
|
||||
boldToggle .onClick = [this] { refreshPreviewBoxFont(); };
|
||||
italicToggle.onClick = [this] { refreshPreviewBoxFont(); };
|
||||
styleBox .onChange = [this] { refreshPreviewBoxFont(); };
|
||||
boldToggle .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:" },
|
||||
|
|
@ -241,8 +247,9 @@ private:
|
|||
horizontalJustificationLabel { {}, "Justification (horizontal):" },
|
||||
verticalJustificationLabel { {}, "Justification (vertical):" };
|
||||
|
||||
ToggleButton boldToggle { "Bold" },
|
||||
italicToggle { "Italic" };
|
||||
ToggleButton boldToggle { "Bold" },
|
||||
italicToggle { "Italic" },
|
||||
underlineToggle { "Underlined" };
|
||||
|
||||
TextButton resetButton { "Reset" };
|
||||
|
||||
|
|
@ -265,8 +272,9 @@ private:
|
|||
heightSlider .setValue (defaultHeight);
|
||||
kerningSlider.setValue (defaultKerning);
|
||||
|
||||
boldToggle .setToggleState (defaultBold, sendNotificationSync);
|
||||
italicToggle.setToggleState (defaultItalic, sendNotificationSync);
|
||||
boldToggle .setToggleState (defaultBold, 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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue