Skip to main content

ferroui_controls/
container_index_changed_event_args.rs

1use crate::Control;
2use ferroui_base::Ref;
3
4/// Provides data for the `ItemsControl::container_index_changed` event.
5///
6/// The args are immutable: copies compare equal when they describe the same
7/// container (and indexes).
8#[derive(Clone, PartialEq)]
9pub struct ContainerIndexChangedEventArgs {
10    container: Ref<Control>,
11    old_index: i32,
12    new_index: i32,
13}
14
15impl ContainerIndexChangedEventArgs {
16    /// Initializes a new instance of the [`ContainerIndexChangedEventArgs`] class.
17    pub fn new(container: Ref<Control>, old_index: i32, new_index: i32) -> Self {
18        Self { container, old_index, new_index }
19    }
20
21    /// Get the container for which the index changed.
22    pub fn container(&self) -> &Ref<Control> {
23        &self.container
24    }
25
26    /// Gets the index of the container after the change.
27    pub fn new_index(&self) -> i32 {
28        self.new_index
29    }
30
31    /// Gets the index of the container before the change.
32    pub fn old_index(&self) -> i32 {
33        self.old_index
34    }
35}