Skip to content

Commit

Permalink
Rename IconPosition to Side in text_input
Browse files Browse the repository at this point in the history
  • Loading branch information
hecrj committed Apr 11, 2023
1 parent 57265ff commit cf9d8e0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion examples/tour/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ impl<'a> Step {
code_point: '\u{E900}',
size: Some(35.0),
spacing: 10.0,
position: text_input::IconPosition::Right,
side: text_input::Side::Right,
});
}

Expand Down
18 changes: 9 additions & 9 deletions native/src/widget/text_input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,16 +347,16 @@ pub struct Icon<Font> {
pub size: Option<f32>,
/// The spacing between the [`Icon`] and the text in a [`TextInput`].
pub spacing: f32,
/// The position of the icon.
pub position: IconPosition,
/// The side of a [`TextInput`] where to display the [`Icon`].
pub side: Side,
}

/// The position of an [`Icon`].
/// The side of a [`TextInput`].
#[derive(Debug, Clone)]
pub enum IconPosition {
/// Position the [`Icon`] on the left side of a [`TextInput`].
pub enum Side {
/// The left side of a [`TextInput`].
Left,
/// Position the [`Icon`] on the right side of a [`TextInput`].
/// The right side of a [`TextInput`].
Right,
}

Expand Down Expand Up @@ -448,16 +448,16 @@ where
let mut icon_node =
layout::Node::new(Size::new(icon_width, text_bounds.height));

match icon.position {
IconPosition::Left => {
match icon.side {
Side::Left => {
text_node.move_to(Point::new(
padding.left + icon_width + icon.spacing,
padding.top,
));

icon_node.move_to(Point::new(padding.left, padding.top));
}
IconPosition::Right => {
Side::Right => {
text_node.move_to(Point::new(padding.left, padding.top));

icon_node.move_to(Point::new(
Expand Down
2 changes: 1 addition & 1 deletion src/widget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ pub mod text_input {
//! Display fields that can be filled with text.
pub use iced_native::widget::text_input::{
focus, move_cursor_to, move_cursor_to_end, move_cursor_to_front,
select_all, Appearance, Icon, IconPosition, Id, StyleSheet,
select_all, Appearance, Icon, Id, Side, StyleSheet,
};

/// A field that can be filled with text.
Expand Down

0 comments on commit cf9d8e0

Please sign in to comment.