gooey/interface/view/
mod.rs

1//! Display and input data
2
3use derive_more::{From, TryInto};
4use crate::interface::CreateOrder;
5use crate::tree::NodeId;
6
7pub use nsys::color::{self, Color};
8
9// input
10pub mod input;
11pub use self::input::Input;
12// view components
13pub mod component;
14pub use self::component::Component;
15// data types
16pub mod coordinates;
17pub use self::coordinates::{
18  Coordinates,
19  position,   Position,
20  dimensions, Dimensions,
21};
22pub mod border;
23pub mod pointer;
24pub mod sound;
25pub mod style;
26pub mod texture;
27pub use self::border::Border;
28pub use self::pointer::Pointer;
29pub use self::sound::Sound;
30pub use self::style::Style;
31pub use self::texture::Texture;
32
33/// Describes the appearance of an element
34#[derive(Clone, Debug, Default, Eq, PartialEq)]
35pub struct View {
36  pub component  : Component,
37  pub appearance : Appearance,
38  pub debug      : bool
39}
40
41/// An event for the presentation layer to process
42#[derive(Clone, Debug)]
43pub enum Display {
44  /// Create a new child with the given node ID
45  Create (View, NodeId, CreateOrder),
46  Update (Update),
47  Destroy
48}
49
50/// Either a view payload or focus re-order event
51#[derive(Clone, Debug, PartialEq, From, TryInto)]
52pub enum Update {
53  View (View),
54  FocusTop
55}
56
57/// Appearance is a combination of visual and audible parameters
58#[derive(Clone, Debug, Default, Eq, PartialEq)]
59pub struct Appearance {
60  pub style   : Option <Style>,
61  pub sound   : Option <Sound>,
62  pub pointer : Option <Pointer>
63}
64
65impl From <Component> for View {
66  fn from (component : Component) -> Self {
67    View { component, .. View::default() }
68  }
69}