Added ability to pass custom layer widgets to stack.
This commit is contained in:
parent
baf4d80867
commit
8c7ebd89f6
2 changed files with 62 additions and 49 deletions
|
|
@ -652,37 +652,6 @@ void LayerStackWidget::resizeEvent(QResizeEvent *e) {
|
||||||
updateLayerBoxes();
|
updateLayerBoxes();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LayerStackWidget::showBox(
|
|
||||||
object_ptr<BoxContent> box,
|
|
||||||
LayerOptions options,
|
|
||||||
anim::type animated) {
|
|
||||||
if (options & LayerOption::KeepOther) {
|
|
||||||
if (options & LayerOption::ShowAfterOther) {
|
|
||||||
prependBox(std::move(box), animated);
|
|
||||||
} else {
|
|
||||||
appendBox(std::move(box), animated);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
replaceBox(std::move(box), animated);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void LayerStackWidget::replaceBox(
|
|
||||||
object_ptr<BoxContent> box,
|
|
||||||
anim::type animated) {
|
|
||||||
const auto pointer = pushBox(std::move(box), animated);
|
|
||||||
const auto removeTill = ranges::find(
|
|
||||||
_layers,
|
|
||||||
pointer,
|
|
||||||
&std::unique_ptr<LayerWidget>::get);
|
|
||||||
_closingLayers.insert(
|
|
||||||
end(_closingLayers),
|
|
||||||
std::make_move_iterator(begin(_layers)),
|
|
||||||
std::make_move_iterator(removeTill));
|
|
||||||
_layers.erase(begin(_layers), removeTill);
|
|
||||||
clearClosingLayers();
|
|
||||||
}
|
|
||||||
|
|
||||||
void LayerStackWidget::prepareForAnimation() {
|
void LayerStackWidget::prepareForAnimation() {
|
||||||
if (isHidden()) {
|
if (isHidden()) {
|
||||||
show();
|
show();
|
||||||
|
|
@ -789,14 +758,33 @@ void LayerStackWidget::showMainMenu(
|
||||||
}, Action::ShowMainMenu, animated);
|
}, Action::ShowMainMenu, animated);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LayerStackWidget::appendBox(
|
void LayerStackWidget::showBox(
|
||||||
object_ptr<BoxContent> box,
|
object_ptr<BoxContent> box,
|
||||||
|
LayerOptions options,
|
||||||
anim::type animated) {
|
anim::type animated) {
|
||||||
pushBox(std::move(box), animated);
|
showLayer(
|
||||||
|
std::make_unique<BoxLayerWidget>(this, std::move(box)),
|
||||||
|
options,
|
||||||
|
animated);
|
||||||
}
|
}
|
||||||
|
|
||||||
LayerWidget *LayerStackWidget::pushBox(
|
void LayerStackWidget::showLayer(
|
||||||
object_ptr<BoxContent> box,
|
std::unique_ptr<LayerWidget> layer,
|
||||||
|
LayerOptions options,
|
||||||
|
anim::type animated) {
|
||||||
|
if (options & LayerOption::KeepOther) {
|
||||||
|
if (options & LayerOption::ShowAfterOther) {
|
||||||
|
prependLayer(std::move(layer), animated);
|
||||||
|
} else {
|
||||||
|
appendLayer(std::move(layer), animated);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
replaceLayer(std::move(layer), animated);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LayerWidget *LayerStackWidget::pushLayer(
|
||||||
|
std::unique_ptr<LayerWidget> layer,
|
||||||
anim::type animated) {
|
anim::type animated) {
|
||||||
const auto oldLayer = currentLayer();
|
const auto oldLayer = currentLayer();
|
||||||
if (oldLayer) {
|
if (oldLayer) {
|
||||||
|
|
@ -805,8 +793,7 @@ LayerWidget *LayerStackWidget::pushBox(
|
||||||
}
|
}
|
||||||
oldLayer->hide();
|
oldLayer->hide();
|
||||||
}
|
}
|
||||||
_layers.push_back(
|
_layers.push_back(std::move(layer));
|
||||||
std::make_unique<BoxLayerWidget>(this, std::move(box)));
|
|
||||||
const auto raw = _layers.back().get();
|
const auto raw = _layers.back().get();
|
||||||
initChildLayer(raw);
|
initChildLayer(raw);
|
||||||
|
|
||||||
|
|
@ -824,21 +811,43 @@ LayerWidget *LayerStackWidget::pushBox(
|
||||||
return raw;
|
return raw;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LayerStackWidget::prependBox(
|
void LayerStackWidget::appendLayer(
|
||||||
object_ptr<BoxContent> box,
|
std::unique_ptr<LayerWidget> layer,
|
||||||
|
anim::type animated) {
|
||||||
|
pushLayer(std::move(layer), animated);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LayerStackWidget::prependLayer(
|
||||||
|
std::unique_ptr<LayerWidget> layer,
|
||||||
anim::type animated) {
|
anim::type animated) {
|
||||||
if (_layers.empty()) {
|
if (_layers.empty()) {
|
||||||
replaceBox(std::move(box), animated);
|
replaceLayer(std::move(layer), animated);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_layers.insert(
|
_layers.insert(
|
||||||
begin(_layers),
|
begin(_layers),
|
||||||
std::make_unique<BoxLayerWidget>(this, std::move(box)));
|
std::move(layer));
|
||||||
const auto raw = _layers.front().get();
|
const auto raw = _layers.front().get();
|
||||||
raw->hide();
|
raw->hide();
|
||||||
initChildLayer(raw);
|
initChildLayer(raw);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LayerStackWidget::replaceLayer(
|
||||||
|
std::unique_ptr<LayerWidget> layer,
|
||||||
|
anim::type animated) {
|
||||||
|
const auto pointer = pushLayer(std::move(layer), animated);
|
||||||
|
const auto removeTill = ranges::find(
|
||||||
|
_layers,
|
||||||
|
pointer,
|
||||||
|
&std::unique_ptr<LayerWidget>::get);
|
||||||
|
_closingLayers.insert(
|
||||||
|
end(_closingLayers),
|
||||||
|
std::make_move_iterator(begin(_layers)),
|
||||||
|
std::make_move_iterator(removeTill));
|
||||||
|
_layers.erase(begin(_layers), removeTill);
|
||||||
|
clearClosingLayers();
|
||||||
|
}
|
||||||
|
|
||||||
bool LayerStackWidget::takeToThirdSection() {
|
bool LayerStackWidget::takeToThirdSection() {
|
||||||
return _specialLayer
|
return _specialLayer
|
||||||
? _specialLayer->takeToThirdSection()
|
? _specialLayer->takeToThirdSection()
|
||||||
|
|
|
||||||
|
|
@ -111,6 +111,10 @@ public:
|
||||||
object_ptr<BoxContent> box,
|
object_ptr<BoxContent> box,
|
||||||
LayerOptions options,
|
LayerOptions options,
|
||||||
anim::type animated);
|
anim::type animated);
|
||||||
|
void showLayer(
|
||||||
|
std::unique_ptr<LayerWidget> layer,
|
||||||
|
LayerOptions options,
|
||||||
|
anim::type animated);
|
||||||
void showSpecialLayer(
|
void showSpecialLayer(
|
||||||
object_ptr<LayerWidget> layer,
|
object_ptr<LayerWidget> layer,
|
||||||
anim::type animated);
|
anim::type animated);
|
||||||
|
|
@ -149,19 +153,19 @@ protected:
|
||||||
void resizeEvent(QResizeEvent *e) override;
|
void resizeEvent(QResizeEvent *e) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void appendBox(
|
void appendLayer(
|
||||||
object_ptr<BoxContent> box,
|
std::unique_ptr<LayerWidget> layer,
|
||||||
anim::type animated);
|
anim::type animated);
|
||||||
void prependBox(
|
void prependLayer(
|
||||||
object_ptr<BoxContent> box,
|
std::unique_ptr<LayerWidget> layer,
|
||||||
anim::type animated);
|
anim::type animated);
|
||||||
void replaceBox(
|
void replaceLayer(
|
||||||
object_ptr<BoxContent> box,
|
std::unique_ptr<LayerWidget> layer,
|
||||||
anim::type animated);
|
anim::type animated);
|
||||||
void backgroundClicked();
|
void backgroundClicked();
|
||||||
|
|
||||||
LayerWidget *pushBox(
|
LayerWidget *pushLayer(
|
||||||
object_ptr<BoxContent> box,
|
std::unique_ptr<LayerWidget> layer,
|
||||||
anim::type animated);
|
anim::type animated);
|
||||||
void showFinished();
|
void showFinished();
|
||||||
void hideCurrent(anim::type animated);
|
void hideCurrent(anim::type animated);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue