1
0
Fork 0
forked from wry/wry

render: bound async title textures to their rect

This commit is contained in:
Julian Orth 2025-02-19 19:34:28 +01:00
parent 5932ec14a7
commit f80ac20220
3 changed files with 16 additions and 18 deletions

View file

@ -253,7 +253,9 @@ impl Renderer<'_> {
}
if let Some(titles) = rd.titles.get(&self.base.scale) {
for title in titles {
let (x, y) = self.base.scale_point(x + title.x, y + title.y);
let rect = title.rect.move_(x, y);
let bounds = self.base.scale_rect(rect);
let (x, y) = self.base.scale_point(rect.x1(), rect.y1());
self.base.render_texture(
&title.tex,
None,
@ -262,7 +264,7 @@ impl Renderer<'_> {
None,
None,
self.base.scale,
None,
Some(&bounds),
None,
AcquireSync::None,
ReleaseSync::None,
@ -486,7 +488,9 @@ impl Renderer<'_> {
self.base.fill_boxes(&title_underline, &uc);
if let Some(title) = floating.title_textures.borrow().get(&self.base.scale) {
if let Some(texture) = title.texture() {
let (x, y) = self.base.scale_point(x + bw, y + bw);
let rect = floating.title_rect.get().move_(x, y);
let bounds = self.base.scale_rect(rect);
let (x, y) = self.base.scale_point(rect.x1(), rect.y1());
self.base.render_texture(
&texture,
None,
@ -495,7 +499,7 @@ impl Renderer<'_> {
None,
None,
self.base.scale,
None,
Some(&bounds),
None,
AcquireSync::None,
ReleaseSync::None,

View file

@ -92,8 +92,7 @@ pub enum ContainerFocus {
tree_id!(ContainerNodeId);
pub struct ContainerTitle {
pub x: i32,
pub y: i32,
pub rect: Rect,
pub tex: Rc<dyn GfxTexture>,
}
@ -765,11 +764,7 @@ impl ContainerNode {
}
if let Some(tex) = tex.texture() {
let titles = rd.titles.get_or_default_mut(*scale);
titles.push(ContainerTitle {
x: rect.x1(),
y: rect.y1(),
tex,
})
titles.push(ContainerTitle { rect, tex })
}
}
}
@ -840,11 +835,7 @@ impl ContainerNode {
for (scale, tex) in tt {
if let Some(tex) = tex.texture() {
let titles = rd.titles.get_or_default_mut(*scale);
titles.push(ContainerTitle {
x: rect.x1(),
y: rect.y1(),
tex,
})
titles.push(ContainerTitle { rect, tex })
}
}
}

View file

@ -47,6 +47,7 @@ pub struct FloatNode {
pub seat_state: NodeSeatState,
pub layout_scheduled: Cell<bool>,
pub render_titles_scheduled: Cell<bool>,
pub title_rect: Cell<Rect>,
pub title: RefCell<String>,
pub title_textures: RefCell<SmallMapMut<Scale, TextTexture, 2>>,
cursors: RefCell<AHashMap<CursorType, CursorState>>,
@ -124,6 +125,7 @@ impl FloatNode {
seat_state: Default::default(),
layout_scheduled: Cell::new(false),
render_titles_scheduled: Cell::new(false),
title_rect: Default::default(),
title: Default::default(),
title_textures: Default::default(),
cursors: Default::default(),
@ -174,7 +176,9 @@ impl FloatNode {
(pos.height() - 2 * bw - th - 1).max(0),
)
.unwrap();
let tr = Rect::new_sized(bw, bw, (pos.width() - 2 * bw).max(0), th).unwrap();
child.clone().tl_change_extents(&cpos);
self.title_rect.set(tr);
self.layout_scheduled.set(false);
self.schedule_render_titles();
}
@ -188,7 +192,6 @@ impl FloatNode {
fn render_title_phase1(&self) -> Rc<AsyncEvent> {
let on_completed = Rc::new(OnDropEvent::default());
let theme = &self.state.theme;
let th = theme.sizes.title_height.get();
let tc = match self.active.get() {
true => theme.colors.focused_title_text.get(),
false => theme.colors.unfocused_title_text.get(),
@ -205,7 +208,7 @@ impl FloatNode {
_ => return on_completed.event(),
};
let scales = self.state.scales.lock();
let tr = Rect::new_sized(pos.x1() + bw, pos.y1() + bw, pos.width() - 2 * bw, th).unwrap();
let tr = self.title_rect.get();
let tt = &mut *self.title_textures.borrow_mut();
for (scale, _) in scales.iter() {
let tex =