2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-09-05 09:05:14 +00:00

Added ability to pass custom layer widgets to stack.

This commit is contained in:
23rd
2021-02-17 08:48:39 +03:00
parent e322733e20
commit 4909ba5a1e
7 changed files with 54 additions and 7 deletions

View File

@@ -43,6 +43,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "base/platform/base_platform_info.h"
#include "ui/platform/ui_platform_utility.h"
#include "base/call_delayed.h"
#include "base/variant.h"
#include "window/notifications_manager.h"
#include "window/themes/window_theme.h"
#include "window/themes/window_theme_warning.h"
@@ -465,13 +466,21 @@ MainWidget *MainWindow::sessionContent() const {
return _main.data();
}
void MainWindow::ui_showBox(
object_ptr<Ui::BoxContent> box,
void MainWindow::showBoxOrLayer(
std::variant<
v::null_t,
object_ptr<Ui::BoxContent>,
std::unique_ptr<Ui::LayerWidget>> &&layer,
Ui::LayerOptions options,
anim::type animated) {
if (box) {
using UniqueLayer = std::unique_ptr<Ui::LayerWidget>;
using ObjectBox = object_ptr<Ui::BoxContent>;
if (auto layerWidget = std::get_if<UniqueLayer>(&layer)) {
ensureLayerCreated();
_layer->showBox(std::move(box), options, animated);
_layer->showLayer(std::move(*layerWidget), options, animated);
} else if (auto box = std::get_if<ObjectBox>(&layer); *box != nullptr) {
ensureLayerCreated();
_layer->showBox(std::move(*box), options, animated);
} else {
if (_layer) {
_layer->hideTopLayer(animated);
@@ -485,6 +494,20 @@ void MainWindow::ui_showBox(
}
}
void MainWindow::ui_showBox(
object_ptr<Ui::BoxContent> box,
Ui::LayerOptions options,
anim::type animated) {
showBoxOrLayer(std::move(box), options, animated);
}
void MainWindow::showLayer(
std::unique_ptr<Ui::LayerWidget> &&layer,
Ui::LayerOptions options,
anim::type animated) {
showBoxOrLayer(std::move(layer), options, animated);
}
bool MainWindow::ui_isLayerShown() {
return _layer != nullptr;
}