Skip to content

Commit 3e049b6

Browse files
committed
More gui tweaks
1 parent eaa133a commit 3e049b6

File tree

3 files changed

+29
-81
lines changed

3 files changed

+29
-81
lines changed

examples/graphics/source/examples/Audio.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ class AudioExample
404404
addAndMakeVisible (*clearButton);
405405

406406
// Add volume control
407-
volumeSlider = std::make_unique<yup::Slider> (yup::Slider::LinearHorizontal, "Volume");
407+
volumeSlider = std::make_unique<yup::Slider> (yup::Slider::LinearBarHorizontal, "Volume");
408408

409409
// Configure slider range and default value
410410
volumeSlider->setRange ({ 0.0f, 1.0f });

examples/graphics/source/examples/SliderDemo.h

Lines changed: 27 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -127,99 +127,47 @@ class SliderDemo : public yup::Component
127127
void resized() override
128128
{
129129
auto bounds = getLocalBounds();
130-
auto margin = 20;
131-
auto sliderHeight = 60;
132-
auto labelHeight = 25;
133-
auto spacing = 10;
130+
auto margin = 20.0f;
131+
auto sliderHeight = 60.0f;
132+
auto labelHeight = 25.0f;
133+
auto spacing = 10.0f;
134134

135-
int y = margin;
135+
auto y = margin;
136136

137137
// Title
138-
titleLabel->setBounds(yup::Rectangle<float>(
139-
static_cast<float>(margin),
140-
static_cast<float>(y),
141-
static_cast<float>(bounds.getWidth() - 2 * margin),
142-
30.0f));
143-
y += 40;
138+
titleLabel->setBounds(margin, y, bounds.getWidth() - 2 * margin, 30.0f);
139+
y += 40.0f;
144140

145141
// Layout in a 2x3 grid
146-
auto sliderWidth = (bounds.getWidth() - 3 * margin) / 2;
142+
auto sliderWidth = (bounds.getWidth() - 3.0f * margin) / 2.0f;
147143
auto columnHeight = sliderHeight + labelHeight + spacing;
148144

149145
// Left column
150-
horizontalSlider->setBounds(yup::Rectangle<float>(
151-
static_cast<float>(margin),
152-
static_cast<float>(y),
153-
static_cast<float>(sliderWidth),
154-
static_cast<float>(sliderHeight)));
155-
horizontalLabel->setBounds(yup::Rectangle<float>(
156-
static_cast<float>(margin),
157-
static_cast<float>(y + sliderHeight + 5),
158-
static_cast<float>(sliderWidth),
159-
static_cast<float>(labelHeight)));
160-
161-
barHorizontalSlider->setBounds(yup::Rectangle<float>(
162-
static_cast<float>(margin),
163-
static_cast<float>(y + columnHeight),
164-
static_cast<float>(sliderWidth),
165-
static_cast<float>(sliderHeight)));
166-
barHorizontalLabel->setBounds(yup::Rectangle<float>(
167-
static_cast<float>(margin),
168-
static_cast<float>(y + columnHeight + sliderHeight + 5),
169-
static_cast<float>(sliderWidth),
170-
static_cast<float>(labelHeight)));
171-
172-
twoValueSlider->setBounds(yup::Rectangle<float>(
173-
static_cast<float>(margin),
174-
static_cast<float>(y + 2 * columnHeight),
175-
static_cast<float>(sliderWidth),
176-
static_cast<float>(sliderHeight)));
177-
twoValueLabel->setBounds(yup::Rectangle<float>(
178-
static_cast<float>(margin),
179-
static_cast<float>(y + 2 * columnHeight + sliderHeight + 5),
180-
static_cast<float>(sliderWidth),
181-
static_cast<float>(labelHeight)));
146+
horizontalSlider->setBounds(margin, y, sliderWidth, sliderHeight);
147+
horizontalLabel->setBounds(margin, y + sliderHeight + 5.0f, sliderWidth, labelHeight);
148+
149+
barHorizontalSlider->setBounds(margin, y + columnHeight, sliderWidth, sliderHeight);
150+
barHorizontalLabel->setBounds(margin, y + columnHeight + sliderHeight + 5.0f, sliderWidth, labelHeight);
151+
152+
twoValueSlider->setBounds(margin, y + 2.0f * columnHeight, sliderWidth, sliderHeight);
153+
twoValueLabel->setBounds(margin, y + 2.0f * columnHeight + sliderHeight + 5.0f, sliderWidth, labelHeight);
182154

183155
// Right column
184156
auto rightX = margin + sliderWidth + margin;
185157

186-
verticalSlider->setBounds(yup::Rectangle<float>(
187-
static_cast<float>(rightX),
188-
static_cast<float>(y),
189-
80.0f,
190-
static_cast<float>(columnHeight)));
191-
verticalLabel->setBounds(yup::Rectangle<float>(
192-
static_cast<float>(rightX + 90),
193-
static_cast<float>(y),
194-
static_cast<float>(sliderWidth - 90),
195-
static_cast<float>(labelHeight)));
196-
197-
rotarySlider->setBounds(yup::Rectangle<float>(
198-
static_cast<float>(rightX),
199-
static_cast<float>(y + columnHeight),
200-
80.0f,
201-
80.0f));
202-
rotaryLabel->setBounds(yup::Rectangle<float>(
203-
static_cast<float>(rightX + 90),
204-
static_cast<float>(y + columnHeight),
205-
static_cast<float>(sliderWidth - 90),
206-
static_cast<float>(labelHeight)));
207-
208-
barVerticalSlider->setBounds(yup::Rectangle<float>(
209-
static_cast<float>(rightX),
210-
static_cast<float>(y + 2 * columnHeight),
211-
60.0f,
212-
static_cast<float>(columnHeight)));
213-
barVerticalLabel->setBounds(yup::Rectangle<float>(
214-
static_cast<float>(rightX + 70),
215-
static_cast<float>(y + 2 * columnHeight),
216-
static_cast<float>(sliderWidth - 70),
217-
static_cast<float>(labelHeight)));
158+
verticalSlider->setBounds(rightX, y, 80.0f, columnHeight);
159+
verticalLabel->setBounds(rightX + 90.0f, y, sliderWidth - 90.0f, labelHeight);
160+
161+
rotarySlider->setBounds(rightX, y + columnHeight, 80.0f, 80.0f);
162+
rotaryLabel->setBounds(rightX + 90.0f, y + columnHeight, sliderWidth - 90.0f, labelHeight);
163+
164+
barVerticalSlider->setBounds(rightX, y + 2.0f * columnHeight, 60.0f, columnHeight);
165+
barVerticalLabel->setBounds(rightX + 70.0f, y + 2.0f * columnHeight, sliderWidth - 70.0f, labelHeight);
218166
}
219167

220168
void paint(yup::Graphics& g) override
221169
{
222-
g.setFillColor(yup::Colors::dimgray);
170+
g.setFillColor(yup::Color (0xff404040));
223171
g.fillAll();
224172

225173
// Draw section dividers
@@ -230,11 +178,11 @@ class SliderDemo : public yup::Component
230178
auto margin = 20;
231179

232180
// Horizontal line under title
233-
g.strokeLine(static_cast<float>(margin), 70.0f, static_cast<float>(bounds.getWidth() - margin), 70.0f);
181+
g.strokeLine(margin, 70.0f, bounds.getWidth() - margin, 70.0f);
234182

235183
// Vertical line separating columns
236184
auto centerX = bounds.getWidth() / 2;
237-
g.strokeLine(static_cast<float>(centerX), 80.0f, static_cast<float>(centerX), static_cast<float>(bounds.getHeight() - margin));
185+
g.strokeLine(centerX, 80.0f, centerX, bounds.getHeight() - margin);
238186
}
239187

240188
private:

modules/yup_gui/themes/theme_v1/yup_ThemeVersion1.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ void paintRotarySlider (Graphics& g, const ApplicationTheme& theme, const Slider
121121

122122
g.setStrokeCap (StrokeCap::Round);
123123
g.setStrokeColor (thumbColor);
124-
g.setStrokeWidth (slider.proportionOfWidth (0.035f));
124+
g.setStrokeWidth (slider.proportionOfWidth (0.075f));
125125
g.strokePath (foregroundArc);
126126

127127
if (slider.hasKeyboardFocus())

0 commit comments

Comments
 (0)