Skip to content

Commit

Permalink
refactor(ribir): 💡 Remove unnecessary dependencies
Browse files Browse the repository at this point in the history
✅ Closes: #447
  • Loading branch information
M-Adoo committed Oct 13, 2024
1 parent 55a7827 commit 7018c24
Show file tree
Hide file tree
Showing 100 changed files with 749 additions and 778 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ env:
CI_BINARY_BUILD: "build18"

# We have some features that are only available on nightly. We need to test it.
NIGHTLY_VERSION: "nightly-2024-04-20"
NIGHTLY_VERSION: "nightly-2024-10-03"

name: CI
jobs:
Expand Down
7 changes: 2 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ keywords = ["gui", "ui", "declarative", "compose-ui"]
license = "MIT"
readme = "README.md"
version = "0.4.0-alpha.12"
rust-version = "1.77.0"
rust-version = "1.81.0"

[workspace.dependencies]
ahash = "0.8.11"
arboard = "3.2.0"
bitflags = "2.0.0"
blake3 = "1.3.3"
colored = "2.0.0"
derive_more = "0.99.17"
derive_more = "1.0.0"
dssim-core="3.2.9"
env_logger = "0.7.1"
euclid = "0.22.6"
Expand All @@ -53,16 +53,13 @@ futures = "0.3.26"
guillotiere = "0.6.0"
image = { version = "0.24.5", default-features = false }
indextree = "4.5.0"
lazy_static = "1.4.0"
log = "0.4.14"
lyon_algorithms = "1.0.1"
lyon_geom = "1.0.1"
lyon_path = "1.0.1"
lyon_tessellation = "1.0.1"
material-color-utilities-rs = "0.2.1"
icrate = "0.0.4"
once_cell = "1.17.1"
ordered-float = "4.1.1"
paste = "1.0"
pin-project-lite = "0.2.9"
proc-macro2 = "1.0.81"
Expand Down
2 changes: 2 additions & 0 deletions algo/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::needless_lifetimes)]

mod cow_rc;
mod frame_cache;
pub use cow_rc::{CowArc, Substr};
Expand Down
1 change: 1 addition & 0 deletions algo/src/sc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use std::{
};

/// A single-thread smart pointer with strong reference count only.
///
/// This is a simplified version of `std::rc::Sc` with the weak reference count.
/// Use it when you are sure that there is no cycle in the reference graph or in
/// a inner resource manage that will break the cycle by itself.
Expand Down
6 changes: 3 additions & 3 deletions cli/src/run_wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ use std::{
};

use anyhow::Result;
use clap::{command, CommandFactory, FromArgMatches, Parser};
use notify_debouncer_mini::{new_debouncer, notify::*, DebounceEventResult, Debouncer};
use clap::{CommandFactory, FromArgMatches, Parser, command};
use notify_debouncer_mini::{DebounceEventResult, Debouncer, new_debouncer, notify::*};

use crate::{
program_check::{check_all_programs, Program},
CliCommand,
program_check::{Program, check_all_programs},
};

const WATCH_DEBOUNCE_GAP: Duration = Duration::from_secs(2);
Expand Down
2 changes: 0 additions & 2 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@ bitflags.workspace = true
blake3 = {workspace = true, features = ["rayon"]}
futures.workspace = true
indextree.workspace = true
lazy_static.workspace = true
log.workspace = true
lyon_geom.workspace = true
once_cell.workspace = true
paste.workspace = true
triomphe.workspace = true
pin-project-lite.workspace = true
Expand Down
13 changes: 7 additions & 6 deletions core/src/animation/easing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,13 @@ pub enum StepsJump {
}

/// Displays an animation iteration along n stops along the transition,
/// displaying each stop for equal lengths of time. For example, if n is 5,
/// there are 5 steps. Whether the animation holds temporarily at 0%, 20%, 40%,
/// 60% and 80%, on the 20%, 40%, 60%, 80% and 100%, or makes 5 stops between
/// the 0% and 100% along the animation, or makes 5 stops including the 0% and
/// 100% marks (on the 0%, 25%, 50%, 75%, and 100%) depends on which of the
/// following jump terms is used
/// displaying each stop for equal lengths of time.
///
/// For example, if n is 5, there are 5 steps. Whether the animation holds
/// temporarily at 0%, 20%, 40%, 60% and 80%, on the 20%, 40%, 60%, 80% and
/// 100%, or makes 5 stops between the 0% and 100% along the animation, or makes
/// 5 stops including the 0% and 100% marks (on the 0%, 25%, 50%, 75%, and 100%)
/// depends on which of the following jump terms is used
pub fn steps(step_cnt: u32, jump: StepsJump) -> Steps {
let time_step = 1. / step_cnt as f32;
match jump {
Expand Down
8 changes: 4 additions & 4 deletions core/src/animation/stagger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,10 +261,10 @@ mod tests {
fn stagger_not_running_after_all_animation_end() {
reset_test_env!();

let stagger = Stagger::new(
Duration::from_millis(100),
EasingTransition { duration: Duration::ZERO, easing: easing::LINEAR },
);
let stagger = Stagger::new(Duration::from_millis(100), EasingTransition {
duration: Duration::ZERO,
easing: easing::LINEAR,
});
let c_stagger = stagger.clone_writer();
let w = fn_widget! {
let mut mock_box = @MockBox { size: Size::new(100., 100.) };
Expand Down
11 changes: 7 additions & 4 deletions core/src/builtin_widgets.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//! Built-in widgets is a set of minimal widgets that describes the most common
//! UI elements. The most of them can be used to extend other object in the
//! UI elements.
//!
//! The most of them can be used to extend other object in the
//! declare syntax, so other objects can use the builtin fields and methods like
//! self fields and methods.
Expand Down Expand Up @@ -76,9 +78,10 @@ use crate::prelude::*;
/// LazyWidgetId is a widget id that will be valid after widget build.
pub struct LazyWidgetId(Sc<Cell<Option<WidgetId>>>);

/// A fat object that extend the `T` object with all builtin widgets ability. A
/// `FatObj` will create during the compose phase, and compose with the builtin
/// widgets it actually use, and drop after composed.
/// A fat object that extend the `T` object with all builtin widgets ability.
///
/// A `FatObj` will create during the compose phase, and compose with the
/// builtin widgets it actually use, and drop after composed.
///
/// It's important to understand that `FatObj` is a temporary mixin object. It
/// doesn't persist in the final widget tree. Therefore, you can only clone a
Expand Down
8 changes: 5 additions & 3 deletions core/src/builtin_widgets/anchor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,11 @@ impl Anchor {
}

/// This widget is used to anchor child constraints relative to the parent
/// widget. It's important to note that if you anchor the child widget outside
/// of its parent, it may become unable to click, so ensure there is ample space
/// within the parent.
/// widget.
///
/// It's important to note that if you anchor the child widget outside of its
/// parent, it may become unable to click, so ensure there is ample space within
/// the parent.
#[derive(Default)]
pub struct RelativeAnchor {
pub anchor: Anchor,
Expand Down
13 changes: 5 additions & 8 deletions core/src/builtin_widgets/class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,9 @@
//!
//! let mut theme = Theme::default();
//! // Define how `RED_BORDER` transforms a widget.
//! theme.classes.insert(
//! RED_BORDER,
//! style_class! {
//! border: Border::all(BorderSide::new(2., Color::RED.into()))
//! },
//! );
//! theme.classes.insert(RED_BORDER, style_class! {
//! border: Border::all(BorderSide::new(2., Color::RED.into()))
//! });
//!
//! let w = fn_widget! {
//! @Container {
Expand Down Expand Up @@ -334,7 +331,7 @@ mod tests {
use super::*;
use crate::{
reset_test_env,
test_helper::{split_value, MockBox, TestWindow},
test_helper::{MockBox, TestWindow, split_value},
};

#[test]
Expand All @@ -358,7 +355,7 @@ mod tests {
.into_widget()
});

unsafe { AppCtx::set_app_theme(theme) };
AppCtx::set_app_theme(theme);

let (cls, w_cls) = split_value(MARGIN);

Expand Down
8 changes: 4 additions & 4 deletions core/src/builtin_widgets/focus_scope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ mod tests {
};

use super::*;
use crate::test_helper::*;
use crate::{reset_test_env, test_helper::*};

#[test]
fn tab_scope() {
let _guard = unsafe { AppCtx::new_lock_scope() };
reset_test_env!();

let size = Size::zero();
let widget = fn_widget! {
Expand Down Expand Up @@ -100,7 +100,7 @@ mod tests {

#[test]
fn tab_scope_self_only() {
let _guard = unsafe { AppCtx::new_lock_scope() };
reset_test_env!();

let size = Size::zero();
let widget = fn_widget! {
Expand Down Expand Up @@ -148,7 +148,7 @@ mod tests {

#[test]
fn focus_scope() {
let _guard = unsafe { AppCtx::new_lock_scope() };
reset_test_env!();

let size = Size::new(50., 50.);
let tap_cnt = Stateful::new(0);
Expand Down
7 changes: 4 additions & 3 deletions core/src/builtin_widgets/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ impl<V: Default> Default for KeyChange<V> {
}

/// A widget that can be used to track if the widget is the same widget in two
/// frames by its key. If two widget has same parent and key in two frames, the
/// new widget in the next frame will be treated as the same widget in the last
/// frame.
/// frames by its key.
///
/// If two widget has same parent and key in two frames, the new widget in the
/// next frame will be treated as the same widget in the last frame.
///
/// ## Notice
///
Expand Down
2 changes: 1 addition & 1 deletion core/src/builtin_widgets/painting_style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::{prelude::*, wrap_render::WrapRender};

/// Explain the method for rendering shapes and paths, including filling or
/// stroking them.
#[derive(Clone, PartialEq, Eq, Hash, Debug, Default)]
#[derive(Clone, Debug, Default)]
pub enum PaintingStyle {
/// Fill the path.
#[default]
Expand Down
15 changes: 8 additions & 7 deletions core/src/builtin_widgets/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,24 @@ use smallvec::SmallVec;
use crate::prelude::*;

/// This widget enables its descendants to access the data it provides,
/// streamlining data sharing throughout the widget tree. Descendants have the
/// ability to inquire about the type of data provided by their ancestors. If
/// the ancestor is a writer, descendants can also access the write reference
/// (`WriteRef`) for that data.
/// streamlining data sharing throughout the widget tree.
///
/// Descendants have the ability to inquire about the type of data provided by
/// their ancestors. If the ancestor is a writer, descendants can also access
/// the write reference (`WriteRef`) for that data.
///
/// Its child must be a function widget, which enforces its subtree to utilize
/// the build context it provides for construction.
///
/// Data querying occurs from the bottom to the top of the widget tree. In cases
/// where there are two providers of the same type in one path, the closer
/// provider will be queried.
///
/// The system theme should serve as a global provider by default.
///
/// You can utilize the provider with `BuildCtx`, the event object, `LayoutCtx`,
/// and `PaintCtx`.
///
/// ## Example
///
/// Any type can be wrapped with `Queryable` for providing data.
Expand Down
13 changes: 8 additions & 5 deletions core/src/builtin_widgets/scrollable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,10 @@ mod tests {
use winit::event::{DeviceId, MouseScrollDelta, TouchPhase, WindowEvent};

use super::*;
use crate::test_helper::{MockBox, TestWindow};
use crate::{
reset_test_env,
test_helper::{MockBox, TestWindow},
};

fn test_assert(scrollable: Scrollable, delta_x: f32, delta_y: f32, expect_x: f32, expect_y: f32) {
let w = fn_widget! {
Expand Down Expand Up @@ -167,7 +170,7 @@ mod tests {

#[test]
fn x_scroll() {
let _guard = unsafe { AppCtx::new_lock_scope() };
reset_test_env!();

test_assert(Scrollable::X, -10., -10., -10., 0.);
test_assert(Scrollable::X, -10000., -10., -900., 0.);
Expand All @@ -176,7 +179,7 @@ mod tests {

#[test]
fn y_scroll() {
let _guard = unsafe { AppCtx::new_lock_scope() };
reset_test_env!();

test_assert(Scrollable::Y, -10., -10., 0., -10.);
test_assert(Scrollable::Y, -10., -10000., 0., -900.);
Expand All @@ -185,7 +188,7 @@ mod tests {

#[test]
fn both_scroll() {
let _guard = unsafe { AppCtx::new_lock_scope() };
reset_test_env!();

test_assert(Scrollable::Both, -10., -10., -10., -10.);
test_assert(Scrollable::Both, -10000., -10000., -900., -900.);
Expand All @@ -210,7 +213,7 @@ mod tests {

#[test]
fn scroll_content_expand() {
let _guard = unsafe { AppCtx::new_lock_scope() };
reset_test_env!();

let w = fn_widget! {
@FixedBox {
Expand Down
6 changes: 4 additions & 2 deletions core/src/builtin_widgets/theme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ pub enum Brightness {
}

/// A `Theme` widget is used to share design configurations among its
/// descendants. This includes palettes, font styles, animation transitions, and
/// icons. An app theme is always present, but you can also use a different
/// descendants.
///
/// This includes palettes, font styles, animation transitions, and icons. An
/// app theme is always present, but you can also use a different
/// theme for parts of your sub-tree. You can customize parts of the theme using
/// `Palette`, `TypographyTheme`, and `IconTheme`.
///
Expand Down
7 changes: 1 addition & 6 deletions core/src/builtin_widgets/theme/compose_decorators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ pub struct ComposeDecorators {
pub(crate) styles: ahash::HashMap<TypeId, Box<ComposeDecoratorFn>>,
}

/// `ComposeDecorator` is a trait let you can convert your host widget to
/// another, it has same signature of `ComposeChild`, but it can be overwrote in
/// `Theme` by a function. The trait implementation only as a default logic if
/// no overwrite function in `Theme`.
pub trait ComposeDecorator: Sized {
fn compose_decorator(this: State<Self>, host: Widget) -> Widget;
}
Expand Down Expand Up @@ -71,8 +67,7 @@ mod tests {
}}
};

unsafe { AppCtx::set_app_theme(theme) };

AppCtx::set_app_theme(theme);
let mut wnd = TestWindow::new_with_size(w, Size::new(500., 500.));
wnd.draw_frame();
wnd.assert_root_size(Size::new(100., 100.));
Expand Down
14 changes: 6 additions & 8 deletions core/src/builtin_widgets/theme/palette.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,12 @@ use super::*;
///
/// ```rust
/// use ribir_core::prelude::*;
/// let _w = Palette::default().with_child(
/// fn_widget! {
/// // Every widget created in this scope can access the `Palette`.
/// let _primary = Palette::of(ctx!()).primary();
/// Void
/// }
/// );
///
/// let _w = Palette::default().with_child(fn_widget! {
/// // Every widget created in this scope can access the `Palette`.
/// let _primary = Palette::of(ctx!()).primary();
/// Void
/// });
/// ```
#[derive(Clone, Debug)]
pub struct Palette {
Expand Down
4 changes: 3 additions & 1 deletion core/src/builtin_widgets/theme/typography_theme.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use super::*;

/// Use typography to present your design and content as clearly and efficiently
/// as possible. The names of the TextTheme properties from the [Material Design
/// as possible.
///
/// The names of the TextTheme properties from the [Material Design
/// spec](https://m3.material.io/styles/typography/type-scale-tokens)
#[derive(Clone, Debug, PartialEq)]
pub struct TypographyTheme {
Expand Down
Loading

0 comments on commit 7018c24

Please sign in to comment.