mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-23 17:35:00 +00:00
Expanded on API for Checkbox and for Enabled. (#447)
Added a `with_x` variant to both, for easier chaining.
This commit is contained in:
parent
57d5b21518
commit
f42fc382e6
@ -119,6 +119,15 @@ impl Checkbox {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Set the checkbox state.
|
||||||
|
///
|
||||||
|
/// Chainable variant.
|
||||||
|
pub fn with_checked(self, is_checked: bool) -> Self {
|
||||||
|
self.with(|s| {
|
||||||
|
s.set_checked(is_checked);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
fn draw_internal(&self, printer: &Printer<'_, '_>) {
|
fn draw_internal(&self, printer: &Printer<'_, '_>) {
|
||||||
printer.print((0, 0), "[ ]");
|
printer.print((0, 0), "[ ]");
|
||||||
if self.checked {
|
if self.checked {
|
||||||
|
@ -44,6 +44,14 @@ macro_rules! impl_enabled {
|
|||||||
self.$x = enabled;
|
self.$x = enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Enable or disable this view.
|
||||||
|
///
|
||||||
|
/// Chainable variant.
|
||||||
|
pub fn with_enabled(mut self, is_enabled: bool) -> Self {
|
||||||
|
self.set_enabled(is_enabled);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns `true` if this view is enabled.
|
/// Returns `true` if this view is enabled.
|
||||||
pub fn is_enabled(&self) -> bool {
|
pub fn is_enabled(&self) -> bool {
|
||||||
self.$x
|
self.$x
|
||||||
|
Loading…
Reference in New Issue
Block a user