Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove clipping when rendering tooltips #192

Merged
merged 1 commit into from
Nov 20, 2023
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
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();
}
}
}