Skip to content

Commit 2f0bb63

Browse files
authored
Improved color management (#87)
1 parent ac2c130 commit 2f0bb63

File tree

20 files changed

+3377
-182
lines changed

20 files changed

+3377
-182
lines changed

.clang-format

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ SpacesInCStyleCastParentheses: false
6767
SpacesInContainerLiterals: true
6868
SpacesInParentheses: false
6969
SpacesInSquareBrackets: false
70-
Standard: "c++17"
70+
Standard: "c++20"
7171
TabWidth: 4
7272
UseTab: Never
7373
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']

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
1818
<a href="./examples/graphics/source/examples/Svg.h"><img src="./docs/images/yup_svg_yellow_car.png" style="width:32.3%;" /></a>
1919
</div>
2020

21+
<div style="display: flex; width: 100%; flex-wrap: nowrap;">
22+
<a href="./examples/graphics/source/examples/ColorLab.h"><img src="./docs/images/yup_gradient_editor.png" style="width:46.8%;" /></a>
23+
<a href="./examples/graphics/source/examples/ColorLab.h"><img src="./docs/images/yup_color_picker.png" style="width:51.8%;" /></a>
24+
</div>
25+
2126
<div style="display: flex; width: 100%; flex-wrap: nowrap;">
2227
<a href="./examples/graphics/source/examples/FilterDemo.h"><img src="./docs/images/yup_dsp_filter_rbj.png" style="width:26.5%;" /></a>
2328
<a href="./examples/graphics/source/examples/FilterDemo.h"><img src="./docs/images/yup_dsp_filter_butter.png" style="width:26.5%;" /></a>

docs/images/yup_audio_scope.png

-15.6 KB
Loading

docs/images/yup_color_picker.png

196 KB
Loading
174 KB
Loading

examples/graphics/source/examples/Artboard.h

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class ArtboardDemo : public yup::Component
2929
ArtboardDemo()
3030
{
3131
setWantsKeyboardFocus (true);
32+
setupControls();
3233
}
3334

3435
bool loadArtboard()
@@ -64,6 +65,8 @@ class ArtboardDemo : public yup::Component
6465
addAndMakeVisible (art);
6566

6667
art->setFile (artboardFile.getValue());
68+
art->setLayout (getSelectedLayout());
69+
art->setAlignment (getSelectedAlignment());
6770

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

8790
auto bounds = getLocalBounds().reduced (10, 20);
91+
auto controls = bounds.removeFromTop (30);
92+
93+
auto labelHeight = 20;
94+
auto comboHeight = 24;
95+
auto labelWidth = 70;
96+
auto comboWidth = 170;
97+
auto spacing = 12;
98+
99+
fitLabel.setBounds (controls.removeFromLeft (labelWidth).withHeight (labelHeight));
100+
fitCombo.setBounds (controls.removeFromLeft (comboWidth).withHeight (comboHeight));
101+
controls.removeFromLeft (spacing);
102+
alignmentLabel.setBounds (controls.removeFromLeft (labelWidth).withHeight (labelHeight));
103+
alignmentCombo.setBounds (controls.removeFromLeft (comboWidth).withHeight (comboHeight));
104+
105+
bounds.removeFromTop (10);
88106
auto width = bounds.getWidth() / totalColumns;
89107
auto height = bounds.getHeight() / totalRows;
90108

@@ -106,7 +124,119 @@ class ArtboardDemo : public yup::Component
106124
}
107125

108126
private:
127+
void setupControls()
128+
{
129+
auto labelFont = yup::ApplicationTheme::getGlobalTheme()->getDefaultFont().withHeight (12.0f);
130+
131+
fitLabel.setText ("Fit", yup::dontSendNotification);
132+
fitLabel.setFont (labelFont);
133+
addAndMakeVisible (fitLabel);
134+
135+
fitCombo.addItem ("Fill", 1);
136+
fitCombo.addItem ("Contain", 2);
137+
fitCombo.addItem ("Cover", 3);
138+
fitCombo.addItem ("Fit Width", 4);
139+
fitCombo.addItem ("Fit Height", 5);
140+
fitCombo.addItem ("None", 6);
141+
fitCombo.addItem ("Scale Down", 7);
142+
fitCombo.addItem ("Layout", 8);
143+
fitCombo.setSelectedId (2);
144+
fitCombo.onSelectedItemChanged = [this]
145+
{
146+
updateArtboardsLayout();
147+
};
148+
addAndMakeVisible (fitCombo);
149+
150+
alignmentLabel.setText ("Align", yup::dontSendNotification);
151+
alignmentLabel.setFont (labelFont);
152+
addAndMakeVisible (alignmentLabel);
153+
154+
alignmentCombo.addItem ("Top Left", 1);
155+
alignmentCombo.addItem ("Top Center", 2);
156+
alignmentCombo.addItem ("Top Right", 3);
157+
alignmentCombo.addItem ("Center Left", 4);
158+
alignmentCombo.addItem ("Center", 5);
159+
alignmentCombo.addItem ("Center Right", 6);
160+
alignmentCombo.addItem ("Bottom Left", 7);
161+
alignmentCombo.addItem ("Bottom Center", 8);
162+
alignmentCombo.addItem ("Bottom Right", 9);
163+
alignmentCombo.setSelectedId (5);
164+
alignmentCombo.onSelectedItemChanged = [this]
165+
{
166+
updateArtboardsLayout();
167+
};
168+
addAndMakeVisible (alignmentCombo);
169+
}
170+
171+
yup::Artboard::Layout getSelectedLayout() const
172+
{
173+
switch (fitCombo.getSelectedId())
174+
{
175+
case 1:
176+
return yup::Artboard::Layout::fill;
177+
case 2:
178+
return yup::Artboard::Layout::contain;
179+
case 3:
180+
return yup::Artboard::Layout::cover;
181+
case 4:
182+
return yup::Artboard::Layout::fitWidth;
183+
case 5:
184+
return yup::Artboard::Layout::fitHeight;
185+
case 6:
186+
return yup::Artboard::Layout::none;
187+
case 7:
188+
return yup::Artboard::Layout::scaleDown;
189+
case 8:
190+
return yup::Artboard::Layout::layout;
191+
}
192+
193+
return yup::Artboard::Layout::contain;
194+
}
195+
196+
yup::Artboard::Alignment getSelectedAlignment() const
197+
{
198+
switch (alignmentCombo.getSelectedId())
199+
{
200+
case 1:
201+
return yup::Artboard::Alignment::topLeft;
202+
case 2:
203+
return yup::Artboard::Alignment::topCenter;
204+
case 3:
205+
return yup::Artboard::Alignment::topRight;
206+
case 4:
207+
return yup::Artboard::Alignment::centerLeft;
208+
case 5:
209+
return yup::Artboard::Alignment::center;
210+
case 6:
211+
return yup::Artboard::Alignment::centerRight;
212+
case 7:
213+
return yup::Artboard::Alignment::bottomLeft;
214+
case 8:
215+
return yup::Artboard::Alignment::bottomCenter;
216+
case 9:
217+
return yup::Artboard::Alignment::bottomRight;
218+
}
219+
220+
return yup::Artboard::Alignment::center;
221+
}
222+
223+
void updateArtboardsLayout()
224+
{
225+
auto newLayout = getSelectedLayout();
226+
auto newAlignment = getSelectedAlignment();
227+
228+
for (auto* artboard : artboards)
229+
{
230+
artboard->setLayout (newLayout);
231+
artboard->setAlignment (newAlignment);
232+
}
233+
}
234+
109235
yup::OwnedArray<yup::Artboard> artboards;
236+
yup::Label fitLabel;
237+
yup::ComboBox fitCombo;
238+
yup::Label alignmentLabel;
239+
yup::ComboBox alignmentCombo;
110240
int totalRows = 1;
111241
int totalColumns = 1;
112242
};

0 commit comments

Comments
 (0)