From 5d6dafeedab8bbe2f2df1058d5b2085aadac7139 Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 14 Oct 2016 21:27:42 +0300 Subject: [PATCH] New media player build fixed for Xcode. --- Telegram/SourceFiles/core/observer.h | 57 ++++++++++--------- Telegram/SourceFiles/core/type_traits.h | 17 +++++- Telegram/SourceFiles/facades.h | 6 +- .../media/player/media_player_widget.h | 1 - Telegram/SourceFiles/sysbuttons.h | 2 +- Telegram/SourceFiles/title.h | 5 +- .../ui/widgets/continuous_slider.cpp | 6 +- .../ui/widgets/widget_slide_wrap.h | 1 + 8 files changed, 53 insertions(+), 42 deletions(-) diff --git a/Telegram/SourceFiles/core/observer.h b/Telegram/SourceFiles/core/observer.h index ea3431623..c7c724125 100644 --- a/Telegram/SourceFiles/core/observer.h +++ b/Telegram/SourceFiles/core/observer.h @@ -108,11 +108,11 @@ private: }; -template -class Observable; - namespace internal { +template +class BaseObservable; + template class CommonObservable { public: @@ -127,30 +127,13 @@ private: QSharedPointer> _data; friend class CommonObservableData; - friend class Observable; + friend class BaseObservable::is_fast_copy_type::value>; }; -} // namespace internal - -template > -class Observable : public internal::CommonObservable { - using SimpleEventType = typename base::type_traits::is_fast_copy_type; - +template +class BaseObservable : public internal::CommonObservable { public: - template > - void notify(EventType &&event, bool sync = false) { - if (this->_data) { - this->_data->notify(std_::move(event), sync); - } - } - template > - void notify(const EventType &event, bool sync = false) { - if (this->_data) { - this->_data->notify(EventType(event), sync); - } - } - template > void notify(EventType event, bool sync = false) { if (this->_data) { this->_data->notify(std_::move(event), sync); @@ -159,6 +142,24 @@ public: }; +template +class BaseObservable : public internal::CommonObservable { +public: + void notify(EventType &&event, bool sync = false) { + if (this->_data) { + this->_data->notify(std_::move(event), sync); + } + } + void notify(const EventType &event, bool sync = false) { + if (this->_data) { + this->_data->notify(EventType(event), sync); + } + } + +}; + +} // namespace internal + namespace internal { template @@ -339,10 +340,8 @@ private: }; -} // namespace internal - template -class Observable : public internal::CommonObservable { +class BaseObservable::is_fast_copy_type::value> : public internal::CommonObservable { public: void notify(bool sync = false) { if (this->_data) { @@ -352,6 +351,12 @@ public: }; +} // namespace internal + +template > +class Observable : public internal::BaseObservable::is_fast_copy_type::value> { +}; + class Subscriber { protected: template diff --git a/Telegram/SourceFiles/core/type_traits.h b/Telegram/SourceFiles/core/type_traits.h index 62effcaa7..f4a4e1640 100644 --- a/Telegram/SourceFiles/core/type_traits.h +++ b/Telegram/SourceFiles/core/type_traits.h @@ -80,7 +80,20 @@ struct is_member_pointer : public std_::true_type { }; template -using is_fast_copy_type = std_::integral_constant::value || is_pointer::value || is_member_pointer::value || custom_is_fast_copy_type::value>; +using is_fast_copy_type = std_::integral_constant::value || is_pointer::value || is_member_pointer::value || custom_is_fast_copy_type::value>; + +template +struct add_const_reference { + using type = const T &; +}; + +template <> +struct add_const_reference { + using type = void; +}; + +template +using add_const_reference_t = typename add_const_reference::type; } // namespace internal @@ -96,7 +109,7 @@ struct type_traits { using is_member_pointer = internal::is_member_pointer; using is_fast_copy_type = internal::is_fast_copy_type; - using parameter_type = std_::conditional_t; + using parameter_type = std_::conditional_t>; }; } // namespace base diff --git a/Telegram/SourceFiles/facades.h b/Telegram/SourceFiles/facades.h index 40c378793..59d0c0462 100644 --- a/Telegram/SourceFiles/facades.h +++ b/Telegram/SourceFiles/facades.h @@ -21,12 +21,10 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #pragma once #include "core/type_traits.h" +#include "core/observer.h" class LayerWidget; -namespace base { -template -class Observable; -} // namespace base + namespace InlineBots { namespace Layout { class ItemBase; diff --git a/Telegram/SourceFiles/media/player/media_player_widget.h b/Telegram/SourceFiles/media/player/media_player_widget.h index edc58b16e..e1e13bde1 100644 --- a/Telegram/SourceFiles/media/player/media_player_widget.h +++ b/Telegram/SourceFiles/media/player/media_player_widget.h @@ -89,7 +89,6 @@ private: int64 _seekPositionMs = -1; int64 _lastDurationMs = 0; QString _time; - bool _mouseOverLabels = false; class PlayButton; ChildWidget _nameLabel; diff --git a/Telegram/SourceFiles/sysbuttons.h b/Telegram/SourceFiles/sysbuttons.h index 91c7a56d9..9d1fced28 100644 --- a/Telegram/SourceFiles/sysbuttons.h +++ b/Telegram/SourceFiles/sysbuttons.h @@ -44,7 +44,6 @@ public: SysBtn(QWidget *parent, const style::sysButton &st, const QString &text = QString()); void setText(const QString &text); - void paintEvent(QPaintEvent *e); void setSysBtnStyle(const style::sysButton &st); HitTestType hitTest(const QPoint &p) const; @@ -55,6 +54,7 @@ public: protected: void onStateChanged(int oldState, ButtonStateChangeSource source) override; + void paintEvent(QPaintEvent *e) override; style::sysButton _st; anim::cvalue a_color; diff --git a/Telegram/SourceFiles/title.h b/Telegram/SourceFiles/title.h index ed184a498..6cfd8edff 100644 --- a/Telegram/SourceFiles/title.h +++ b/Telegram/SourceFiles/title.h @@ -39,9 +39,6 @@ public: void updateCounter(); - void mousePressEvent(QMouseEvent *e); - void mouseDoubleClickEvent(QMouseEvent *e); - void maximizedChanged(bool maximized, bool force = false); HitTestType hitTest(const QPoint &p); @@ -62,6 +59,8 @@ signals: protected: void paintEvent(QPaintEvent *e) override; void resizeEvent(QResizeEvent *e) override; + void mousePressEvent(QMouseEvent *e) override; + void mouseDoubleClickEvent(QMouseEvent *e) override; private: void updatePlayerButton(bool usePanel); diff --git a/Telegram/SourceFiles/ui/widgets/continuous_slider.cpp b/Telegram/SourceFiles/ui/widgets/continuous_slider.cpp index e0fea6107..dbd31bef2 100644 --- a/Telegram/SourceFiles/ui/widgets/continuous_slider.cpp +++ b/Telegram/SourceFiles/ui/widgets/continuous_slider.cpp @@ -140,11 +140,7 @@ void ContinuousSlider::wheelEvent(QWheelEvent *e) { } else { deltaX *= -1; } - if (deltaX * deltaY < 0) { - return; - } - - auto delta = (deltaX >= 0 && deltaY >= 0) ? qMax(deltaX, deltaY) : qMin(deltaX, deltaY); + auto delta = (qAbs(deltaX) > qAbs(deltaY)) ? deltaX : deltaY; auto finalValue = snap(a_value.to() + delta * coef, 0., 1.); setValue(finalValue, false); if (_changeProgressCallback) { diff --git a/Telegram/SourceFiles/ui/widgets/widget_slide_wrap.h b/Telegram/SourceFiles/ui/widgets/widget_slide_wrap.h index 380e65209..b7a5cc781 100644 --- a/Telegram/SourceFiles/ui/widgets/widget_slide_wrap.h +++ b/Telegram/SourceFiles/ui/widgets/widget_slide_wrap.h @@ -139,6 +139,7 @@ private: a_height.finish(); _a_height.stop(); _forceHeight = _hiding ? 0 : -1; + sendSynteticMouseEvent(this, QEvent::MouseMove, Qt::NoButton); if (_hiding) hide(); } else { a_height.update(dt, anim::linear);