Files
bsnes/hiro/core/widget/tab-frame.cpp
Tim Allen e0815b55b9 Update to v094r28 release.
byuu says:

This WIP substantially restructures the ruby API for the first time
since that project started.

It is my hope that with this restructuring, destruction of the ruby
objects should now be deterministic, which should fix the crashing on
closing the emulator on Linux. We'll see I guess ... either way, it
removed two layers of wrappers from ruby, so it's a pretty nice code
cleanup.

It won't compile on Windows due to a few issues I didn't see until
uploading the WIP, too lazy to upload another. But I fixed all the
compilation issues locally, so it'll work on Windows again with the next
WIP (unless I break something else.)

(Kind of annoying that Linux defines glActiveTexture but Windows
doesn't.)
2015-06-20 15:44:05 +10:00

98 lines
2.2 KiB
C++

#if defined(Hiro_TabFrame)
auto mTabFrame::allocate() -> pObject* {
return new pTabFrame(*this);
}
auto mTabFrame::destruct() -> void {
for(auto& item : state.items) item->destruct();
mWidget::destruct();
}
//
auto mTabFrame::append(sTabFrameItem item) -> type& {
state.items.append(item);
item->setParent(this, items() - 1);
signal(append, item);
return *this;
}
auto mTabFrame::doChange() const -> void {
if(state.onChange) return state.onChange();
}
auto mTabFrame::doClose(sTabFrameItem item) const -> void {
if(state.onClose) return state.onClose(item);
}
auto mTabFrame::doMove(sTabFrameItem from, sTabFrameItem to) const -> void {
if(state.onMove) return state.onMove(from, to);
}
auto mTabFrame::edge() const -> Edge {
return state.edge;
}
auto mTabFrame::item(unsigned position) const -> TabFrameItem {
if(position < items()) return state.items[position];
return {};
}
auto mTabFrame::items() const -> unsigned {
return state.items.size();
}
auto mTabFrame::onChange(const function<void ()>& callback) -> type& {
state.onChange = callback;
return *this;
}
auto mTabFrame::onClose(const function<void (TabFrameItem)>& callback) -> type& {
state.onClose = callback;
return *this;
}
auto mTabFrame::onMove(const function<void (TabFrameItem, TabFrameItem)>& callback) -> type& {
state.onMove = callback;
return *this;
}
auto mTabFrame::remove(sTabFrameItem item) -> type& {
auto offset = item->offset();
item->setParent();
signal(remove, item);
state.items.remove(item->offset());
for(auto n : range(offset, items())) {
state.items[n]->adjustOffset(-1);
}
return *this;
}
auto mTabFrame::reset() -> type& {
while(state.items) remove(state.items.last());
return *this;
}
auto mTabFrame::selected() const -> TabFrameItem {
for(auto& item : state.items) {
if(item->selected()) return item;
}
return {};
}
auto mTabFrame::setEdge(Edge edge) -> type& {
state.edge = edge;
signal(setEdge, edge);
return *this;
}
auto mTabFrame::setParent(mObject* parent, signed offset) -> type& {
for(auto& item : state.items) item->destruct();
mObject::setParent(parent, offset);
for(auto& item : state.items) item->setParent(this, item->offset());
return *this;
}
#endif