Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(macros): 🎸 derive Declare support builtin abilitify #535

Merged
merged 4 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 33 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,38 @@ Please only add new entries below the [Unreleased](#unreleased---releasedate) he

## [@Unreleased] - @ReleaseDate

## Features

- **core**: All built-in widget abilities are now exported on `FatObj`. (#535 @M-Adoo)
You can directly use `FatObj` to configure built-in widget abilities such as `on_click`, `on_key_down`, etc.
```rust
let _ = FatObj::new(Void)
.margin(EdgeInsets::all(1.0))
.on_click(|_, _| { println!("click"); });
```
- **macros**: `#[derive(Decalre)]` now generates a `FatObj<State<T>>` instead of `State<T>`, and supports initialization of all built-in widgets on its DeclareBuilder. (#535 @M-Adoo)
All pipes used to initialize the field will be unsubscribed when the FatObj is disposed.
```rust
let row = Row::declare_builder()
.margin(...)
.on_click(...)
.build_declare(ctx);
```
- **macros**: Introduced `simple_declare` macro for types that don't use `Pipe` for initialization. (#535 @M-Adoo)

## Changed

- **macros**: removed crate `ribir_builtin` that is no longer needed. (#535 @M-Adoo)

## Breaking

- **core**: removed `FatObj::unzip` and `FatObj::from_host` (#535 @M-Adoo)
- **core**: removed `BuiltinObj`. (#535 @M-Adoo)
- **core**: `FatObj::new(host: T, builtin: BuiltinObj)` -> `FatObj::new(host: T)`

While these are public APIs, they are typically not required for direct use in user code.


## [0.2.0-alpha.5] - 2024-03-05

### Features
Expand All @@ -32,12 +64,9 @@ Please only add new entries below the [Unreleased](#unreleased---releasedate) he

## [0.2.0-alpha.4] - 2024-02-27

### Fixed

- Optimization, StateReader auto unsubscribe if not writer(#532 @wjian23)

### Changed

- **core**: StateReader now automatically unsubscribes when no writer is present (#532 @wjian23)
- **core**: Consolidated all listener and `FocusNode` into a `MixBuiltin` widget (#534 @M-Adoo)
- The `MixBuiltin` widget reduces memory usage and allows users to utilize all `on_xxx` event handlers, not only during the build declaration but also after the widget has been built.

Expand Down
3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ members = [
"gpu",
"painter",
"macros",
"macros/builtin",
"algo",
"text",
"widgets",
Expand Down Expand Up @@ -37,7 +36,6 @@ readme = "README.md"
version = "0.2.0-alpha.5"

[workspace.dependencies]
Inflector = "0.11.4"
ahash = "0.8.3"
arboard = "3.2.0"
bitflags = "2.0.0"
Expand Down Expand Up @@ -90,6 +88,7 @@ macos-accessibility-client = { version = "0.0.1" }
tokio = { version = "1.0" }
tokio-stream = { version = "0.1" }
priority-queue = "1.3.2"
phf = "0.11.2"

[workspace.metadata.release]
shared-version = true
Expand Down
2 changes: 1 addition & 1 deletion core/src/animation/animate.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{prelude::*, ticker::FrameMsg, window::WindowId};
use std::time::Instant;

#[derive(Declare)]
#[simple_declare]
pub struct Animate<S>
where
S: AnimateState + 'static,
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 @@ -25,7 +25,7 @@
//! let first_fade_in = @Animate {
//! transition: transitions::EASE_IN.of(ctx!()),
//! state: map_writer!($first.opacity),
//! }.into_inner();
//! };
//!
//! stagger.write().push_animation(first_fade_in);
//! stagger.write().push_state(map_writer!($second.opacity), 0., ctx!());
Expand Down Expand Up @@ -103,7 +103,7 @@
A: AnimateState + 'static,
{
let transition = Box::new(self.transition.clone());
let animate = rdl! { Animate { transition, state, from } }.into_inner();
let animate = rdl! { Animate { transition, state, from } };
self.push_animation_with(stagger, animate.clone_writer().into_inner());
animate
}
Expand All @@ -116,7 +116,7 @@
/// Add an animation to the end of the stagger animation with a different
/// stagger duration.
///
/// **stagger** the duration between the previous animation start and this
/// **stagger**: the duration between the previous animation start and this
/// animation start.
pub fn push_animation_with(
&mut self,
Expand Down Expand Up @@ -237,7 +237,7 @@
from: 0.,
};

stagger.write().push_animation(animate.into_inner());
stagger.write().push_animation(animate);

Check warning on line 240 in core/src/animation/stagger.rs

View check run for this annotation

Codecov / codecov/patch

core/src/animation/stagger.rs#L240

Added line #L240 was not covered by tests
stagger.write().push_state(
map_writer!($mock_box.size),
Size::new(200., 200.),
Expand Down
Loading
Loading