mirror of https://github.com/bsnes-emu/bsnes.git
59 lines
1.6 KiB
C++
59 lines
1.6 KiB
C++
auto mLayout::allocate() -> pObject* {
|
|
return new pLayout(*this);
|
|
}
|
|
|
|
auto mLayout::destruct() -> void {
|
|
for(auto& sizable : state.sizables) sizable->destruct();
|
|
mSizable::destruct();
|
|
}
|
|
|
|
//
|
|
|
|
auto mLayout::append(shared_pointer<mSizable> sizable) -> type& {
|
|
state.sizables.append(sizable);
|
|
sizable->setParent(this, sizables() - 1);
|
|
setGeometry(geometry());
|
|
return *this;
|
|
}
|
|
|
|
auto mLayout::remove() -> type& {
|
|
if(auto tabFrameItem = parentTabFrameItem()) tabFrameItem->remove(tabFrameItem->layout());
|
|
if(auto layout = parentLayout()) layout->remove(layout->sizable(offset()));
|
|
if(auto window = parentWindow()) window->remove(window->layout());
|
|
setParent();
|
|
for(auto& sizable : state.sizables) sizable->setParent(this, sizable->offset());
|
|
return *this;
|
|
}
|
|
|
|
auto mLayout::remove(shared_pointer<mSizable> sizable) -> type& {
|
|
auto offset = sizable->offset();
|
|
sizable->setParent();
|
|
state.sizables.remove(offset);
|
|
for(auto n : range(offset, sizables())) {
|
|
state.sizables[n]->offset(-1);
|
|
}
|
|
setGeometry(geometry());
|
|
return *this;
|
|
}
|
|
|
|
auto mLayout::reset() -> type& {
|
|
while(state.sizables) remove(state.sizables.last());
|
|
return *this;
|
|
}
|
|
|
|
auto mLayout::setParent(mObject* parent, signed offset) -> type& {
|
|
for(auto& sizable : state.sizables) sizable->destruct();
|
|
mObject::setParent(parent, offset);
|
|
for(auto& sizable : state.sizables) sizable->setParent(this, sizable->offset());
|
|
return *this;
|
|
}
|
|
|
|
auto mLayout::sizable(unsigned position) const -> shared_pointer<mSizable> {
|
|
if(position >= sizables()) throw;
|
|
return state.sizables[position];
|
|
}
|
|
|
|
auto mLayout::sizables() const -> unsigned {
|
|
return state.sizables.size();
|
|
}
|