Skip to content
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
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -175,4 +175,4 @@ resolver = "2"

[patch.crates-io.kas-text]
git = "https://github.com/kas-gui/kas-text.git"
rev = "efe15a6040edde83b64cb668c64da63b164abfd7"
rev = "9554604bbaa40af58114126496a2c20e1553c468"
3 changes: 2 additions & 1 deletion crates/kas-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ ab_glyph = { version = "0.2.10", optional = true }
swash = { version = "0.2.4", features = ["scale"] }
linearize = { version = "0.1.5", features = ["derive"] }
kas-text = "0.9.0"
easy-cast = "0.6.1"
easy-cast = "0.7.0"
pulldown-cmark = { version = "0.13.0", optional = true }

[dependencies.kas-macros]
Expand Down Expand Up @@ -144,6 +144,7 @@ collapsible_if = "allow"
collapsible_else_if = "allow"
bool_comparison = "allow"
option_map_unit_fn = "allow"
needless_late_init = "allow"

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(internal_doc)'] }
6 changes: 3 additions & 3 deletions crates/kas-core/src/draw/color.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

use std::ops::Add;

use crate::cast::{Conv, ConvFloat};
use crate::cast::{Conv, ConvTo, Nearest};
use thiserror::Error;

/// 4-part colour data, linear, sRGB colour space
Expand Down Expand Up @@ -561,7 +561,7 @@ fn from_linear(x: f32) -> u8 {
} else {
x.powf(1.0 / 2.4) * 1.055 - 0.055
};
u8::conv_nearest(x * 255.0)
u8::conv_to(Nearest, x * 255.0)
}

impl From<Rgba8Srgb> for Rgba {
Expand Down Expand Up @@ -592,7 +592,7 @@ impl From<Rgba> for Rgba8Srgb {
from_linear(c.r),
from_linear(c.g),
from_linear(c.b),
u8::conv_nearest(c.a * 255.0),
u8::conv_to(Nearest, c.a * 255.0),
])
}
}
Expand Down
8 changes: 4 additions & 4 deletions crates/kas-core/src/event/components.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//! Event handling components

use super::*;
use crate::cast::traits::*;
use crate::cast::{Nearest, Trunc, traits::*};
use crate::geom::{Coord, Offset, Rect, Size, Vec2};
use crate::text::CursorRange;
use crate::{ActionMoved, Id};
Expand Down Expand Up @@ -87,7 +87,7 @@ impl Kinetic {
pub fn start(&mut self, start: KineticStart) -> Offset {
self.vel += start.vel;
let d = self.rest + start.rest;
let delta = Offset::conv_trunc(d);
let delta = Offset::conv_to(Trunc, d);
self.rest = d - Vec2::conv(delta);
self.t_step = Instant::now();
delta
Expand Down Expand Up @@ -120,7 +120,7 @@ impl Kinetic {
}

let d = self.vel * dur + self.rest;
let delta = Offset::conv_trunc(d);
let delta = Offset::conv_to(Trunc, d);
self.rest = d - Vec2::conv(delta);

Some(delta)
Expand Down Expand Up @@ -308,7 +308,7 @@ impl ScrollComponent {

fn scroll_by_delta(&mut self, cx: &mut EventCx, d: Vec2) {
let delta = d + self.kinetic.rest;
let offset = delta.cast_nearest();
let offset = delta.cast_to(Nearest);
self.kinetic.rest = delta - Vec2::conv(offset);
let delta = self.scroll_self_by_delta(cx, offset);
cx.set_scroll(if delta != Offset::ZERO {
Expand Down
4 changes: 2 additions & 2 deletions crates/kas-core/src/event/cx/press.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ pub(crate) mod velocity;
use super::{EventCx, IsUsed};
#[allow(unused)] use crate::Events; // for doc-links
use crate::Id;
use crate::cast::{Approx, Cast, CastTo, Conv};
use crate::event::{CursorIcon, MouseButton, Unused, Used};
use crate::geom::{Coord, DVec2, Offset, Vec2};
use cast::{Cast, CastApprox, Conv};
pub(crate) use mouse::Mouse;
pub(crate) use touch::Touch;
use winit::event::FingerId;
Expand Down Expand Up @@ -191,7 +191,7 @@ impl PressStart {
/// Get the current press coordinate
#[inline]
pub fn coord(&self) -> Coord {
self.position.cast_approx()
self.position.cast_to(Approx)
}

/// Grab pan/move/press-end events for widget `id`
Expand Down
8 changes: 4 additions & 4 deletions crates/kas-core/src/event/cx/press/mouse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use crate::geom::{Affine, Coord, DVec2, Vec2};
use crate::window::WindowErased;
use crate::window::WindowWidget;
use crate::{ActionRedraw, Id, Node, Tile, TileExt};
use cast::{CastApprox, CastFloat};
use cast::{CastApprox, CastTo, Nearest};
use std::time::{Duration, Instant};
use winit::cursor::CursorIcon;
use winit::event::{ElementState, MouseButton, MouseScrollDelta};
Expand Down Expand Up @@ -330,7 +330,7 @@ impl<'a> EventCx<'a> {
let press = Press {
source: PressSource::mouse(Some(grab.button), grab.repetitions),
id: self.mouse.over.clone(),
coord: self.mouse.last_position.cast_nearest(),
coord: self.mouse.last_position.cast_to(Nearest),
};
let event = Event::PressEnd { press, success };
to_send = Some((grab.start_id.clone(), event));
Expand All @@ -357,7 +357,7 @@ impl<'a> EventCx<'a> {
self.action_redraw(redraw);

if self.action_moved.is_some() {
let over = node.try_probe(self.mouse.last_position.cast_nearest());
let over = node.try_probe(self.mouse.last_position.cast_to(Nearest));
self.set_over(node, over);
}
}
Expand All @@ -369,7 +369,7 @@ impl<'a> EventCx<'a> {
data: &A,
position: DVec2,
) {
let coord = position.cast_nearest();
let coord = position.cast_to(Nearest);
let id = win.try_probe(coord);
self.tooltip_motion(win, &id);
self.handle_pointer_moved_(id, win.as_node(data), coord, position);
Expand Down
12 changes: 6 additions & 6 deletions crates/kas-core/src/event/cx/press/touch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::config::EventWindowConfig;
use crate::event::{Event, EventCx, EventState, FocusSource, NavAdvance, PressStart};
use crate::geom::{Affine, DVec2, Vec2};
use crate::{ActionRedraw, Id, Node};
use cast::{Cast, CastApprox, CastFloat, Conv};
use cast::{Cast, CastApprox, CastTo, Conv, Nearest};
use smallvec::SmallVec;
use winit::event::FingerId;

Expand Down Expand Up @@ -259,7 +259,7 @@ impl<'a> EventCx<'a> {
let press = Press {
source: PressSource::touch(grab.finger_id),
id: grab.over,
coord: grab.last_position.cast_nearest(),
coord: grab.last_position.cast_to(Nearest),
};
let event = Event::PressEnd {
press,
Expand All @@ -273,7 +273,7 @@ impl<'a> EventCx<'a> {

if self.action_moved.is_some() {
for grab in self.touch.touch_grab.iter_mut() {
grab.over = node.try_probe(grab.last_position.cast_nearest());
grab.over = node.try_probe(grab.last_position.cast_to(Nearest));
}
}
}
Expand Down Expand Up @@ -310,7 +310,7 @@ impl<'a> EventCx<'a> {
finger_id: FingerId,
position: DVec2,
) {
let coord = position.cast_nearest();
let coord = position.cast_to(Nearest);
let over = node.try_probe(coord);
self.close_non_ancestors_of(over.as_ref());

Expand All @@ -337,7 +337,7 @@ impl<'a> EventCx<'a> {
finger_id: FingerId,
position: DVec2,
) {
let coord = position.cast_nearest();
let coord = position.cast_to(Nearest);
let over = node.try_probe(coord);

let mut pan_grab = None;
Expand Down Expand Up @@ -402,7 +402,7 @@ impl<'a> EventCx<'a> {
let source = PressSource::touch(finger_id);
let id = grab.over.clone();
let success = id.is_some();
let coord = position.cast_nearest();
let coord = position.cast_to(Nearest);
let press = Press { source, id, coord };

let event = Event::PressEnd { press, success };
Expand Down
Loading