Derive Macro native_windows_derive::NwgPartial
source · [−]#[derive(NwgPartial)]
{
// Attributes available to this derive:
#[nwg_control]
#[nwg_resource]
#[nwg_events]
#[nwg_layout]
#[nwg_layout_item]
#[nwg_partial]
}
Expand description
The NwgPartial
macro implements the native-windows-gui PartialUi
trait on the selected struct
NwgPartial
accepts the same attributes as NwgUi
. See the docs of the NwgUi
trait for detailed usage. There are some particularities though:
- Partials cannot be used by independently. They must be included in a UI that implements
NwgUi
. - Partials do not require a top level window. If no window is defined, the partial will require a parent value passed from the
nwg_partial
attribute - It’s possible to derive both
NwgUi
andNwgPartial
from the same struct as long as the partial do not need a parent. - Partials can contains other partials
#[derive(Default, NwgPartial)]
pub struct MyPartial {
partial_data: u32,
#[nwg_control]
button: nwg::Button
}
#[derive(Default, NwgUi)]
pub struct MyApp {
app_data: u32,
#[nwg_control]
#[nwg_events( OnInit: [hello], OnWindowClose: [nwg::stop_thread_dispatch()] )]
window: nwg::Window,
#[nwg_partial(parent: window)]
partial: MyPartial
}