move everything out of layout
This commit is contained in:
@@ -8,7 +8,7 @@ fn main() {
|
||||
}
|
||||
|
||||
pub struct Client {
|
||||
info: WidgetId<Text>,
|
||||
info: WidgetHandle<Text>,
|
||||
}
|
||||
|
||||
event_ctx!(Client);
|
||||
@@ -143,7 +143,7 @@ impl DefaultAppState for Client {
|
||||
|
||||
let main = pad_test.clone().pad(10).add(ui);
|
||||
|
||||
let switch_button = |color, to: WidgetId, label| {
|
||||
let switch_button = |color, to: WidgetHandle, label| {
|
||||
let main_ = main.clone();
|
||||
let rect = rect(color)
|
||||
.on(CursorSense::click(), move |ctx| {
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
use crate::{default::UiState, prelude::*};
|
||||
use crate::prelude::*;
|
||||
use std::time::{Duration, Instant};
|
||||
use winit::dpi::{LogicalPosition, LogicalSize};
|
||||
|
||||
pub struct Selector;
|
||||
|
||||
impl<W: 'static + Widget> WidgetAttr<W> for Selector {
|
||||
type Input = WidgetId<TextEdit>;
|
||||
type Input = WidgetHandle<TextEdit>;
|
||||
|
||||
fn run(ui: &mut Ui, container: &WidgetId<W>, id: Self::Input) {
|
||||
fn run(ui: &mut Ui, container: &WidgetHandle<W>, id: Self::Input) {
|
||||
let container = container.clone();
|
||||
ui.register_event(
|
||||
&container.clone(),
|
||||
@@ -30,7 +30,7 @@ pub struct Selectable;
|
||||
impl WidgetAttr<TextEdit> for Selectable {
|
||||
type Input = ();
|
||||
|
||||
fn run(ui: &mut Ui, id: &WidgetId<TextEdit>, _: Self::Input) {
|
||||
fn run(ui: &mut Ui, id: &WidgetHandle<TextEdit>, _: Self::Input) {
|
||||
let id = id.clone();
|
||||
ui.register_event(&id.clone(), CursorSense::click_or_drag(), move |ctx| {
|
||||
select(ctx.ui, id.clone(), ctx.state, ctx.data);
|
||||
@@ -38,7 +38,7 @@ impl WidgetAttr<TextEdit> for Selectable {
|
||||
}
|
||||
}
|
||||
|
||||
fn select(ui: &mut Ui, id: WidgetId<TextEdit>, state: &mut UiState, data: CursorData) {
|
||||
fn select(ui: &mut Ui, id: WidgetHandle<TextEdit>, state: &mut UiState, data: CursorData) {
|
||||
let now = Instant::now();
|
||||
let recent = (now - state.last_click) < Duration::from_millis(300);
|
||||
state.last_click = now;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use crate::layout::DefaultEvent;
|
||||
use iris_core::DefaultEvent;
|
||||
|
||||
#[derive(Eq, PartialEq, Hash, Clone)]
|
||||
pub struct Submit;
|
||||
|
||||
@@ -30,7 +30,7 @@ pub struct DefaultState<AppState> {
|
||||
pub struct UiState {
|
||||
pub renderer: UiRenderer,
|
||||
pub input: Input,
|
||||
pub focus: Option<WidgetId<TextEdit>>,
|
||||
pub focus: Option<WidgetHandle<TextEdit>>,
|
||||
pub clipboard: Clipboard,
|
||||
pub window: Arc<Window>,
|
||||
pub ime: usize,
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
use crate::{
|
||||
layout::Ui,
|
||||
render::{UiLimits, UiRenderNode},
|
||||
};
|
||||
use iris_core::{Ui, UiLimits, UiRenderNode};
|
||||
use pollster::FutureExt;
|
||||
use std::sync::Arc;
|
||||
use wgpu::{util::StagingBelt, *};
|
||||
|
||||
@@ -7,17 +7,13 @@ mod default;
|
||||
mod event;
|
||||
mod widget;
|
||||
|
||||
pub use iris_core::*;
|
||||
pub use iris_macro::*;
|
||||
|
||||
pub mod prelude {
|
||||
use super::*;
|
||||
pub use default::*;
|
||||
pub use event::*;
|
||||
pub use iris_core::*;
|
||||
pub use iris_macro::*;
|
||||
pub use layout::*;
|
||||
pub use render::*;
|
||||
pub use widget::*;
|
||||
|
||||
pub use super::util::Vec2;
|
||||
pub use iris_core::util::Vec2;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use crate::prelude::*;
|
||||
|
||||
pub struct Masked {
|
||||
pub inner: WidgetId,
|
||||
pub inner: WidgetHandle,
|
||||
}
|
||||
|
||||
impl Widget for Masked {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use crate::prelude::*;
|
||||
|
||||
pub struct Aligned {
|
||||
pub inner: WidgetId,
|
||||
pub inner: WidgetHandle,
|
||||
pub align: Align,
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use crate::prelude::*;
|
||||
|
||||
pub struct LayerOffset {
|
||||
pub inner: WidgetId,
|
||||
pub inner: WidgetHandle,
|
||||
pub offset: usize,
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use crate::prelude::*;
|
||||
|
||||
pub struct MaxSize {
|
||||
pub inner: WidgetId,
|
||||
pub inner: WidgetHandle,
|
||||
pub x: Option<Len>,
|
||||
pub y: Option<Len>,
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use crate::prelude::*;
|
||||
|
||||
pub struct Offset {
|
||||
pub inner: WidgetId,
|
||||
pub inner: WidgetHandle,
|
||||
pub amt: UiVec2,
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ use crate::prelude::*;
|
||||
|
||||
pub struct Pad {
|
||||
pub padding: Padding,
|
||||
pub inner: WidgetId,
|
||||
pub inner: WidgetHandle,
|
||||
}
|
||||
|
||||
impl Widget for Pad {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use crate::prelude::*;
|
||||
|
||||
pub struct Scroll {
|
||||
inner: WidgetId,
|
||||
inner: WidgetHandle,
|
||||
axis: Axis,
|
||||
amt: f32,
|
||||
snap_end: bool,
|
||||
@@ -41,7 +41,7 @@ impl Widget for Scroll {
|
||||
}
|
||||
|
||||
impl Scroll {
|
||||
pub fn new(inner: WidgetId, axis: Axis) -> Self {
|
||||
pub fn new(inner: WidgetHandle, axis: Axis) -> Self {
|
||||
Self {
|
||||
inner,
|
||||
axis,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use crate::prelude::*;
|
||||
|
||||
pub struct Sized {
|
||||
pub inner: WidgetId,
|
||||
pub inner: WidgetHandle,
|
||||
pub x: Option<Len>,
|
||||
pub y: Option<Len>,
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ use crate::prelude::*;
|
||||
use std::marker::PhantomData;
|
||||
|
||||
pub struct Span {
|
||||
pub children: Vec<WidgetId>,
|
||||
pub children: Vec<WidgetHandle>,
|
||||
pub dir: Dir,
|
||||
pub gap: f32,
|
||||
}
|
||||
@@ -182,7 +182,7 @@ impl<const LEN: usize, Wa: WidgetArrLike<LEN, Tag>, Tag> SpanBuilder<LEN, Wa, Ta
|
||||
}
|
||||
|
||||
impl std::ops::Deref for Span {
|
||||
type Target = Vec<WidgetId>;
|
||||
type Target = Vec<WidgetHandle>;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.children
|
||||
|
||||
@@ -3,7 +3,7 @@ use std::marker::PhantomData;
|
||||
use crate::prelude::*;
|
||||
|
||||
pub struct Stack {
|
||||
pub children: Vec<WidgetId>,
|
||||
pub children: Vec<WidgetHandle>,
|
||||
pub size: StackSize,
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ use crate::prelude::*;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct WidgetPtr {
|
||||
pub inner: Option<WidgetId>,
|
||||
pub inner: Option<WidgetHandle>,
|
||||
}
|
||||
|
||||
impl Widget for WidgetPtr {
|
||||
|
||||
@@ -1,15 +1,10 @@
|
||||
use crate::prelude::*;
|
||||
|
||||
use iris_core::util::{HashMap, Id};
|
||||
use std::{
|
||||
ops::{BitOr, Deref, DerefMut},
|
||||
rc::Rc,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
layout::{UiModule, UiRegion},
|
||||
util::{HashMap, Id, Vec2},
|
||||
};
|
||||
|
||||
#[derive(Clone, Copy, PartialEq)]
|
||||
pub enum Button {
|
||||
Left,
|
||||
@@ -125,7 +120,7 @@ pub struct CursorModule<Ctx> {
|
||||
}
|
||||
|
||||
impl<Ctx: 'static> UiModule for CursorModule<Ctx> {
|
||||
fn on_draw(&mut self, inst: &WidgetInstance) {
|
||||
fn on_draw(&mut self, inst: &ActiveData) {
|
||||
if self.map.contains_key(&inst.id) {
|
||||
self.active
|
||||
.entry(inst.layer)
|
||||
@@ -134,7 +129,7 @@ impl<Ctx: 'static> UiModule for CursorModule<Ctx> {
|
||||
}
|
||||
}
|
||||
|
||||
fn on_undraw(&mut self, inst: &WidgetInstance) {
|
||||
fn on_undraw(&mut self, inst: &ActiveData) {
|
||||
if let Some(layer) = self.active.get_mut(&inst.layer) {
|
||||
layer.remove(&inst.id);
|
||||
}
|
||||
@@ -147,7 +142,7 @@ impl<Ctx: 'static> UiModule for CursorModule<Ctx> {
|
||||
}
|
||||
}
|
||||
|
||||
fn on_move(&mut self, inst: &WidgetInstance) {
|
||||
fn on_move(&mut self, inst: &ActiveData) {
|
||||
if let Some(map) = self.active.get_mut(&inst.layer)
|
||||
&& let Some(region) = map.get_mut(&inst.id)
|
||||
{
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
use std::ops::{Deref, DerefMut};
|
||||
|
||||
use crate::prelude::*;
|
||||
use cosmic_text::{Affinity, Attrs, Cursor, FontSystem, LayoutRun, Motion};
|
||||
use std::ops::{Deref, DerefMut};
|
||||
use unicode_segmentation::UnicodeSegmentation;
|
||||
use winit::{
|
||||
event::KeyEvent,
|
||||
|
||||
@@ -3,8 +3,9 @@ mod edit;
|
||||
|
||||
pub use build::*;
|
||||
pub use edit::*;
|
||||
use iris_core::util::MutDetect;
|
||||
|
||||
use crate::{prelude::*, util::MutDetect};
|
||||
use crate::prelude::*;
|
||||
use cosmic_text::{Attrs, BufferLine, Cursor, Metrics, Shaping};
|
||||
use std::ops::{Deref, DerefMut};
|
||||
|
||||
@@ -21,11 +22,11 @@ pub struct TextView {
|
||||
// cache
|
||||
tex: Option<RenderedText>,
|
||||
width: Option<f32>,
|
||||
pub hint: Option<WidgetId>,
|
||||
pub hint: Option<WidgetHandle>,
|
||||
}
|
||||
|
||||
impl TextView {
|
||||
pub fn new(buf: TextBuffer, attrs: TextAttrs, hint: Option<WidgetId>) -> Self {
|
||||
pub fn new(buf: TextBuffer, attrs: TextAttrs, hint: Option<WidgetHandle>) -> Self {
|
||||
Self {
|
||||
attrs: attrs.into(),
|
||||
buf: buf.into(),
|
||||
|
||||
Reference in New Issue
Block a user