Skip to content

Commit

Permalink
Merge pull request #366 from kas-gui/work
Browse files Browse the repository at this point in the history
Prepare v0.12, update deps
  • Loading branch information
dhardy committed Dec 13, 2022
2 parents 3c3fcfe + 105277e commit 3c41cc9
Show file tree
Hide file tree
Showing 27 changed files with 117 additions and 87 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ on:
pull_request:
branches: [ master, '[0-9]+.[0-9]+' ]

permissions:
contents: read

jobs:
nightly:
name: Nightly, format and Doc
Expand Down Expand Up @@ -48,6 +51,7 @@ jobs:
run: |
# TODO: allow manual_clamp in source code, when lint is stable
cargo clippy --all --features nightly -- -W clippy::all \
-A clippy::bool-assert-comparison \
-A clippy::collapsible-if \
-A clippy::collapsible_else_if \
-A clippy::single_match \
Expand Down
31 changes: 31 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,37 @@
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.12.0] — 2022-12-13

Stabilise support for Generic Associated Types (GATs). This requires Rust 1.65.0,
removes the `gat` feature flag, revises the `SharedData{,Mut}`, `ListData` and
`MatrixData` traits. #357

### Breaking changes

- Forbid usage of non-`#[widget]` fields in a widget's `layout` (#356)
- Rename `{Text,}Button::on_push` to `on_press` (#356)
- Adjust `Driver::set` method; add `Driver::set_mo` (#357)
- `impl_singleton!` macro: remove implied `Widget` bound on fields using
`impl Trait` syntax, allow usage of `_` and `impl Trait` within types (#359)
- Rename `impl_singleton!` to `singleton!`, moving impl to `impl-tools-lib` (#360)
- Re-export macros from `kas{,_core}` root instead of `macros` module (#364)
- Bump dependencies: `tiny-skia` v0.8.2, `resvg` and `usvg` v0.28.0 (#362, #366)
- Bump depencency: `wgpu` v0.14 (#362)

### Other changes

- Fix tab navigation to loop when first result is `None` (#356)
- Fix input state for view widgets with changed data binding by fully
resetting the widget (#365)
- Add `SingleDataMut` trait (#357)
- Add `DrawMgr::draw_iface` (#366)
- Bump dependency: `impl-tools-lib` v0.7.0 (#357, #360, #366)
- Bump dependencies: `env_logger` v0.10 (#366), `kas-text` v0.6.0 (#366)
- New dependency: `maybe-owned` v0.3.4
- Move Clippy lint configuration to CI runner (#359)
- Adjust code formatting (#361)

## [0.11.0] — 2022-09-05

With a year since the previous release, KAS v0.11 sees *a lot* of changes. In
Expand Down
21 changes: 9 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "kas"
version = "0.11.0"
version = "0.12.0"
authors = ["Diggory Hardy <git@dhardy.name>"]
edition = "2021"
license = "Apache-2.0"
Expand Down Expand Up @@ -104,28 +104,28 @@ macros_log = ["kas-core/macros_log"]
winit = ["kas-core/winit"]

[dependencies]
kas-core = { version = "0.11.0", path = "crates/kas-core" }
kas-dylib = { version = "0.11.0", path = "crates/kas-dylib", optional = true }
kas-widgets = { version = "0.11.0", path = "crates/kas-widgets" }
kas-view = { version = "0.11.0", path = "crates/kas-view", optional = true }
kas-resvg = { version = "0.11.0", path = "crates/kas-resvg", optional = true }
kas-core = { version = "0.12.0", path = "crates/kas-core" }
kas-dylib = { version = "0.12.0", path = "crates/kas-dylib", optional = true }
kas-widgets = { version = "0.12.0", path = "crates/kas-widgets" }
kas-view = { version = "0.12.0", path = "crates/kas-view", optional = true }
kas-resvg = { version = "0.12.0", path = "crates/kas-resvg", optional = true }

[dependencies.kas-theme]
version = "0.11.0" # used in doc links
version = "0.12.0" # used in doc links
path = "crates/kas-theme"
optional = true
default-features = false

[dependencies.kas-wgpu]
version = "0.11.0"
version = "0.12.0"
path = "crates/kas-wgpu"
optional = true
default-features = false
features = ["raster"]

[dev-dependencies]
chrono = "0.4"
env_logger = "0.9"
env_logger = "0.10"
log = "0.4"

[workspace]
Expand All @@ -140,6 +140,3 @@ members = [
"crates/kas-view",
"examples/mandlebrot",
]

[patch.crates-io]
kas-text = { git = "https://github.com/kas-gui/kas-text.git", rev = "b62e42fc2d6aa1446a955a769d91d13ba0b45b1e" }
6 changes: 3 additions & 3 deletions crates/kas-core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "kas-core"
version = "0.11.0"
version = "0.12.0"
authors = ["Diggory Hardy <git@dhardy.name>"]
edition = "2021"
license = "Apache-2.0"
Expand Down Expand Up @@ -73,11 +73,11 @@ ron = { version = "0.8.0", package = "ron", optional = true }
num_enum = "0.5.6"

[dependencies.kas-macros]
version = "0.11.0"
version = "0.12.0"
path = "../kas-macros"

[dependencies.kas-text]
version = "0.5.0"
version = "0.6.0"

[dependencies.easy-cast]
version = "0.5.0" # used in doc links
Expand Down
10 changes: 5 additions & 5 deletions crates/kas-core/src/core/widget_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ impl Default for WidgetId {
impl fmt::Debug for WidgetId {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
write!(f, "WidgetId({})", self)
write!(f, "WidgetId({self})")
}
}

Expand Down Expand Up @@ -663,7 +663,7 @@ mod test {
let c2 = WidgetId::ROOT.make_child(1).make_child(15);
let c3 = WidgetId::ROOT.make_child(0).make_child(14);
let c4 = WidgetId::ROOT.make_child(0).make_child(15);
println!("c1: {}", c1);
println!("c1: {c1}");
assert!(c1 != c2);
assert!(c1 != c3);
assert!(c2 != c3);
Expand Down Expand Up @@ -750,7 +750,7 @@ mod test {
#[test]
fn test_parent() {
fn test(seq: &[usize]) {
println!("seq: {:?}", seq);
println!("seq: {seq:?}");
let mut id = WidgetId::ROOT;
let len = seq.len();
for key in &seq[..len - 1] {
Expand Down Expand Up @@ -783,7 +783,7 @@ mod test {
}
let v = id.as_u64();
if v != x {
panic!("test({:?}, {:x}): found {:x}", seq, x, v);
panic!("test({seq:?}, {x:x}): found {v:x}");
}

// Every id is its own ancestor:
Expand All @@ -804,7 +804,7 @@ mod test {
for x in seq {
id = id.make_child(*x);
}
format!("{}", id)
format!("{id}")
}

assert_eq!(from_seq(&[]), "#");
Expand Down
3 changes: 1 addition & 2 deletions crates/kas-core/src/event/components.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,10 @@ impl Glide {
fn opt_start(&mut self, timeout: Duration) -> bool {
if let Glide::Drag(_, samples) = self {
let now = Instant::now();
let start = now - timeout;
let mut delta = Offset::ZERO;
let mut t0 = now;
for (time, d) in samples {
if *time >= start {
if *time + timeout >= now {
t0 = t0.min(*time);
delta += *d;
}
Expand Down
8 changes: 4 additions & 4 deletions crates/kas-core/src/geom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ impl Size {
/// In debug mode, this asserts that components are non-negative.
#[inline]
pub fn new(w: i32, h: i32) -> Self {
debug_assert!(w >= 0 && h >= 0, "Size::new({}, {}): negative value", w, h);
debug_assert!(w >= 0 && h >= 0, "Size::new({w}, {h}): negative value");
Self(w, h)
}

Expand All @@ -291,7 +291,7 @@ impl Size {
/// In debug mode, this asserts that components are non-negative.
#[inline]
pub fn splat(n: i32) -> Self {
debug_assert!(n >= 0, "Size::splat({}): negative value", n);
debug_assert!(n >= 0, "Size::splat({n}): negative value");
Self(n, n)
}

Expand Down Expand Up @@ -382,7 +382,7 @@ impl std::ops::Div<i32> for Size {
impl Conv<Offset> for Coord {
#[inline]
fn try_conv(v: Offset) -> Result<Self> {
debug_assert!(v.0 >= 0 && v.1 >= 0, "Coord::conv({:?}): negative value", v);
debug_assert!(v.0 >= 0 && v.1 >= 0, "Coord::conv({v:?}): negative value");
Ok(Self(v.0, v.1))
}
}
Expand All @@ -393,7 +393,7 @@ impl Conv<Offset> for Coord {
impl Conv<Offset> for Size {
#[inline]
fn try_conv(v: Offset) -> Result<Self> {
debug_assert!(v.0 >= 0 && v.1 >= 0, "Size::conv({:?}): negative value", v);
debug_assert!(v.0 >= 0 && v.1 >= 0, "Size::conv({v:?}): negative value");
Ok(Self(v.0, v.1))
}
}
Expand Down
10 changes: 9 additions & 1 deletion crates/kas-core/src/theme/draw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

use super::{FrameStyle, MarkStyle, SizeMgr, TextClass, ThemeSize};
use crate::dir::Direction;
use crate::draw::{color::Rgb, Draw, DrawShared, ImageId, PassType};
use crate::draw::color::Rgb;
use crate::draw::{Draw, DrawIface, DrawShared, DrawSharedImpl, ImageId, PassType};
use crate::event::{ConfigMgr, EventState};
use crate::geom::{Offset, Rect};
use crate::text::{TextApi, TextDisplay};
Expand Down Expand Up @@ -122,6 +123,13 @@ impl<'a> DrawMgr<'a> {
self.h.components().1
}

/// Access the low-level draw device (implementation type)
///
/// The implementing type must be specified. See [`DrawIface::downcast_from`].
pub fn draw_iface<DS: DrawSharedImpl>(&mut self) -> Option<DrawIface<DS>> {
DrawIface::downcast_from(self.draw_device())
}

/// Draw to a new pass
///
/// Adds a new draw pass for purposes of enforcing draw order. Content of
Expand Down
12 changes: 6 additions & 6 deletions crates/kas-dylib/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "kas-dylib"
version = "0.11.0"
version = "0.12.0"
authors = ["Diggory Hardy <git@dhardy.name>"]
edition = "2021"
license = "Apache-2.0"
Expand All @@ -18,8 +18,8 @@ crate-type = ["dylib"]
resvg = ["dep:kas-resvg"]

[dependencies]
kas-core = { version = "0.11.0", path = "../kas-core" }
kas-widgets = { version = "0.11.0", path = "../kas-widgets" }
kas-resvg = { version = "0.11.0", path = "../kas-resvg", optional = true }
kas-theme = { version = "0.11.0", path = "../kas-theme" }
kas-wgpu = { version = "0.11.0", path = "../kas-wgpu" }
kas-core = { version = "0.12.0", path = "../kas-core" }
kas-widgets = { version = "0.12.0", path = "../kas-widgets" }
kas-resvg = { version = "0.12.0", path = "../kas-resvg", optional = true }
kas-theme = { version = "0.12.0", path = "../kas-theme" }
kas-wgpu = { version = "0.12.0", path = "../kas-wgpu" }
4 changes: 2 additions & 2 deletions crates/kas-macros/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "kas-macros"
version = "0.11.0"
version = "0.12.0"
authors = ["Diggory Hardy <git@dhardy.name>"]
edition = "2021"
license = "Apache-2.0"
Expand All @@ -26,7 +26,7 @@ proc-macro-error = "1.0"
bitflags = "1.3.1"

[dependencies.impl-tools-lib]
version = "0.5.2" # version used in doc links
version = "0.7.0" # version used in doc links

[dependencies.syn]
version = "1.0.14"
Expand Down
6 changes: 3 additions & 3 deletions crates/kas-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ mod widget_index;

/// Implement `Default`
///
/// See [`impl_tools::impl_default`](https://docs.rs/impl-tools/0.5/impl_tools/attr.impl_default.html)
/// See [`impl_tools::impl_default`](https://docs.rs/impl-tools/0.6/impl_tools/attr.impl_default.html)
/// for full documentation.
#[proc_macro_attribute]
#[proc_macro_error]
Expand All @@ -42,7 +42,7 @@ pub fn impl_default(attr: TokenStream, item: TokenStream) -> TokenStream {

/// A variant of the standard `derive` macro
///
/// See [`impl_tools::autoimpl`](https://docs.rs/impl-tools/0.5/impl_tools/attr.autoimpl.html)
/// See [`impl_tools::autoimpl`](https://docs.rs/impl-tools/0.6/impl_tools/attr.autoimpl.html)
/// for full documentation.
///
/// The following traits are supported:
Expand Down Expand Up @@ -128,7 +128,7 @@ fn find_attr(path: &syn::Path) -> Option<&'static dyn lib::ScopeAttr> {
/// [rustfmt#5254](https://github.com/rust-lang/rustfmt/issues/5254),
/// [rustfmt#5538](https://github.com/rust-lang/rustfmt/pull/5538)).
///
/// See [`impl_tools::impl_scope`](https://docs.rs/impl-tools/0.5/impl_tools/macro.impl_scope.html)
/// See [`impl_tools::impl_scope`](https://docs.rs/impl-tools/0.6/impl_tools/macro.impl_scope.html)
/// for full documentation.
///
/// ## Special attribute macros
Expand Down
5 changes: 1 addition & 4 deletions crates/kas-macros/src/make_layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,7 @@ fn parse_cell_info(input: ParseStream) -> Result<CellInfo> {
let lit = input.parse::<LitInt>()?;
let end = lit.base10_parse()?;
if start >= end {
return Err(Error::new(
lit.span(),
format!("expected value > {}", start),
));
return Err(Error::new(lit.span(), format!("expected value > {start}")));
}
Ok(end)
} else {
Expand Down
8 changes: 4 additions & 4 deletions crates/kas-resvg/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "kas-resvg"
version = "0.11.0"
version = "0.12.0"
authors = ["Diggory Hardy <git@dhardy.name>"]
edition = "2021"
license = "Apache-2.0"
Expand All @@ -24,8 +24,8 @@ svg = ["dep:resvg", "dep:usvg"]

[dependencies]
tiny-skia = { version = "0.8.2" }
resvg = { version = "0.25.0", optional = true }
usvg = { version = "0.25.0", optional = true }
resvg = { version = "0.28.0", optional = true }
usvg = { version = "0.28.0", optional = true }

# We must rename this package since macros expect kas to be in scope:
kas = { version = "0.11.0", package = "kas-core", path = "../kas-core" }
kas = { version = "0.12.0", package = "kas-core", path = "../kas-core" }
12 changes: 5 additions & 7 deletions crates/kas-resvg/src/svg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ impl_scope! {
/// This sets [`PixmapScaling::size`] from the SVG.
pub fn load(&mut self, data: &[u8], resources_dir: Option<&Path>) {
let fonts_db = kas::text::fonts::fonts().read_db();
let fontdb = fonts_db.db();
let font_family = fonts_db.font_family_from_alias("SERIF").unwrap_or_default();

// Defaults are taken from usvg::Options::default(). Notes:
Expand All @@ -58,19 +57,18 @@ impl_scope! {
// - default_size: affected by screen scale factor later
// - dpi: according to css-values-3, 1in = 96px
// - font_size: units are (logical) px per em; 16px = 12pt
let opts = usvg::OptionsRef {
resources_dir,
let opts = usvg::Options {
resources_dir: resources_dir.map(|path| path.to_owned()),
dpi: 96.0,
font_family: &font_family,
font_family,
font_size: 16.0, // units: "logical pixels" per Em
languages: &["en".to_string()],
languages: vec!["en".to_string()],
shape_rendering: usvg::ShapeRendering::default(),
text_rendering: usvg::TextRendering::default(),
image_rendering: usvg::ImageRendering::default(),
keep_named_groups: false,
default_size: usvg::Size::new(100.0, 100.0).unwrap(),
fontdb,
image_href_resolver: &Default::default(),
image_href_resolver: Default::default(),
};

self.tree = Some(usvg::Tree::from_data(data, &opts).unwrap());
Expand Down
4 changes: 2 additions & 2 deletions crates/kas-theme/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "kas-theme"
version = "0.11.0"
version = "0.12.0"
authors = ["Diggory Hardy <git@dhardy.name>"]
edition = "2021"
license = "Apache-2.0"
Expand Down Expand Up @@ -35,7 +35,7 @@ dark-light = ["dep:dark-light"]

[dependencies]
# Rename package purely for convenience:
kas = { version = "0.11.0", package = "kas-core", path = "../kas-core" }
kas = { version = "0.12.0", package = "kas-core", path = "../kas-core" }
linear-map = "1.2.0"
log = "0.4"
serde = { version = "1.0.123", features = ["derive"], optional = true }
Expand Down
Loading

0 comments on commit 3c41cc9

Please sign in to comment.