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

Examples/DemoRunner: Accessibility updates

This commit is contained in:
ed 2021-05-10 09:39:36 +01:00
parent 69085b2a61
commit f28acdb48c
10 changed files with 232 additions and 125 deletions

View file

@ -94,6 +94,7 @@ public:
Font::findFonts (fonts); // Generate the list of fonts
listBox.setTitle ("Fonts");
listBox.setRowHeight (20);
listBox.setModel (this); // Tell the listbox where to get its data model
listBox.setColour (ListBox::textColourId, Colours::black);
@ -218,12 +219,17 @@ public:
AttributedString s;
s.setWordWrap (AttributedString::none);
s.setJustification (Justification::centredLeft);
s.append (font.getTypefaceName(), font.withHeight ((float) height * 0.7f), Colours::black);
s.append (getNameForRow (rowNumber), font.withHeight ((float) height * 0.7f), Colours::black);
s.append (" " + font.getTypefaceName(), Font ((float) height * 0.5f, Font::italic), Colours::grey);
s.draw (g, Rectangle<int> (width, height).expanded (-4, 50).toFloat());
}
String getNameForRow (int rowNumber) override
{
return fonts[rowNumber].getTypefaceName();
}
void selectedRowsChanged (int /*lastRowselected*/) override
{
refreshPreviewBoxFont();

View file

@ -644,35 +644,44 @@ public:
demos.add (new LinesDemo (controls));
addAndMakeVisible (listBox);
listBox.setTitle ("Test List");
listBox.setModel (this);
listBox.selectRow (0);
}
void resized()
void resized() override
{
listBox.setBounds (getLocalBounds());
}
int getNumRows()
int getNumRows() override
{
return demos.size();
}
void paintListBoxItem (int rowNumber, Graphics& g, int width, int height, bool rowIsSelected)
void paintListBoxItem (int rowNumber, Graphics& g, int width, int height, bool rowIsSelected) override
{
if (auto* demo = demos[rowNumber])
{
if (rowIsSelected)
g.fillAll (Colour::contrasting (findColour (ListBox::textColourId),
findColour (ListBox::backgroundColourId)));
if (demos[rowNumber] == nullptr)
return;
g.setColour (findColour (ListBox::textColourId));
g.setFont (14.0f);
g.drawFittedText (demo->getName(), 8, 0, width - 10, height, Justification::centredLeft, 2);
}
if (rowIsSelected)
g.fillAll (Colour::contrasting (findColour (ListBox::textColourId),
findColour (ListBox::backgroundColourId)));
g.setColour (findColour (ListBox::textColourId));
g.setFont (14.0f);
g.drawFittedText (getNameForRow (rowNumber), 8, 0, width - 10, height, Justification::centredLeft, 2);
}
void selectedRowsChanged (int lastRowSelected)
String getNameForRow (int rowNumber) override
{
if (auto* demo = demos[rowNumber])
return demo->getName();
return {};
}
void selectedRowsChanged (int lastRowSelected) override
{
demoHolder.setDemo (demos [lastRowSelected]);
}

View file

@ -59,6 +59,7 @@ public:
imageList.setDirectory (File::getSpecialLocation (File::userPicturesDirectory), true, true);
directoryThread.startThread (1);
fileTree.setTitle ("Files");
fileTree.addListener (this);
fileTree.setColour (TreeView::backgroundColourId, Colours::grey);
addAndMakeVisible (fileTree);

View file

@ -156,6 +156,7 @@ public:
movieList.setDirectory (File::getSpecialLocation (File::userMoviesDirectory), true, true);
directoryThread.startThread (1);
fileTree.setTitle ("Files");
fileTree.addListener (this);
fileTree.setColour (FileTreeComponent::backgroundColourId, Colours::lightgrey.withAlpha (0.6f));
addAndMakeVisible (fileTree);