Skip to main content

DiagramState

Struct DiagramState 

Source
pub struct DiagramState {
    pub vp: Viewport,
    pub sel: BTreeSet<u64>,
    pub focus: u64,
    pub grid: f32,
    pub snap: bool,
    pub hover: DHit,
    pub edge_width: f32,
    pub test_keys: u32,
    pub tab_edges: bool,
    pub name: String,
    pub frame_bar: f32,
    pub gpu: CanvasGpu,
    /* private fields */
}
Expand description

the widget’s state, kept by the app: the view, the selection (node and edge keys), the focused node, grid and snapping, the hover, the gesture in progress and the index

Fields§

§vp: Viewport§sel: BTreeSet<u64>§focus: u64

the node with the keyboard focus (0 = none): Tab walks, Enter activates it

§grid: f32

grid step in world units (0 = no grid)

§snap: bool

moves, waypoints and DG_PLACE clicks snap to the grid (Alt held: free)

§hover: DHit

what the pointer is over (after the last diagram call)

§edge_width: f32

the stroke width of the edges in world units (hit testing, the highlight)

§test_keys: u32

scripts cannot hold keys: 1 = as if Space were held, 2 = Ctrl

§tab_edges: bool

Tab / Shift+Tab also walk the edges (after the nodes, in model order): the focused edge is selected, Enter activates it, the menu key asks for its context menu

§name: String

the canvas’ name for screen readers (its K_CANVAS record; empty: none)

§frame_bar: f32

the height of a DN_FRAME node’s title bar in world units (its hit area, its record, the side of its DN_TOGGLE button)

§gpu: CanvasGpu

how the view’s pan and zoom use the GPU (canvas.rs)

Implementations§

Source§

impl DiagramState

Source

pub fn new() -> DiagramState

grid 16, snapping on, edges 2 units wide; the first diagram call fits the content

Source

pub fn request_fit(&mut self)

fit the whole content into the view with the next diagram call

Source

pub fn busy(&self) -> bool

a gesture (drag, marquee, connection, pan) is in progress

Source

pub fn route(&self, key: u64) -> Option<&DgRoute>

the route of edge key (as of the last diagram call)

Source

pub fn geo(&self) -> &Rc<DgGeo>

every route (model order), shared with the paint

Source

pub fn bounds(&self) -> Option<[f32; 4]>

the bounding box x0, y0, x1, y1 of nodes and routes (None: empty)

Source

pub fn visible(&self) -> &[u32]

the indices of the nodes the canvas showed in the last diagram call

Trait Implementations§

Source§

impl Default for DiagramState

Source§

fn default() -> DiagramState

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.