-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathprogress.rs
More file actions
106 lines (84 loc) · 2.29 KB
/
Copy pathprogress.rs
File metadata and controls
106 lines (84 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
use crate::{
BorrowedWindow, Component, ComponentSender, Enable, Layoutable, Point, Size, Visible, ui,
};
/// A progress bar.
#[derive(Debug)]
pub struct Progress {
widget: ui::Progress,
}
impl Progress {
/// Value range.
pub fn range(&self) -> (usize, usize) {
self.widget.range()
}
/// Set the value range.
pub fn set_range(&mut self, min: usize, max: usize) {
self.widget.set_range(min, max);
}
/// Current position.
pub fn pos(&self) -> usize {
self.widget.pos()
}
/// Set current position.
pub fn set_pos(&mut self, pos: usize) {
self.widget.set_pos(pos);
}
/// Get if the progress bar is in indeterminate state.
pub fn is_indeterminate(&self) -> bool {
self.widget.is_indeterminate()
}
/// Set if the progress bar is in indeterminate state.
pub fn set_indeterminate(&mut self, v: bool) {
self.widget.set_indeterminate(v);
}
}
impl Visible for Progress {
fn is_visible(&self) -> bool {
self.widget.is_visible()
}
fn set_visible(&mut self, v: bool) {
self.widget.set_visible(v);
}
}
impl Enable for Progress {
fn is_enabled(&self) -> bool {
self.widget.is_enabled()
}
fn set_enabled(&mut self, v: bool) {
self.widget.set_enabled(v);
}
}
impl Layoutable for Progress {
fn loc(&self) -> Point {
self.widget.loc()
}
fn set_loc(&mut self, p: Point) {
self.widget.set_loc(p)
}
fn size(&self) -> Size {
self.widget.size()
}
fn set_size(&mut self, v: Size) {
self.widget.set_size(v)
}
fn preferred_size(&self) -> Size {
self.widget.preferred_size()
}
}
/// Events of [`Progress`].
#[non_exhaustive]
pub enum ProgressEvent {}
impl Component for Progress {
type Event = ProgressEvent;
type Init<'a> = BorrowedWindow<'a>;
type Message = ();
fn init(init: Self::Init<'_>, _sender: &ComponentSender<Self>) -> Self {
let widget = ui::Progress::new(init);
Self { widget }
}
async fn start(&mut self, _sender: &ComponentSender<Self>) {}
async fn update(&mut self, _message: Self::Message, _sender: &ComponentSender<Self>) -> bool {
false
}
fn render(&mut self, _sender: &ComponentSender<Self>) {}
}