Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions examples/remove_demo/remove_widget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,33 @@ impl ObjectImpl for RemoveWidget {
self.parent_construct();

self.bottom.set_margin_top(5);
self.bottom.set_background(Color::GREY_LIGHT);

self.set_hexpand(true);
self.set_vexpand(true);
let mut button_0 = Button::new(Some("Remove 1th"));
let mut button_1 = Button::new(Some("Remove Left"));
let mut button_2 = Button::new(Some("Remove Right"));
let mut button_3 = Button::new(Some("Remove Stack"));
let mut button_4 = Button::new(Some("Remove SplitPane Left"));
let mut button_5 = Button::new(Some("Remove SplitPane RightTop"));
let mut button_6 = Button::new(Some("Remove SplitPane RightBottomLeft"));
let mut button_7 = Button::new(Some("Remove SplitPane RightBottomRight"));
button_0.width_request(100);
button_1.width_request(100);
button_1.width_request(100);
button_2.width_request(100);
button_3.width_request(100);
button_4.width_request(200);
button_5.width_request(200);
button_6.width_request(200);
button_7.width_request(200);
connect!(
button_0,
mouse_pressed(),
self,
remove_0th_pressed(MouseEvent)
);
connect!(
button_1,
mouse_pressed(),
Expand Down Expand Up @@ -94,6 +104,7 @@ impl ObjectImpl for RemoveWidget {
self,
remove_split_pane_right_bottom_right(MouseEvent)
);
self.top.add_child(button_0);
self.top.add_child(button_1);
self.top.add_child(button_2);
self.top.add_child(button_3);
Expand Down Expand Up @@ -123,6 +134,13 @@ impl RemoveWidget {
Self::new_alloc()
}

pub fn remove_0th_pressed(&mut self, _: MouseEvent) {
let id = self.bottom.children().first().map(|c| c.id());
if let Some(id) = id {
self.bottom.remove_children(id);
}
}

pub fn remove_left_pressed(&mut self, _: MouseEvent) {
self.bottom.remove_children(self.to_remove);
}
Expand Down
4 changes: 4 additions & 0 deletions tmui/src/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,8 @@ impl SizeCalculation for dyn WidgetImpl {
} else {
if self.detecting_width() != 0 {
self.set_fixed_width(self.detecting_width())
} else {
self.set_fixed_width(0);
}
}
}
Expand Down Expand Up @@ -442,6 +444,8 @@ impl SizeCalculation for dyn WidgetImpl {
} else {
if self.detecting_height() != 0 {
self.set_fixed_height(self.detecting_height())
} else {
self.set_fixed_height(0);
}
}
}
Expand Down