Skip to content

Commit

Permalink
Merge pull request #457 from kas-gui/work
Browse files Browse the repository at this point in the history
Use kas-text 0.7.0; prepare 0.15.0
  • Loading branch information
dhardy authored Dec 2, 2024
2 parents 6d741f4 + 3a6e263 commit 8a20070
Show file tree
Hide file tree
Showing 23 changed files with 101 additions and 74 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
toolchain: [stable]
include:
- os: ubuntu-latest
toolchain: "1.79.0"
toolchain: "1.80.0"
- os: ubuntu-latest
toolchain: beta

Expand Down
29 changes: 27 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,34 @@
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).

## [Unreleased]
## [0.15.0] — 2024-12-02

- Rename `Application``Runner`
Most significant is the addition of the `Collection` trait representing a list or tuple of widgets.

### Uncategorized
- Bump MSRV to 1.80 (#457)
- Add struct `kas::config::Config` to house event/theme/font config (#449)
- Make `PRIMARY` backend default and fix transparency (#452)
- Add `kas::decorations` module (#452)
- Rename `Application``Runner` and `kas::app``kas::runner` (#456)

### Event handling
- Add `fn EventState::send` and `send_erased` to allow *sending* a message to any widget (#429)
- Assume `Action::UPDATE` from some handlers instead of requiring this explicitly (#432)
- Remove event stealing and revise handling of disabled events (#453)

### Layout
- Add trait `Collection` and macro `kas::collection!` (#431)
- Add trait `CellCollection` and macro `kas::cell_collection!` (#443)
- Replace trait `AutoLayout` with `LayoutVisitor` using RPITIT (#434)
- Replace `align!(spec DSL, child)`, `pack!(spec DSL, child)` and `margins!(spec DSL, child)` with `.align(hints)`, `.pack(hints)`, `.margins(dirs, style)` widget/layout adapters; more uniform support for adapters within and without layout macros (#438)
- Pass `AlignHints` to `fn set_rect` not `size_rules` (#447)

### Widgets
- Make `kas::widgets::ImageError` public (#428)
- Make `AdaptEvents` a thin wrapper without `Id` (#430)
- Use RPITIT in traits `ListData`, `MatrixData` (#433)
- Remove widget aliases `StrLabel`, `StringLabel`, `StrText`, `StringText` (#438)

## [0.14.2] — 2023-12-12

Expand Down
20 changes: 8 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "kas"
version = "0.14.3"
version = "0.15.0"
authors = ["Diggory Hardy <git@dhardy.name>"]
edition = "2021"
license = "Apache-2.0"
Expand All @@ -11,7 +11,7 @@ keywords = ["gui"]
categories = ["gui"]
repository = "https://github.com/kas-gui/kas"
exclude = ["/examples"]
rust-version = "1.79.0"
rust-version = "1.80.0"

[package.metadata.docs.rs]
features = ["stable"]
Expand Down Expand Up @@ -132,14 +132,14 @@ recursive-layout-widgets = ["kas-core/recursive-layout-widgets"]
unsafe_node = ["kas-core/unsafe_node"]

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

[dependencies.kas-wgpu]
version = "0.14.2"
version = "0.15.0"
path = "crates/kas-wgpu"
optional = true
default-features = false
Expand All @@ -161,7 +161,3 @@ members = [
"crates/kas-view",
"examples/mandlebrot",
]

[patch.crates-io.kas-text]
git = "https://github.com/kas-gui/kas-text.git"
rev = "8828bb3df7c34559e18429a18a38974ddc3e905f"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ KAS GUI
[![Crates.io](https://img.shields.io/crates/v/kas.svg)](https://crates.io/crates/kas)
[![kas-text](https://img.shields.io/badge/GitHub-kas--text-blueviolet)](https://github.com/kas-gui/kas-text/)
[![Docs](https://docs.rs/kas/badge.svg)](https://docs.rs/kas)
![Minimum rustc version](https://img.shields.io/badge/rustc-1.79+-lightgray.svg)
![Minimum rustc version](https://img.shields.io/badge/rustc-1.80+-lightgray.svg)

KAS is a stateful, pure-Rust GUI toolkit supporting:

Expand Down
5 changes: 5 additions & 0 deletions ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,11 @@ to event handlers and to a new `update` method. The key advantages of this chang

For more on *input data*, read the [design document](https://github.com/kas-gui/design/blob/input-data/widget/input-data.md).

### 0.15.0 — December 2024

Add traits `Collection` and `CellCollection` representing a list/tuple of widgets.
Revise layout macros with `.align` / `.pack` / `.margins` adapters.


Future work
-----------
Expand Down
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.14.1"
version = "0.15.0"
authors = ["Diggory Hardy <git@dhardy.name>"]
edition = "2021"
license = "Apache-2.0"
Expand Down Expand Up @@ -119,11 +119,11 @@ arboard = { version = "3.2.0", optional = true, default-features = false }


[dependencies.kas-macros]
version = "0.14.1"
version = "0.15.0"
path = "../kas-macros"

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

[dependencies.easy-cast]
version = "0.5.0" # used in doc links
Expand Down
6 changes: 3 additions & 3 deletions crates/kas-core/src/config/font.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

//! Font configuration
use crate::text::fonts::{self, AddMode, FontSelector};
use crate::text::fonts::{library, AddMode, FontSelector};
use crate::theme::TextClass;
use crate::Action;
use std::collections::BTreeMap;
Expand Down Expand Up @@ -166,9 +166,9 @@ impl FontConfig {
/// Apply config effects which only happen on startup
pub(super) fn init(&self) {
if !self.aliases.is_empty() {
fonts::library().update_db(|db| {
library().adjust_resolver(|resolver| {
for (family, aliases) in self.aliases.iter() {
db.add_aliases(
resolver.add_aliases(
family.to_string().into(),
aliases.list.iter().map(|s| s.to_string().into()),
aliases.mode,
Expand Down
10 changes: 4 additions & 6 deletions crates/kas-core/src/event/cx/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@ use super::PendingNavFocus;
use crate::event::{EventState, FocusSource};
use crate::geom::{Rect, Size};
use crate::layout::AlignPair;
use crate::messages::Erased;
use crate::text::format::FormattableText;
use crate::theme::{Feature, SizeCx, Text, ThemeSize};
use crate::{Id, Node};
use cast::Cast;
use std::fmt::Debug;
use std::ops::{Deref, DerefMut};

#[allow(unused)] use crate::event::{Event, EventCx};
Expand Down Expand Up @@ -92,13 +90,12 @@ impl<'a> ConfigCx<'a> {
widget._update(self);
}

/* TODO: can we support these (i.e. track `id`)?
/// Push a message (replay)
///
/// Unlike [`EventCx::push`], this is not handled while unwinding
/// from event sending, but via a fresh traversal of the widget tree.
///
/// TODO: `id` should not be part of the function signature?
pub fn push<M: Debug + 'static>(&mut self, id: Id, msg: M) {
pub fn push<M: Debug + 'static>(&mut self, msg: M) {
self.send(id, msg);
}
Expand All @@ -110,9 +107,10 @@ impl<'a> ConfigCx<'a> {
/// The message may be [popped](EventCx::try_pop) or
/// [observed](EventCx::try_observe) from [`Events::handle_messages`]
/// by the widget itself, its parent, or any ancestor.
pub fn push_erased(&mut self, id: Id, msg: Erased) {
pub fn push_erased(&mut self, msg: Erased) {
self.send_erased(id, msg);
}
*/

/// Align a feature's rect
///
Expand Down
10 changes: 9 additions & 1 deletion crates/kas-core/src/event/cx/cx_pub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -596,11 +596,19 @@ impl EventState {
}

/// Send a message to `id`
///
/// Similar to [`EventCx::push`], the message is sent as part of a widget
/// tree traversal.
/// The message may be [popped](EventCx::try_pop) or
/// [observed](EventCx::try_observe) from [`Events::handle_messages`]
/// by the widget itself, its parent, or any ancestor.
pub fn send<M: Debug + 'static>(&mut self, id: Id, msg: M) {
self.send_erased(id, Erased::new(msg));
}

/// Send an erased message to `id`
/// Push a type-erased message to the stack
///
/// This is a lower-level variant of [`Self::send`].
pub fn send_erased(&mut self, id: Id, msg: Erased) {
self.send_queue.push_back((id, msg));
}
Expand Down
4 changes: 2 additions & 2 deletions crates/kas-core/src/theme/simple_theme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ where

fn init(&mut self, config: &RefCell<Config>) {
let fonts = fonts::library();
if let Err(e) = fonts.select_default() {
panic!("Error loading font: {e}");
if let Err(e) = fonts.init() {
panic!("Error initializing fonts: {e}");
}
self.fonts = Some(Rc::new(
config
Expand Down
10 changes: 5 additions & 5 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.14.2"
version = "0.15.0"
authors = ["Diggory Hardy <git@dhardy.name>"]
edition = "2021"
license = "Apache-2.0"
Expand All @@ -27,7 +27,7 @@ resvg = ["dep:kas-resvg"]
docs_rs = ["kas-core/winit", "kas-core/wayland"]

[dependencies]
kas-core = { version = "0.14.1", path = "../kas-core" }
kas-widgets = { version = "0.14.2", path = "../kas-widgets" }
kas-resvg = { version = "0.14.2", path = "../kas-resvg", optional = true }
kas-wgpu = { version = "0.14.1", path = "../kas-wgpu", default-features = false }
kas-core = { version = "0.15.0", path = "../kas-core" }
kas-widgets = { version = "0.15.0", path = "../kas-widgets" }
kas-resvg = { version = "0.15.0", path = "../kas-resvg", optional = true }
kas-wgpu = { version = "0.15.0", path = "../kas-wgpu", default-features = false }
2 changes: 1 addition & 1 deletion 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.14.1"
version = "0.15.0"
authors = ["Diggory Hardy <git@dhardy.name>"]
edition = "2021"
license = "Apache-2.0"
Expand Down
4 changes: 2 additions & 2 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.14.2"
version = "0.15.0"
authors = ["Diggory Hardy <git@dhardy.name>"]
edition = "2021"
license = "Apache-2.0"
Expand Down Expand Up @@ -33,7 +33,7 @@ thiserror = "2.0.3"

[dependencies.kas]
# We must rename this package since macros expect kas to be in scope:
version = "0.14.1"
version = "0.15.0"
package = "kas-core"
path = "../kas-core"
features = ["spawn"]
7 changes: 5 additions & 2 deletions crates/kas-resvg/src/svg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,11 @@ enum LoadError {
fn load(data: &[u8], resources_dir: Option<&Path>) -> Result<Tree, usvg::Error> {
use once_cell::sync::Lazy;
static FONT_FAMILY: Lazy<String> = Lazy::new(|| {
let fonts_db = kas::text::fonts::library().read_db();
fonts_db.font_family_from_alias("SERIF").unwrap_or_default()
let resolver = kas::text::fonts::library().resolver();
let db = kas::text::fonts::db().unwrap();
resolver
.font_family_from_alias(db, "SERIF")
.unwrap_or_default()
});

// Defaults are taken from usvg::Options::default(). Notes:
Expand Down
6 changes: 3 additions & 3 deletions crates/kas-view/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "kas-view"
version = "0.14.2"
version = "0.15.0"
authors = ["Diggory Hardy <git@dhardy.name>"]
edition = "2021"
license = "Apache-2.0"
Expand All @@ -17,12 +17,12 @@ features = ["kas/winit", "kas/wayland"]
rustdoc-args = ["--cfg", "docsrs"]

[dependencies]
kas-widgets = { version = "0.14.1", path = "../kas-widgets" }
kas-widgets = { version = "0.15.0", path = "../kas-widgets" }
log = "0.4"
linear-map = "1.2.0"

# We must rename this package since macros expect kas to be in scope:
kas = { version = "0.14.1", package = "kas-core", path = "../kas-core" }
kas = { version = "0.15.0", package = "kas-core", path = "../kas-core" }

[lints.clippy]
collapsible_else_if = "allow"
Expand Down
6 changes: 3 additions & 3 deletions crates/kas-wgpu/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "kas-wgpu"
version = "0.14.2"
version = "0.15.0"
authors = ["Diggory Hardy <git@dhardy.name>"]
edition = "2021"
license = "Apache-2.0"
Expand Down Expand Up @@ -39,12 +39,12 @@ rustc-hash = "2.0"

[dependencies.kas]
# Rename package purely for convenience:
version = "0.14.1"
version = "0.15.0"
package = "kas-core"
path = "../kas-core"

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

[dependencies.wgpu]
version = "23.0.1"
Expand Down
6 changes: 3 additions & 3 deletions crates/kas-widgets/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "kas-widgets"
version = "0.14.2"
version = "0.15.0"
authors = ["Diggory Hardy <git@dhardy.name>"]
edition = "2021"
license = "Apache-2.0"
Expand All @@ -26,11 +26,11 @@ smallvec = "1.6.1"
unicode-segmentation = "1.7"
thiserror = "2.0.3"
image = { version = "0.25.1", optional = true }
kas-macros = { version = "0.14.1", path = "../kas-macros" }
kas-macros = { version = "0.15.0", path = "../kas-macros" }
linear-map = "1.2.0"

# We must rename this package since macros expect kas to be in scope:
kas = { version = "0.14.1", package = "kas-core", path = "../kas-core" }
kas = { version = "0.15.0", package = "kas-core", path = "../kas-core" }

[lints.clippy]
collapsible_else_if = "allow"
Expand Down
20 changes: 6 additions & 14 deletions crates/kas-widgets/src/label.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,6 @@ use kas::prelude::*;
use kas::text::format::{EditableText, FormattableText};
use kas::theme::{Text, TextClass};

/// Construct a [`Label`]
#[inline]
pub fn label<T: FormattableText + 'static>(text: T) -> Label<T> {
Label::new(text)
}

/// Construct a [`Label`] which accepts any data
///
/// This is just a shortcut for `Label::new(text).map_any()`.
#[inline]
pub fn label_any<A, T: FormattableText + 'static>(text: T) -> MapAny<A, Label<T>> {
MapAny::new(Label::new(text))
}

impl_scope! {
/// A text label
///
Expand Down Expand Up @@ -56,6 +42,12 @@ impl_scope! {
}
}

/// Construct from `text`, mapping to support any data type
#[inline]
pub fn new_any<A>(text: T) -> MapAny<A, Self> {
MapAny::new(Label::new(text))
}

/// Get text class
#[inline]
pub fn class(&self) -> TextClass {
Expand Down
2 changes: 1 addition & 1 deletion crates/kas-widgets/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ pub use filler::Filler;
pub use frame::Frame;
pub use grid::Grid;
pub use grip::{GripMsg, GripPart};
pub use label::{label, label_any, AccessLabel, Label};
pub use label::{AccessLabel, Label};
pub use list::*;
pub use mark::{Mark, MarkButton};
pub use nav_frame::NavFrame;
Expand Down
Loading

0 comments on commit 8a20070

Please sign in to comment.