switch to default iris app

This commit is contained in:
2025-12-04 14:31:34 -05:00
parent 1904560244
commit 02696b1f75
10 changed files with 61 additions and 528 deletions

View File

@@ -1,5 +1,3 @@
use std::time::{Duration, Instant};
use super::*;
pub fn werror(ui: &mut Ui, msg: &str) -> WidgetId {
@@ -11,63 +9,6 @@ pub fn werror(ui: &mut Ui, msg: &str) -> WidgetId {
.any()
}
pub struct Selector;
impl<W: 'static> WidgetAttr<W> for Selector {
type Input = WidgetId<TextEdit>;
fn run(ui: &mut Ui, container: &WidgetId<W>, id: Self::Input) {
let container = container.clone();
ui.register_event(
&container.clone(),
CursorSense::click_or_drag(),
move |client: &mut Client, mut data| {
let region = client.ui.window_region(&id).unwrap();
let id_pos = region.top_left;
let container_pos = client.ui.window_region(&container).unwrap().top_left;
data.cursor += container_pos - id_pos;
data.size = region.size();
select(id.clone(), client, data);
},
);
}
}
pub struct Selectable;
impl WidgetAttr<TextEdit> for Selectable {
type Input = ();
fn run(ui: &mut Ui, id: &WidgetId<TextEdit>, _: Self::Input) {
let id = id.clone();
ui.register_event(
&id.clone(),
CursorSense::click_or_drag(),
move |client: &mut Client, data| {
select(id.clone(), client, data);
},
);
}
}
fn select(id: WidgetId<TextEdit>, client: &mut Client, data: CursorData) {
let now = Instant::now();
let recent = (now - client.last_click) < Duration::from_millis(300);
client.last_click = now;
client
.ui
.text(&id)
.select(data.cursor, data.size, data.sense.is_dragging(), recent);
if let Some(region) = client.ui.window_region(&id) {
client.handle.window.set_ime_allowed(true);
client.handle.window.set_ime_cursor_area(
LogicalPosition::<f32>::from(region.top_left.tuple()),
LogicalSize::<f32>::from(region.size().tuple()),
);
}
client.focus = Some(id);
}
pub fn hint(msg: impl Into<String>) -> TextBuilder {
wtext(msg).size(20).color(Color::GRAY)
}