Skip to content

Commit 0d9677f

Browse files
committed
[libgui] Update clients for Label API change
1 parent 520fc3a commit 0d9677f

File tree

5 files changed

+15
-14
lines changed

5 files changed

+15
-14
lines changed

rust_programs/dock/src/main.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,13 @@ impl TaskView {
5858
// We'll draw the border ourselves, so the inner View shouldn't
5959
view.set_border_enabled(false);
6060

61-
// TODO(PT): Sizer for labels?
61+
// TODO(PT): Sizer
6262
let title_label = Rc::new(Label::new(
63-
Rect::from_parts(
64-
Point::new(insets.left + 4, insets.top + 4),
65-
Size::new(300, 30),
66-
),
6763
&title,
6864
Color::new(30, 30, 30),
65+
move |label, superview_size| {
66+
Rect::from_parts(Point::new(insets.left + 4, insets.top), Size::new(300, 30))
67+
},
6968
));
7069
let title_label_clone = Rc::clone(&title_label);
7170
// TODO(PT): Set font size as attribute?
@@ -82,12 +81,13 @@ impl TaskView {
8281
}
8382

8483
fn text_width(self: &Rc<Self>) -> usize {
85-
8 * self.title.borrow().len()
84+
20 * self.title.borrow().len()
8685
}
8786

8887
fn resize_title_label(self: &Rc<Self>, superview_size: Size) {
8988
// TODO(PT): This is a hack until labels have sizers
9089
// TODO(PT): Expose font size of labels
90+
//let font_size = Size::new(20, 20);
9191
let font_size = Size::new(8, 10);
9292
let insets = Self::border_insets();
9393
let usable_frame = Rect::from_parts(Point::zero(), superview_size).inset_by_insets(insets);
@@ -97,6 +97,7 @@ impl TaskView {
9797
Point::new(
9898
usable_frame.mid_x() - (text_width / 2),
9999
usable_frame.mid_y() - (font_size.height / 2),
100+
//usable_frame.min_y(),
100101
),
101102
Size::new(text_width, font_size.height),
102103
);

rust_programs/example_program/src/main_axle.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ impl WindowState {
3434
Rc::clone(&window).add_component(Rc::clone(&content_view) as Rc<dyn UIElement>);
3535

3636
let label = Rc::new(Label::new(
37-
Rect::from_parts(Point::new(4, 4), Size::new(300, 30)),
3837
"Hello from Rust!!",
3938
Color::black(),
39+
|label, superview_size| Rect::from_parts(Point::new(4, 4), Size::new(300, 30)),
4040
));
4141
Rc::clone(&content_view).add_component(Rc::clone(&label) as Rc<dyn UIElement>);
4242

rust_programs/file_browser/src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ impl CurrentPathView {
5555

5656
let initial_path = "/";
5757
let current_path_label = Rc::new(Label::new(
58-
Rect::new(10, 10, 400, 16),
5958
&format!("Current path: {}", initial_path),
6059
Color::new(30, 30, 30),
60+
|_, _| Rect::new(10, 10, 400, 16),
6161
));
6262
let current_path_label_clone = Rc::clone(&current_path_label);
6363
Rc::clone(&view).add_component(current_path_label_clone);

rust_programs/ide/src/output_view.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,9 @@ impl OutputView {
2828
);
2929

3030
println!("Create title label");
31-
let title_label = Rc::new(Label::new(
32-
Rect::new(8, 8, 200, 16),
33-
"Title",
34-
Color::black(),
35-
));
31+
let title_label = Rc::new(Label::new("Title", Color::black(), |_, _| {
32+
Rect::new(8, 8, 200, 16)
33+
}));
3634
println!("Add title label");
3735
//Rc::clone(&view.view).add_component(Rc::clone(&title_label) as Rc<dyn UIElement>);
3836
println!("Done adding title label");

rust_programs/ide/src/status_view.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ impl StatusView {
3838
}));
3939
Rc::clone(&view).add_component(Rc::clone(&run_button) as Rc<dyn UIElement>);
4040

41-
let status_label = Rc::new(Label::new(Rect::new(10, 10, 400, 16), "", Color::black()));
41+
let status_label = Rc::new(Label::new("", Color::black(), |_, _| {
42+
Rect::new(10, 10, 400, 16)
43+
}));
4244
Rc::clone(&view).add_component(Rc::clone(&status_label) as Rc<dyn UIElement>);
4345

4446
let ret = Rc::new(Self {

0 commit comments

Comments
 (0)