Skip to content

Commit ca4972f

Browse files
committed
re-order elements to keep gui usable
1 parent 1b8a479 commit ca4972f

File tree

1 file changed

+54
-51
lines changed

1 file changed

+54
-51
lines changed

src/editor.rs

Lines changed: 54 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -295,60 +295,63 @@ fn duration_position(cx: &mut Context) {
295295
VStack::new(cx, |cx| {
296296

297297
// Duration
298-
ZStack::new(cx, |cx| {
299-
// Label that changes according to Parameter
300-
VStack::new(cx, |cx| {
301-
ParamLabel::new(
302-
cx,
303-
Data::params,
304-
|params| &params.use_bpm,
305-
|param| {
306-
if param < 0.5 {
307-
String::from("Duration in Seconds")
308-
} else {
309-
String::from("Duration in Quarter Notes")
310-
}
311-
},
312-
)
313-
.alignment(Alignment::BottomCenter)
314-
.font_weight(FontWeightKeyword::Bold);
315-
316-
ParamSlider::new(cx, Data::params, |params|
317-
&params.metric_dur_selector)
318-
.width(Pixels(200.0));
319-
320-
HStack::new(cx, |cx| {
321-
// BPM Toggle
322-
ParamButton::new(cx, Data::params, |params|
323-
&params.use_bpm)
324-
.with_label(" Use BPM")
325-
.width(Pixels(100.0));
326-
// Reset Phase
327-
Button::new(
328-
cx,
329-
|cx| Label::new(cx, "reset phase"))
330-
.on_press(|cx| {
331-
cx.emit(MetreFiddlerEvent::TriggerPhaseReset);
298+
ParamBinding::new(
299+
cx,
300+
Data::params,
301+
|params| &params.use_position,
302+
|cx, use_pos| {
303+
304+
ZStack::new(cx, |cx| {
305+
// Label that changes according to Parameter
306+
VStack::new(cx, |cx| {
307+
ParamLabel::new(
308+
cx,
309+
Data::params,
310+
|params| &params.use_bpm,
311+
|param| {
312+
if param < 0.5 {
313+
String::from("Duration in Seconds")
314+
} else {
315+
String::from("Duration in Quarter Notes")
316+
}
317+
},
318+
)
319+
.alignment(Alignment::BottomCenter)
320+
.font_weight(FontWeightKeyword::Bold);
321+
322+
ParamSlider::new(cx, Data::params, |params|
323+
&params.metric_dur_selector)
324+
.width(Pixels(200.0));
325+
326+
HStack::new(cx, |cx| {
327+
// BPM Toggle
328+
ParamButton::new(cx, Data::params, |params|
329+
&params.use_bpm)
330+
.with_label(" Use BPM")
331+
.width(Pixels(100.0));
332+
// Reset Phase
333+
Button::new(
334+
cx,
335+
|cx| Label::new(cx, "reset phase"))
336+
.on_press(|cx| {
337+
cx.emit(MetreFiddlerEvent::TriggerPhaseReset);
338+
})
339+
.width(Pixels(100.0));
332340
})
333-
.width(Pixels(100.0));
341+
.alignment(Alignment::Center)
342+
.top(Pixels(10.0));
343+
})
344+
.alignment(Alignment::TopCenter);
345+
346+
// Hide Duration Gui when using the position slider
347+
if use_pos > 0.5 {
348+
Element::new(cx)
349+
.background_color(RGBA::rgba(250, 250, 250, 255))
350+
.opacity(1.0);
351+
}
334352
})
335-
.alignment(Alignment::Center)
336-
.top(Pixels(10.0));
353+
.alignment(Alignment::Center);
337354
})
338-
.alignment(Alignment::TopCenter);
339-
340-
ParamBinding::new(
341-
cx,
342-
Data::params,
343-
|params| &params.use_position,
344-
|cx, use_pos| {
345-
if use_pos > 0.5 {
346-
Element::new(cx)
347-
.background_color(RGBA::rgba(250, 250, 250, 255))
348-
.opacity(1.0);
349-
}
350-
});
351-
})
352355
.height(Stretch(0.4))
353356
.alignment(Alignment::Center);
354357

0 commit comments

Comments
 (0)