YggdrasilWM  0.1.1
A tiny window manager coded in C++
BinarySpace Class Reference

BinarySpace class This class represents a space in the layout. it's designed like a binary tree, with a parent, a right and a left child. Only leaf spaces have clients. More...

#include <BinarySpace.hpp>

Collaboration diagram for BinarySpace:
Collaboration graph

Public Member Functions

 BinarySpace (Point pos, Point size, int index, BinarySpace *parent=nullptr)
 Construct a new BinarySpace object. More...
 
 ~BinarySpace ()=default
 
const PointgetPos () const
 
void setPos (const Point &pos)
 
const PointgetSize () const
 
void setSize (const Point &size)
 
int getSubspaceCount () const
 
int getIndex () const
 
void setIndex (int index)
 
BinarySpacegetParent () const
 
void setParent (BinarySpace *parent)
 
const std::unique_ptr< BinarySpace > & getRight () const
 
void setRight (std::unique_ptr< BinarySpace > right)
 
const std::unique_ptr< BinarySpace > & getLeft () const
 
void setLeft (std::unique_ptr< BinarySpace > left)
 
std::shared_ptr< ClientgetClient () const
 
void setClient (std::shared_ptr< Client > client)
 
void incSubSpaceCount ()
 

Private Attributes

Point pos_
 
Point size_
 
int index_
 
int subspace_count_
 
BinarySpaceparent_
 
std::unique_ptr< BinarySpaceright_
 
std::unique_ptr< BinarySpaceleft_
 
std::weak_ptr< Clientclient_
 

Detailed Description

BinarySpace class This class represents a space in the layout. it's designed like a binary tree, with a parent, a right and a left child. Only leaf spaces have clients.

Todo:

create an interface for Spaces and implement it in BinarySpace

redefine BinarySpace not as a nested class but as a separate class

Constructor & Destructor Documentation

◆ BinarySpace()

BinarySpace::BinarySpace ( Point  pos,
Point  size,
int  index,
BinarySpace parent = nullptr 
)

Construct a new BinarySpace object.

Parameters
pos
size
index
parent
7  :
8  pos_(pos),
9  size_(size),
10  index_(index),
11  subspace_count_(1),
12  parent_(parent),
13  left_(nullptr),
14  right_(nullptr){}
std::unique_ptr< BinarySpace > right_
Definition: BinarySpace.hpp:48
int index_
Definition: BinarySpace.hpp:45
std::unique_ptr< BinarySpace > left_
Definition: BinarySpace.hpp:49
int subspace_count_
Definition: BinarySpace.hpp:46
BinarySpace * parent_
Definition: BinarySpace.hpp:47
Point pos_
Definition: BinarySpace.hpp:43
Point size_
Definition: BinarySpace.hpp:44

◆ ~BinarySpace()

BinarySpace::~BinarySpace ( )
default

Member Function Documentation

◆ getClient()

std::shared_ptr< Client > BinarySpace::getClient ( ) const
28  {
29  auto c = client_.lock();
30  if (c)
31  return c;
32  else
33  return nullptr;
34 }
std::weak_ptr< Client > client_
Definition: BinarySpace.hpp:50

References client_.

Referenced by TreeLayoutManager::addClientRecursive(), TreeLayoutManager::findSpaceRecursive(), TreeLayoutManager::growSpace(), TreeLayoutManager::placeClientInSpace(), TreeLayoutManager::recursiveResize(), TreeLayoutManager::recursiveShrinkSiblingSpace(), TreeLayoutManager::removeClientRecursive(), and TreeLayoutManager::splitSpace().

Here is the caller graph for this function:

◆ getIndex()

int BinarySpace::getIndex ( ) const
20 { return index_; }

References index_.

◆ getLeft()

◆ getParent()

BinarySpace * BinarySpace::getParent ( ) const
22 { return parent_; }

References parent_.

Referenced by TreeLayoutManager::growSpace(), TreeLayoutManager::removeClientRecursive(), and TreeLayoutManager::splitSpace().

Here is the caller graph for this function:

◆ getPos()

const Point & BinarySpace::getPos ( ) const
15 { return pos_; }

References pos_.

Referenced by TreeLayoutManager::growSpace(), TreeLayoutManager::placeClientInSpace(), and TreeLayoutManager::splitSpace().

Here is the caller graph for this function:

◆ getRight()

◆ getSize()

◆ getSubspaceCount()

int BinarySpace::getSubspaceCount ( ) const
36 {return subspace_count_; }

References subspace_count_.

◆ incSubSpaceCount()

void BinarySpace::incSubSpaceCount ( )
16 { subspace_count_ ++; }

References subspace_count_.

Referenced by TreeLayoutManager::splitSpace().

Here is the caller graph for this function:

◆ setClient()

void BinarySpace::setClient ( std::shared_ptr< Client client)
35 { BinarySpace::client_ = std::weak_ptr<Client>(client); }

References client_.

Referenced by TreeLayoutManager::placeClientInSpace(), TreeLayoutManager::removeClientRecursive(), and TreeLayoutManager::splitSpace().

Here is the caller graph for this function:

◆ setIndex()

void BinarySpace::setIndex ( int  index)
21 { BinarySpace::index_ = index; }

References index_.

◆ setLeft()

void BinarySpace::setLeft ( std::unique_ptr< BinarySpace left)
27 { this->left_ = std::move(left); }

References left_.

Referenced by TreeLayoutManager::removeClientRecursive(), and TreeLayoutManager::splitSpace().

Here is the caller graph for this function:

◆ setParent()

void BinarySpace::setParent ( BinarySpace parent)
23 { BinarySpace::parent_ = parent;}

References parent_.

◆ setPos()

void BinarySpace::setPos ( const Point pos)
17 { BinarySpace::pos_ = pos; }

References pos_.

Referenced by TreeLayoutManager::growSpace(), and TreeLayoutManager::recursiveResize().

Here is the caller graph for this function:

◆ setRight()

void BinarySpace::setRight ( std::unique_ptr< BinarySpace right)
25 { this->right_ = std::move(right); }

References right_.

Referenced by TreeLayoutManager::removeClientRecursive(), and TreeLayoutManager::splitSpace().

Here is the caller graph for this function:

◆ setSize()

void BinarySpace::setSize ( const Point size)
19 { BinarySpace::size_ = size; }

References size_.

Referenced by TreeLayoutManager::growSpace(), TreeLayoutManager::recursiveResize(), and TreeLayoutManager::recursiveShrinkSiblingSpace().

Here is the caller graph for this function:

Member Data Documentation

◆ client_

std::weak_ptr<Client> BinarySpace::client_
private

Referenced by getClient(), and setClient().

◆ index_

int BinarySpace::index_
private

Referenced by getIndex(), and setIndex().

◆ left_

std::unique_ptr<BinarySpace> BinarySpace::left_
private

Referenced by getLeft(), and setLeft().

◆ parent_

BinarySpace* BinarySpace::parent_
private

Referenced by getParent(), and setParent().

◆ pos_

Point BinarySpace::pos_
private

Referenced by getPos(), and setPos().

◆ right_

std::unique_ptr<BinarySpace> BinarySpace::right_
private

Referenced by getRight(), and setRight().

◆ size_

Point BinarySpace::size_
private

Referenced by getSize(), and setSize().

◆ subspace_count_

int BinarySpace::subspace_count_
private

The documentation for this class was generated from the following files: