More docs refactor.

This commit is contained in:
Samuel Guerra 2024-02-13 20:51:03 -03:00
parent a1319d5e26
commit 07696523fa
18 changed files with 88 additions and 74 deletions

View File

@ -5,7 +5,7 @@
- Review badges.
* Review docs.
- Do a full read, look for typos or failed links.
- Last reviewing `zero_ui::layer`.
- Last reviewing `zero_ui::mouse`.
# Publish

View File

@ -1041,7 +1041,7 @@ impl APP {
impl APP {
/// Gets a variable that configures if [`INSTANT.now`] is the same exact value during each update, info, layout or render pass.
///
/// Time is paused for each single pass by default, setting this to `false` will cause `INSTANT.now` to read
/// Time is paused for each single pass by default, setting this to `false` will cause [`INSTANT.now`] to read
/// the system time for every call.
///
/// [`INSTANT.now`]: crate::INSTANT::now

View File

@ -5,10 +5,10 @@ use std::{fmt, mem, sync::Arc};
use zero_ui_app_context::context_local;
use zero_ui_color::{colors, Hsla, Hsva, Rgba};
use zero_ui_layout::{
context::LAYOUT,
context::{LayoutMask, LAYOUT},
unit::{
Factor, FactorPercent, FactorSideOffsets, FactorUnits, Layout2d, LayoutMask, Length, PxCornerRadius, PxPoint, PxRect,
PxSideOffsets, PxSize, Size,
Factor, FactorPercent, FactorSideOffsets, FactorUnits, Layout2d, Length, PxCornerRadius, PxPoint, PxRect, PxSideOffsets, PxSize,
Size,
},
};
use zero_ui_var::{

View File

@ -21,10 +21,10 @@ mod hit;
pub(crate) use hit::{HitTestClips, ParallelSegmentOffsets};
use zero_ui_clone_move::clmv;
use zero_ui_layout::{
context::LayoutMetricsSnapshot,
context::{LayoutMask, LayoutMetricsSnapshot},
unit::{
euclid, DistanceKey, Factor, FactorUnits, LayoutMask, Orientation2D, Px, PxBox, PxCornerRadius, PxPoint, PxRect, PxSideOffsets,
PxSize, PxTransform, PxVector,
euclid, DistanceKey, Factor, FactorUnits, Orientation2D, Px, PxBox, PxCornerRadius, PxPoint, PxRect, PxSideOffsets, PxSize,
PxTransform, PxVector,
},
};
use zero_ui_state_map::{OwnedStateMap, StateMapRef};

View File

@ -1,7 +1,7 @@
use parking_lot::Mutex;
use zero_ui_layout::{
context::{InlineConstraints, InlineConstraintsLayout, InlineConstraintsMeasure, InlineSegment, InlineSegmentPos, LAYOUT},
unit::{Factor, LayoutMask, Px, PxBox, PxPoint, PxRect, PxSize, PxVector},
context::{InlineConstraints, InlineConstraintsLayout, InlineConstraintsMeasure, InlineSegment, InlineSegmentPos, LayoutMask, LAYOUT},
unit::{Factor, Px, PxBox, PxPoint, PxRect, PxSize, PxVector},
};
use zero_ui_state_map::{OwnedStateMap, StateId, StateMapMut, StateValue};
use zero_ui_unique_id::{IdMap, IdSet};

View File

@ -2,7 +2,10 @@
use std::fmt;
use zero_ui_layout::unit::{about_eq, about_eq_hash, AngleDegree, Factor, FactorUnits, Layout1d, Layout2d, LayoutMask, Length, Point};
use zero_ui_layout::{
context::LayoutMask,
unit::{about_eq, about_eq_hash, AngleDegree, Factor, FactorUnits, Layout1d, Layout2d, Length, Point},
};
use zero_ui_var::{
animation::{easing::EasingStep, Transitionable},
impl_from_and_into_var,

View File

@ -1419,8 +1419,7 @@ impl MOUSE {
///
/// In headless apps the default is [`MultiClickConfig::default`] and does not change.
///
/// Internally the [`RAW_MULTI_CLICK_CONFIG_CHANGED_EVENT`] is listened to update this variable, so you can notify
/// this event to set this variable, if you really must.
/// Internally the [`RAW_MULTI_CLICK_CONFIG_CHANGED_EVENT`] is listened to update this variable.
pub fn multi_click_config(&self) -> ReadOnlyArcVar<MultiClickConfig> {
MOUSE_SV.read().multi_click_config.read_only()
}

View File

@ -150,8 +150,7 @@ impl TOUCH {
///
/// In headless apps the default is [`TouchConfig::default`] and does not change.
///
/// Internally the [`RAW_TOUCH_CONFIG_CHANGED_EVENT`] is listened to update this variable, so you can notify
/// this event to set this variable, if you really must.
/// Internally the [`RAW_TOUCH_CONFIG_CHANGED_EVENT`] is listened to update this variable.
pub fn touch_config(&self) -> ReadOnlyArcVar<TouchConfig> {
TOUCH_SV.read().touch_config.read_only()
}

View File

@ -141,7 +141,7 @@ type StatusError = Vec<Arc<dyn std::error::Error + Send + Sync>>;
/// Localized message variable builder.
///
/// See [`L10N.message`] for more details.
///
///
/// [`L10N.message`]: L10N::message
pub struct L10nMessageBuilder {
pub(super) file: Txt,

View File

@ -2,6 +2,7 @@
use std::{fmt, sync::Arc};
use bitflags::bitflags;
use unicode_bidi::BidiDataSource as _;
use zero_ui_app_context::context_local;
use zero_ui_unit::{about_eq, about_eq_hash, euclid, Factor, Px, PxRect, PxSize};
@ -9,7 +10,7 @@ use zero_ui_var::context_var;
use atomic::{Atomic, Ordering::Relaxed};
use crate::unit::{LayoutAxis, LayoutMask, Ppi, PxConstraints, PxConstraints2d};
use crate::unit::{LayoutAxis, Ppi, PxConstraints, PxConstraints2d};
/// Current layout context.
///
@ -216,7 +217,6 @@ impl LAYOUT {
/// Context leftover length for the widget, given the [`Length::Leftover`] value it communicated to the parent.
///
/// [`leftover_count`]: Self::leftover_count
/// [`Length::Leftover`]: crate::unit::Length::Leftover
pub fn leftover(&self) -> euclid::Size2D<Option<Px>, ()> {
LAYOUT_CTX.get().metrics.leftover()
@ -923,3 +923,36 @@ impl From<TextSegmentKind> for unicode_bidi::BidiClass {
}
}
}
bitflags! {
/// Mask of values that can affect the layout operation of a value.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, bytemuck::NoUninit)]
#[repr(transparent)]
pub struct LayoutMask: u32 {
/// The `default_value`.
const DEFAULT_VALUE = 1 << 31;
/// The [`LayoutMetrics::constraints`], [`LayoutMetrics::z_constraints`] and [`LayoutMetrics::inline_constraints`].
const CONSTRAINTS = 1 << 30;
/// The [`LayoutMetrics::font_size`].
const FONT_SIZE = 1;
/// The [`LayoutMetrics::root_font_size`].
const ROOT_FONT_SIZE = 1 << 1;
/// The [`LayoutMetrics::scale_factor`].
const SCALE_FACTOR = 1 << 2;
/// The [`LayoutMetrics::viewport`].
const VIEWPORT = 1 << 3;
/// The [`LayoutMetrics::screen_ppi`].
const SCREEN_PPI = 1 << 4;
/// The [`LayoutMetrics::direction`].
const DIRECTION = 1 << 5;
/// The [`LayoutMetrics::leftover`].
const LEFTOVER = 1 << 6;
}
}
impl Default for LayoutMask {
/// Empty.
fn default() -> Self {
LayoutMask::empty()
}
}

View File

@ -44,6 +44,8 @@ pub use transform::*;
mod vector;
pub use vector::*;
use crate::context::LayoutMask;
/// Implement From<{tuple of Into<Length>}> and IntoVar for Length compound types.
macro_rules! impl_length_comp_conversions {
($(

View File

@ -3,13 +3,12 @@ use super::{
};
use std::{fmt, mem, ops};
use bitflags::bitflags;
use zero_ui_var::{
animation::{easing::EasingStep, Transitionable},
impl_from_and_into_var,
};
use crate::context::LAYOUT;
use crate::context::{LayoutMask, LAYOUT};
/// 1D length units.
///
@ -665,39 +664,6 @@ impl super::Layout1d for Length {
}
}
bitflags! {
/// Mask of values that can affect the [`Length::layout`] operation.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, bytemuck::NoUninit)]
#[repr(transparent)]
pub struct LayoutMask: u32 {
/// The `default_value`.
const DEFAULT_VALUE = 1 << 31;
/// The [`LayoutMetrics::constraints`], [`LayoutMetrics::z_constraints`] and [`LayoutMetrics::inline_constraints`].
const CONSTRAINTS = 1 << 30;
/// The [`LayoutMetrics::font_size`].
const FONT_SIZE = 1;
/// The [`LayoutMetrics::root_font_size`].
const ROOT_FONT_SIZE = 1 << 1;
/// The [`LayoutMetrics::scale_factor`].
const SCALE_FACTOR = 1 << 2;
/// The [`LayoutMetrics::viewport`].
const VIEWPORT = 1 << 3;
/// The [`LayoutMetrics::screen_ppi`].
const SCREEN_PPI = 1 << 4;
/// The [`LayoutMetrics::direction`].
const DIRECTION = 1 << 5;
/// The [`LayoutMetrics::leftover`] and [`LayoutMetrics::leftover_count`].
const LEFTOVER = 1 << 6;
}
}
impl Default for LayoutMask {
/// Empty.
fn default() -> Self {
LayoutMask::empty()
}
}
/// Represents an unresolved [`Length`] expression.
#[derive(Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub enum LengthExpr {

View File

@ -49,70 +49,70 @@ event_property! {
filter: |args| args.is_mouse_up() && args.is_enabled(WIDGET.id()) && args.capture_allows(),
}
/// Mouse clicked on the widget with any button and including double+ clicks and the widget is enabled.
/// Mouse clicked on the widget with any button and including repeat clicks and it is enabled.
pub fn mouse_any_click {
event: MOUSE_CLICK_EVENT,
args: MouseClickArgs,
filter: |args| args.is_enabled(WIDGET.id()),
}
/// Mouse clicked on the widget with any button and including double+ clicks and the widget is disabled.
/// Mouse clicked on the disabled widget with any button, including repeat clicks.
pub fn disabled_mouse_any_click {
event: MOUSE_CLICK_EVENT,
args: MouseClickArgs,
filter: |args| args.is_disabled(WIDGET.id()),
}
/// Mouse clicked on the widget with any button but excluding double+ clicks and the widget is enabled.
/// Mouse clicked on the widget with any button but excluding repeat clicks and it is enabled.
pub fn mouse_any_single_click {
event: MOUSE_CLICK_EVENT,
args: MouseClickArgs,
filter: |args| args.is_single() && args.is_enabled(WIDGET.id()),
}
/// Mouse double clicked on the widget with any button and the widget is enabled.
/// Mouse double clicked on the widget with any button and it is enabled.
pub fn mouse_any_double_click {
event: MOUSE_CLICK_EVENT,
args: MouseClickArgs,
filter: |args| args.is_double() && args.is_enabled(WIDGET.id()),
}
/// Mouse triple clicked on the widget with any button and the widget is enabled.
/// Mouse triple clicked on the widget with any button and it is enabled.
pub fn mouse_any_triple_click {
event: MOUSE_CLICK_EVENT,
args: MouseClickArgs,
filter: |args| args.is_triple() && args.is_enabled(WIDGET.id()),
}
/// Mouse clicked on the widget with the primary button including double+ clicks and the widget is enabled.
/// Mouse clicked on the widget with the primary button including repeat clicks and it is enabled.
pub fn mouse_click {
event: MOUSE_CLICK_EVENT,
args: MouseClickArgs,
filter: |args| args.is_primary() && args.is_enabled(WIDGET.id()),
}
/// Mouse clicked on the widget with the primary button including double+ clicks and the widget is disabled.
/// Mouse clicked on the disabled widget with the primary button, including repeat clicks.
pub fn disabled_mouse_click {
event: MOUSE_CLICK_EVENT,
args: MouseClickArgs,
filter: |args| args.is_primary() && args.is_disabled(WIDGET.id()),
}
/// Mouse clicked on the widget with the primary button excluding double+ clicks and the widget is enabled.
/// Mouse clicked on the widget with the primary button excluding repeat clicks and it is enabled.
pub fn mouse_single_click {
event: MOUSE_CLICK_EVENT,
args: MouseClickArgs,
filter: |args| args.is_primary() && args.is_single() && args.is_enabled(WIDGET.id()),
}
/// Mouse double clicked on the widget with the primary button and the widget is enabled.
/// Mouse double clicked on the widget with the primary button and it is enabled.
pub fn mouse_double_click {
event: MOUSE_CLICK_EVENT,
args: MouseClickArgs,
filter: |args| args.is_primary() && args.is_double() && args.is_enabled(WIDGET.id()),
}
/// Mouse triple clicked on the widget with the primary button and the widget is enabled.
/// Mouse triple clicked on the widget with the primary button and it is enabled.
pub fn mouse_triple_click {
event: MOUSE_CLICK_EVENT,
args: MouseClickArgs,
@ -152,14 +152,14 @@ event_property! {
filter: |args| args.is_disabled(WIDGET.id()) && args.capture_allows(),
}
/// Mouse wheel scrolled while pointer is hovering widget and the widget is enabled.
/// Mouse wheel scrolled while pointer is hovering widget and it is enabled.
pub fn mouse_wheel {
event: MOUSE_WHEEL_EVENT,
args: MouseWheelArgs,
filter: |args| args.is_enabled(WIDGET.id()),
}
/// Mouse wheel scrolled while pointer is hovering widget and the widget is disabled.
/// Mouse wheel scrolled while pointer is hovering widget and it is disabled.
pub fn disabled_mouse_wheel {
event: MOUSE_WHEEL_EVENT,
args: MouseWheelArgs,

View File

@ -86,7 +86,7 @@ pub fn is_cap_hovered(child: impl UiNode, state: impl IntoVar<bool>) -> impl UiN
)
}
/// If the mouse pointer is pressed in the widget and the widget is [`ENABLED`].
/// If the mouse pointer is pressed in the widget and it is enabled.
///
/// This is `true` when the mouse primary button started pressing in the widget
/// and the pointer is over the widget and the primary button is still pressed and
@ -163,7 +163,7 @@ pub fn is_mouse_pressed(child: impl UiNode, state: impl IntoVar<bool>) -> impl U
)
}
/// If the mouse pointer is pressed in the widget or was captured during press and the widget is [`ENABLED`].
/// If the mouse pointer is pressed or captured by the widget and it is enabled.
///
/// [`ENABLED`]: Interactivity::ENABLED
#[property(EVENT)]

View File

@ -87,6 +87,8 @@ pub fn panel_fn(child: impl UiNode, panel: impl IntoVar<WidgetFn<zero_ui_wgt_pan
/// Default [`Menu!`] style.
///
/// Gives the button a *menu-item* look.
///
/// [`Menu!`]: struct@Menu
#[widget($crate::DefaultStyle)]
pub struct DefaultStyle(Style);
impl DefaultStyle {
@ -107,6 +109,9 @@ impl DefaultStyle {
/// Style applied to all [`Button!`] widgets inside [`Menu!`].
///
/// Gives the button a *menu-item* look.
///
/// [`Button!`]: struct@zero_ui_wgt_button::Button
/// [`Menu!`]: struct@Menu
#[widget($crate::ButtonStyle)]
pub struct ButtonStyle(Style);
impl ButtonStyle {
@ -180,6 +185,9 @@ impl TouchButtonStyle {
/// Style applied to all [`Button!`] widgets inside [`Menu!`].
///
/// Gives the toggle a *menu-item* look, the checkmark is placed in the icon position.
///
/// [`Button!`]: struct@zero_ui_wgt_button::Button
/// [`Menu!`]: struct@Menu
#[widget($crate::ToggleStyle)]
pub struct ToggleStyle(ButtonStyle);
impl ToggleStyle {

View File

@ -360,6 +360,7 @@ pub fn end_column(child: impl UiNode, cell: impl UiNode) -> impl UiNode {
/// multiple times to generate duplicates of the start cell.
///
/// [`start_column`]: fn@start_column
/// [`WidgetFn<()>`]: WidgetFn
#[property(FILL)]
pub fn start_column_fn(child: impl UiNode, cell_fn: impl IntoVar<WidgetFn<()>>) -> impl UiNode {
start_column(child, presenter((), cell_fn))
@ -371,6 +372,7 @@ pub fn start_column_fn(child: impl UiNode, cell_fn: impl IntoVar<WidgetFn<()>>)
/// multiple times to generate duplicates of the start cell.
///
/// [`end_column`]: fn@end_column
/// [`WidgetFn<()>`]: WidgetFn
#[property(FILL)]
pub fn end_column_fn(child: impl UiNode, cell_fn: impl IntoVar<WidgetFn<()>>) -> impl UiNode {
end_column(child, presenter((), cell_fn))
@ -474,6 +476,8 @@ impl DefaultStyle {
}
/// Style applied to all [`SubMenu!`] widgets inside other sub-menus.
///
/// [`SubMenu!`]: struct@SubMenu
#[widget($crate::sub::SubMenuStyle)]
pub struct SubMenuStyle(ButtonStyle);
impl SubMenuStyle {

View File

@ -1,5 +1,5 @@
use std::{fmt, mem, ops};
use zero_ui_layout::unit::LayoutMask;
use zero_ui_layout::context::LayoutMask;
use zero_ui_var::animation::{easing::EasingStep, Transitionable};
use zero_ui_wgt::prelude::*;

View File

@ -349,15 +349,15 @@
pub use zero_ui_layout::unit::{
slerp_enabled, slerp_sampler, Align, AngleDegree, AngleGradian, AngleRadian, AngleTurn, AngleUnits, BoolVector2D, ByteLength,
ByteUnits, CornerRadius2D, Dip, DipBox, DipCornerRadius, DipPoint, DipRect, DipSideOffsets, DipSize, DipToPx, DipVector, DistanceKey,
Factor, Factor2d, FactorPercent, FactorSideOffsets, FactorUnits, GridSpacing, Layout1d, Layout2d, LayoutAxis, LayoutMask, Length,
LengthExpr, LengthUnits, Line, LineFromTuplesBuilder, Orientation2D, Point, Ppi, Ppm, Px, PxBox, PxConstraints, PxConstraints2d,
PxCornerRadius, PxGridSpacing, PxLine, PxPoint, PxRect, PxSideOffsets, PxSize, PxToDip, PxTransform, PxVector, Rect,
RectFromTuplesBuilder, RenderAngle, ResolutionUnits, SideOffsets, SideOffsets2D, Size, TimeUnits, Transform, Vector,
Factor, Factor2d, FactorPercent, FactorSideOffsets, FactorUnits, GridSpacing, Layout1d, Layout2d, LayoutAxis, Length, LengthExpr,
LengthUnits, Line, LineFromTuplesBuilder, Orientation2D, Point, Ppi, Ppm, Px, PxBox, PxConstraints, PxConstraints2d, PxCornerRadius,
PxGridSpacing, PxLine, PxPoint, PxRect, PxSideOffsets, PxSize, PxToDip, PxTransform, PxVector, Rect, RectFromTuplesBuilder,
RenderAngle, ResolutionUnits, SideOffsets, SideOffsets2D, Size, TimeUnits, Transform, Vector,
};
pub use zero_ui_layout::context::{
InlineConstraints, InlineConstraintsLayout, InlineConstraintsMeasure, InlineSegment, InlineSegmentPos, LayoutDirection, LayoutMetrics,
LayoutMetricsSnapshot, LayoutPassId, TextSegmentKind, DIRECTION_VAR, LAYOUT,
InlineConstraints, InlineConstraintsLayout, InlineConstraintsMeasure, InlineSegment, InlineSegmentPos, LayoutDirection, LayoutMask,
LayoutMetrics, LayoutMetricsSnapshot, LayoutPassId, TextSegmentKind, DIRECTION_VAR, LAYOUT,
};
pub use zero_ui_app::widget::info::{WidgetLayout, WidgetMeasure};