mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-03 21:54:05 +02:00
Moved out swipe handler from history view to ui controls.
This commit is contained in:
parent
acb0b029b9
commit
5cdfaab2db
11 changed files with 57 additions and 49 deletions
|
@ -11,6 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "chat_helpers/stickers_list_widget.h"
|
||||
#include "chat_helpers/gifs_list_widget.h"
|
||||
#include "menu/menu_send.h"
|
||||
#include "ui/controls/swipe_handler.h"
|
||||
#include "ui/controls/tabbed_search.h"
|
||||
#include "ui/text/text_utilities.h"
|
||||
#include "ui/widgets/buttons.h"
|
||||
|
@ -35,7 +36,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "data/stickers/data_stickers.h"
|
||||
#include "data/stickers/data_custom_emoji.h" // AllowEmojiWithoutPremium.
|
||||
#include "boxes/premium_preview_box.h"
|
||||
#include "history/history_view_swipe.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "mainwindow.h"
|
||||
#include "apiwrap.h"
|
||||
|
@ -533,11 +533,11 @@ TabbedSelector::TabbedSelector(
|
|||
TabbedSelector::~TabbedSelector() = default;
|
||||
|
||||
void TabbedSelector::setupSwipe() {
|
||||
HistoryView::SetupSwipeHandler(this, _scroll.data(), [=](
|
||||
Ui::Controls::SetupSwipeHandler(this, _scroll.data(), [=](
|
||||
HistoryView::ChatPaintGestureHorizontalData data) {
|
||||
if (data.translation != 0) {
|
||||
if (!_swipeBackData.callback) {
|
||||
_swipeBackData = HistoryView::SetupSwipeBack(
|
||||
_swipeBackData = Ui::Controls::SetupSwipeBack(
|
||||
this,
|
||||
[=]() -> std::pair<QColor, QColor> {
|
||||
return {
|
||||
|
@ -554,13 +554,13 @@ void TabbedSelector::setupSwipe() {
|
|||
}
|
||||
}, [=](int, Qt::LayoutDirection direction) {
|
||||
if (!_tabsSlider) {
|
||||
return HistoryView::SwipeHandlerFinishData();
|
||||
return Ui::Controls::SwipeHandlerFinishData();
|
||||
}
|
||||
const auto activeSection = _tabsSlider->activeSection();
|
||||
const auto isToLeft = direction == Qt::RightToLeft;
|
||||
if ((isToLeft && activeSection > 0)
|
||||
|| (!isToLeft && activeSection < _tabs.size() - 1)) {
|
||||
return HistoryView::DefaultSwipeBackHandlerFinishData([=] {
|
||||
return Ui::Controls::DefaultSwipeBackHandlerFinishData([=] {
|
||||
if (_tabsSlider
|
||||
&& _tabsSlider->activeSection() == activeSection) {
|
||||
_swipeBackData = {};
|
||||
|
@ -570,7 +570,7 @@ void TabbedSelector::setupSwipe() {
|
|||
}
|
||||
});
|
||||
}
|
||||
return HistoryView::SwipeHandlerFinishData();
|
||||
return Ui::Controls::SwipeHandlerFinishData();
|
||||
}, nullptr);
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "dialogs/dialogs_key.h"
|
||||
#include "history/history.h"
|
||||
#include "history/history_item.h"
|
||||
#include "history/history_view_swipe.h"
|
||||
#include "history/view/history_view_top_bar_widget.h"
|
||||
#include "history/view/history_view_contact_status.h"
|
||||
#include "history/view/history_view_requests_bar.h"
|
||||
|
@ -36,6 +35,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "ui/chat/more_chats_bar.h"
|
||||
#include "ui/controls/download_bar.h"
|
||||
#include "ui/controls/jump_down_button.h"
|
||||
#include "ui/controls/swipe_handler.h"
|
||||
#include "ui/painter.h"
|
||||
#include "ui/rect.h"
|
||||
#include "ui/ui_utility.h"
|
||||
|
@ -677,11 +677,11 @@ Widget::Widget(
|
|||
}
|
||||
|
||||
void Widget::setupSwipeBack() {
|
||||
HistoryView::SetupSwipeHandler(_scroll.data(), _scroll.data(), [=](
|
||||
Ui::Controls::SetupSwipeHandler(_scroll.data(), _scroll.data(), [=](
|
||||
HistoryView::ChatPaintGestureHorizontalData data) {
|
||||
if (data.translation > 0) {
|
||||
if (!_swipeBackData.callback) {
|
||||
_swipeBackData = HistoryView::SetupSwipeBack(
|
||||
_swipeBackData = Ui::Controls::SetupSwipeBack(
|
||||
this,
|
||||
[]() -> std::pair<QColor, QColor> {
|
||||
return {
|
||||
|
@ -703,9 +703,9 @@ void Widget::setupSwipeBack() {
|
|||
|| (!controller()->isPrimary() && (_layout != Layout::Child))
|
||||
|| (!controller()->shownForum().current()
|
||||
&& !controller()->openedFolder().current())) {
|
||||
return HistoryView::SwipeHandlerFinishData();
|
||||
return Ui::Controls::SwipeHandlerFinishData();
|
||||
}
|
||||
return HistoryView::DefaultSwipeBackHandlerFinishData([=] {
|
||||
return Ui::Controls::DefaultSwipeBackHandlerFinishData([=] {
|
||||
_swipeBackData = {};
|
||||
if (const auto forum = controller()->shownForum().current()) {
|
||||
const auto id = controller()->windowId();
|
||||
|
|
|
@ -9,10 +9,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
|
||||
#include "history/admin_log/history_admin_log_inner.h"
|
||||
#include "history/admin_log/history_admin_log_filter.h"
|
||||
#include "history/history_view_swipe.h"
|
||||
#include "profile/profile_back_button.h"
|
||||
#include "core/shortcuts.h"
|
||||
#include "ui/chat/chat_style.h"
|
||||
#include "ui/controls/swipe_handler.h"
|
||||
#include "ui/effects/animations.h"
|
||||
#include "ui/widgets/scroll_area.h"
|
||||
#include "ui/widgets/shadow.h"
|
||||
|
@ -420,11 +420,11 @@ void Widget::setupShortcuts() {
|
|||
}
|
||||
|
||||
void Widget::setupSwipeReply() {
|
||||
HistoryView::SetupSwipeHandler(this, _scroll.data(), [=](
|
||||
Ui::Controls::SetupSwipeHandler(this, _scroll.data(), [=](
|
||||
HistoryView::ChatPaintGestureHorizontalData data) {
|
||||
if (data.translation > 0) {
|
||||
if (!_swipeBackData.callback) {
|
||||
_swipeBackData = HistoryView::SetupSwipeBack(
|
||||
_swipeBackData = Ui::Controls::SetupSwipeBack(
|
||||
this,
|
||||
[=]() -> std::pair<QColor, QColor> {
|
||||
auto context = _inner->preparePaintContext({});
|
||||
|
@ -441,11 +441,11 @@ void Widget::setupSwipeReply() {
|
|||
}
|
||||
}, [=](int, Qt::LayoutDirection direction) {
|
||||
if (direction == Qt::RightToLeft) {
|
||||
return HistoryView::DefaultSwipeBackHandlerFinishData([=] {
|
||||
return Ui::Controls::DefaultSwipeBackHandlerFinishData([=] {
|
||||
controller()->showBackFromStack();
|
||||
});
|
||||
}
|
||||
return HistoryView::SwipeHandlerFinishData();
|
||||
return Ui::Controls::SwipeHandlerFinishData();
|
||||
}, nullptr);
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "history/view/history_view_emoji_interactions.h"
|
||||
#include "history/history_item_components.h"
|
||||
#include "history/history_item_text.h"
|
||||
#include "history/history_view_swipe.h"
|
||||
#include "payments/payments_reaction_process.h"
|
||||
#include "ui/widgets/menu/menu_add_action_callback_factory.h"
|
||||
#include "ui/widgets/menu/menu_multiline_action.h"
|
||||
|
@ -42,6 +41,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "ui/boxes/edit_factcheck_box.h"
|
||||
#include "ui/boxes/report_box_graphics.h"
|
||||
#include "ui/controls/delete_message_context_action.h"
|
||||
#include "ui/controls/swipe_handler.h"
|
||||
#include "ui/inactive_press.h"
|
||||
#include "ui/painter.h"
|
||||
#include "ui/rect.h"
|
||||
|
@ -528,11 +528,11 @@ void HistoryInner::setupSwipeReplyAndBack() {
|
|||
return;
|
||||
}
|
||||
const auto peer = _peer;
|
||||
HistoryView::SetupSwipeHandler(this, _scroll, [=, history = _history](
|
||||
Ui::Controls::SetupSwipeHandler(this, _scroll, [=, history = _history](
|
||||
HistoryView::ChatPaintGestureHorizontalData data) {
|
||||
if (data.translation > 0) {
|
||||
if (!_swipeBackData.callback) {
|
||||
_swipeBackData = HistoryView::SetupSwipeBack(
|
||||
_swipeBackData = Ui::Controls::SetupSwipeBack(
|
||||
_widget,
|
||||
[=]() -> std::pair<QColor, QColor> {
|
||||
auto context = preparePaintContext({});
|
||||
|
@ -563,11 +563,11 @@ void HistoryInner::setupSwipeReplyAndBack() {
|
|||
int cursorTop,
|
||||
Qt::LayoutDirection direction) {
|
||||
if (direction == Qt::RightToLeft) {
|
||||
return HistoryView::DefaultSwipeBackHandlerFinishData([=] {
|
||||
return Ui::Controls::DefaultSwipeBackHandlerFinishData([=] {
|
||||
_controller->showBackFromStack();
|
||||
});
|
||||
}
|
||||
auto result = HistoryView::SwipeHandlerFinishData();
|
||||
auto result = Ui::Controls::SwipeHandlerFinishData();
|
||||
if (inSelectionMode().inSelectionMode
|
||||
|| (peer->isChannel() && !peer->isMegagroup())) {
|
||||
return result;
|
||||
|
|
|
@ -8,9 +8,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "history/history_view_swipe_back_session.h"
|
||||
|
||||
#include "history/history_view_swipe_data.h"
|
||||
#include "history/history_view_swipe.h"
|
||||
#include "history/view/history_view_list_widget.h"
|
||||
#include "ui/chat/chat_style.h"
|
||||
#include "ui/controls/swipe_handler.h"
|
||||
#include "window/window_session_controller.h"
|
||||
|
||||
namespace Window {
|
||||
|
@ -21,7 +21,7 @@ void SetupSwipeBackSection(
|
|||
not_null<HistoryView::ListWidget*> list) {
|
||||
const auto swipeBackData
|
||||
= list->lifetime().make_state<HistoryView::SwipeBackResult>();
|
||||
HistoryView::SetupSwipeHandler(parent, scroll, [=](
|
||||
Ui::Controls::SetupSwipeHandler(parent, scroll, [=](
|
||||
HistoryView::ChatPaintGestureHorizontalData data) {
|
||||
if (data.translation > 0) {
|
||||
if (!swipeBackData->callback) {
|
||||
|
@ -34,7 +34,9 @@ void SetupSwipeBackSection(
|
|||
c.st->msgServiceFg()->c,
|
||||
};
|
||||
};
|
||||
(*swipeBackData) = HistoryView::SetupSwipeBack(parent, color);
|
||||
(*swipeBackData) = Ui::Controls::SetupSwipeBack(
|
||||
parent,
|
||||
color);
|
||||
}
|
||||
swipeBackData->callback(data);
|
||||
return;
|
||||
|
@ -43,9 +45,9 @@ void SetupSwipeBackSection(
|
|||
}
|
||||
}, [=](int, Qt::LayoutDirection direction) {
|
||||
if (direction != Qt::RightToLeft) {
|
||||
return HistoryView::SwipeHandlerFinishData();
|
||||
return Ui::Controls::SwipeHandlerFinishData();
|
||||
}
|
||||
return HistoryView::DefaultSwipeBackHandlerFinishData([=] {
|
||||
return Ui::Controls::DefaultSwipeBackHandlerFinishData([=] {
|
||||
list->controller()->showBackFromStack();
|
||||
});
|
||||
}, list->touchMaybeSelectingValue());
|
||||
|
|
|
@ -52,13 +52,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "ui/controls/send_button.h"
|
||||
#include "ui/controls/send_as_button.h"
|
||||
#include "ui/controls/silent_toggle.h"
|
||||
#include "ui/controls/swipe_handler.h"
|
||||
#include "ui/ui_utility.h"
|
||||
#include "inline_bots/inline_bot_result.h"
|
||||
#include "base/event_filter.h"
|
||||
#include "base/qt_signal_producer.h"
|
||||
#include "base/qt/qt_key_modifiers.h"
|
||||
#include "base/unixtime.h"
|
||||
#include "history/history_view_swipe.h"
|
||||
#include "history/history_view_swipe_data.h"
|
||||
#include "base/call_delayed.h"
|
||||
#include "data/business/data_shortcut_messages.h"
|
||||
|
|
|
@ -25,9 +25,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "history/history_drag_area.h"
|
||||
#include "history/history_item_components.h"
|
||||
#include "history/history_item_helpers.h" // GetErrorForSending.
|
||||
#include "history/history_view_swipe.h"
|
||||
#include "ui/chat/pinned_bar.h"
|
||||
#include "ui/chat/chat_style.h"
|
||||
#include "ui/controls/swipe_handler.h"
|
||||
#include "ui/widgets/menu/menu_add_action_callback_factory.h"
|
||||
#include "ui/widgets/buttons.h"
|
||||
#include "ui/widgets/scroll_area.h"
|
||||
|
@ -890,11 +890,11 @@ void RepliesWidget::setupSwipeReplyAndBack() {
|
|||
}
|
||||
return false;
|
||||
};
|
||||
HistoryView::SetupSwipeHandler(_inner, _scroll.get(), [=](
|
||||
Ui::Controls::SetupSwipeHandler(_inner, _scroll.get(), [=](
|
||||
HistoryView::ChatPaintGestureHorizontalData data) {
|
||||
if (data.translation > 0) {
|
||||
if (!_swipeBackData.callback) {
|
||||
_swipeBackData = HistoryView::SetupSwipeBack(
|
||||
_swipeBackData = Ui::Controls::SetupSwipeBack(
|
||||
this,
|
||||
[=]() -> std::pair<QColor, QColor> {
|
||||
const auto context = listPreparePaintContext({
|
||||
|
@ -927,11 +927,11 @@ void RepliesWidget::setupSwipeReplyAndBack() {
|
|||
int cursorTop,
|
||||
Qt::LayoutDirection direction) {
|
||||
if (direction == Qt::RightToLeft) {
|
||||
return HistoryView::DefaultSwipeBackHandlerFinishData([=] {
|
||||
return Ui::Controls::DefaultSwipeBackHandlerFinishData([=] {
|
||||
controller()->showBackFromStack();
|
||||
});
|
||||
}
|
||||
auto result = HistoryView::SwipeHandlerFinishData();
|
||||
auto result = Ui::Controls::SwipeHandlerFinishData();
|
||||
if (_inner->elementInSelectionMode(nullptr).inSelectionMode) {
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -18,11 +18,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "info/media/info_media_widget.h"
|
||||
#include "info/common_groups/info_common_groups_widget.h"
|
||||
#include "info/info_layer_widget.h"
|
||||
#include "history/history_view_swipe.h"
|
||||
#include "info/info_section_widget.h"
|
||||
#include "info/info_controller.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "main/main_session.h"
|
||||
#include "ui/controls/swipe_handler.h"
|
||||
#include "ui/widgets/scroll_area.h"
|
||||
#include "ui/widgets/fields/input_field.h"
|
||||
#include "ui/wrap/padding_wrap.h"
|
||||
|
@ -385,11 +385,11 @@ not_null<Ui::ScrollArea*> ContentWidget::scroll() const {
|
|||
}
|
||||
|
||||
void ContentWidget::setupSwipeReply() {
|
||||
HistoryView::SetupSwipeHandler(this, _scroll.data(), [=](
|
||||
Ui::Controls::SetupSwipeHandler(this, _scroll.data(), [=](
|
||||
HistoryView::ChatPaintGestureHorizontalData data) {
|
||||
if (data.translation > 0) {
|
||||
if (!_swipeBackData.callback) {
|
||||
_swipeBackData = HistoryView::SetupSwipeBack(
|
||||
_swipeBackData = Ui::Controls::SetupSwipeBack(
|
||||
this,
|
||||
[]() -> std::pair<QColor, QColor> {
|
||||
return {
|
||||
|
@ -418,8 +418,8 @@ void ContentWidget::setupSwipeReply() {
|
|||
}();
|
||||
|
||||
return !can
|
||||
? HistoryView::SwipeHandlerFinishData()
|
||||
: HistoryView::DefaultSwipeBackHandlerFinishData([=] {
|
||||
? Ui::Controls::SwipeHandlerFinishData()
|
||||
: Ui::Controls::DefaultSwipeBackHandlerFinishData([=] {
|
||||
_controller->showBackFromStack();
|
||||
});
|
||||
}, nullptr);
|
||||
|
|
|
@ -5,7 +5,7 @@ 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 "history/history_view_swipe.h"
|
||||
#include "ui/controls/swipe_handler.h"
|
||||
|
||||
#include "base/platform/base_platform_haptic.h"
|
||||
#include "base/platform/base_platform_info.h"
|
||||
|
@ -22,7 +22,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
|
||||
#include <QtWidgets/QApplication>
|
||||
|
||||
namespace HistoryView {
|
||||
namespace Ui::Controls {
|
||||
namespace {
|
||||
|
||||
constexpr auto kSwipeSlow = 0.2;
|
||||
|
@ -30,6 +30,10 @@ constexpr auto kSwipeSlow = 0.2;
|
|||
constexpr auto kMsgBareIdSwipeBack = std::numeric_limits<int64>::max() - 77;
|
||||
constexpr auto kSwipedBackSpeedRatio = 0.35;
|
||||
|
||||
using ChatPaintGestureHorizontalData
|
||||
= HistoryView::ChatPaintGestureHorizontalData;
|
||||
using SwipeBackResult = HistoryView::SwipeBackResult;
|
||||
|
||||
} // namespace
|
||||
|
||||
void SetupSwipeHandler(
|
||||
|
@ -438,4 +442,4 @@ SwipeHandlerFinishData DefaultSwipeBackHandlerFinishData(
|
|||
};
|
||||
}
|
||||
|
||||
} // namespace HistoryView
|
||||
} // namespace Ui::Controls
|
|
@ -7,16 +7,18 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
*/
|
||||
#pragma once
|
||||
|
||||
namespace HistoryView {
|
||||
struct ChatPaintGestureHorizontalData;
|
||||
struct SwipeBackResult;
|
||||
} // namespace HistoryView
|
||||
|
||||
namespace Ui {
|
||||
class ElasticScroll;
|
||||
class RpWidget;
|
||||
class ScrollArea;
|
||||
} // namespace Ui
|
||||
|
||||
namespace HistoryView {
|
||||
|
||||
struct ChatPaintGestureHorizontalData;
|
||||
struct SwipeBackResult;
|
||||
namespace Ui::Controls {
|
||||
|
||||
struct SwipeHandlerFinishData {
|
||||
Fn<void(void)> callback;
|
||||
|
@ -32,11 +34,11 @@ using Scroll = std::variant<
|
|||
void SetupSwipeHandler(
|
||||
not_null<Ui::RpWidget*> widget,
|
||||
Scroll scroll,
|
||||
Fn<void(ChatPaintGestureHorizontalData)> update,
|
||||
Fn<void(HistoryView::ChatPaintGestureHorizontalData)> update,
|
||||
Fn<SwipeHandlerFinishData(int, Qt::LayoutDirection)> generateFinishByTop,
|
||||
rpl::producer<bool> dontStart = nullptr);
|
||||
|
||||
[[nodiscard]] SwipeBackResult SetupSwipeBack(
|
||||
[[nodiscard]] HistoryView::SwipeBackResult SetupSwipeBack(
|
||||
not_null<Ui::RpWidget*> widget,
|
||||
Fn<std::pair<QColor, QColor>()> colors,
|
||||
bool mirrored = false);
|
||||
|
@ -44,4 +46,4 @@ void SetupSwipeHandler(
|
|||
[[nodiscard]] SwipeHandlerFinishData DefaultSwipeBackHandlerFinishData(
|
||||
Fn<void(void)> callback);
|
||||
|
||||
} // namespace HistoryView
|
||||
} // namespace Ui::Controls
|
|
@ -129,8 +129,6 @@ PRIVATE
|
|||
history/admin_log/history_admin_log_filter_value.h
|
||||
history/history_view_top_toast.cpp
|
||||
history/history_view_top_toast.h
|
||||
history/history_view_swipe.cpp
|
||||
history/history_view_swipe.h
|
||||
history/history_view_swipe_data.h
|
||||
history/view/controls/history_view_characters_limit.cpp
|
||||
history/view/controls/history_view_characters_limit.h
|
||||
|
@ -382,6 +380,8 @@ PRIVATE
|
|||
ui/controls/send_as_button.h
|
||||
ui/controls/send_button.cpp
|
||||
ui/controls/send_button.h
|
||||
ui/controls/swipe_handler.cpp
|
||||
ui/controls/swipe_handler.h
|
||||
ui/controls/tabbed_search.cpp
|
||||
ui/controls/tabbed_search.h
|
||||
ui/controls/who_reacted_context_action.cpp
|
||||
|
|
Loading…
Add table
Reference in a new issue