Skip to content

Commit a4cbd38

Browse files
committed
Merge branch 'develop' into feature/jack4all
2 parents 706a48f + d0a04c0 commit a4cbd38

31 files changed

+4265
-133
lines changed

Libraries/pd-else

Resources/Fonts/IconFont.ttf

2.29 KB
Binary file not shown.

Source/Canvas.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,13 @@ Canvas::Canvas(PluginEditor* parent, pd::Patch::Ptr p, Component* parentGraph)
316316
commandLocked.referTo(pd->commandLocked);
317317
commandLocked.addListener(this);
318318

319+
// pd->commandLocked doesn't get updated when a canvas isn't active
320+
// So we set it to false here when a canvas is remade
321+
// Otherwise the last canvas could have set it true, and it would still be
322+
// in that state without command actually being locked
323+
if (!isGraph)
324+
commandLocked.setValue(false);
325+
319326
// init border for testing
320327
settingsChanged("border", SettingsFile::getInstance()->getPropertyAsValue("border"));
321328

@@ -1320,7 +1327,9 @@ void Canvas::middleMouseChanged(bool isHeld)
13201327

13211328
void Canvas::altKeyChanged(bool isHeld)
13221329
{
1323-
SettingsFile::getInstance()->getValueTree().getChildWithName("Overlays").setProperty("alt_mode", isHeld, nullptr);
1330+
if(!isGraph) {
1331+
SettingsFile::getInstance()->getValueTree().getChildWithName("Overlays").setProperty("alt_mode", isHeld, nullptr);
1332+
}
13241333
}
13251334

13261335
void Canvas::mouseDown(MouseEvent const& e)

Source/Components/DraggableNumber.h

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ class DraggableNumber : public Label
5454
addListener(this);
5555
setFont(Fonts::getTabularNumbersFont().withHeight(14.0f));
5656
lookAndFeelChanged();
57+
setInterceptsMouseClicks(true, true);
5758
}
5859

5960
void colourChanged() override
@@ -104,10 +105,10 @@ class DraggableNumber : public Label
104105
onInteraction(false);
105106
}
106107

107-
void setEditableOnClick(bool editable)
108+
void setEditableOnClick(bool editable, bool handleFocusLossManually = false)
108109
{
109-
setEditable(editable, editable);
110-
setInterceptsMouseClicks(true, true);
110+
setEditable(editable, editable, handleFocusLossManually);
111+
setWantsKeyboardFocus(true);
111112
}
112113

113114
void setMaximum(double maximum)
@@ -589,14 +590,14 @@ class DraggableNumber : public Label
589590

590591
void textEditorFocusLost (TextEditor& editor) override
591592
{
592-
textEditorReturnKeyPressed(editor);
593+
//hideEditor(false);
593594
}
594595

595596
void textEditorReturnKeyPressed(TextEditor& editor) override
596597
{
597598
auto text = editor.getText();
598599
double newValue = parseExpression(text);
599-
setValue(newValue);
600+
setValue(newValue, dontSendNotification);
600601
onReturnKey(newValue);
601602
}
602603
};
@@ -610,7 +611,7 @@ struct DraggableListNumber : public DraggableNumber {
610611
explicit DraggableListNumber()
611612
: DraggableNumber(true)
612613
{
613-
setEditableOnClick(true);
614+
setEditableOnClick(true, true);
614615
}
615616

616617
void mouseDown(MouseEvent const& e) override
@@ -693,7 +694,6 @@ struct DraggableListNumber : public DraggableNumber {
693694
void paint(Graphics& g) override
694695
{
695696
if (hoveredDecimal >= 0) {
696-
// TODO: make this colour Id configurable?
697697
g.setColour(outlineColour.withAlpha(isMouseButtonDown() ? 0.5f : 0.3f));
698698
g.fillRoundedRectangle(hoveredDecimalPosition, 2.5f);
699699
}
@@ -724,7 +724,6 @@ struct DraggableListNumber : public DraggableNumber {
724724
}
725725

726726
if (hoveredDecimal >= 0) {
727-
// TODO: make this colour Id configurable
728727
auto const highlightColour = outlineColour.withAlpha(isMouseButtonDown() ? 0.5f : 0.3f);
729728
nvgFillColor(nvg, NVGComponent::convertColour(highlightColour));
730729
nvgFillRoundedRect(nvg, hoveredDecimalPosition.getX(), hoveredDecimalPosition.getY() - 1, hoveredDecimalPosition.getWidth(), hoveredDecimalPosition.getHeight(), 2.5f);
@@ -759,6 +758,12 @@ struct DraggableListNumber : public DraggableNumber {
759758
repaint();
760759
}
761760
}
761+
762+
void textEditorReturnKeyPressed(TextEditor& editor) override
763+
{
764+
onReturnKey(0);
765+
hideEditor(false);
766+
}
762767

763768
std::tuple<int, int, double> getListItemAtPosition(int x, Rectangle<float>* position = nullptr)
764769
{

Source/Components/PropertiesPanel.h

Lines changed: 41 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -322,22 +322,56 @@ class PropertiesPanel : public Component {
322322
struct FontComponent : public PropertiesPanelProperty {
323323
Value fontValue;
324324
StringArray options = Font::findAllTypefaceNames();
325+
bool isFontMissing = false;
325326

326-
FontComponent(String const& propertyName, Value& value)
327+
FontComponent(String const& propertyName, Value& value, File const& extraFontsDir = File())
327328
: PropertiesPanelProperty(propertyName)
328329
{
329-
options.addIfNotAlreadyThere("Inter");
330+
StringArray extraFontOptions;
331+
332+
if(extraFontsDir.isDirectory() && !extraFontsDir.isRoot()) {
333+
auto patchFonts = Fonts::getFontsInFolder(extraFontsDir);
334+
for (int n = 0; n < patchFonts.size(); n++) {
335+
extraFontOptions.addIfNotAlreadyThere(patchFonts[n].getFileNameWithoutExtension());
336+
}
337+
}
338+
#if JUCE_WINDOWS
339+
extraFontOptions.addIfNotAlreadyThere("Inter Regular");
340+
#else
341+
extraFontOptions.addIfNotAlreadyThere("Inter");
342+
#endif
343+
344+
auto offset = extraFontOptions.size();
345+
extraFontOptions.addArray(options);
346+
347+
for (int n = 0; n < extraFontOptions.size(); n++) {
348+
if (n == offset)
349+
comboBox.getRootMenu()->addSeparator();
350+
351+
comboBox.getRootMenu()->addCustomItem(n + 1, std::make_unique<FontEntry>(extraFontOptions[n]), nullptr, extraFontOptions[n]);
330352

331-
for (int n = 0; n < options.size(); n++) {
332-
comboBox.getRootMenu()->addCustomItem(n + 1, std::make_unique<FontEntry>(options[n]), nullptr, options[n]);
333353
}
334354

335355
comboBox.setText(value.toString());
336356
comboBox.getProperties().set("Style", "Inspector");
337357
fontValue.referTo(value);
338358

339-
comboBox.onChange = [this]() {
340-
fontValue.setValue(options[comboBox.getSelectedItemIndex()]);
359+
comboBox.onChange = [this, extraFontOptions, propertyName]() {
360+
auto fontName = extraFontOptions[comboBox.getSelectedItemIndex()];
361+
362+
if (fontName.isEmpty()) {
363+
isFontMissing = true;
364+
fontName = fontValue.toString();
365+
PropertiesPanelProperty::setName(propertyName + " (missing)");
366+
}
367+
else {
368+
isFontMissing = false;
369+
PropertiesPanelProperty::setName(propertyName);
370+
}
371+
372+
lookAndFeelChanged();
373+
getParentComponent()->repaint();
374+
fontValue.setValue(fontName);
341375
};
342376

343377
setLookAndFeel(&LookAndFeel::getDefaultLookAndFeel());
@@ -354,12 +388,11 @@ class PropertiesPanel : public Component {
354388

355389
void lookAndFeelChanged() override
356390
{
357-
comboBox.setColour(ComboBox::textColourId, findColour(PlugDataColour::panelTextColourId));
391+
comboBox.setColour(ComboBox::textColourId, isFontMissing ? Colours::red : findColour(PlugDataColour::panelTextColourId));
358392
}
359393

360394
void setFont(String const& fontName)
361395
{
362-
fontValue.setValue(fontValue);
363396
comboBox.setText(fontName);
364397
}
365398

0 commit comments

Comments
 (0)