Write docs for iced and iced_native

This commit is contained in:
Héctor Ramón Jiménez 2019-11-22 19:36:57 +01:00
parent ba56a561b2
commit a7dba612f0
30 changed files with 877 additions and 214 deletions

View file

@ -4,6 +4,7 @@ use crate::{
Rectangle, Renderer, Size, VerticalAlignment,
};
/// A renderer that does nothing.
pub struct Null;
impl Renderer for Null {

View file

@ -2,11 +2,21 @@ use crate::MouseCursor;
use raw_window_handle::HasRawWindowHandle;
/// A renderer that can target windows.
pub trait Windowed: super::Renderer + Sized {
/// The type of target.
type Target: Target<Renderer = Self>;
/// Creates a new [`Windowed`] renderer.
///
/// [`Windowed`]: trait.Windowed.html
fn new() -> Self;
/// Performs the drawing operations described in the output on the given
/// target.
///
/// The overlay can be a bunch of debug text logs. It should be rendered on
/// top of the GUI on most scenarios.
fn draw<T: AsRef<str>>(
&mut self,
output: &Self::Output,
@ -15,9 +25,15 @@ pub trait Windowed: super::Renderer + Sized {
) -> MouseCursor;
}
/// A rendering target.
pub trait Target {
/// The renderer of this target.
type Renderer;
/// Creates a new rendering [`Target`] from the given window handle, width,
/// height and dpi factor.
///
/// [`Target`]: trait.Target.html
fn new<W: HasRawWindowHandle>(
window: &W,
width: u16,
@ -26,6 +42,9 @@ pub trait Target {
renderer: &Self::Renderer,
) -> Self;
/// Resizes the current [`Target`].
///
/// [`Target`]: trait.Target.html
fn resize(
&mut self,
width: u16,