Improve misc docs
This commit is contained in:
@@ -53,6 +53,20 @@ pub fn show_tooltip(ctx: &CtxRef, id: Id, add_contents: impl FnOnce(&mut Ui)) {
|
||||
show_tooltip_at_pointer(ctx, id, add_contents)
|
||||
}
|
||||
|
||||
/// Show a tooltip at the current pointer position (if any).
|
||||
///
|
||||
/// Most of the time it is easier to use [`Response::on_hover_ui`].
|
||||
///
|
||||
/// See also [`show_tooltip_text`].
|
||||
///
|
||||
/// ```
|
||||
/// # let mut ui = egui::Ui::__test();
|
||||
/// if ui.ui_contains_pointer() {
|
||||
/// egui::show_tooltip_at_pointer(ui.ctx(), egui::Id::new("my_tooltip"), |ui| {
|
||||
/// ui.label("Helpful text");
|
||||
/// });
|
||||
/// }
|
||||
/// ```
|
||||
pub fn show_tooltip_at_pointer(ctx: &CtxRef, id: Id, add_contents: impl FnOnce(&mut Ui)) {
|
||||
let suggested_pos = ctx
|
||||
.input()
|
||||
|
||||
+8
-2
@@ -394,7 +394,10 @@ pub fn warn_if_debug_build(ui: &mut crate::Ui) {
|
||||
|
||||
/// Create a [`Hyperlink`](crate::Hyperlink) to the current [`file!()`] (and line) on Github
|
||||
///
|
||||
/// Example: `ui.add(github_link_file_line!("https://github.com/YOUR/PROJECT/blob/master/", "(source code)"));`
|
||||
/// ```
|
||||
/// # let ui = &mut egui::Ui::__test();
|
||||
/// ui.add(egui::github_link_file_line!("https://github.com/YOUR/PROJECT/blob/master/", "(source code)"));
|
||||
/// ```
|
||||
#[macro_export]
|
||||
macro_rules! github_link_file_line {
|
||||
($github_url:expr, $label:expr) => {{
|
||||
@@ -405,7 +408,10 @@ macro_rules! github_link_file_line {
|
||||
|
||||
/// Create a [`Hyperlink`](crate::Hyperlink) to the current [`file!()`] on github.
|
||||
///
|
||||
/// Example: `ui.add(github_link_file!("https://github.com/YOUR/PROJECT/blob/master/", "(source code)"));`
|
||||
/// ```
|
||||
/// # let ui = &mut egui::Ui::__test();
|
||||
/// ui.add(egui::github_link_file!("https://github.com/YOUR/PROJECT/blob/master/", "(source code)"));
|
||||
/// ```
|
||||
#[macro_export]
|
||||
macro_rules! github_link_file {
|
||||
($github_url:expr, $label:expr) => {{
|
||||
|
||||
+7
-6
@@ -92,14 +92,15 @@ impl Painter {
|
||||
|
||||
/// ## Accessors etc
|
||||
impl Painter {
|
||||
/// Get a reference to the parent [`CtxRef`].
|
||||
#[inline(always)]
|
||||
pub(crate) fn ctx(&self) -> &CtxRef {
|
||||
pub fn ctx(&self) -> &CtxRef {
|
||||
&self.ctx
|
||||
}
|
||||
|
||||
/// Available fonts
|
||||
/// Available fonts.
|
||||
#[inline(always)]
|
||||
pub(crate) fn fonts(&self) -> &Fonts {
|
||||
pub fn fonts(&self) -> &Fonts {
|
||||
self.ctx.fonts()
|
||||
}
|
||||
|
||||
@@ -123,19 +124,19 @@ impl Painter {
|
||||
self.clip_rect = clip_rect;
|
||||
}
|
||||
|
||||
/// Useful for pixel-perfect rendering
|
||||
/// Useful for pixel-perfect rendering.
|
||||
#[inline(always)]
|
||||
pub fn round_to_pixel(&self, point: f32) -> f32 {
|
||||
self.ctx().round_to_pixel(point)
|
||||
}
|
||||
|
||||
/// Useful for pixel-perfect rendering
|
||||
/// Useful for pixel-perfect rendering.
|
||||
#[inline(always)]
|
||||
pub fn round_vec_to_pixels(&self, vec: Vec2) -> Vec2 {
|
||||
self.ctx().round_vec_to_pixels(vec)
|
||||
}
|
||||
|
||||
/// Useful for pixel-perfect rendering
|
||||
/// Useful for pixel-perfect rendering.
|
||||
#[inline(always)]
|
||||
pub fn round_pos_to_pixels(&self, pos: Pos2) -> Pos2 {
|
||||
self.ctx().round_pos_to_pixels(pos)
|
||||
|
||||
+2
-2
@@ -698,9 +698,9 @@ impl Ui {
|
||||
widget_rect
|
||||
}
|
||||
|
||||
/// Allocate a specific part of the `Ui‘.
|
||||
/// Allocate a specific part of the `Ui`.
|
||||
///
|
||||
/// Ignore the layout of the `Ui‘: just put my widget here!
|
||||
/// Ignore the layout of the `Ui`: just put my widget here!
|
||||
/// The layout cursor will advance to past this `rect`.
|
||||
pub fn allocate_rect(&mut self, rect: Rect, sense: Sense) -> Response {
|
||||
let id = self.advance_cursor_after_rect(rect);
|
||||
|
||||
Reference in New Issue
Block a user