init
Some checks failed
Docker. / Ubuntu (push) Has been cancelled
User-agent updater. / User-agent (push) Failing after 15s
Lock Threads / lock (push) Failing after 10s
Waiting for answer. / waiting-for-answer (push) Failing after 22s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
Close stale issues and PRs / stale (push) Has been cancelled
Some checks failed
Docker. / Ubuntu (push) Has been cancelled
User-agent updater. / User-agent (push) Failing after 15s
Lock Threads / lock (push) Failing after 10s
Waiting for answer. / waiting-for-answer (push) Failing after 22s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
Close stale issues and PRs / stale (push) Has been cancelled
This commit is contained in:
33
Telegram/SourceFiles/editor/controllers/controllers.h
Normal file
33
Telegram/SourceFiles/editor/controllers/controllers.h
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
This file is part of Telegram Desktop,
|
||||
the official desktop application for the Telegram messaging service.
|
||||
|
||||
For license and copyright information please follow this link:
|
||||
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "editor/controllers/stickers_panel_controller.h"
|
||||
#include "editor/controllers/undo_controller.h"
|
||||
#include "ui/layers/show.h"
|
||||
|
||||
namespace Editor {
|
||||
|
||||
struct Controllers final {
|
||||
Controllers(
|
||||
std::unique_ptr<StickersPanelController> stickersPanelController,
|
||||
std::unique_ptr<UndoController> undoController,
|
||||
std::shared_ptr<Ui::Show> show)
|
||||
: stickersPanelController(std::move(stickersPanelController))
|
||||
, undoController(std::move(undoController))
|
||||
, show(std::move(show)) {
|
||||
}
|
||||
~Controllers() {
|
||||
};
|
||||
|
||||
const std::unique_ptr<StickersPanelController> stickersPanelController;
|
||||
const std::unique_ptr<UndoController> undoController;
|
||||
const std::shared_ptr<Ui::Show> show;
|
||||
};
|
||||
|
||||
} // namespace Editor
|
||||
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
This file is part of Telegram Desktop,
|
||||
the official desktop application for the Telegram messaging service.
|
||||
|
||||
For license and copyright information please follow this link:
|
||||
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#include "editor/controllers/stickers_panel_controller.h"
|
||||
|
||||
#include "chat_helpers/tabbed_panel.h"
|
||||
#include "chat_helpers/tabbed_selector.h"
|
||||
#include "window/window_session_controller.h" // Window::GifPauseReason
|
||||
|
||||
#include "styles/style_chat_helpers.h"
|
||||
#include "styles/style_media_view.h"
|
||||
|
||||
namespace Editor {
|
||||
|
||||
StickersPanelController::StickersPanelController(
|
||||
not_null<Ui::RpWidget*> panelContainer,
|
||||
std::shared_ptr<ChatHelpers::Show> show)
|
||||
: _stickersPanel(
|
||||
base::make_unique_q<ChatHelpers::TabbedPanel>(
|
||||
panelContainer,
|
||||
ChatHelpers::TabbedPanelDescriptor{
|
||||
.ownedSelector = object_ptr<ChatHelpers::TabbedSelector>(
|
||||
nullptr,
|
||||
ChatHelpers::TabbedSelectorDescriptor{
|
||||
.show = show,
|
||||
.st = st::storiesComposeControls.tabbed,
|
||||
.level = Window::GifPauseReason::Layer,
|
||||
.mode = ChatHelpers::TabbedSelector::Mode::MediaEditor,
|
||||
.features = {
|
||||
.megagroupSet = false,
|
||||
.stickersSettings = false,
|
||||
.openStickerSets = false,
|
||||
},
|
||||
}),
|
||||
})) {
|
||||
_stickersPanel->setDesiredHeightValues(
|
||||
1.,
|
||||
st::emojiPanMinHeight / 2,
|
||||
st::emojiPanMinHeight);
|
||||
_stickersPanel->hide();
|
||||
}
|
||||
|
||||
auto StickersPanelController::stickerChosen() const
|
||||
-> rpl::producer<not_null<DocumentData*>> {
|
||||
return _stickersPanel->selector()->fileChosen(
|
||||
) | rpl::map([](const ChatHelpers::FileChosen &data) {
|
||||
return data.document;
|
||||
});
|
||||
}
|
||||
|
||||
rpl::producer<bool> StickersPanelController::panelShown() const {
|
||||
return _stickersPanel->shownValue();
|
||||
}
|
||||
|
||||
void StickersPanelController::setShowRequestChanges(
|
||||
rpl::producer<ShowRequest> &&showRequest) {
|
||||
std::move(
|
||||
showRequest
|
||||
) | rpl::on_next([=](ShowRequest show) {
|
||||
if (show == ShowRequest::ToggleAnimated) {
|
||||
_stickersPanel->toggleAnimated();
|
||||
_stickersPanel->raise();
|
||||
} else if (show == ShowRequest::ShowAnimated) {
|
||||
_stickersPanel->showAnimated();
|
||||
_stickersPanel->raise();
|
||||
} else if (show == ShowRequest::HideAnimated) {
|
||||
_stickersPanel->hideAnimated();
|
||||
} else if (show == ShowRequest::HideFast) {
|
||||
_stickersPanel->hideFast();
|
||||
}
|
||||
}, _stickersPanel->lifetime());
|
||||
}
|
||||
|
||||
void StickersPanelController::setMoveRequestChanges(
|
||||
rpl::producer<QPoint> &&moveRequest) {
|
||||
std::move(
|
||||
moveRequest
|
||||
) | rpl::on_next([=](const QPoint &point) {
|
||||
_stickersPanel->moveBottomRight(
|
||||
point.y(),
|
||||
point.x() + _stickersPanel->width() / 2);
|
||||
}, _stickersPanel->lifetime());
|
||||
}
|
||||
|
||||
} // namespace Editor
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
This file is part of Telegram Desktop,
|
||||
the official desktop application for the Telegram messaging service.
|
||||
|
||||
For license and copyright information please follow this link:
|
||||
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "base/unique_qptr.h"
|
||||
|
||||
namespace ChatHelpers {
|
||||
class TabbedPanel;
|
||||
class Show;
|
||||
} // namespace ChatHelpers
|
||||
|
||||
namespace Ui {
|
||||
class RpWidget;
|
||||
} // namespace Ui
|
||||
|
||||
namespace Editor {
|
||||
|
||||
class StickersPanelController final {
|
||||
public:
|
||||
enum class ShowRequest {
|
||||
ToggleAnimated,
|
||||
ShowAnimated,
|
||||
HideAnimated,
|
||||
HideFast,
|
||||
};
|
||||
|
||||
StickersPanelController(
|
||||
not_null<Ui::RpWidget*> panelContainer,
|
||||
std::shared_ptr<ChatHelpers::Show> show);
|
||||
|
||||
[[nodiscard]] auto stickerChosen() const
|
||||
-> rpl::producer<not_null<DocumentData*>>;
|
||||
[[nodiscard]] rpl::producer<bool> panelShown() const;
|
||||
|
||||
void setShowRequestChanges(rpl::producer<ShowRequest> &&showRequest);
|
||||
// Middle x and plain y position.
|
||||
void setMoveRequestChanges(rpl::producer<QPoint> &&moveRequest);
|
||||
|
||||
private:
|
||||
const base::unique_qptr<ChatHelpers::TabbedPanel> _stickersPanel;
|
||||
|
||||
};
|
||||
|
||||
} // namespace Editor
|
||||
39
Telegram/SourceFiles/editor/controllers/undo_controller.cpp
Normal file
39
Telegram/SourceFiles/editor/controllers/undo_controller.cpp
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
This file is part of Telegram Desktop,
|
||||
the official desktop application for the Telegram messaging service.
|
||||
|
||||
For license and copyright information please follow this link:
|
||||
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#include "editor/controllers/undo_controller.h"
|
||||
|
||||
namespace Editor {
|
||||
namespace {
|
||||
using EnableRequest = UndoController::EnableRequest;
|
||||
} // namespace
|
||||
|
||||
UndoController::UndoController() {
|
||||
}
|
||||
|
||||
void UndoController::setCanPerformChanges(
|
||||
rpl::producer<EnableRequest> &&command) {
|
||||
std::move(
|
||||
command
|
||||
) | rpl::start_to_stream(_enable, _lifetime);
|
||||
}
|
||||
|
||||
void UndoController::setPerformRequestChanges(rpl::producer<Undo> &&command) {
|
||||
std::move(
|
||||
command
|
||||
) | rpl::start_to_stream(_perform, _lifetime);
|
||||
}
|
||||
|
||||
rpl::producer<EnableRequest> UndoController::canPerformChanges() const {
|
||||
return _enable.events();
|
||||
}
|
||||
|
||||
rpl::producer<Undo> UndoController::performRequestChanges() const {
|
||||
return _perform.events();
|
||||
}
|
||||
|
||||
} // namespace Editor
|
||||
41
Telegram/SourceFiles/editor/controllers/undo_controller.h
Normal file
41
Telegram/SourceFiles/editor/controllers/undo_controller.h
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
This file is part of Telegram Desktop,
|
||||
the official desktop application for the Telegram messaging service.
|
||||
|
||||
For license and copyright information please follow this link:
|
||||
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
namespace Editor {
|
||||
|
||||
enum class Undo {
|
||||
Undo,
|
||||
Redo,
|
||||
};
|
||||
|
||||
class UndoController final {
|
||||
public:
|
||||
struct EnableRequest {
|
||||
Undo command = Undo::Undo;
|
||||
bool enable = true;
|
||||
};
|
||||
|
||||
UndoController();
|
||||
|
||||
void setCanPerformChanges(rpl::producer<EnableRequest> &&command);
|
||||
void setPerformRequestChanges(rpl::producer<Undo> &&command);
|
||||
|
||||
[[nodiscard]] rpl::producer<EnableRequest> canPerformChanges() const;
|
||||
[[nodiscard]] rpl::producer<Undo> performRequestChanges() const;
|
||||
|
||||
private:
|
||||
|
||||
rpl::event_stream<Undo> _perform;
|
||||
rpl::event_stream<EnableRequest> _enable;
|
||||
|
||||
rpl::lifetime _lifetime;
|
||||
|
||||
};
|
||||
|
||||
} // namespace Editor
|
||||
Reference in New Issue
Block a user