autocommit 2022-01-25 16:45:44 CET
This commit is contained in:
parent
0336bf3bde
commit
c340df0d08
59 changed files with 3085 additions and 1710 deletions
67
src/tree/workspace.rs
Normal file
67
src/tree/workspace.rs
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
use crate::render::Renderer;
|
||||
use crate::tree::container::ContainerNode;
|
||||
use crate::tree::{FloatNode, FoundNode, Node, NodeId, OutputNode};
|
||||
use crate::utils::clonecell::CloneCell;
|
||||
use crate::utils::linkedlist::LinkedList;
|
||||
use std::rc::Rc;
|
||||
|
||||
tree_id!(WorkspaceNodeId);
|
||||
|
||||
pub struct WorkspaceNode {
|
||||
pub id: WorkspaceNodeId,
|
||||
pub output: CloneCell<Rc<OutputNode>>,
|
||||
pub container: CloneCell<Option<Rc<ContainerNode>>>,
|
||||
pub floaters: LinkedList<Rc<FloatNode>>,
|
||||
}
|
||||
|
||||
impl WorkspaceNode {
|
||||
pub fn set_container(&self, container: &Rc<ContainerNode>) {
|
||||
let output = self.output.get().position.get();
|
||||
container
|
||||
.clone()
|
||||
.change_size(output.width(), output.height());
|
||||
self.container.set(Some(container.clone()));
|
||||
}
|
||||
}
|
||||
|
||||
impl Node for WorkspaceNode {
|
||||
fn id(&self) -> NodeId {
|
||||
self.id.into()
|
||||
}
|
||||
|
||||
fn clear(&self) {
|
||||
if let Some(child) = self.container.take() {
|
||||
child.clear();
|
||||
}
|
||||
}
|
||||
|
||||
fn find_child_at(&self, x: i32, y: i32) -> Option<FoundNode> {
|
||||
match self.container.get() {
|
||||
Some(node) => Some(FoundNode {
|
||||
node,
|
||||
x,
|
||||
y,
|
||||
contained: true,
|
||||
}),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
fn render(&self, renderer: &mut dyn Renderer, _x: i32, _y: i32) {
|
||||
renderer.render_workspace(self);
|
||||
}
|
||||
|
||||
fn get_workspace(self: Rc<Self>) -> Option<Rc<WorkspaceNode>> {
|
||||
Some(self)
|
||||
}
|
||||
|
||||
fn remove_child(&self, _child: &dyn Node) {
|
||||
self.container.set(None);
|
||||
}
|
||||
|
||||
fn change_size(self: Rc<Self>, width: i32, height: i32) {
|
||||
if let Some(c) = self.container.get() {
|
||||
c.change_size(width, height);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue