Skip to content

Commit

Permalink
Remove clipping when rendering tooltips (#192)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zoxc authored Nov 20, 2023
1 parent 5957e1e commit 918b2e9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1675,6 +1675,12 @@ impl<'a> PaintCx<'a> {
self.clip = Some(rect);
}

/// Remove clipping so the entire window can be rendered to.
pub fn clear_clip(&mut self) {
self.clip = None;
self.paint_state.renderer.clear_clip();
}

pub fn offset(&mut self, offset: (f64, f64)) {
let mut new = self.transform.as_coeffs();
new[4] += offset.0;
Expand Down
14 changes: 13 additions & 1 deletion src/views/tooltip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use taffy::style::Display;

use crate::{
action::{exec_after, TimerToken},
context::{EventCx, StyleCx},
context::{EventCx, PaintCx, StyleCx},
event::Event,
id::Id,
prop, prop_extracter,
Expand Down Expand Up @@ -138,4 +138,16 @@ impl View for Tooltip {

default_event(self, cx, id_path, event)
}

fn paint(&mut self, cx: &mut PaintCx) {
cx.paint_view(&mut self.child);

if self.visible {
// Remove clipping for the tooltip.
cx.save();
cx.clear_clip();
cx.paint_view(&mut self.tip);
cx.restore();
}
}
}

0 comments on commit 918b2e9

Please sign in to comment.