mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-03 21:54:05 +02:00
Moved out data for swipe handler from history view to ui controls.
This commit is contained in:
parent
5cdfaab2db
commit
de87bed375
19 changed files with 41 additions and 47 deletions
|
@ -534,7 +534,7 @@ TabbedSelector::~TabbedSelector() = default;
|
|||
|
||||
void TabbedSelector::setupSwipe() {
|
||||
Ui::Controls::SetupSwipeHandler(this, _scroll.data(), [=](
|
||||
HistoryView::ChatPaintGestureHorizontalData data) {
|
||||
Ui::Controls::SwipeContextData data) {
|
||||
if (data.translation != 0) {
|
||||
if (!_swipeBackData.callback) {
|
||||
_swipeBackData = Ui::Controls::SetupSwipeBack(
|
||||
|
|
|
@ -10,10 +10,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "api/api_common.h"
|
||||
#include "chat_helpers/compose/compose_features.h"
|
||||
#include "ui/rp_widget.h"
|
||||
#include "ui/controls/swipe_handler_data.h"
|
||||
#include "ui/effects/animations.h"
|
||||
#include "ui/effects/message_sending_animation_common.h"
|
||||
#include "ui/effects/panel_animation.h"
|
||||
#include "history/history_view_swipe_data.h"
|
||||
#include "ui/cached_round_corners.h"
|
||||
#include "mtproto/sender.h"
|
||||
#include "base/object_ptr.h"
|
||||
|
@ -296,7 +296,7 @@ private:
|
|||
const PauseReason _level = {};
|
||||
const Fn<QColor()> _customTextColor;
|
||||
|
||||
HistoryView::SwipeBackResult _swipeBackData;
|
||||
Ui::Controls::SwipeBackResult _swipeBackData;
|
||||
|
||||
Mode _mode = Mode::Full;
|
||||
int _roundRadius = 0;
|
||||
|
|
|
@ -678,7 +678,7 @@ Widget::Widget(
|
|||
|
||||
void Widget::setupSwipeBack() {
|
||||
Ui::Controls::SetupSwipeHandler(_scroll.data(), _scroll.data(), [=](
|
||||
HistoryView::ChatPaintGestureHorizontalData data) {
|
||||
Ui::Controls::SwipeContextData data) {
|
||||
if (data.translation > 0) {
|
||||
if (!_swipeBackData.callback) {
|
||||
_swipeBackData = Ui::Controls::SetupSwipeBack(
|
||||
|
|
|
@ -9,8 +9,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
|
||||
#include "base/timer.h"
|
||||
#include "dialogs/dialogs_key.h"
|
||||
#include "history/history_view_swipe_data.h"
|
||||
#include "window/section_widget.h"
|
||||
#include "ui/controls/swipe_handler_data.h"
|
||||
#include "ui/effects/animations.h"
|
||||
#include "ui/userpic_view.h"
|
||||
#include "mtproto/sender.h"
|
||||
|
@ -385,7 +385,7 @@ private:
|
|||
ChatSearchTab _searchQueryTab = {};
|
||||
ChatTypeFilter _searchQueryFilter = {};
|
||||
|
||||
HistoryView::SwipeBackResult _swipeBackData;
|
||||
Ui::Controls::SwipeBackResult _swipeBackData;
|
||||
|
||||
SearchProcessState _searchProcess;
|
||||
SearchProcessState _migratedProcess;
|
||||
|
|
|
@ -421,7 +421,7 @@ void Widget::setupShortcuts() {
|
|||
|
||||
void Widget::setupSwipeReply() {
|
||||
Ui::Controls::SetupSwipeHandler(this, _scroll.data(), [=](
|
||||
HistoryView::ChatPaintGestureHorizontalData data) {
|
||||
Ui::Controls::SwipeContextData data) {
|
||||
if (data.translation > 0) {
|
||||
if (!_swipeBackData.callback) {
|
||||
_swipeBackData = Ui::Controls::SetupSwipeBack(
|
||||
|
|
|
@ -11,7 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "window/section_memento.h"
|
||||
#include "history/admin_log/history_admin_log_item.h"
|
||||
#include "history/admin_log/history_admin_log_filter_value.h"
|
||||
#include "history/history_view_swipe_data.h"
|
||||
#include "ui/controls/swipe_handler_data.h"
|
||||
#include "mtproto/sender.h"
|
||||
|
||||
namespace Ui {
|
||||
|
@ -83,7 +83,7 @@ private:
|
|||
object_ptr<Ui::PlainShadow> _fixedBarShadow;
|
||||
object_ptr<Ui::FlatButton> _whatIsThis;
|
||||
|
||||
HistoryView::SwipeBackResult _swipeBackData;
|
||||
Ui::Controls::SwipeBackResult _swipeBackData;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -529,7 +529,7 @@ void HistoryInner::setupSwipeReplyAndBack() {
|
|||
}
|
||||
const auto peer = _peer;
|
||||
Ui::Controls::SetupSwipeHandler(this, _scroll, [=, history = _history](
|
||||
HistoryView::ChatPaintGestureHorizontalData data) {
|
||||
Ui::Controls::SwipeContextData data) {
|
||||
if (data.translation > 0) {
|
||||
if (!_swipeBackData.callback) {
|
||||
_swipeBackData = Ui::Controls::SetupSwipeBack(
|
||||
|
|
|
@ -10,11 +10,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "base/timer.h"
|
||||
#include "data/data_report.h"
|
||||
#include "ui/rp_widget.h"
|
||||
#include "ui/controls/swipe_handler_data.h"
|
||||
#include "ui/effects/animations.h"
|
||||
#include "ui/dragging_scroll_manager.h"
|
||||
#include "ui/widgets/tooltip.h"
|
||||
#include "ui/widgets/scroll_area.h"
|
||||
#include "history/history_view_swipe_data.h"
|
||||
#include "history/view/history_view_top_bar_widget.h"
|
||||
|
||||
#include <QtGui/QPainterPath>
|
||||
|
@ -543,8 +543,8 @@ private:
|
|||
crl::time _touchTime = 0;
|
||||
base::Timer _touchScrollTimer;
|
||||
|
||||
HistoryView::ChatPaintGestureHorizontalData _gestureHorizontal;
|
||||
HistoryView::SwipeBackResult _swipeBackData;
|
||||
Ui::Controls::SwipeContextData _gestureHorizontal;
|
||||
Ui::Controls::SwipeBackResult _swipeBackData;
|
||||
|
||||
// _menu must be destroyed before _whoReactedMenuLifetime.
|
||||
rpl::lifetime _whoReactedMenuLifetime;
|
||||
|
|
|
@ -7,10 +7,10 @@ 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/view/history_view_list_widget.h"
|
||||
#include "ui/chat/chat_style.h"
|
||||
#include "ui/controls/swipe_handler.h"
|
||||
#include "ui/controls/swipe_handler_data.h"
|
||||
#include "window/window_session_controller.h"
|
||||
|
||||
namespace Window {
|
||||
|
@ -20,9 +20,9 @@ void SetupSwipeBackSection(
|
|||
not_null<Ui::ScrollArea*> scroll,
|
||||
not_null<HistoryView::ListWidget*> list) {
|
||||
const auto swipeBackData
|
||||
= list->lifetime().make_state<HistoryView::SwipeBackResult>();
|
||||
= list->lifetime().make_state<Ui::Controls::SwipeBackResult>();
|
||||
Ui::Controls::SetupSwipeHandler(parent, scroll, [=](
|
||||
HistoryView::ChatPaintGestureHorizontalData data) {
|
||||
Ui::Controls::SwipeContextData data) {
|
||||
if (data.translation > 0) {
|
||||
if (!swipeBackData->callback) {
|
||||
const auto color = [=]() -> std::pair<QColor, QColor> {
|
||||
|
|
|
@ -53,13 +53,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "ui/controls/send_as_button.h"
|
||||
#include "ui/controls/silent_toggle.h"
|
||||
#include "ui/controls/swipe_handler.h"
|
||||
#include "ui/controls/swipe_handler_data.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_data.h"
|
||||
#include "base/call_delayed.h"
|
||||
#include "data/business/data_shortcut_messages.h"
|
||||
#include "data/components/credits.h"
|
||||
|
|
|
@ -891,7 +891,7 @@ void RepliesWidget::setupSwipeReplyAndBack() {
|
|||
return false;
|
||||
};
|
||||
Ui::Controls::SetupSwipeHandler(_inner, _scroll.get(), [=](
|
||||
HistoryView::ChatPaintGestureHorizontalData data) {
|
||||
Ui::Controls::SwipeContextData data) {
|
||||
if (data.translation > 0) {
|
||||
if (!_swipeBackData.callback) {
|
||||
_swipeBackData = Ui::Controls::SetupSwipeBack(
|
||||
|
|
|
@ -12,8 +12,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "history/view/history_view_corner_buttons.h"
|
||||
#include "history/view/history_view_list_widget.h"
|
||||
#include "history/history_item_helpers.h"
|
||||
#include "history/history_view_swipe_data.h"
|
||||
#include "data/data_messages.h"
|
||||
#include "ui/controls/swipe_handler_data.h"
|
||||
#include "base/timer.h"
|
||||
|
||||
class History;
|
||||
|
@ -393,8 +393,8 @@ private:
|
|||
HistoryView::CornerButtons _cornerButtons;
|
||||
rpl::lifetime _topicLifetime;
|
||||
|
||||
HistoryView::ChatPaintGestureHorizontalData _gestureHorizontal;
|
||||
HistoryView::SwipeBackResult _swipeBackData;
|
||||
Ui::Controls::SwipeContextData _gestureHorizontal;
|
||||
Ui::Controls::SwipeBackResult _swipeBackData;
|
||||
|
||||
SendPaymentHelper _sendPayment;
|
||||
|
||||
|
|
|
@ -386,7 +386,7 @@ not_null<Ui::ScrollArea*> ContentWidget::scroll() const {
|
|||
|
||||
void ContentWidget::setupSwipeReply() {
|
||||
Ui::Controls::SetupSwipeHandler(this, _scroll.data(), [=](
|
||||
HistoryView::ChatPaintGestureHorizontalData data) {
|
||||
Ui::Controls::SwipeContextData data) {
|
||||
if (data.translation > 0) {
|
||||
if (!_swipeBackData.callback) {
|
||||
_swipeBackData = Ui::Controls::SetupSwipeBack(
|
||||
|
|
|
@ -9,7 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
|
||||
#include "info/info_wrap_widget.h"
|
||||
#include "info/statistics/info_statistics_tag.h"
|
||||
#include "history/history_view_swipe_data.h"
|
||||
#include "ui/controls/swipe_handler_data.h"
|
||||
|
||||
namespace Api {
|
||||
struct WhoReadList;
|
||||
|
@ -192,7 +192,7 @@ private:
|
|||
// To paint round edges from content.
|
||||
style::margins _paintPadding;
|
||||
|
||||
HistoryView::SwipeBackResult _swipeBackData;
|
||||
Ui::Controls::SwipeBackResult _swipeBackData;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -10,8 +10,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "ui/cached_round_corners.h"
|
||||
#include "ui/chat/message_bubble.h"
|
||||
#include "ui/chat/chat_style_radius.h"
|
||||
#include "ui/controls/swipe_handler_data.h"
|
||||
#include "ui/style/style_core_palette.h"
|
||||
#include "history/history_view_swipe_data.h"
|
||||
#include "layout/layout_selection.h"
|
||||
#include "styles/style_basic.h"
|
||||
|
||||
|
@ -165,7 +165,7 @@ struct ChatPaintContext {
|
|||
QPainterPath *highlightPathCache = nullptr;
|
||||
mutable QRect highlightInterpolateTo;
|
||||
crl::time now = 0;
|
||||
HistoryView::ChatPaintGestureHorizontalData gestureHorizontal;
|
||||
Ui::Controls::SwipeContextData gestureHorizontal;
|
||||
|
||||
void translate(int x, int y) {
|
||||
viewport.translate(x, y);
|
||||
|
|
|
@ -11,8 +11,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "base/platform/base_platform_info.h"
|
||||
#include "base/qt/qt_common_adapters.h"
|
||||
#include "base/event_filter.h"
|
||||
#include "history/history_view_swipe_data.h"
|
||||
#include "ui/chat/chat_style.h"
|
||||
#include "ui/controls/swipe_handler_data.h"
|
||||
#include "ui/painter.h"
|
||||
#include "ui/rect.h"
|
||||
#include "ui/ui_utility.h"
|
||||
|
@ -30,16 +30,12 @@ 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(
|
||||
not_null<Ui::RpWidget*> widget,
|
||||
Scroll scroll,
|
||||
Fn<void(ChatPaintGestureHorizontalData)> update,
|
||||
Fn<void(SwipeContextData)> update,
|
||||
Fn<SwipeHandlerFinishData(int, Qt::LayoutDirection)> generateFinish,
|
||||
rpl::producer<bool> dontStart) {
|
||||
constexpr auto kThresholdWidth = 50;
|
||||
|
@ -54,7 +50,7 @@ void SetupSwipeHandler(
|
|||
base::unique_qptr<QObject> filter;
|
||||
Ui::Animations::Simple animationReach;
|
||||
Ui::Animations::Simple animationEnd;
|
||||
ChatPaintGestureHorizontalData data;
|
||||
SwipeContextData data;
|
||||
SwipeHandlerFinishData finishByTopData;
|
||||
std::optional<Qt::Orientation> orientation;
|
||||
std::optional<Qt::LayoutDirection> direction;
|
||||
|
@ -306,7 +302,7 @@ SwipeBackResult SetupSwipeBack(
|
|||
bool mirrored) {
|
||||
struct State {
|
||||
base::unique_qptr<Ui::RpWidget> back;
|
||||
ChatPaintGestureHorizontalData data;
|
||||
SwipeContextData data;
|
||||
};
|
||||
|
||||
constexpr auto kMaxInnerOffset = 0.5;
|
||||
|
@ -396,7 +392,7 @@ SwipeBackResult SetupSwipeBack(
|
|||
};
|
||||
};
|
||||
|
||||
const auto callback = ([=](ChatPaintGestureHorizontalData data) {
|
||||
const auto callback = ([=](SwipeContextData data) {
|
||||
const auto ratio = std::min(1.0, data.ratio);
|
||||
state->data = std::move(data);
|
||||
if (ratio > 0) {
|
||||
|
|
|
@ -7,11 +7,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
*/
|
||||
#pragma once
|
||||
|
||||
namespace HistoryView {
|
||||
struct ChatPaintGestureHorizontalData;
|
||||
struct SwipeBackResult;
|
||||
} // namespace HistoryView
|
||||
|
||||
namespace Ui {
|
||||
class ElasticScroll;
|
||||
class RpWidget;
|
||||
|
@ -20,6 +15,9 @@ class ScrollArea;
|
|||
|
||||
namespace Ui::Controls {
|
||||
|
||||
struct SwipeContextData;
|
||||
struct SwipeBackResult;
|
||||
|
||||
struct SwipeHandlerFinishData {
|
||||
Fn<void(void)> callback;
|
||||
int64 msgBareId = 0;
|
||||
|
@ -34,11 +32,11 @@ using Scroll = std::variant<
|
|||
void SetupSwipeHandler(
|
||||
not_null<Ui::RpWidget*> widget,
|
||||
Scroll scroll,
|
||||
Fn<void(HistoryView::ChatPaintGestureHorizontalData)> update,
|
||||
Fn<void(SwipeContextData)> update,
|
||||
Fn<SwipeHandlerFinishData(int, Qt::LayoutDirection)> generateFinishByTop,
|
||||
rpl::producer<bool> dontStart = nullptr);
|
||||
|
||||
[[nodiscard]] HistoryView::SwipeBackResult SetupSwipeBack(
|
||||
[[nodiscard]] SwipeBackResult SetupSwipeBack(
|
||||
not_null<Ui::RpWidget*> widget,
|
||||
Fn<std::pair<QColor, QColor>()> colors,
|
||||
bool mirrored = false);
|
||||
|
|
|
@ -7,9 +7,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
*/
|
||||
#pragma once
|
||||
|
||||
namespace HistoryView {
|
||||
namespace Ui::Controls {
|
||||
|
||||
struct ChatPaintGestureHorizontalData {
|
||||
struct SwipeContextData final {
|
||||
float64 ratio = 0.;
|
||||
float64 reachRatio = 0.;
|
||||
int64 msgBareId = 0;
|
||||
|
@ -19,7 +19,7 @@ struct ChatPaintGestureHorizontalData {
|
|||
|
||||
struct SwipeBackResult final {
|
||||
rpl::lifetime lifetime;
|
||||
Fn<void(ChatPaintGestureHorizontalData)> callback;
|
||||
Fn<void(SwipeContextData)> callback;
|
||||
};
|
||||
|
||||
} // namespace HistoryView
|
||||
} // namespace Ui::Controls
|
|
@ -129,7 +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_data.h
|
||||
history/view/controls/history_view_characters_limit.cpp
|
||||
history/view/controls/history_view_characters_limit.h
|
||||
history/view/controls/history_view_voice_record_button.cpp
|
||||
|
@ -382,6 +381,7 @@ PRIVATE
|
|||
ui/controls/send_button.h
|
||||
ui/controls/swipe_handler.cpp
|
||||
ui/controls/swipe_handler.h
|
||||
ui/controls/swipe_handler_data.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