pub struct Frame(/* private fields */);Expand description
Where a view lives: it holds the view, the controllers that fit it, their actions and a unit of work. A handle, so controllers and actions can keep one.
Changing the view tells whoever watches, turns off the controllers that were on, changes the view, turns on those that fit the new one, and tells again.
Implementations§
Source§impl Frame
impl Frame
Sourcepub fn new(
context: FrameContext,
space: Rc<RefCell<dyn ObjectSpace>>,
model: Option<Rc<ModelNode>>,
view_controllers: Vec<Box<dyn ViewController>>,
window_controllers: Vec<Box<dyn WindowController>>,
) -> Self
pub fn new( context: FrameContext, space: Rc<RefCell<dyn ObjectSpace>>, model: Option<Rc<ModelNode>>, view_controllers: Vec<Box<dyn ViewController>>, window_controllers: Vec<Box<dyn WindowController>>, ) -> Self
A frame with no view, with these controllers. Window controllers turn on now, if the context fits them, and stay on.
Sourcepub fn set_messenger(&self, messenger: impl Fn(Message) + 'static)
pub fn set_messenger(&self, messenger: impl Fn(Message) + 'static)
Gives messages to this, which shows them.
Sourcepub fn show_message(&self, message: Message)
pub fn show_message(&self, message: Message)
Tells people something, as long as someone showing the application listens.
Sourcepub fn context(&self) -> FrameContext
pub fn context(&self) -> FrameContext
Where it is.
Sourcepub fn space(&self) -> Rc<RefCell<dyn ObjectSpace>>
pub fn space(&self) -> Rc<RefCell<dyn ObjectSpace>>
The unit of work of its view.
Sourcepub fn set_entities(&self, entities: Rc<Vec<EntityInfo>>)
pub fn set_entities(&self, entities: Rc<Vec<EntityInfo>>)
The entities whose appearance rules turn actions on and off.
Sourcepub fn set_security(&self, security: Rc<SecurityContext>)
pub fn set_security(&self, security: Rc<SecurityContext>)
Turns actions off by what this person can do. What protects records is the secured space; this is what keeps people from reaching for what would be refused.
Sourcepub fn security(&self) -> Option<Rc<SecurityContext>>
pub fn security(&self) -> Option<Rc<SecurityContext>>
What this person can do, when the application has permissions.
Sourcepub fn set_extension<T: 'static>(&self, value: Rc<T>)
pub fn set_extension<T: 'static>(&self, value: Rc<T>)
Keeps something for whoever holds the frame to find by its type, as what shows it does for its controllers and actions.
Sourcepub fn open_popup(&self) -> Option<(String, String)>
pub fn open_popup(&self) -> Option<(String, String)>
The popup open, as its action’s id and its view’s id.
Sourcepub fn on_event(&self, watcher: impl Fn(&FrameEvent) + 'static)
pub fn on_event(&self, watcher: impl Fn(&FrameEvent) + 'static)
Calls this as the view changes.
Sourcepub fn set_validator(
&self,
validator: impl Fn(&[String], &ActionContext) -> Result<(), String> + 'static,
)
pub fn set_validator( &self, validator: impl Fn(&[String], &ActionContext) -> Result<(), String> + 'static, )
What passes actions’ validation contexts before they run.
Sourcepub fn show_view(&self, id: &str) -> Result<(), ModelError>
pub fn show_view(&self, id: &str) -> Result<(), ModelError>
Shows the view with this id in the model.
Sourcepub fn set_view(&self, view: Option<ViewInfo>)
pub fn set_view(&self, view: Option<ViewInfo>)
Changes the view. Asked while a change is under way, as from a controller turning on, it happens after that one ends.
Sourcepub fn set_view_in(
&self,
view: Option<ViewInfo>,
space: Rc<RefCell<dyn ObjectSpace>>,
)
pub fn set_view_in( &self, view: Option<ViewInfo>, space: Rc<RefCell<dyn ObjectSpace>>, )
Changes the view and takes on a new unit of work with it, as each view has its own. The controllers that turn on already see it.
Sourcepub fn view_controls_created(&self)
pub fn view_controls_created(&self)
Tells the controllers that are on that the view’s controls exist now.
Sourcepub fn set_controller_active(&self, id: &str, reason: &str, on: bool)
pub fn set_controller_active(&self, id: &str, reason: &str, on: bool)
Gives a reason for a controller being on or off. Off, it turns off all its actions.
Sourcepub fn is_controller_active(&self, id: &str) -> bool
pub fn is_controller_active(&self, id: &str) -> bool
Whether a controller is on.
Sourcepub fn set_selected(&self, selected: Vec<Object>)
pub fn set_selected(&self, selected: Vec<Object>)
Sets what is selected, which turns actions on and off.
Sourcepub fn actions(&self) -> Vec<Action>
pub fn actions(&self) -> Vec<Action>
Every action of its controllers, whether on or off, in the order they came.
Sourcepub fn execute(
&self,
id: &str,
input: ActionInput,
) -> Result<ActionResult, ActionError>
pub fn execute( &self, id: &str, input: ActionInput, ) -> Result<ActionResult, ActionError>
Runs an action, if it is on: asks whoever guards it, passes its validation contexts, runs it, and says what comes next. Asking the question first is up to whoever shows it.
Sourcepub fn set_job_waker(&self, waker: JobWaker)
pub fn set_job_waker(&self, waker: JobWaker)
Wakes whoever shows the frame, from any thread, when background work has something to show.
Sourcepub fn apply_jobs(&self) -> bool
pub fn apply_jobs(&self) -> bool
Keeps what background work handed back, tells what it asked to, and ends the work that ended: its action turns on again and says it ran. Says whether records changed, so what shows them reads again. Whoever shows the frame calls it once it is woken.
Sourcepub fn open_popup_on(&self, action: &str, view: &str)
pub fn open_popup_on(&self, action: &str, view: &str)
Opens a popup on this view for this action, for when the view depends on what it is run on. OK runs the action again, with what was picked.
Sourcepub fn prepare_popup(&self, object: &mut Object)
pub fn prepare_popup(&self, object: &mut Object)
Fills in the record the form of the open popup starts with.
Sourcepub fn accept_popup(
&self,
input: ActionInput,
) -> Result<ActionResult, ActionError>
pub fn accept_popup( &self, input: ActionInput, ) -> Result<ActionResult, ActionError>
Ends the open popup with OK, which runs its action.
Sourcepub fn cancel_popup(&self)
pub fn cancel_popup(&self)
Ends the open popup with Cancel, and nothing runs but what cancels.