summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2021-08-26 14:41:33 +0700
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2021-08-26 14:41:33 +0700
commit7614127d3641cf3224798c2f0ff07b6ae57d9a53 (patch)
tree413fc3a6f7a22bfaf00de05dfcc9acf5b40bdd26 /core
parentaa63841e2c80ca8130adf41d25e5d731409b92f4 (diff)
downloadiced-7614127d3641cf3224798c2f0ff07b6ae57d9a53.tar.gz
iced-7614127d3641cf3224798c2f0ff07b6ae57d9a53.tar.bz2
iced-7614127d3641cf3224798c2f0ff07b6ae57d9a53.zip
Rename `HitTestResult` to `Hit`
... and also move it to a new `text` module in `iced_core`
Diffstat (limited to 'core')
-rw-r--r--core/src/keyboard.rs2
-rw-r--r--core/src/lib.rs3
-rw-r--r--core/src/mouse.rs2
-rw-r--r--core/src/text.rs (renamed from core/src/hit_test.rs)9
4 files changed, 8 insertions, 8 deletions
diff --git a/core/src/keyboard.rs b/core/src/keyboard.rs
index cb64701a..6827a4db 100644
--- a/core/src/keyboard.rs
+++ b/core/src/keyboard.rs
@@ -1,4 +1,4 @@
-//! Reuse basic keyboard types.
+//! Listen to keyboard events.
mod event;
mod hotkey;
mod key_code;
diff --git a/core/src/lib.rs b/core/src/lib.rs
index 7c4c3c0c..a0decdab 100644
--- a/core/src/lib.rs
+++ b/core/src/lib.rs
@@ -17,12 +17,12 @@
pub mod keyboard;
pub mod menu;
pub mod mouse;
+pub mod text;
mod align;
mod background;
mod color;
mod font;
-mod hit_test;
mod length;
mod padding;
mod point;
@@ -34,7 +34,6 @@ pub use align::{Align, HorizontalAlignment, VerticalAlignment};
pub use background::Background;
pub use color::Color;
pub use font::Font;
-pub use hit_test::HitTestResult;
pub use length::Length;
pub use menu::Menu;
pub use padding::Padding;
diff --git a/core/src/mouse.rs b/core/src/mouse.rs
index 25ce6ac3..48214f65 100644
--- a/core/src/mouse.rs
+++ b/core/src/mouse.rs
@@ -1,4 +1,4 @@
-//! Reuse basic mouse types.
+//! Handle mouse events.
mod button;
mod event;
mod interaction;
diff --git a/core/src/hit_test.rs b/core/src/text.rs
index a4a7b610..ded22eef 100644
--- a/core/src/hit_test.rs
+++ b/core/src/text.rs
@@ -1,8 +1,9 @@
+//! Draw and interact with text.
use crate::Vector;
/// The result of hit testing on text.
#[derive(Debug, Clone, Copy, PartialEq)]
-pub enum HitTestResult {
+pub enum Hit {
/// The point was within the bounds of the returned character index.
CharOffset(usize),
/// The provided point was not within the bounds of a glyph. The index
@@ -11,12 +12,12 @@ pub enum HitTestResult {
NearestCharOffset(usize, Vector),
}
-impl HitTestResult {
+impl Hit {
/// Computes the cursor position corresponding to this [`HitTestResult`] .
pub fn cursor(&self) -> usize {
match self {
- HitTestResult::CharOffset(i) => *i,
- HitTestResult::NearestCharOffset(i, delta) => {
+ Self::CharOffset(i) => *i,
+ Self::NearestCharOffset(i, delta) => {
if delta.x > f32::EPSILON {
i + 1
} else {