pub struct Numeric { /* private fields */ }Expand description
Numerical Up/Down component, where a number can be changed by stepping up or down with a given stepcount Design:
-128▼▲Implementations§
Source§impl Numeric
impl Numeric
pub const ARROW_UP: Grapheme = ScrollViewer::ARROW_UP
pub const ARROW_DOWN: Grapheme = ScrollViewer::ARROW_DOWN
pub const ARROW_UP_DISABLED: Grapheme = ScrollViewer::ARROW_UP_DISABLED
pub const ARROW_DOWN_DISABLED: Grapheme = ScrollViewer::ARROW_DOWN_DISABLED
pub const NUMERIC_PLACEHOLDER: Grapheme
pub fn default_key_handler(&mut self, event: &mut WindowEvent)
pub fn default_callback(_: &mut Self)
pub fn set_changed_value_callback<F: Fn(&mut Numeric) + 'static>( &mut self, callback: F, )
pub fn set_key_handler(&mut self, f: NumericKeyHandler)
Sourcepub fn set_min_range(&mut self, min_range: i32)
pub fn set_min_range(&mut self, min_range: i32)
Examples found in repository?
examples/stackpanel.rs (line 68)
52 fn default() -> Self {
53 let label = WindowFactory::create::<Label>();
54 label
55 .borrow_mut()
56 .set_text("Please enter a valid number (x ∈ ℕ):");
57 let button = WindowFactory::create::<Button>();
58 button.borrow_mut().set_text("Press to increment:");
59 button.borrow_mut().set_border(BorderKind::Solid.into());
60 let mut cb: Combobox<u8> = Combobox::default();
61 for v in [1, 2, 4] {
62 cb.add_item(DisplayValue::new(v, format!("Increment by {}", v)));
63 }
64 let cb = Rc::new(RefCell::new(cb));
65 let combobox = cb.clone();
66 let numeric = WindowFactory::create::<Numeric>();
67 numeric.borrow_mut().set_base(Radix::Hexadecimal);
68 numeric.borrow_mut().set_min_range(8);
69 numeric.borrow_mut().set_max_range(64);
70 numeric.borrow_mut().set_focus_color(Some(Color::Cyan));
71 let nc = numeric.clone();
72 combobox
73 .borrow_mut()
74 .set_selection_changed_callback(move |cb| {
75 let mut brw = nc.borrow_mut();
76 brw.set_stepcount(*cb.get_value().unwrap().value())
77 });
78
79 let stackpanel = WindowFactory::create::<Stackpanel>();
80 stackpanel.borrow_mut().set_border(BorderKind::Solid.into());
81 stackpanel.borrow_mut().add_item(label);
82 stackpanel.borrow_mut().add_item(numeric);
83 stackpanel.borrow_mut().add_item(cb);
84
85 Self {
86 uid: WindowUID::new(),
87 stackpanel,
88 running: true,
89 }
90 }Sourcepub fn set_max_range(&mut self, max_range: i32)
pub fn set_max_range(&mut self, max_range: i32)
Examples found in repository?
examples/stackpanel.rs (line 69)
52 fn default() -> Self {
53 let label = WindowFactory::create::<Label>();
54 label
55 .borrow_mut()
56 .set_text("Please enter a valid number (x ∈ ℕ):");
57 let button = WindowFactory::create::<Button>();
58 button.borrow_mut().set_text("Press to increment:");
59 button.borrow_mut().set_border(BorderKind::Solid.into());
60 let mut cb: Combobox<u8> = Combobox::default();
61 for v in [1, 2, 4] {
62 cb.add_item(DisplayValue::new(v, format!("Increment by {}", v)));
63 }
64 let cb = Rc::new(RefCell::new(cb));
65 let combobox = cb.clone();
66 let numeric = WindowFactory::create::<Numeric>();
67 numeric.borrow_mut().set_base(Radix::Hexadecimal);
68 numeric.borrow_mut().set_min_range(8);
69 numeric.borrow_mut().set_max_range(64);
70 numeric.borrow_mut().set_focus_color(Some(Color::Cyan));
71 let nc = numeric.clone();
72 combobox
73 .borrow_mut()
74 .set_selection_changed_callback(move |cb| {
75 let mut brw = nc.borrow_mut();
76 brw.set_stepcount(*cb.get_value().unwrap().value())
77 });
78
79 let stackpanel = WindowFactory::create::<Stackpanel>();
80 stackpanel.borrow_mut().set_border(BorderKind::Solid.into());
81 stackpanel.borrow_mut().add_item(label);
82 stackpanel.borrow_mut().add_item(numeric);
83 stackpanel.borrow_mut().add_item(cb);
84
85 Self {
86 uid: WindowUID::new(),
87 stackpanel,
88 running: true,
89 }
90 }pub fn set_value(&mut self, value: i32)
pub fn get_value(&self) -> i32
Sourcepub fn set_base(&mut self, base: Radix)
pub fn set_base(&mut self, base: Radix)
Examples found in repository?
examples/stackpanel.rs (line 67)
52 fn default() -> Self {
53 let label = WindowFactory::create::<Label>();
54 label
55 .borrow_mut()
56 .set_text("Please enter a valid number (x ∈ ℕ):");
57 let button = WindowFactory::create::<Button>();
58 button.borrow_mut().set_text("Press to increment:");
59 button.borrow_mut().set_border(BorderKind::Solid.into());
60 let mut cb: Combobox<u8> = Combobox::default();
61 for v in [1, 2, 4] {
62 cb.add_item(DisplayValue::new(v, format!("Increment by {}", v)));
63 }
64 let cb = Rc::new(RefCell::new(cb));
65 let combobox = cb.clone();
66 let numeric = WindowFactory::create::<Numeric>();
67 numeric.borrow_mut().set_base(Radix::Hexadecimal);
68 numeric.borrow_mut().set_min_range(8);
69 numeric.borrow_mut().set_max_range(64);
70 numeric.borrow_mut().set_focus_color(Some(Color::Cyan));
71 let nc = numeric.clone();
72 combobox
73 .borrow_mut()
74 .set_selection_changed_callback(move |cb| {
75 let mut brw = nc.borrow_mut();
76 brw.set_stepcount(*cb.get_value().unwrap().value())
77 });
78
79 let stackpanel = WindowFactory::create::<Stackpanel>();
80 stackpanel.borrow_mut().set_border(BorderKind::Solid.into());
81 stackpanel.borrow_mut().add_item(label);
82 stackpanel.borrow_mut().add_item(numeric);
83 stackpanel.borrow_mut().add_item(cb);
84
85 Self {
86 uid: WindowUID::new(),
87 stackpanel,
88 running: true,
89 }
90 }pub fn get_base(&self) -> Radix
pub fn step_up(&mut self)
pub fn step_down(&mut self)
pub fn get_stepcount(&self) -> u8
Sourcepub fn set_stepcount(&mut self, stepcount: u8)
pub fn set_stepcount(&mut self, stepcount: u8)
Examples found in repository?
examples/stackpanel.rs (line 76)
52 fn default() -> Self {
53 let label = WindowFactory::create::<Label>();
54 label
55 .borrow_mut()
56 .set_text("Please enter a valid number (x ∈ ℕ):");
57 let button = WindowFactory::create::<Button>();
58 button.borrow_mut().set_text("Press to increment:");
59 button.borrow_mut().set_border(BorderKind::Solid.into());
60 let mut cb: Combobox<u8> = Combobox::default();
61 for v in [1, 2, 4] {
62 cb.add_item(DisplayValue::new(v, format!("Increment by {}", v)));
63 }
64 let cb = Rc::new(RefCell::new(cb));
65 let combobox = cb.clone();
66 let numeric = WindowFactory::create::<Numeric>();
67 numeric.borrow_mut().set_base(Radix::Hexadecimal);
68 numeric.borrow_mut().set_min_range(8);
69 numeric.borrow_mut().set_max_range(64);
70 numeric.borrow_mut().set_focus_color(Some(Color::Cyan));
71 let nc = numeric.clone();
72 combobox
73 .borrow_mut()
74 .set_selection_changed_callback(move |cb| {
75 let mut brw = nc.borrow_mut();
76 brw.set_stepcount(*cb.get_value().unwrap().value())
77 });
78
79 let stackpanel = WindowFactory::create::<Stackpanel>();
80 stackpanel.borrow_mut().set_border(BorderKind::Solid.into());
81 stackpanel.borrow_mut().add_item(label);
82 stackpanel.borrow_mut().add_item(numeric);
83 stackpanel.borrow_mut().add_item(cb);
84
85 Self {
86 uid: WindowUID::new(),
87 stackpanel,
88 running: true,
89 }
90 }Sourcepub fn set_focus_color(&mut self, color: Option<Color>)
pub fn set_focus_color(&mut self, color: Option<Color>)
Examples found in repository?
examples/stackpanel.rs (line 70)
52 fn default() -> Self {
53 let label = WindowFactory::create::<Label>();
54 label
55 .borrow_mut()
56 .set_text("Please enter a valid number (x ∈ ℕ):");
57 let button = WindowFactory::create::<Button>();
58 button.borrow_mut().set_text("Press to increment:");
59 button.borrow_mut().set_border(BorderKind::Solid.into());
60 let mut cb: Combobox<u8> = Combobox::default();
61 for v in [1, 2, 4] {
62 cb.add_item(DisplayValue::new(v, format!("Increment by {}", v)));
63 }
64 let cb = Rc::new(RefCell::new(cb));
65 let combobox = cb.clone();
66 let numeric = WindowFactory::create::<Numeric>();
67 numeric.borrow_mut().set_base(Radix::Hexadecimal);
68 numeric.borrow_mut().set_min_range(8);
69 numeric.borrow_mut().set_max_range(64);
70 numeric.borrow_mut().set_focus_color(Some(Color::Cyan));
71 let nc = numeric.clone();
72 combobox
73 .borrow_mut()
74 .set_selection_changed_callback(move |cb| {
75 let mut brw = nc.borrow_mut();
76 brw.set_stepcount(*cb.get_value().unwrap().value())
77 });
78
79 let stackpanel = WindowFactory::create::<Stackpanel>();
80 stackpanel.borrow_mut().set_border(BorderKind::Solid.into());
81 stackpanel.borrow_mut().add_item(label);
82 stackpanel.borrow_mut().add_item(numeric);
83 stackpanel.borrow_mut().add_item(cb);
84
85 Self {
86 uid: WindowUID::new(),
87 stackpanel,
88 running: true,
89 }
90 }Trait Implementations§
Source§impl HasWindowUID for Numeric
impl HasWindowUID for Numeric
Source§impl Widget for Numeric
impl Widget for Numeric
Source§fn set_height(&mut self, _: Size)
fn set_height(&mut self, _: Size)
Unsupported
Source§fn set_width_constraint(&mut self, _: SizeConstraint)
fn set_width_constraint(&mut self, _: SizeConstraint)
Unsupported
Source§fn set_height_constraint(&mut self, _: SizeConstraint)
fn set_height_constraint(&mut self, _: SizeConstraint)
Unsupported
fn set_visibility(&mut self, visibility: bool)
fn set_margin(&mut self, margin: Thickness)
fn set_border(&mut self, border: BorderStyle)
fn set_alignment( &mut self, horizontal: HorizontalAlignment, vertical: VerticalAlignment, )
Source§fn set_enabled_state(&mut self, is_enabled: bool)
fn set_enabled_state(&mut self, is_enabled: bool)
Changing the IsEnabled state usually changes the highlight color
Source§impl WidgetColors for Numeric
impl WidgetColors for Numeric
fn set_disabled_color(&mut self, color: Option<Color>)
fn set_base_fg_color(&mut self, color: Option<Color>)
fn set_base_bg_color(&mut self, color: Option<Color>)
Source§impl Window for Numeric
impl Window for Numeric
Source§fn handle_event(&mut self, event: &mut WindowEvent)
fn handle_event(&mut self, event: &mut WindowEvent)
Source§fn is_enabled(&self) -> bool
fn is_enabled(&self) -> bool
Source§fn children(&mut self, builder: SubWindowBuilder) -> SubWindows
fn children(&mut self, builder: SubWindowBuilder) -> SubWindows
Returns all children windows (and layouting Rects)
Note: When changing the children make sure to also adjust the focus
Source§impl WindowLayout for Numeric
impl WindowLayout for Numeric
Source§fn desired_size(&self, available_size: TPoint) -> TPoint
fn desired_size(&self, available_size: TPoint) -> TPoint
Parents call this to get the desired size of the child
This must not exceed
available_size on any axis
When the result’s product is equal to 0, this window wont be drawnfn border(&self) -> BorderStyle
Source§fn alignment(&self) -> (HorizontalAlignment, VerticalAlignment)
fn alignment(&self) -> (HorizontalAlignment, VerticalAlignment)
fn is_visible(&self) -> bool
fn margin(&self) -> Thickness
Source§fn desired_size_pre_hook(&mut self, available_size: TPoint)
fn desired_size_pre_hook(&mut self, available_size: TPoint)
This is similar to desired_size but will not return anything and can mutably change self
This is executed before WindowLayout::desired_size
Only implement if actually necessary
Auto Trait Implementations§
impl !RefUnwindSafe for Numeric
impl !Send for Numeric
impl !Sync for Numeric
impl !UnwindSafe for Numeric
impl Freeze for Numeric
impl Unpin for Numeric
impl UnsafeUnpin for Numeric
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Downcast for T
impl<T> Downcast for T
Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
Source§impl<T> WindowHelper for Twhere
T: Window,
impl<T> WindowHelper for Twhere
T: Window,
Source§fn provoke_changed_property(&self, property: WindowProperty)
fn provoke_changed_property(&self, property: WindowProperty)
Helper method for WindowEventQueue::provoke_changed_property