pub trait FactoryView: IsA<Widget> {
type ReturnedWidget: Debug + Hash;
type Children: Debug + AsRef<Self::Children>;
type Position;
// Required methods
fn factory_remove(&self, widget: &Self::ReturnedWidget);
fn factory_append(
&self,
widget: impl AsRef<Self::Children>,
position: &Self::Position,
) -> Self::ReturnedWidget;
fn factory_prepend(
&self,
widget: impl AsRef<Self::Children>,
position: &Self::Position,
) -> Self::ReturnedWidget;
fn factory_insert_after(
&self,
widget: impl AsRef<Self::Children>,
position: &Self::Position,
other: &Self::ReturnedWidget,
) -> Self::ReturnedWidget;
fn returned_widget_to_child(
root_child: &Self::ReturnedWidget,
) -> Self::Children;
fn factory_move_after(
&self,
widget: &Self::ReturnedWidget,
other: &Self::ReturnedWidget,
);
fn factory_move_start(&self, widget: &Self::ReturnedWidget);
// Provided method
fn factory_update_position(
&self,
_widget: &Self::ReturnedWidget,
_position: &Self::Position,
) { ... }
}Expand description
A trait implemented for GTK4 widgets that allows a factory to create and remove widgets.
Required Associated Types§
Sourcetype ReturnedWidget: Debug + Hash
type ReturnedWidget: Debug + Hash
The widget returned when inserting a widget.
This doesn’t matter on containers like gtk::Box.
However, widgets such as gtk::Stack return a gtk::StackPage
which might be used to set additional parameters.
Therefore, this “returned widget” is explicitly handled here.
Sourcetype Children: Debug + AsRef<Self::Children>
type Children: Debug + AsRef<Self::Children>
Widget type that is attached to the container and also the root of the components.
Sourcetype Position
type Position
Position type used by this widget.
For example GridPosition for gtk::Grid or () for gtk::Box
Required Methods§
Sourcefn factory_remove(&self, widget: &Self::ReturnedWidget)
fn factory_remove(&self, widget: &Self::ReturnedWidget)
Removes a widget.
Sourcefn factory_append(
&self,
widget: impl AsRef<Self::Children>,
position: &Self::Position,
) -> Self::ReturnedWidget
fn factory_append( &self, widget: impl AsRef<Self::Children>, position: &Self::Position, ) -> Self::ReturnedWidget
Adds a new widget to self at the end.
Sourcefn factory_prepend(
&self,
widget: impl AsRef<Self::Children>,
position: &Self::Position,
) -> Self::ReturnedWidget
fn factory_prepend( &self, widget: impl AsRef<Self::Children>, position: &Self::Position, ) -> Self::ReturnedWidget
Add an widget to the front.
Sourcefn factory_insert_after(
&self,
widget: impl AsRef<Self::Children>,
position: &Self::Position,
other: &Self::ReturnedWidget,
) -> Self::ReturnedWidget
fn factory_insert_after( &self, widget: impl AsRef<Self::Children>, position: &Self::Position, other: &Self::ReturnedWidget, ) -> Self::ReturnedWidget
Insert a widget after another widget.
Sourcefn returned_widget_to_child(root_child: &Self::ReturnedWidget) -> Self::Children
fn returned_widget_to_child(root_child: &Self::ReturnedWidget) -> Self::Children
Converts a returned widget to the children type.
Sourcefn factory_move_after(
&self,
widget: &Self::ReturnedWidget,
other: &Self::ReturnedWidget,
)
fn factory_move_after( &self, widget: &Self::ReturnedWidget, other: &Self::ReturnedWidget, )
Move an item after another item.
Sourcefn factory_move_start(&self, widget: &Self::ReturnedWidget)
fn factory_move_start(&self, widget: &Self::ReturnedWidget)
Move an item to the start.
Provided Methods§
Sourcefn factory_update_position(
&self,
_widget: &Self::ReturnedWidget,
_position: &Self::Position,
)
fn factory_update_position( &self, _widget: &Self::ReturnedWidget, _position: &Self::Position, )
Update the position inside positioned containers like gtk::Grid.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.