import { StandardButton, HorizontalBox, VerticalBox, Button, LineEdit, CheckBox, Slider } from "std-widgets.slint";

export global InputProfileData {
    in-out property <bool> dinput;
    in-out property <string> profile_name;
    in-out property <int> deadzone;
}

export component InputProfileDialog inherits Window {
    title: @tr("Create Input Profile");
    callback profile_creation_button_clicked;
    in-out property dinput <=> InputProfileData.dinput;
    in-out property profile_name <=> InputProfileData.profile_name;
    in-out property deadzone <=> InputProfileData.deadzone;
    VerticalBox {
        HorizontalBox {
            LineEdit {
                placeholder-text: @tr("Enter profile name");
                preferred-width: 300px;
                edited(text) => {
                    InputProfileData.profile_name = text;
                }
            }
        }

        HorizontalBox {
            alignment: center;
            Text {
                text: @tr("Deadzone Percentage");
                vertical-alignment: center;
            }

            Slider {
                min-width: 160px;
                maximum: 99;
                value: InputProfileData.deadzone;
                changed(value) => {
                    InputProfileData.deadzone = value;
                }
            }

            Text {
                text: InputProfileData.deadzone + "%";
                vertical-alignment: center;
            }
        }

        HorizontalBox {
            alignment: center;
            CheckBox {
                text: @tr("Use DirectInput");
                checked: InputProfileData.dinput;
                toggled => {
                    InputProfileData.dinput = self.checked;
                }
            }
        }

        HorizontalBox {
            Button {
                text: @tr("Start Profile Creation Wizard");
                enabled: InputProfileData.profile_name != "" && InputProfileData.profile_name != "default";
                clicked => {
                    profile_creation_button_clicked();
                }
            }
        }
    }
}
