Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ SpacesInCStyleCastParentheses: false
SpacesInContainerLiterals: true
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: "c++17"
Standard: "c++20"
TabWidth: 4
UseTab: Never
WhitespaceSensitiveMacros: ['YUP_NTH_ARG_', 'EM_ASM', 'EM_JS', 'EM_ASM_INT', 'EM_ASM_DOUBLE', 'EM_ASM_PTR', 'MAIN_THREAD_EM_ASM', 'MAIN_THREAD_EM_ASM_INT', 'MAIN_THREAD_EM_ASM_DOUBLE', 'MAIN_THREAD_EM_ASM_DOUBLE', 'MAIN_THREAD_ASYNC_EM_ASM']
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
<a href="./examples/graphics/source/examples/Svg.h"><img src="./docs/images/yup_svg_yellow_car.png" style="width:32.3%;" /></a>
</div>

<div style="display: flex; width: 100%; flex-wrap: nowrap;">
<a href="./examples/graphics/source/examples/ColorLab.h"><img src="./docs/images/yup_gradient_editor.png" style="width:46.8%;" /></a>
<a href="./examples/graphics/source/examples/ColorLab.h"><img src="./docs/images/yup_color_picker.png" style="width:51.8%;" /></a>
</div>

<div style="display: flex; width: 100%; flex-wrap: nowrap;">
<a href="./examples/graphics/source/examples/FilterDemo.h"><img src="./docs/images/yup_dsp_filter_rbj.png" style="width:26.5%;" /></a>
<a href="./examples/graphics/source/examples/FilterDemo.h"><img src="./docs/images/yup_dsp_filter_butter.png" style="width:26.5%;" /></a>
Expand Down
Binary file modified docs/images/yup_audio_scope.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/yup_color_picker.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/yup_gradient_editor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
130 changes: 130 additions & 0 deletions examples/graphics/source/examples/Artboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class ArtboardDemo : public yup::Component
ArtboardDemo()
{
setWantsKeyboardFocus (true);
setupControls();
}

bool loadArtboard()
Expand Down Expand Up @@ -64,6 +65,8 @@ class ArtboardDemo : public yup::Component
addAndMakeVisible (art);

art->setFile (artboardFile.getValue());
art->setLayout (getSelectedLayout());
art->setAlignment (getSelectedAlignment());

art->advanceAndApply (i * art->durationSeconds());
}
Expand All @@ -85,6 +88,21 @@ class ArtboardDemo : public yup::Component
return;

auto bounds = getLocalBounds().reduced (10, 20);
auto controls = bounds.removeFromTop (30);

auto labelHeight = 20;
auto comboHeight = 24;
auto labelWidth = 70;
auto comboWidth = 170;
auto spacing = 12;

fitLabel.setBounds (controls.removeFromLeft (labelWidth).withHeight (labelHeight));
fitCombo.setBounds (controls.removeFromLeft (comboWidth).withHeight (comboHeight));
controls.removeFromLeft (spacing);
alignmentLabel.setBounds (controls.removeFromLeft (labelWidth).withHeight (labelHeight));
alignmentCombo.setBounds (controls.removeFromLeft (comboWidth).withHeight (comboHeight));

bounds.removeFromTop (10);
auto width = bounds.getWidth() / totalColumns;
auto height = bounds.getHeight() / totalRows;

Expand All @@ -106,7 +124,119 @@ class ArtboardDemo : public yup::Component
}

private:
void setupControls()
{
auto labelFont = yup::ApplicationTheme::getGlobalTheme()->getDefaultFont().withHeight (12.0f);

fitLabel.setText ("Fit", yup::dontSendNotification);
fitLabel.setFont (labelFont);
addAndMakeVisible (fitLabel);

fitCombo.addItem ("Fill", 1);
fitCombo.addItem ("Contain", 2);
fitCombo.addItem ("Cover", 3);
fitCombo.addItem ("Fit Width", 4);
fitCombo.addItem ("Fit Height", 5);
fitCombo.addItem ("None", 6);
fitCombo.addItem ("Scale Down", 7);
fitCombo.addItem ("Layout", 8);
fitCombo.setSelectedId (2);
fitCombo.onSelectedItemChanged = [this]
{
updateArtboardsLayout();
};
addAndMakeVisible (fitCombo);

alignmentLabel.setText ("Align", yup::dontSendNotification);
alignmentLabel.setFont (labelFont);
addAndMakeVisible (alignmentLabel);

alignmentCombo.addItem ("Top Left", 1);
alignmentCombo.addItem ("Top Center", 2);
alignmentCombo.addItem ("Top Right", 3);
alignmentCombo.addItem ("Center Left", 4);
alignmentCombo.addItem ("Center", 5);
alignmentCombo.addItem ("Center Right", 6);
alignmentCombo.addItem ("Bottom Left", 7);
alignmentCombo.addItem ("Bottom Center", 8);
alignmentCombo.addItem ("Bottom Right", 9);
alignmentCombo.setSelectedId (5);
alignmentCombo.onSelectedItemChanged = [this]
{
updateArtboardsLayout();
};
addAndMakeVisible (alignmentCombo);
}

yup::Artboard::Layout getSelectedLayout() const
{
switch (fitCombo.getSelectedId())
{
case 1:
return yup::Artboard::Layout::fill;
case 2:
return yup::Artboard::Layout::contain;
case 3:
return yup::Artboard::Layout::cover;
case 4:
return yup::Artboard::Layout::fitWidth;
case 5:
return yup::Artboard::Layout::fitHeight;
case 6:
return yup::Artboard::Layout::none;
case 7:
return yup::Artboard::Layout::scaleDown;
case 8:
return yup::Artboard::Layout::layout;
}

return yup::Artboard::Layout::contain;
}

yup::Artboard::Alignment getSelectedAlignment() const
{
switch (alignmentCombo.getSelectedId())
{
case 1:
return yup::Artboard::Alignment::topLeft;
case 2:
return yup::Artboard::Alignment::topCenter;
case 3:
return yup::Artboard::Alignment::topRight;
case 4:
return yup::Artboard::Alignment::centerLeft;
case 5:
return yup::Artboard::Alignment::center;
case 6:
return yup::Artboard::Alignment::centerRight;
case 7:
return yup::Artboard::Alignment::bottomLeft;
case 8:
return yup::Artboard::Alignment::bottomCenter;
case 9:
return yup::Artboard::Alignment::bottomRight;
}

return yup::Artboard::Alignment::center;
}

void updateArtboardsLayout()
{
auto newLayout = getSelectedLayout();
auto newAlignment = getSelectedAlignment();

for (auto* artboard : artboards)
{
artboard->setLayout (newLayout);
artboard->setAlignment (newAlignment);
}
}

yup::OwnedArray<yup::Artboard> artboards;
yup::Label fitLabel;
yup::ComboBox fitCombo;
yup::Label alignmentLabel;
yup::ComboBox alignmentCombo;
int totalRows = 1;
int totalColumns = 1;
};
Loading
Loading