Skip to content

Commit

Permalink
fix: docs
Browse files Browse the repository at this point in the history
  • Loading branch information
wash2 committed Oct 21, 2024
1 parent 29743fc commit ec8f7a7
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 124 deletions.
2 changes: 1 addition & 1 deletion core/src/overlay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ where
cursor: mouse::Cursor,
);

/// Applies an [`Operation`] to the [`Overlay`].
/// Applies an [`crate::widget::Operation`] to the [`Overlay`].
fn operate(
&mut self,
_layout: Layout<'_>,
Expand Down
14 changes: 7 additions & 7 deletions runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub use program::Program;
pub use task::Task;
pub use user_interface::UserInterface;

use crate::core::{Color, widget};
use crate::core::{widget, Color};
use crate::futures::futures::channel::oneshot;

use std::borrow::Cow;
Expand Down Expand Up @@ -146,14 +146,14 @@ pub fn exit<T>() -> Task<T> {
/// The appearance of a program.
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct Appearance {
/// The background [`Color`] of the application.
pub background_color: Color,
/// The background [`iced_core::Color`] of the application.
pub background_color: iced_core::Color,

/// The default text [`Color`] of the application.
pub text_color: Color,
/// The default text [`iced_core::Color`] of the application.
pub text_color: iced_core::Color,

/// The default icon [`Color`] of the application.
pub icon_color: Color,
/// The default icon [`iced_core::Color`] of the application.
pub icon_color: iced_core::Color,
}

/// The default style of a [`Program`].
Expand Down
2 changes: 1 addition & 1 deletion src/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ pub trait Program: Sized {
}

#[cfg(feature = "winit")]
/// Runs the [`Program`] with the given [`Settings`](crate::Settings) and a closure that creates the initial state.
/// Runs the [`Program`] with the given settings, and a closure that creates the initial state.
fn run_with<I>(
self,
settings: crate::Settings,
Expand Down
6 changes: 3 additions & 3 deletions widget/src/checkbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,14 +263,14 @@ where
}

#[cfg(feature = "a11y")]
/// Sets the name of the [`Button`].
/// Sets the name of the [`Checkbox`].
pub fn name(mut self, name: impl Into<Cow<'a, str>>) -> Self {
self.name = Some(name.into());
self
}

#[cfg(feature = "a11y")]
/// Sets the description of the [`Button`].
/// Sets the description of the [`Checkbox`].
pub fn description_widget<T: iced_accessibility::Describes>(
mut self,
description: &T,
Expand All @@ -282,7 +282,7 @@ where
}

#[cfg(feature = "a11y")]
/// Sets the description of the [`Button`].
/// Sets the description of the [`Checkbox`].
pub fn description(mut self, description: impl Into<Cow<'a, str>>) -> Self {
self.description =
Some(iced_accessibility::Description::Text(description.into()));
Expand Down
8 changes: 4 additions & 4 deletions widget/src/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,14 @@ impl<'a, Handle> Image<'a, Handle> {
}

#[cfg(feature = "a11y")]
/// Sets the name of the [`Button`].
/// Sets the name of the [`Image`].
pub fn name(mut self, name: impl Into<Cow<'a, str>>) -> Self {
self.name = Some(name.into());
self
}

#[cfg(feature = "a11y")]
/// Sets the description of the [`Button`].
/// Sets the description of the [`Image`].
pub fn description_widget<T: iced_accessibility::Describes>(
mut self,
description: &T,
Expand All @@ -168,15 +168,15 @@ impl<'a, Handle> Image<'a, Handle> {
}

#[cfg(feature = "a11y")]
/// Sets the description of the [`Button`].
/// Sets the description of the [`Image`].
pub fn description(mut self, description: impl Into<Cow<'a, str>>) -> Self {
self.description =
Some(iced_accessibility::Description::Text(description.into()));
self
}

#[cfg(feature = "a11y")]
/// Sets the label of the [`Button`].
/// Sets the label of the [`Image`].
pub fn label(mut self, label: &dyn iced_accessibility::Labels) -> Self {
self.label =
Some(label.label().into_iter().map(|l| l.into()).collect());
Expand Down
8 changes: 4 additions & 4 deletions widget/src/scrollable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,14 +268,14 @@ where
}

#[cfg(feature = "a11y")]
/// Sets the name of the [`Button`].
/// Sets the name of the [`Scrollable`].
pub fn name(mut self, name: impl Into<Cow<'a, str>>) -> Self {
self.name = Some(name.into());
self
}

#[cfg(feature = "a11y")]
/// Sets the description of the [`Button`].
/// Sets the description of the [`Scrollable`].
pub fn description_widget(
mut self,
description: &impl iced_accessibility::Describes,
Expand All @@ -287,15 +287,15 @@ where
}

#[cfg(feature = "a11y")]
/// Sets the description of the [`Button`].
/// Sets the description of the [`Scrollable`].
pub fn description(mut self, description: impl Into<Cow<'a, str>>) -> Self {
self.description =
Some(iced_accessibility::Description::Text(description.into()));
self
}

#[cfg(feature = "a11y")]
/// Sets the label of the [`Button`].
/// Sets the label of the [`Scrollable`].
pub fn label(mut self, label: &dyn iced_accessibility::Labels) -> Self {
self.label =
Some(label.label().into_iter().map(|l| l.into()).collect());
Expand Down
8 changes: 4 additions & 4 deletions widget/src/slider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,14 +239,14 @@ where
}

#[cfg(feature = "a11y")]
/// Sets the name of the [`Button`].
/// Sets the name of the [`Slider`].
pub fn name(mut self, name: impl Into<Cow<'a, str>>) -> Self {
self.name = Some(name.into());
self
}

#[cfg(feature = "a11y")]
/// Sets the description of the [`Button`].
/// Sets the description of the [`Slider`].
pub fn description_widget(
mut self,
description: &impl iced_accessibility::Describes,
Expand All @@ -258,15 +258,15 @@ where
}

#[cfg(feature = "a11y")]
/// Sets the description of the [`Button`].
/// Sets the description of the [`Slider`].
pub fn description(mut self, description: impl Into<Cow<'a, str>>) -> Self {
self.description =
Some(iced_accessibility::Description::Text(description.into()));
self
}

#[cfg(feature = "a11y")]
/// Sets the label of the [`Button`].
/// Sets the label of the [`Slider`].
pub fn label(mut self, label: &dyn iced_accessibility::Labels) -> Self {
self.label =
Some(label.label().into_iter().map(|l| l.into()).collect());
Expand Down
8 changes: 4 additions & 4 deletions widget/src/svg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,14 +179,14 @@ where
}

#[cfg(feature = "a11y")]
/// Sets the name of the [`Button`].
/// Sets the name of the [`Svg`].
pub fn name(mut self, name: impl Into<Cow<'a, str>>) -> Self {
self.name = Some(name.into());
self
}

#[cfg(feature = "a11y")]
/// Sets the description of the [`Button`].
/// Sets the description of the [`Svg`].
pub fn description_widget<T: iced_accessibility::Describes>(
mut self,
description: &T,
Expand All @@ -198,15 +198,15 @@ where
}

#[cfg(feature = "a11y")]
/// Sets the description of the [`Button`].
/// Sets the description of the [`Svg`].
pub fn description(mut self, description: impl Into<Cow<'a, str>>) -> Self {
self.description =
Some(iced_accessibility::Description::Text(description.into()));
self
}

#[cfg(feature = "a11y")]
/// Sets the label of the [`Button`].
/// Sets the label of the [`Svg`].
pub fn label(mut self, label: &dyn iced_accessibility::Labels) -> Self {
self.label =
Some(label.label().into_iter().map(|l| l.into()).collect());
Expand Down
8 changes: 4 additions & 4 deletions widget/src/toggler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,14 +263,14 @@ where
}

#[cfg(feature = "a11y")]
/// Sets the name of the [`Button`].
/// Sets the name of the [`Toggler`].
pub fn name(mut self, name: impl Into<Cow<'a, str>>) -> Self {
self.name = Some(name.into());
self
}

#[cfg(feature = "a11y")]
/// Sets the description of the [`Button`].
/// Sets the description of the [`Toggler`].
pub fn description_widget<T: iced_accessibility::Describes>(
mut self,
description: &T,
Expand All @@ -282,15 +282,15 @@ where
}

#[cfg(feature = "a11y")]
/// Sets the description of the [`Button`].
/// Sets the description of the [`Toggler`].
pub fn description(mut self, description: impl Into<Cow<'a, str>>) -> Self {
self.description =
Some(iced_accessibility::Description::Text(description.into()));
self
}

#[cfg(feature = "a11y")]
/// Sets the label of the [`Button`] using another widget.
/// Sets the label of the [`Toggler`] using another widget.
pub fn labeled_by_widget(
mut self,
label: &dyn iced_accessibility::Labels,
Expand Down
92 changes: 0 additions & 92 deletions winit/src/platform_specific/wayland/sctk_event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ use std::{
collections::HashMap,
num::NonZeroU32,
sync::{Arc, Mutex},
time::Instant,
};
use wayland_protocols::wp::viewporter::client::wp_viewport::WpViewport;
use winit::{
Expand All @@ -82,67 +81,6 @@ use super::{
winit_window::SctkWinitWindow,
};

pub enum IcedSctkEvent {
/// Emitted when new events arrive from the OS to be processed.
///
/// This event type is useful as a place to put code that should be done before you start
/// processing events, such as updating frame timing information for benchmarking or checking
/// the [`StartCause`] to see if a timer set by
/// [`ControlFlow::WaitUntil`](crate::platform_specific::wayland::event_loop::control_flow::ControlFlow::WaitUntil)
/// has elapsed.
NewEvents(StartCause),

/// An event produced by sctk
SctkEvent(SctkEvent),

/// Emitted when all of the event loop's input events have been processed and redraw processing
/// is about to begin.
///
/// This event is useful as a place to put your code that should be run after all
/// state-changing events have been handled and you want to do stuff (updating state, performing
/// calculations, etc) that happens as the "main body" of your event loop. If your program only draws
/// graphics when something changes, it's usually better to do it in response to
/// [`window::RedrawRequest`], which gets emitted
/// immediately after this event. Programs that draw graphics continuously, like most games,
/// can render here unconditionally for simplicity.
MainEventsCleared,

/// Emitted after [`MainEventsCleared`] when a window should be redrawn.
///
/// This gets triggered in two scenarios:
/// - The OS has performed an operation that's invalidated the window's contents (such as
/// resizing the window).
/// - The application has explicitly requested a redraw via [`iced_runtime::core::Shell::request_redraw`].
///
/// During each iteration of the event loop, Winit will aggregate duplicate redraw requests
/// into a single event, to help avoid duplicating rendering work.
///
/// Mainly of interest to applications with mostly-static graphics that avoid redrawing unless
/// something changes, like most non-game GUIs.
///
/// [`MainEventsCleared`]: Self::MainEventsCleared
RedrawRequested(ObjectId),

/// Emitted after all [`RedrawRequested`] events have been processed and control flow is about to
/// be taken away from the program. If there are no `RedrawRequested` events, it is emitted
/// immediately after `MainEventsCleared`.
///
/// This event is useful for doing any cleanup or bookkeeping work after all the rendering
/// tasks have been completed.
///
/// [`RedrawRequested`]: Self::RedrawRequested
RedrawEventsCleared,

/// Emitted when the event loop is being shut down.
///
/// This is irreversible - if this event is emitted, it is guaranteed to be the last event that
/// gets emitted. You generally want to treat this as an "do on quit" event.
LoopDestroyed,

/// Frame callback event
Frame(WlSurface, u32),
}

#[derive(Debug, Clone)]
pub enum SctkEvent {
//
Expand Down Expand Up @@ -324,36 +262,6 @@ pub enum LayerSurfaceEventVariant {
ScaleFactorChanged(f64, Option<WpViewport>),
}

/// Describes the reason the event loop is resuming.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum StartCause {
/// Sent if the time specified by [`ControlFlow::WaitUntil`] has been reached. Contains the
/// moment the timeout was requested and the requested resume time. The actual resume time is
/// guaranteed to be equal to or after the requested resume time.
///
/// [`ControlFlow::WaitUntil`]: crate::platform_specific::wayland::event_loop::control_flow::ControlFlow::WaitUntil
ResumeTimeReached {
start: Instant,
requested_resume: Instant,
},

/// Sent if the OS has new events to send to the window, after a wait was requested. Contains
/// the moment the wait was requested and the resume time, if requested.
WaitCancelled {
start: Instant,
requested_resume: Option<Instant>,
},

/// Sent if the event loop is being resumed after the loop's control flow was set to
/// [`ControlFlow::Poll`].
///
/// [`ControlFlow::Poll`]: crate::platform_specific::wayland::event_loop::control_flow::ControlFlow::Poll
Poll,

/// Sent once, immediately after `run` is called. Indicates that the loop was just initialized.
Init,
}

/// Pending update to a window requested by the user.
#[derive(Default, Debug, Clone, Copy)]
pub struct SurfaceUserRequest {
Expand Down

0 comments on commit ec8f7a7

Please sign in to comment.