Fixed typos.
This commit is contained in:
parent
242c3cbb07
commit
7a966d6f05
|
@ -1,3 +1,15 @@
|
|||
{
|
||||
"rust.features": ["app_profiler"]
|
||||
"rust.features": [
|
||||
"app_profiler"
|
||||
],
|
||||
"spellright.language": [
|
||||
"en"
|
||||
],
|
||||
"spellright.documentTypes": [
|
||||
"markdown",
|
||||
"latex",
|
||||
"plaintext",
|
||||
"rust",
|
||||
"toml"
|
||||
]
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
ctx
|
||||
scancode
|
||||
winit
|
||||
formatx
|
||||
vn
|
|
@ -291,7 +291,7 @@ version = "0.1.6"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"procedural-masquerade 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"syn 1.0.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -299,9 +299,9 @@ name = "derive_more"
|
|||
version = "0.99.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"proc-macro2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"syn 1.0.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -634,8 +634,8 @@ name = "malloc_size_of_derive"
|
|||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"proc-macro2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"syn 1.0.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"synstructure 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
|
@ -810,9 +810,9 @@ name = "peek-poke-derive"
|
|||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"proc-macro2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"syn 1.0.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"synstructure 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
@ -851,9 +851,9 @@ name = "proc-macro-hack"
|
|||
version = "0.5.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"proc-macro2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"syn 1.0.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -871,7 +871,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.8"
|
||||
version = "1.0.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -895,7 +895,7 @@ name = "quote"
|
|||
version = "1.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"proc-macro2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1138,10 +1138,10 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.14"
|
||||
version = "1.0.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"proc-macro2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
@ -1151,9 +1151,9 @@ name = "synstructure"
|
|||
version = "0.12.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"proc-macro2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"syn 1.0.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
|
@ -1463,9 +1463,9 @@ version = "0.1.0"
|
|||
dependencies = [
|
||||
"proc-macro-crate 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"proc-macro-hack 0.5.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"proc-macro2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"syn 1.0.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[metadata]
|
||||
|
@ -1575,7 +1575,7 @@ dependencies = [
|
|||
"checksum proc-macro-hack 0.5.11 (registry+https://github.com/rust-lang/crates.io-index)" = "ecd45702f76d6d3c75a80564378ae228a85f0b59d2f3ed43c91b4a69eb2ebfc5"
|
||||
"checksum proc-macro-nested 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "369a6ed065f249a159e06c45752c780bda2fb53c995718f9e484d08daa9eb42e"
|
||||
"checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759"
|
||||
"checksum proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3acb317c6ff86a4e579dfa00fc5e6cca91ecbb4e7eb2df0468805b674eb88548"
|
||||
"checksum proc-macro2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)" = "6c09721c6781493a2a492a96b5a5bf19b65917fe6728884e7c44dd0c60ca3435"
|
||||
"checksum procedural-masquerade 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "9a1574a51c3fd37b26d2c0032b649d08a7d51d4cca9c41bbc5bf7118fa4509d0"
|
||||
"checksum quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1"
|
||||
"checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe"
|
||||
|
@ -1608,7 +1608,7 @@ dependencies = [
|
|||
"checksum stb_truetype 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f77b6b07e862c66a9f3e62a07588fee67cd90a9135a2b942409f195507b4fb51"
|
||||
"checksum svg_fmt 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8fb1df15f412ee2e9dfc1c504260fa695c1c3f10fe9f4a6ee2d2184d7d6450e2"
|
||||
"checksum syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)" = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5"
|
||||
"checksum syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)" = "af6f3550d8dff9ef7dc34d384ac6f107e5d31c8f57d9f28e0081503f547ac8f5"
|
||||
"checksum syn 1.0.16 (registry+https://github.com/rust-lang/crates.io-index)" = "123bd9499cfb380418d509322d7a6d52e5315f064fe4b3ad18a53d6b92c07859"
|
||||
"checksum synstructure 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "67656ea1dc1b41b1451851562ea232ec2e5a80242139f7e679ceccfb5d61f545"
|
||||
"checksum thread_profiler 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "5920e77802b177479ab5795767fa48e68f61b2f516c2ac0041e2978dd8efe483"
|
||||
"checksum time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f"
|
||||
|
|
|
@ -8,21 +8,21 @@ extern crate enclose;
|
|||
use zero_ui::prelude::*;
|
||||
|
||||
fn main() {
|
||||
//App::default().run(|ctx| {
|
||||
// ctx.services.req::<Windows>().open(|ctx| {
|
||||
// window! {
|
||||
// title: "Button Example";
|
||||
// => example()
|
||||
// }
|
||||
// });
|
||||
//})
|
||||
App::default().run(|ctx| {
|
||||
//ctx.services.req::<Windows>().open(|ctx| {
|
||||
// window! {
|
||||
// title: "Button Example";
|
||||
// => example()
|
||||
// }
|
||||
//});
|
||||
})
|
||||
}
|
||||
|
||||
fn example() -> impl UiNode {
|
||||
let t = var("Click Me!");
|
||||
button! {
|
||||
on_click: enclose!{ (t) move |a| {
|
||||
a.ctx().updates.push_set(&t, "Clicked!".to_text());
|
||||
a.ctx().updates.push_set(&t, "Clicked!".to_text()).ok();
|
||||
}};
|
||||
align: Alignment::CENTER;
|
||||
font_size: 28;
|
||||
|
|
|
@ -53,7 +53,7 @@ pub trait AppExtension: 'static {
|
|||
#[inline]
|
||||
fn on_shutdown_requested(&mut self, _args: &ShutdownRequestedArgs, _ctx: &mut AppContext) {}
|
||||
|
||||
/// Called when the application is shuting down.
|
||||
/// Called when the application is shutting down.
|
||||
///
|
||||
/// Update requests generated during this call are ignored.
|
||||
#[inline]
|
||||
|
@ -195,7 +195,7 @@ impl<E: AppExtension> AppExtended<E> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Runs the application event loop calling `start` once at the begining.
|
||||
/// Runs the application event loop calling `start` once at the beginning.
|
||||
#[inline]
|
||||
pub fn run(self, start: impl FnOnce(&mut AppContext)) -> ! {
|
||||
profile_scope!("app::run");
|
||||
|
|
|
@ -86,7 +86,7 @@ pub struct UpdateRequest {
|
|||
/// If should notify all that variables or events change occurred.
|
||||
pub update: bool,
|
||||
/// If should notify all that variables or events change occurred using
|
||||
/// the hight-pressure band when applicable.
|
||||
/// the high-pressure band when applicable.
|
||||
pub update_hp: bool,
|
||||
}
|
||||
|
||||
|
@ -185,7 +185,7 @@ pub type ContextVarStageId = (Option<WidgetId>, u32);
|
|||
impl Vars {
|
||||
/// Produces the instance of `Vars`. Only a single
|
||||
/// instance can exist at a time, panics if called
|
||||
/// again before droping the previous instance.
|
||||
/// again before dropping the previous instance.
|
||||
pub fn instance() -> Self {
|
||||
Vars {
|
||||
context_vars: RefCell::default(),
|
||||
|
@ -421,7 +421,7 @@ pub struct Events {
|
|||
impl Events {
|
||||
/// Produces the instance of `Events`. Only a single
|
||||
/// instance can exist at a time, panics if called
|
||||
/// again before droping the previous instance.
|
||||
/// again before dropping the previous instance.
|
||||
pub fn instance() -> Self {
|
||||
Events {
|
||||
events: Default::default(),
|
||||
|
@ -459,7 +459,7 @@ impl Events {
|
|||
/// Identifies an application level service type.
|
||||
pub trait AppService: 'static {}
|
||||
|
||||
/// Indentifies a window level service type.
|
||||
/// Identifies a window level service type.
|
||||
pub trait WindowService: 'static {}
|
||||
|
||||
#[derive(Default)]
|
||||
|
@ -539,7 +539,7 @@ pub struct WindowServicesInit {
|
|||
impl WindowServicesInit {
|
||||
/// Register a new window service initializer.
|
||||
///
|
||||
/// Window services have diferent instances for each window and exist for the duration
|
||||
/// Window services have different instances for each window and exist for the duration
|
||||
/// of that window. The `new` closure is called when a new window is created to
|
||||
pub fn register<S: WindowService>(&mut self, new: impl Fn(&WindowContext) -> S + 'static) {
|
||||
self.builders.push((TypeId::of::<S>(), Box::new(move |ctx| Box::new(new(ctx)))));
|
||||
|
@ -609,7 +609,7 @@ impl OwnedUpdates {
|
|||
/// # Assert Borrows
|
||||
///
|
||||
/// When variable and event values are borrowed the instance of `Vars`/`Events` is
|
||||
/// imutable borrowed, so the requirement of borrowing both mutable here is an assert
|
||||
/// immutable borrowed, so the requirement of borrowing both mutable here is an assert
|
||||
/// that all variable and event borrows have been dropped.
|
||||
pub fn apply_updates(
|
||||
&mut self,
|
||||
|
@ -655,7 +655,7 @@ impl Updates {
|
|||
}
|
||||
}
|
||||
|
||||
/// Clonable out-of-band notification sender.
|
||||
/// Cloneable out-of-band notification sender.
|
||||
pub fn notifier(&self) -> &UpdateNotifier {
|
||||
&self.notifier
|
||||
}
|
||||
|
@ -698,7 +698,7 @@ impl Updates {
|
|||
self.update.update = true;
|
||||
}
|
||||
|
||||
/// Schelues a high-pressure update.
|
||||
/// Schedules a high-pressure update.
|
||||
pub fn push_update_hp(&mut self) {
|
||||
self.update.update_hp = true;
|
||||
}
|
||||
|
@ -844,7 +844,7 @@ pub struct AppContext<'a> {
|
|||
pub type WindowState = StateMap;
|
||||
|
||||
impl<'a> AppContext<'a> {
|
||||
/// Initializes state and services for a new iwndow.
|
||||
/// Initializes state and services for a new window.
|
||||
pub fn new_window(&mut self, window_id: WindowId, render_api: &Arc<RenderApi>) -> (WindowState, WindowServices) {
|
||||
let mut window_state = StateMap::default();
|
||||
let mut event_state = StateMap::default();
|
||||
|
|
|
@ -318,8 +318,8 @@ impl<'a> WidgetFocusInfo<'a> {
|
|||
(Some(false), _, _, _, _) => FocusInfo::NotFocusable,
|
||||
|
||||
// Set as focus scope and not set as not focusable
|
||||
// or set tab nav and did not set as not focus scope
|
||||
// or set directional nav and did not set as not focus scope.
|
||||
// or set tab navigation and did not set as not focus scope
|
||||
// or set directional navigation and did not set as not focus scope.
|
||||
(_, Some(true), idx, tab, dir) | (_, None, idx, tab @ Some(_), dir) | (_, None, idx, tab, dir @ Some(_)) => {
|
||||
FocusInfo::FocusScope(
|
||||
idx.unwrap_or(TabIndex::AUTO),
|
||||
|
|
|
@ -150,7 +150,7 @@ impl Event for MouseClick {
|
|||
type Args = MouseClickArgs;
|
||||
}
|
||||
|
||||
/// Mouse singleclick event ([click_count](MouseClickArgs::click_count) = `1`).
|
||||
/// Mouse single-click event ([click_count](MouseClickArgs::click_count) = `1`).
|
||||
pub struct MouseSingleClick;
|
||||
impl Event for MouseSingleClick {
|
||||
type Args = MouseClickArgs;
|
||||
|
|
|
@ -236,7 +236,7 @@ impl FrameBuilder {
|
|||
.push_gradient(&self.common_item_properties(rect.clone()), rect, gradient, tile_size, tile_spacing);
|
||||
}
|
||||
|
||||
/// Finializes the build.
|
||||
/// Finalizes the build.
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
|
@ -278,7 +278,7 @@ pub struct FrameHitInfo {
|
|||
}
|
||||
|
||||
impl FrameHitInfo {
|
||||
/// Initializes from a webrender hit-test result.
|
||||
/// Initializes from a Webrender hit-test result.
|
||||
///
|
||||
/// Only item tags produced by [FrameBuilder] are expected.
|
||||
///
|
||||
|
@ -653,7 +653,7 @@ impl<'a> WidgetInfo<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Widget retangle in the frame.
|
||||
/// Widget rectangle in the frame.
|
||||
#[inline]
|
||||
pub fn bounds(self) -> &'a LayoutRect {
|
||||
&self.info().bounds
|
||||
|
|
|
@ -64,7 +64,7 @@ pub(crate) mod protected {
|
|||
}
|
||||
}
|
||||
|
||||
/// Error when trying to set or motify a read-only variable.
|
||||
/// Error when trying to set or modify a read-only variable.
|
||||
#[derive(Debug, Hash, PartialEq, Eq)]
|
||||
pub struct VarIsReadOnly;
|
||||
|
||||
|
@ -227,7 +227,7 @@ impl<T: VarValue> LocalVar<T> for BoxLocalVar<T> {
|
|||
/// to support boxing.
|
||||
///
|
||||
/// Cannot be implemented outside of zero-ui crate. Use this together with [IntoVar] to
|
||||
/// support dinamic values in property definitions.
|
||||
/// support dynamic values in property definitions.
|
||||
pub trait Var<T: VarValue>: ObjVar<T> {
|
||||
/// Return type of [as_read_only](Var::as_read_only).
|
||||
type AsReadOnly: Var<T>;
|
||||
|
|
|
@ -49,7 +49,7 @@ macro_rules! stack {
|
|||
stack!(HStack, width, height, x);
|
||||
stack!(VStack, height, width, y);
|
||||
|
||||
/// Stack the children in a line (X). The first child at the begining (0, 0) the last child
|
||||
/// Stack the children in a line (X). The first child at the beginning (0, 0) the last child
|
||||
/// at the end (n, 0);
|
||||
pub fn h_stack<T: UiNode>(children: Stack<T>) -> impl UiNode {
|
||||
HStack { children: children.stack }
|
||||
|
|
|
@ -30,7 +30,7 @@ macro_rules! uid {
|
|||
$(#[$outer])*
|
||||
/// # Details
|
||||
/// Underlying value is a `NonZeroU64` generated using a relaxed global atomic `fetch_add`,
|
||||
/// so IDs are unique for the process duration but order is not garanteed.
|
||||
/// so IDs are unique for the process duration, but order is not guaranteed.
|
||||
///
|
||||
/// Panics if you somehow reach `u64::max_value()` calls to `new`.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
||||
|
@ -313,7 +313,7 @@ macro_rules! event_args {
|
|||
|
||||
/// Declares new [`CancelableEventArgs`](crate::core::event::CancelableEventArgs) types.
|
||||
///
|
||||
/// Same sintax as [`event_args!`](event_args) but the generated args is also cancelable.
|
||||
/// Same syntax as [`event_args!`](event_args) but the generated args is also cancelable.
|
||||
///
|
||||
/// # Example
|
||||
/// ```
|
||||
|
|
|
@ -4,7 +4,7 @@ use crate::core::types::*;
|
|||
use crate::core::var::*;
|
||||
use crate::core::UiNode;
|
||||
use crate::{impl_ui_node, property};
|
||||
use webrender::api as wapi;
|
||||
use webrender::api as w_api;
|
||||
|
||||
impl IntoVar<BorderDetails> for ColorF {
|
||||
type Var = OwnedVar<BorderDetails>;
|
||||
|
@ -131,24 +131,24 @@ impl LayoutSideOffsetsExt for LayoutSideOffsets {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<BorderStyle> for wapi::BorderStyle {
|
||||
impl From<BorderStyle> for w_api::BorderStyle {
|
||||
fn from(border_style: BorderStyle) -> Self {
|
||||
// SAFETY: wapi::BorderStyle is also repr(u32)
|
||||
// SAFETY: w_api::BorderStyle is also repr(u32)
|
||||
// and contains all values
|
||||
unsafe { std::mem::transmute(border_style) }
|
||||
}
|
||||
}
|
||||
impl From<BorderSide> for wapi::BorderSide {
|
||||
impl From<BorderSide> for w_api::BorderSide {
|
||||
fn from(border_side: BorderSide) -> Self {
|
||||
wapi::BorderSide {
|
||||
w_api::BorderSide {
|
||||
color: border_side.color,
|
||||
style: border_side.style.into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
impl From<BorderDetails> for wapi::BorderDetails {
|
||||
impl From<BorderDetails> for w_api::BorderDetails {
|
||||
fn from(border_details: BorderDetails) -> Self {
|
||||
wapi::BorderDetails::Normal(wapi::NormalBorder {
|
||||
w_api::BorderDetails::Normal(w_api::NormalBorder {
|
||||
left: border_details.left.into(),
|
||||
right: border_details.right.into(),
|
||||
top: border_details.top.into(),
|
||||
|
@ -163,7 +163,7 @@ struct Border<T: UiNode, L: LocalVar<LayoutSideOffsets>, B: Var<BorderDetails>>
|
|||
child: T,
|
||||
widths: L,
|
||||
details: B,
|
||||
render_details: wapi::BorderDetails,
|
||||
render_details: w_api::BorderDetails,
|
||||
child_rect: LayoutRect,
|
||||
final_size: LayoutSize,
|
||||
visible: bool,
|
||||
|
@ -243,19 +243,19 @@ pub fn border(child: impl UiNode, widths: impl IntoVar<LayoutSideOffsets>, detai
|
|||
}
|
||||
}
|
||||
|
||||
fn border_details_none() -> wapi::BorderDetails {
|
||||
let side_none = wapi::BorderSide {
|
||||
fn border_details_none() -> w_api::BorderDetails {
|
||||
let side_none = w_api::BorderSide {
|
||||
color: ColorF::BLACK,
|
||||
style: wapi::BorderStyle::None,
|
||||
style: w_api::BorderStyle::None,
|
||||
};
|
||||
|
||||
wapi::BorderDetails::Normal(wapi::NormalBorder {
|
||||
w_api::BorderDetails::Normal(w_api::NormalBorder {
|
||||
left: side_none,
|
||||
right: side_none,
|
||||
top: side_none,
|
||||
bottom: side_none,
|
||||
radius: {
|
||||
wapi::BorderRadius {
|
||||
w_api::BorderRadius {
|
||||
top_left: LayoutSize::zero(),
|
||||
top_right: LayoutSize::zero(),
|
||||
bottom_left: LayoutSize::zero(),
|
||||
|
|
|
@ -29,7 +29,7 @@ impl<U: UiNode, H: LocalVar<bool>> UiNode for HitTestable<U, H> {
|
|||
|
||||
/// If the widget is visible during hit-testing.
|
||||
///
|
||||
/// When `false` the widget and is descendents do not
|
||||
/// When `false` the widget and is descendants do not
|
||||
/// participate in pointer events and do not set the cursor.
|
||||
///
|
||||
/// Widgets inherit their hit-testability from their parents and by default
|
||||
|
|
|
@ -140,7 +140,7 @@ pub fn size(child: impl UiNode, size: impl IntoVar<LayoutSize>) -> impl UiNode {
|
|||
}
|
||||
}
|
||||
|
||||
/// Nomalized `x, y` alignment.
|
||||
/// Normalized `x, y` alignment.
|
||||
///
|
||||
/// The numbers indicate how much to the right and bottom the content is moved within
|
||||
/// a larger available space.
|
||||
|
|
|
@ -8,8 +8,8 @@ edition = "2018"
|
|||
proc-macro = true
|
||||
|
||||
[dependencies]
|
||||
proc-macro2 = "1.0.8"
|
||||
syn = { version = "1.0.14", features = ["full", "visit-mut", "extra-traits"] }
|
||||
proc-macro2 = "1.0.9"
|
||||
syn = { version = "1.0.16", features = ["full", "visit-mut", "extra-traits"] }
|
||||
quote = "1.0.2"
|
||||
|
||||
proc-macro-hack = "0.5.11"
|
||||
|
|
|
@ -18,7 +18,7 @@ pub(crate) mod widget_new;
|
|||
///
|
||||
/// # Usage
|
||||
///
|
||||
/// In a inherent impl, anotate the impl block with `#[impl_ui_node(..)]` and custom `UiNode` methods with `#[UiNode]`.
|
||||
/// In a inherent impl, annotate the impl block with `#[impl_ui_node(..)]` and custom `UiNode` methods with `#[UiNode]`.
|
||||
///
|
||||
/// ```rust
|
||||
/// #[impl_ui_node(none)]
|
||||
|
@ -30,7 +30,7 @@ pub(crate) mod widget_new;
|
|||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// In a `UiNode` trait impl block, anotate the impl block with `#[impl_ui_node(..)]` and only implement custom methods.
|
||||
/// In a `UiNode` trait impl block, annotate the impl block with `#[impl_ui_node(..)]` and only implement custom methods.
|
||||
///
|
||||
/// ```rust
|
||||
/// #[impl_ui_node(none)]
|
||||
|
@ -45,7 +45,7 @@ pub(crate) mod widget_new;
|
|||
///
|
||||
/// ## `#[impl_ui_node(none)]`
|
||||
///
|
||||
/// Generates defaults for UI components without descendents.
|
||||
/// Generates defaults for UI components without descendants.
|
||||
///
|
||||
/// ### Defaults
|
||||
/// * Init, Updates: Does nothing, blank implementation.
|
||||
|
|
|
@ -158,7 +158,7 @@ pub fn expand_property(args: proc_macro::TokenStream, input: proc_macro::TokenSt
|
|||
|
||||
// templates for compile-time sorting functions:
|
||||
// widget_new! will generate a call to all widget properties set_context,
|
||||
// then set_event for all, etc, the returns args of set_context are fed into
|
||||
// then set_event for all, etc., the returns args of set_context are fed into
|
||||
// set_event end so on, so we need to generate dummy functions for before and after
|
||||
// or actual set:
|
||||
//
|
||||
|
@ -227,7 +227,7 @@ pub fn expand_property(args: proc_macro::TokenStream, input: proc_macro::TokenSt
|
|||
}
|
||||
}
|
||||
|
||||
// generate documentation that must be formated.
|
||||
// generate documentation that must be formatted.
|
||||
let mod_property_doc = doc!("This module is a widget `{}` property.", priority);
|
||||
let fn_set_doc = doc!(
|
||||
"Manually sets the [`{0}`]({0}) property.\n\nThis property must be set with `{1}` priority to work properly.",
|
||||
|
|
|
@ -18,7 +18,7 @@ pub fn pub_vis() -> Visibility {
|
|||
})
|
||||
}
|
||||
|
||||
///-> (docs, other_attrs)
|
||||
///-> (docs, other_attributes)
|
||||
pub fn split_doc_other(attrs: &mut Vec<Attribute>) -> (Vec<Attribute>, Vec<Attribute>) {
|
||||
let mut docs = vec![];
|
||||
let mut other_attrs = vec![];
|
||||
|
@ -86,7 +86,7 @@ macro_rules! doc {
|
|||
/// Input error not caused by the user.
|
||||
pub const NON_USER_ERROR: &str = "invalid non-user input";
|
||||
|
||||
/// Does a `baced!` parse but panics with [NON_USER_ERROR] if the parsing fails.
|
||||
/// Does a `braced!` parse but panics with [NON_USER_ERROR] if the parsing fails.
|
||||
pub fn non_user_braced(input: syn::parse::ParseStream) -> syn::parse::ParseBuffer {
|
||||
fn inner(input: syn::parse::ParseStream) -> Result<syn::parse::ParseBuffer> {
|
||||
let inner;
|
||||
|
|
|
@ -126,7 +126,7 @@ pub fn expand_widget(input: proc_macro::TokenStream) -> proc_macro::TokenStream
|
|||
// Group all self properties in one DefaultBlock that will be send to widget_new!.
|
||||
let mut default_self: Vec<_> = input.default_self.into_iter().flat_map(|d| d.properties).collect();
|
||||
|
||||
// add missing requiried properties from new_child function.
|
||||
// add missing required properties from new_child function.
|
||||
for p in new_child_properties.iter() {
|
||||
if !default_child.iter().any(|c| &c.ident == p) {
|
||||
default_child.push(parse_quote!(#p: required!;));
|
||||
|
@ -154,7 +154,7 @@ pub fn expand_widget(input: proc_macro::TokenStream) -> proc_macro::TokenStream
|
|||
// 2 - Generate widget_new property metadata.
|
||||
let mut built_child = vec![];
|
||||
let mut built_self = vec![];
|
||||
// 3 - Separate the property documentation. Each vec contains (DefaultBlockTarget, &mut PropertyDeclaration).
|
||||
// 3 - Separate the property documentation. Each vector contains (DefaultBlockTarget, &mut PropertyDeclaration).
|
||||
let mut required_docs = vec![];
|
||||
let mut default_docs = vec![];
|
||||
let mut other_docs = vec![];
|
||||
|
@ -705,7 +705,7 @@ impl PropertyDefaultValue {
|
|||
pub enum PropertyValue {
|
||||
/// Named arguments.
|
||||
Fields(Punctuated<FieldValue, Token![,]>),
|
||||
/// Unamed arguments.
|
||||
/// Unnamed arguments.
|
||||
Args(Punctuated<Expr, Token![,]>),
|
||||
/// unset!.
|
||||
Unset,
|
||||
|
|
|
@ -24,16 +24,20 @@ pub fn expand_widget_new(input: proc_macro::TokenStream) -> proc_macro::TokenStr
|
|||
let input = parse_macro_input!(input as WidgetNewInput);
|
||||
let widget_name = input.ident;
|
||||
|
||||
let map_props =
|
||||
|default_block: BuiltDefaultBlock, target| default_block.properties.into_iter().map(move |p| (p.ident, (target, p.kind)));
|
||||
// map properties for collection into a HashMap.
|
||||
let map_props = |bdb: BuiltDefaultBlock, target| bdb.properties.into_iter().map(move |p| (p.ident, (target, p.kind)));
|
||||
|
||||
// map of metadata of properties defined by the widget.
|
||||
let mut known_props: HashMap<_, _> = map_props(input.default_child, DefaultBlockTarget::Child)
|
||||
.chain(map_props(input.default_self, DefaultBlockTarget::Self_))
|
||||
.collect();
|
||||
|
||||
// declarations of property arguments in the user written order.
|
||||
let mut let_args = Vec::with_capacity(input.input.sets.len());
|
||||
// metadata about [let_args].
|
||||
let mut setted_props = Vec::with_capacity(let_args.capacity());
|
||||
|
||||
// collects property assigns from the user.
|
||||
for set in input.input.sets {
|
||||
let name = ident! {"{}_args", set.ident};
|
||||
let prop = set.ident;
|
||||
|
@ -71,6 +75,7 @@ pub fn expand_widget_new(input: proc_macro::TokenStream) -> proc_macro::TokenStr
|
|||
|
||||
setted_props.push((prop, target, in_widget));
|
||||
}
|
||||
// collects property assigns from default widget properties.
|
||||
for (prop, (target, kind)) in known_props {
|
||||
let name = ident! {"{}_args", prop};
|
||||
match kind {
|
||||
|
|
Loading…
Reference in New Issue