Document the canvas and div
This commit is contained in:
parent
a44aae9e91
commit
bf878b8257
4 changed files with 366 additions and 55 deletions
|
@ -22,7 +22,7 @@
|
||||||
//! # Implementing your own elements
|
//! # Implementing your own elements
|
||||||
//!
|
//!
|
||||||
//! Elements are intended to be the low level, imperative API to GPUI. They are responsible for upholding,
|
//! Elements are intended to be the low level, imperative API to GPUI. They are responsible for upholding,
|
||||||
//! or breaking, GPUI's features as they deem nescessary. As an example, most GPUI elements are expected
|
//! or breaking, GPUI's features as they deem necessary. As an example, most GPUI elements are expected
|
||||||
//! to stay in the bounds that their parent element gives them. But with [`WindowContext::break_content_mask`],
|
//! to stay in the bounds that their parent element gives them. But with [`WindowContext::break_content_mask`],
|
||||||
//! you can ignore this restriction and paint anywhere inside of the window's bounds. This is useful for overlays
|
//! you can ignore this restriction and paint anywhere inside of the window's bounds. This is useful for overlays
|
||||||
//! and popups and anything else that shows up 'on top' of other elements.
|
//! and popups and anything else that shows up 'on top' of other elements.
|
||||||
|
|
|
@ -2,6 +2,8 @@ use refineable::Refineable as _;
|
||||||
|
|
||||||
use crate::{Bounds, Element, IntoElement, Pixels, Style, StyleRefinement, Styled, WindowContext};
|
use crate::{Bounds, Element, IntoElement, Pixels, Style, StyleRefinement, Styled, WindowContext};
|
||||||
|
|
||||||
|
/// Construct a canvas element with the given paint callback.
|
||||||
|
/// Useful for adding short term custom drawing to a view.
|
||||||
pub fn canvas(callback: impl 'static + FnOnce(&Bounds<Pixels>, &mut WindowContext)) -> Canvas {
|
pub fn canvas(callback: impl 'static + FnOnce(&Bounds<Pixels>, &mut WindowContext)) -> Canvas {
|
||||||
Canvas {
|
Canvas {
|
||||||
paint_callback: Some(Box::new(callback)),
|
paint_callback: Some(Box::new(callback)),
|
||||||
|
@ -9,6 +11,8 @@ pub fn canvas(callback: impl 'static + FnOnce(&Bounds<Pixels>, &mut WindowContex
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A canvas element, meant for accessing the low level paint API without defining a whole
|
||||||
|
/// custom element
|
||||||
pub struct Canvas {
|
pub struct Canvas {
|
||||||
paint_callback: Option<Box<dyn FnOnce(&Bounds<Pixels>, &mut WindowContext)>>,
|
paint_callback: Option<Box<dyn FnOnce(&Bounds<Pixels>, &mut WindowContext)>>,
|
||||||
style: StyleRefinement,
|
style: StyleRefinement,
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,5 +1,3 @@
|
||||||
#![deny(missing_docs)]
|
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
mod action;
|
mod action;
|
||||||
mod app;
|
mod app;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue