fn render_button<'a>(ui: &Ui<'a>, button: &mut config::Button) {
    ui.text(im_str!("Button"));
    // Channel
    let mut channel = button.channel().value().into();
    ui.slider_int(im_str!("MIDI Channel"), &mut channel, config::MidiChannel::MIN as i32,
        config::MidiChannel::MAX as i32).build();
    button.channel_mut().update(channel.into());
    // Button mode
    let mut mode = button.mode().value().into();
    ui.text(im_str!("Button Mode"));
    ui.radio_button(im_str!("Control Code"), &mut mode, config::ButtonMode::Control.into());
    ui.same_line(0f32);
    ui.radio_button(im_str!("Note"), &mut mode, config::ButtonMode::Note.into());
    button.mode_mut().update(mode.into());
    match button.mode().value() {
        config::ButtonMode::Control => {
            // Control Code
            let mut control = button.control().value().into();
            ui.slider_int(im_str!("CC Number"), &mut control, config::MidiValue::MIN as i32,
                config::MidiValue::MAX as i32).build();
            button.control_mut().update(control.into());
            // On CC value
            let mut on = button.on().value().into();
            ui.slider_int(im_str!("Active CC Value"), &mut on, config::MidiValue::MIN as i32,
                config::MidiValue::MAX as i32).build();
            button.on_mut().update(on.into());
            // Off CC value
            let mut off = button.off().value().into();
            ui.slider_int(im_str!("Inactive CC Value"), &mut off, config::MidiValue::MIN as i32,
                config::MidiValue::MAX as i32).build();
            button.off_mut().update(off.into());
        },
        config::ButtonMode::Note => {
            // Note
            let mut note = button.note().value().into();
            ui.slider_int(im_str!("MIDI Note"), &mut note, config::MidiValue::MIN as i32,
                config::MidiValue::MAX as i32).build();
            button.note_mut().update(note.into());
            // Note velocity
            let mut note_vel = button.note_vel().value().into();
            ui.slider_int(im_str!("Note Velocity"), &mut note_vel, config::MidiValue::MIN as i32,
                config::MidiValue::MAX as i32).build();
            button.note_vel_mut().update(note_vel.into());
        },
        config::ButtonMode::Invalid { n } => {
            ui.text(im_str!("-- Invalid Button Mode Selected -- "));
        },
    }
    // Button style
    let mut style = button.style().value().into();
    ui.text(im_str!("Button Style"));
    ui.radio_button(im_str!("Momentary"), &mut style, config::ButtonStyle::Momentary.into());
    ui.same_line(0f32);
    ui.radio_button(im_str!("Toggle"), &mut style, config::ButtonStyle::Toggle.into());
    button.style_mut().update(style.into());
}
/// Renders a button onto a UI and handles user changes
Renders a button onto a UI and handles user changes
Renders a button onto a UI and handles user changes
fn render_button<'a>(ui: &Ui<'a>, button: &mut config::Button) {
    ui.text(im_str!("Button"));
    // Channel
    let mut channel = button.channel().value().into();
    ui.slider_int(im_str!("MIDI Channel"), &mut channel, config::MidiChannel::MIN as i32,
        config::MidiChannel::MAX as i32).build();
    button.channel_mut().update(channel.into());
    // Button mode
    let mut mode = button.mode().value().into();
    ui.text(im_str!("Button Mode"));
    ui.radio_button(im_str!("Control Code"), &mut mode, config::ButtonMode::Control.into());
    ui.same_line(0f32);
    ui.radio_button(im_str!("Note"), &mut mode, config::ButtonMode::Note.into());
    button.mode_mut().update(mode.into());
    match button.mode().value() {
        config::ButtonMode::Control => {
            // Control Code
            let mut control = button.control().value().into();
            ui.slider_int(im_str!("CC Number"), &mut control, config::MidiValue::MIN as i32,
                config::MidiValue::MAX as i32).build();
            button.control_mut().update(control.into());
            // On CC value
            let mut on = button.on().value().into();
            ui.slider_int(im_str!("Active CC Value"), &mut on, config::MidiValue::MIN as i32,
                config::MidiValue::MAX as i32).build();
            button.on_mut().update(on.into());
            // Off CC value
            let mut off = button.off().value().into();
            ui.slider_int(im_str!("Inactive CC Value"), &mut off, config::MidiValue::MIN as i32,
                config::MidiValue::MAX as i32).build();
            button.off_mut().update(off.into());
        },
        config::ButtonMode::Note => {
            // Note
            let mut note = button.note().value().into();
            ui.slider_int(im_str!("MIDI Note"), &mut note, config::MidiValue::MIN as i32,
                config::MidiValue::MAX as i32).build();
            button.note_mut().update(note.into());
            // Note velocity
            let mut note_vel = button.note_vel().value().into();
            ui.slider_int(im_str!("Note Velocity"), &mut note_vel, config::MidiValue::MIN as i32,
                config::MidiValue::MAX as i32).build();
            button.note_vel_mut().update(note_vel.into());
        },
        config::ButtonMode::Invalid { n } => {
            ui.text(im_str!("-- Invalid Button Mode Selected -- "));
        },
    }
    // Button style
    let mut style = button.style().value().into();
    ui.text(im_str!("Button Style"));
    ui.radio_button(im_str!("Momentary"), &mut style, config::ButtonStyle::Momentary.into());
    ui.same_line(0f32);
    ui.radio_button(im_str!("Toggle"), &mut style, config::ButtonStyle::Toggle.into());
    button.style_mut().update(style.into());
}
fn render_button < ' a > ( ui : & Ui < ' a > , button : & mut config :: Button ) { ui . text ( im_str ! ( " " ) ) ; // Channel let mut channel = button . channel ( ) . value ( ) . into ( ) ; ui . slider_int ( im_str ! ( " " ) , & mut channel , config :: MidiChannel :: MIN as i32 , config :: MidiChannel :: MAX as i32 ) . build ( ) ; button . channel_mut ( ) . update ( channel . into ( ) ) ; // Button mode let mut mode = button . mode ( ) . value ( ) . into ( ) ; ui . text ( im_str ! ( " " ) ) ; ui . radio_button ( im_str ! ( " " ) , & mut mode , config :: ButtonMode :: Control . into ( ) ) ; ui . same_line ( 0f32 ) ; ui . radio_button ( im_str ! ( " " ) , & mut mode , config :: ButtonMode :: Note . into ( ) ) ; button . mode_mut ( ) . update ( mode . into ( ) ) ; match button . mode ( ) . value ( ) { config :: ButtonMode :: Control => { // Control Code let mut control = button . control ( ) . value ( ) . into ( ) ; ui . slider_int ( im_str ! ( " " ) , & mut control , config :: MidiValue :: MIN as i32 , config :: MidiValue :: MAX as i32 ) . build ( ) ; button . control_mut ( ) . update ( control . into ( ) ) ; // On CC value let mut on = button . on ( ) . value ( ) . into ( ) ; ui . slider_int ( im_str ! ( " " ) , & mut on , config :: MidiValue :: MIN as i32 , config :: MidiValue :: MAX as i32 ) . build ( ) ; button . on_mut ( ) . update ( on . into ( ) ) ; // Off CC value let mut off = button . off ( ) . value ( ) . into ( ) ; ui . slider_int ( im_str ! ( " " ) , & mut off , config :: MidiValue :: MIN as i32 , config :: MidiValue :: MAX as i32 ) . build ( ) ; button . off_mut ( ) . update ( off . into ( ) ) ; } , config :: ButtonMode :: Note => { // Note let mut note = button . note ( ) . value ( ) . into ( ) ; ui . slider_int ( im_str ! ( " " ) , & mut note , config :: MidiValue :: MIN as i32 , config :: MidiValue :: MAX as i32 ) . build ( ) ; button . note_mut ( ) . update ( note . into ( ) ) ; // Note velocity let mut note_vel = button . note_vel ( ) . value ( ) . into ( ) ; ui . slider_int ( im_str ! ( " " ) , & mut note_vel , config :: MidiValue :: MIN as i32 , config :: MidiValue :: MAX as i32 ) . build ( ) ; button . note_vel_mut ( ) . update ( note_vel . into ( ) ) ; } , config :: ButtonMode :: Invalid { n } => { ui . text ( im_str ! ( " " ) ) ; } , } // Button style let mut style = button . style ( ) . value ( ) . into ( ) ; ui . text ( im_str ! ( " " ) ) ; ui . radio_button ( im_str ! ( " " ) , & mut style , config :: ButtonStyle :: Momentary . into ( ) ) ; ui . same_line ( 0f32 ) ; ui . radio_button ( im_str ! ( " " ) , & mut style , config :: ButtonStyle :: Toggle . into ( ) ) ; button . style_mut ( ) . update ( style . into ( ) ) ; }
Renders a button onto a UI and handles user changes
Renders a button onto a UI and handles user changes
ui
&Ui<'a>
button
&mut config::Button