About control templates

Control templates are transparent structures that describe a control in details. A control template must implement the ControlTemplate trait.

Unlike other GUI toolkit where it's possible to create controls with very little required informations (aka sane defaults), in NWG every parameter must be defined in the template beforehand. The reason behind that is that nowdays, GUI are mostly done though markup languages or WYSIWYG interfaces and predefined templates make it easier to create those tools.

For a list of all built-in control template see 4. List of built-in controls .

Controls creation

To create a control in a Ui, the new_control(ID, template) -> Result<ID, Error> method must be used. If the creation was successful, the ID that was just added is returned otherwise an Error enum is returned.

Arguments
Behaviour
Failures
Example:
let mut ui: Ui<&'static str> = Ui::new();
ui.new_control("MainWindow", window_template).expect("Something went wrong!");

Controls destruction

To remove a control from a Ui, the remove_control(ID) -> Result<Vec<ID>, Error> method must be used. The method return a Vec of all removed IDS.

Arguments
Behaviour
Failures
Example:
let removed_ids = ui.remove_control("MainWindow").unwrap();