mirror of
https://github.com/danbulant/cushy
synced 2026-07-07 12:10:44 +00:00
parent
1ed1a95a1d
commit
c39f8f33ad
11 changed files with 1036 additions and 393 deletions
11
Cargo.lock
generated
11
Cargo.lock
generated
|
|
@ -831,6 +831,8 @@ dependencies = [
|
||||||
"pollster",
|
"pollster",
|
||||||
"tracing",
|
"tracing",
|
||||||
"tracing-subscriber",
|
"tracing-subscriber",
|
||||||
|
"unicode-segmentation",
|
||||||
|
"zeroize",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
@ -1087,7 +1089,7 @@ checksum = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc"
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "kludgine"
|
name = "kludgine"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/khonsulabs/kludgine#c0135da62309896fab58a2f5b517c32cde151fb3"
|
source = "git+https://github.com/khonsulabs/kludgine#220df4ed07fcf86459a34591a7923d7ddb25e67e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ahash",
|
"ahash",
|
||||||
"alot",
|
"alot",
|
||||||
|
|
@ -1101,6 +1103,7 @@ dependencies = [
|
||||||
"lyon_tessellation",
|
"lyon_tessellation",
|
||||||
"pollster",
|
"pollster",
|
||||||
"smallvec",
|
"smallvec",
|
||||||
|
"unicode-bidi",
|
||||||
"wgpu",
|
"wgpu",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
@ -3152,3 +3155,9 @@ dependencies = [
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "zeroize"
|
||||||
|
version = "1.7.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d"
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,8 @@ ahash = "0.8.6"
|
||||||
gooey-macros = { version = "0.1.0", path = "gooey-macros" }
|
gooey-macros = { version = "0.1.0", path = "gooey-macros" }
|
||||||
derive_more = { version = "1.0.0-beta.6", features = ["from"] }
|
derive_more = { version = "1.0.0-beta.6", features = ["from"] }
|
||||||
arboard = "3.2.1"
|
arboard = "3.2.1"
|
||||||
|
zeroize = "1.6.1"
|
||||||
|
unicode-segmentation = "1.10.1"
|
||||||
|
|
||||||
|
|
||||||
# [patch."https://github.com/khonsulabs/kludgine"]
|
# [patch."https://github.com/khonsulabs/kludgine"]
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
use std::process::exit;
|
use std::process::exit;
|
||||||
|
|
||||||
use gooey::value::{Dynamic, MapEach, StringValue};
|
use gooey::value::{Dynamic, MapEach};
|
||||||
use gooey::widget::{MakeWidget, MakeWidgetWithId, WidgetTag};
|
use gooey::widget::{MakeWidget, MakeWidgetWithId, WidgetTag};
|
||||||
|
use gooey::widgets::input::{InputValue, MaskedString};
|
||||||
use gooey::widgets::Expand;
|
use gooey::widgets::Expand;
|
||||||
use gooey::Run;
|
use gooey::Run;
|
||||||
use kludgine::figures::units::Lp;
|
use kludgine::figures::units::Lp;
|
||||||
|
|
@ -33,7 +34,6 @@ fn main() -> gooey::Result {
|
||||||
|
|
||||||
let password_row = "Password"
|
let password_row = "Password"
|
||||||
.and(
|
.and(
|
||||||
// TODO secure input
|
|
||||||
password
|
password
|
||||||
.clone()
|
.clone()
|
||||||
.into_input()
|
.into_input()
|
||||||
|
|
@ -79,6 +79,6 @@ fn main() -> gooey::Result {
|
||||||
.run()
|
.run()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn validate(username: &String, password: &String) -> bool {
|
fn validate(username: &String, password: &MaskedString) -> bool {
|
||||||
!username.is_empty() && !password.is_empty()
|
!username.is_empty() && !password.is_empty()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
use gooey::value::{Dynamic, StringValue};
|
use gooey::value::Dynamic;
|
||||||
use gooey::widget::{MakeWidget, HANDLED, IGNORED};
|
use gooey::widget::{MakeWidget, HANDLED, IGNORED};
|
||||||
|
use gooey::widgets::input::InputValue;
|
||||||
use gooey::widgets::Space;
|
use gooey::widgets::Space;
|
||||||
use gooey::Run;
|
use gooey::Run;
|
||||||
use kludgine::app::winit::event::ElementState;
|
use kludgine::app::winit::event::ElementState;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,21 @@
|
||||||
use gooey::value::StringValue;
|
use gooey::value::Dynamic;
|
||||||
use gooey::widget::MakeWidget;
|
use gooey::widget::MakeWidget;
|
||||||
|
use gooey::widgets::input::{InputValue, MaskedString};
|
||||||
use gooey::Run;
|
use gooey::Run;
|
||||||
|
use kludgine::figures::units::Px;
|
||||||
|
|
||||||
fn main() -> gooey::Result {
|
fn main() -> gooey::Result {
|
||||||
"Hello".into_input().expand().run()
|
let contents = Dynamic::from("Hello World");
|
||||||
|
let password = Dynamic::new(MaskedString::default());
|
||||||
|
|
||||||
|
"Text Input Field:"
|
||||||
|
.and(contents.into_input())
|
||||||
|
.and("Masked Input Field:")
|
||||||
|
.and(password.into_input())
|
||||||
|
.into_rows()
|
||||||
|
.width(Px(100)..Px(800))
|
||||||
|
.scroll()
|
||||||
|
.centered()
|
||||||
|
.expand()
|
||||||
|
.run()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
use std::process::exit;
|
use std::process::exit;
|
||||||
|
|
||||||
use gooey::value::{Dynamic, MapEach, StringValue};
|
use gooey::value::{Dynamic, MapEach};
|
||||||
use gooey::widget::MakeWidget;
|
use gooey::widget::MakeWidget;
|
||||||
|
use gooey::widgets::input::{InputValue, MaskedString};
|
||||||
use gooey::widgets::Expand;
|
use gooey::widgets::Expand;
|
||||||
use gooey::Run;
|
use gooey::Run;
|
||||||
use kludgine::figures::units::Lp;
|
use kludgine::figures::units::Lp;
|
||||||
|
|
@ -58,6 +59,6 @@ fn main() -> gooey::Result {
|
||||||
.run()
|
.run()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn validate(username: &String, password: &String) -> bool {
|
fn validate(username: &String, password: &MaskedString) -> bool {
|
||||||
!username.is_empty() && !password.is_empty()
|
!username.is_empty() && !password.is_empty()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
use gooey::animation::{LinearInterpolate, PercentBetween};
|
use gooey::animation::{LinearInterpolate, PercentBetween};
|
||||||
use gooey::value::{Dynamic, StringValue};
|
use gooey::value::Dynamic;
|
||||||
use gooey::widget::MakeWidget;
|
use gooey::widget::MakeWidget;
|
||||||
|
use gooey::widgets::input::InputValue;
|
||||||
use gooey::widgets::slider::Slidable;
|
use gooey::widgets::slider::Slidable;
|
||||||
use gooey::Run;
|
use gooey::Run;
|
||||||
use kludgine::figures::units::Lp;
|
use kludgine::figures::units::Lp;
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,9 @@ use gooey::styles::components::{TextColor, WidgetBackground};
|
||||||
use gooey::styles::{
|
use gooey::styles::{
|
||||||
ColorScheme, ColorSource, ColorTheme, FixedTheme, SurfaceTheme, Theme, ThemePair,
|
ColorScheme, ColorSource, ColorTheme, FixedTheme, SurfaceTheme, Theme, ThemePair,
|
||||||
};
|
};
|
||||||
use gooey::value::{Dynamic, MapEach, StringValue};
|
use gooey::value::{Dynamic, MapEach};
|
||||||
use gooey::widget::MakeWidget;
|
use gooey::widget::MakeWidget;
|
||||||
|
use gooey::widgets::input::InputValue;
|
||||||
use gooey::widgets::slider::Slidable;
|
use gooey::widgets::slider::Slidable;
|
||||||
use gooey::widgets::{Slider, Stack};
|
use gooey::widgets::{Slider, Stack};
|
||||||
use gooey::window::ThemeMode;
|
use gooey::window::ThemeMode;
|
||||||
|
|
|
||||||
24
src/value.rs
24
src/value.rs
|
|
@ -17,7 +17,7 @@ use crate::animation::{DynamicTransition, LinearInterpolate};
|
||||||
use crate::context::{WidgetContext, WindowHandle};
|
use crate::context::{WidgetContext, WindowHandle};
|
||||||
use crate::utils::{IgnorePoison, WithClone};
|
use crate::utils::{IgnorePoison, WithClone};
|
||||||
use crate::widget::{WidgetId, WidgetInstance};
|
use crate::widget::{WidgetId, WidgetInstance};
|
||||||
use crate::widgets::{Input, Switcher};
|
use crate::widgets::Switcher;
|
||||||
|
|
||||||
/// An instance of a value that provides APIs to observe and react to its
|
/// An instance of a value that provides APIs to observe and react to its
|
||||||
/// contents.
|
/// contents.
|
||||||
|
|
@ -504,6 +504,18 @@ impl<T> From<Dynamic<T>> for DynamicReader<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<&str> for Dynamic<String> {
|
||||||
|
fn from(value: &str) -> Self {
|
||||||
|
Dynamic::from(value.to_string())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<String> for Dynamic<String> {
|
||||||
|
fn from(value: String) -> Self {
|
||||||
|
Dynamic::new(value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
struct DynamicMutexGuard<'a, T> {
|
struct DynamicMutexGuard<'a, T> {
|
||||||
dynamic: &'a DynamicData<T>,
|
dynamic: &'a DynamicData<T>,
|
||||||
|
|
@ -1384,13 +1396,3 @@ macro_rules! impl_tuple_map_each {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl_all_tuples!(impl_tuple_map_each);
|
impl_all_tuples!(impl_tuple_map_each);
|
||||||
|
|
||||||
/// A type that can be converted into a [`Value<String>`].
|
|
||||||
pub trait StringValue: IntoValue<String> + Sized {
|
|
||||||
/// Returns this string as a text input widget.
|
|
||||||
fn into_input(self) -> Input {
|
|
||||||
Input::new(self.into_value())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T> StringValue for T where T: IntoValue<String> {}
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ mod canvas;
|
||||||
pub mod checkbox;
|
pub mod checkbox;
|
||||||
pub mod container;
|
pub mod container;
|
||||||
mod expand;
|
mod expand;
|
||||||
mod input;
|
pub mod input;
|
||||||
pub mod label;
|
pub mod label;
|
||||||
mod mode_switch;
|
mod mode_switch;
|
||||||
mod resize;
|
mod resize;
|
||||||
|
|
|
||||||
1352
src/widgets/input.rs
1352
src/widgets/input.rs
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue