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

Implement Slider #542

Merged
merged 17 commits into from
Nov 9, 2024
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Unreleased

* Properties `size` and related now have a default value allowing conditional assign.
* Add `zng::slider` with `Slider` widget.
* Fix `force_size` returning the parent's constraint min size.
* Fix hit-test in rounded rectangles with too large corner radius.
* Fix headless rendering in Wayland. Property `needs_fallback_chrome` now is `false` for headless windows.
Expand Down
1 change: 1 addition & 0 deletions crates/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ or for custom properties that deeply integrate with a widget.
- `zng-wgt-tooltip`
- `zng-wgt-markdown`
- `zng-wgt-progress`
- `zng-wgt-slider`
- `zng-wgt-material-icons`
- `zng-wgt-webrender-debug`

Expand Down
12 changes: 6 additions & 6 deletions crates/zng-wgt-size-offset/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ pub fn max_height(child: impl UiNode, max_height: impl IntoVar<Length>) -> impl
/// [`height`]: fn@height
/// [`force_size`]: fn@force_size
/// [`align`]: fn@zng_wgt::align
#[property(SIZE)]
#[property(SIZE, default(Size::default()))]
pub fn size(child: impl UiNode, size: impl IntoVar<Size>) -> impl UiNode {
let size = size.into_var();
match_node(child, move |child, op| match op {
Expand Down Expand Up @@ -399,7 +399,7 @@ pub fn size(child: impl UiNode, size: impl IntoVar<Size>) -> impl UiNode {
/// [`min_width`]: fn@min_width
/// [`max_width`]: fn@max_width
/// [`force_width`]: fn@force_width
#[property(SIZE)]
#[property(SIZE, default(Length::Default))]
pub fn width(child: impl UiNode, width: impl IntoVar<Length>) -> impl UiNode {
let width = width.into_var();
match_node(child, move |child, op| match op {
Expand Down Expand Up @@ -454,7 +454,7 @@ pub fn width(child: impl UiNode, width: impl IntoVar<Length>) -> impl UiNode {
/// [`min_height`]: fn@min_height
/// [`max_height`]: fn@max_height
/// [`force_height`]: fn@force_height
#[property(SIZE)]
#[property(SIZE, default(Length::Default))]
pub fn height(child: impl UiNode, height: impl IntoVar<Length>) -> impl UiNode {
let height = height.into_var();
match_node(child, move |child, op| match op {
Expand Down Expand Up @@ -507,7 +507,7 @@ pub fn height(child: impl UiNode, height: impl IntoVar<Length>) -> impl UiNode {
///
/// [`force_width`]: fn@force_width
/// [`force_height`]: fn@force_height
#[property(SIZE)]
#[property(SIZE, default(Size::default()))]
pub fn force_size(child: impl UiNode, size: impl IntoVar<Size>) -> impl UiNode {
let size = size.into_var();
match_node(child, move |child, op| match op {
Expand Down Expand Up @@ -551,7 +551,7 @@ pub fn force_size(child: impl UiNode, size: impl IntoVar<Size>) -> impl UiNode {
/// # `force_size`
///
/// You can set both `force_width` and `force_height` at the same time using the [`force_size`](fn@force_size) property.
#[property(SIZE)]
#[property(SIZE, default(Length::Default))]
pub fn force_width(child: impl UiNode, width: impl IntoVar<Length>) -> impl UiNode {
let width = width.into_var();
match_node(child, move |child, op| match op {
Expand Down Expand Up @@ -598,7 +598,7 @@ pub fn force_width(child: impl UiNode, width: impl IntoVar<Length>) -> impl UiNo
/// # `force_size`
///
/// You can set both `force_width` and `force_height` at the same time using the [`force_size`](fn@force_size) property.
#[property(SIZE)]
#[property(SIZE, default(Length::Default))]
pub fn force_height(child: impl UiNode, height: impl IntoVar<Length>) -> impl UiNode {
let height = height.into_var();
match_node(child, move |child, op| match op {
Expand Down
26 changes: 26 additions & 0 deletions crates/zng-wgt-slider/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[package]
name = "zng-wgt-slider"
version = "0.1.0"
authors = ["The Zng Project Developers"]
edition = "2021"
license = "Apache-2.0 OR MIT"
readme = "README.md"
description = "Part of the zng project."
documentation = "https://zng-ui.github.io/doc/zng_wgt_slider"
repository = "https://github.com/zng-ui/zng"
categories = ["gui"]
keywords = ["gui", "ui", "user-interface", "zng"]

[dependencies]
zng-var = { path = "../zng-var", version = "0.5.9" }
zng-wgt = { path = "../zng-wgt", version = "0.5.5" }
zng-wgt-style = { path = "../zng-wgt-style", version = "0.3.29" }
zng-wgt-input = { path = "../zng-wgt-input", version = "0.2.41" }
zng-ext-input = { path = "../zng-ext-input", version = "0.5.29" }
zng-wgt-container = { path = "../zng-wgt-container", version = "0.4.1" }
zng-wgt-size-offset = { path = "../zng-wgt-size-offset", version = "0.2.39" }
zng-wgt-fill = { path = "../zng-wgt-fill", version = "0.2.39" }
zng-wgt-transform = { path = "../zng-wgt-transform", version = "0.2.39" }

parking_lot = "0.12"
tracing = "0.1"
7 changes: 7 additions & 0 deletions crates/zng-wgt-slider/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<!--do doc --readme header-->
This crate is part of the [`zng`](https://github.com/zng-ui/zng?tab=readme-ov-file#crates) project.


<!--do doc --readme features-->


Loading