Skip to content

Commit

Permalink
Rename to ChangeFlags
Browse files Browse the repository at this point in the history
  • Loading branch information
Zoxc committed Nov 30, 2022
1 parent 934b639 commit 7a32dd1
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use futures_task::{ArcWake, Waker};
use crate::{
event::EventResult,
id::{Id, IdPath},
widget::{UpdateFlags, Widget},
widget::{ChangeFlags, Widget},
};

/// A view object representing a node in the UI.
Expand Down Expand Up @@ -73,7 +73,7 @@ pub trait View<T, A = ()>: Send {
id: &mut Id,
state: &mut Self::State,
element: &mut Self::Element,
) -> UpdateFlags;
) -> ChangeFlags;

/// Propagate an event.
///
Expand Down
6 changes: 3 additions & 3 deletions src/view/button.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

use std::any::Any;

use crate::{event::EventResult, id::Id, widget::UpdateFlags};
use crate::{event::EventResult, id::Id, widget::ChangeFlags};

use super::{Cx, View};

Expand Down Expand Up @@ -58,11 +58,11 @@ impl<T, A> View<T, A> for Button<T, A> {
_id: &mut crate::id::Id,
_state: &mut Self::State,
element: &mut Self::Element,
) -> UpdateFlags {
) -> ChangeFlags {
if prev.label != self.label {
element.set_label(self.label.clone())
} else {
UpdateFlags::empty()
ChangeFlags::empty()
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/view/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

use std::any::Any;

use crate::{event::EventResult, id::Id, widget::UpdateFlags};
use crate::{event::EventResult, id::Id, widget::ChangeFlags};

use super::{Cx, View};

Expand All @@ -35,11 +35,11 @@ impl<T, A> View<T, A> for String {
_id: &mut crate::id::Id,
_state: &mut Self::State,
element: &mut Self::Element,
) -> UpdateFlags {
) -> ChangeFlags {
if prev != self {
element.set_text(self.clone())
} else {
UpdateFlags::empty()
ChangeFlags::empty()
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/widget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use piet_scene::SceneBuilder;
use self::contexts::LifeCycleCx;
pub use self::contexts::{AlignCx, CxState, EventCx, LayoutCx, PaintCx, PreparePaintCx, UpdateCx};
pub use self::core::Pod;
pub(crate) use self::core::{PodFlags, UpdateFlags, WidgetState};
pub(crate) use self::core::{ChangeFlags, PodFlags, WidgetState};
pub use self::raw_event::{LifeCycle, RawEvent};

use self::align::SingleAlignment;
Expand Down
6 changes: 3 additions & 3 deletions src/widget/button.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use super::{
align::{FirstBaseline, LastBaseline, SingleAlignment},
contexts::LifeCycleCx,
piet_scene_helpers::{self, UnitPoint},
AlignCx, EventCx, LayoutCx, LifeCycle, PaintCx, RawEvent, UpdateCx, UpdateFlags, Widget,
AlignCx, ChangeFlags, EventCx, LayoutCx, LifeCycle, PaintCx, RawEvent, UpdateCx, Widget,
};

pub struct Button {
Expand All @@ -40,10 +40,10 @@ impl Button {
}
}

pub fn set_label(&mut self, label: String) -> UpdateFlags {
pub fn set_label(&mut self, label: String) -> ChangeFlags {
self.label = label;
self.layout = None;
UpdateFlags::REQUEST_LAYOUT | UpdateFlags::REQUEST_PAINT
ChangeFlags::REQUEST_LAYOUT | ChangeFlags::REQUEST_PAINT
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/widget/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ bitflags! {
bitflags! {
#[derive(Default)]
#[must_use]
pub struct UpdateFlags: u8 {
pub struct ChangeFlags: u8 {
const REQUEST_UPDATE = 1;
const REQUEST_LAYOUT = 2;
const REQUEST_PAINT = 4;
Expand Down Expand Up @@ -137,7 +137,7 @@ impl Pod {
(*self.widget).as_any_mut().downcast_mut()
}

pub fn mark(&mut self, flags: UpdateFlags) {
pub fn mark(&mut self, flags: ChangeFlags) {
self.state
.request(PodFlags::from_bits(flags.bits().into()).unwrap());
}
Expand Down
6 changes: 3 additions & 3 deletions src/widget/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use crate::text::ParleyBrush;
use super::{
align::{FirstBaseline, LastBaseline, SingleAlignment, VertAlignment},
contexts::LifeCycleCx,
AlignCx, EventCx, LayoutCx, LifeCycle, PaintCx, RawEvent, UpdateCx, UpdateFlags, Widget,
AlignCx, ChangeFlags, EventCx, LayoutCx, LifeCycle, PaintCx, RawEvent, UpdateCx, Widget,
};

pub struct TextWidget {
Expand All @@ -39,9 +39,9 @@ impl TextWidget {
}
}

pub fn set_text(&mut self, text: String) -> UpdateFlags {
pub fn set_text(&mut self, text: String) -> ChangeFlags {
self.text = text;
UpdateFlags::REQUEST_LAYOUT | UpdateFlags::REQUEST_PAINT
ChangeFlags::REQUEST_LAYOUT | ChangeFlags::REQUEST_PAINT
}
}

Expand Down

0 comments on commit 7a32dd1

Please sign in to comment.