mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-03 01:55:27 +00:00
prevent panic on set_width_request when the parent widget yet not rendered
This commit is contained in:
parent
8e6dc4b4dc
commit
0b8960c60c
1 changed files with 9 additions and 3 deletions
|
|
@ -9,6 +9,7 @@ const REGEX_HR: &str = r"(?m)^(?P<hr>\\?[-]{3,})$";
|
||||||
|
|
||||||
/// Apply --- `Tag` to given `TextBuffer`
|
/// Apply --- `Tag` to given `TextBuffer`
|
||||||
pub fn render(text_view: &TextView) {
|
pub fn render(text_view: &TextView) {
|
||||||
|
const OFFSET: i32 = 18;
|
||||||
let separator = Separator::builder()
|
let separator = Separator::builder()
|
||||||
.orientation(Orientation::Horizontal)
|
.orientation(Orientation::Horizontal)
|
||||||
.build();
|
.build();
|
||||||
|
|
@ -16,10 +17,15 @@ pub fn render(text_view: &TextView) {
|
||||||
let text_view = text_view.clone();
|
let text_view = text_view.clone();
|
||||||
let separator = separator.clone();
|
let separator = separator.clone();
|
||||||
move || {
|
move || {
|
||||||
separator.set_width_request(text_view.width() - 18);
|
let w = text_view.width();
|
||||||
|
if w < OFFSET {
|
||||||
|
ControlFlow::Continue
|
||||||
|
} else {
|
||||||
|
separator.set_width_request(w - OFFSET);
|
||||||
ControlFlow::Break
|
ControlFlow::Break
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
}); // @TODO something with the widgets init/activation priority..
|
||||||
|
|
||||||
let buffer = text_view.buffer();
|
let buffer = text_view.buffer();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue