mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-08-31 06:26:18 +00:00
Start non-unique ChatTheme.
This commit is contained in:
@@ -12,7 +12,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "base/weak_ptr.h"
|
||||
#include "base/timer.h"
|
||||
#include "dialogs/dialogs_key.h"
|
||||
#include "ui/effects/animations.h"
|
||||
#include "ui/layers/layer_widget.h"
|
||||
#include "window/window_adaptive.h"
|
||||
|
||||
@@ -50,9 +49,16 @@ class FormController;
|
||||
namespace Ui {
|
||||
class LayerWidget;
|
||||
enum class ReportReason;
|
||||
struct BubblePattern;
|
||||
} // namespace Ui
|
||||
|
||||
namespace Window::Theme {
|
||||
class ChatTheme;
|
||||
} // namespace Window::Theme
|
||||
|
||||
namespace Data {
|
||||
struct CloudTheme;
|
||||
} // namespace Data
|
||||
|
||||
namespace Window {
|
||||
|
||||
class MainWindow;
|
||||
@@ -60,55 +66,6 @@ class SectionMemento;
|
||||
class Controller;
|
||||
class FiltersMenu;
|
||||
|
||||
struct CacheBackgroundRequest {
|
||||
QImage prepared;
|
||||
QImage preparedForTiled;
|
||||
QSize area;
|
||||
int gradientRotation = 0;
|
||||
bool tile = false;
|
||||
bool isPattern = false;
|
||||
bool recreateGradient = false;
|
||||
QImage gradient;
|
||||
std::vector<QColor> gradientColors;
|
||||
float64 gradientProgress = 1.;
|
||||
float64 patternOpacity = 1.;
|
||||
|
||||
explicit operator bool() const {
|
||||
return !prepared.isNull() || !gradient.isNull();
|
||||
}
|
||||
};
|
||||
|
||||
bool operator==(
|
||||
const CacheBackgroundRequest &a,
|
||||
const CacheBackgroundRequest &b);
|
||||
bool operator!=(
|
||||
const CacheBackgroundRequest &a,
|
||||
const CacheBackgroundRequest &b);
|
||||
|
||||
struct CacheBackgroundResult {
|
||||
QImage image;
|
||||
QImage gradient;
|
||||
QSize area;
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
};
|
||||
|
||||
struct CachedBackground {
|
||||
CachedBackground() = default;
|
||||
CachedBackground(CacheBackgroundResult &&result);
|
||||
|
||||
QPixmap pixmap;
|
||||
QSize area;
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
};
|
||||
|
||||
struct BackgroundState {
|
||||
CachedBackground was;
|
||||
CachedBackground now;
|
||||
float64 shown = 1.;
|
||||
};
|
||||
|
||||
enum class GifPauseReason {
|
||||
Any = 0,
|
||||
InlineResults = (1 << 0),
|
||||
@@ -445,22 +402,23 @@ public:
|
||||
void toggleFiltersMenu(bool enabled);
|
||||
[[nodiscard]] rpl::producer<> filtersMenuChanged() const;
|
||||
|
||||
void setBubblesBackground(QImage image);
|
||||
const Ui::BubblePattern *bubblesBackgroundPattern() const {
|
||||
return _bubblesBackgroundPattern.get();
|
||||
[[nodiscard]] auto defaultChatTheme() const
|
||||
-> const std::shared_ptr<Theme::ChatTheme> & {
|
||||
return _defaultChatTheme;
|
||||
}
|
||||
[[nodiscard]] auto cachedChatThemeValue(
|
||||
const Data::CloudTheme &data)
|
||||
-> rpl::producer<std::shared_ptr<Theme::ChatTheme>>;
|
||||
|
||||
struct BubblesContextArgs {
|
||||
struct PaintContextArgs {
|
||||
not_null<Theme::ChatTheme*> theme;
|
||||
int visibleAreaTop = 0;
|
||||
int visibleAreaTopGlobal = 0;
|
||||
int visibleAreaWidth = 0;
|
||||
QRect clip;
|
||||
};
|
||||
[[nodiscard]] HistoryView::PaintContext bubblesContext(
|
||||
BubblesContextArgs &&args);
|
||||
[[nodiscard]] const BackgroundState &backgroundState(QSize area);
|
||||
[[nodiscard]] rpl::producer<> repaintBackgroundRequests() const;
|
||||
void rotateComplexGradientBackground();
|
||||
[[nodiscard]] HistoryView::PaintContext preparePaintContext(
|
||||
PaintContextArgs &&args);
|
||||
|
||||
rpl::lifetime &lifetime() {
|
||||
return _lifetime;
|
||||
@@ -491,18 +449,7 @@ private:
|
||||
|
||||
void checkInvitePeek();
|
||||
|
||||
void cacheBackground();
|
||||
void cacheBackgroundNow();
|
||||
void cacheBackgroundAsync(
|
||||
const CacheBackgroundRequest &request,
|
||||
Fn<void(CacheBackgroundResult&&)> done = nullptr);
|
||||
void clearCachedBackground();
|
||||
void setCachedBackground(CacheBackgroundResult &&cached);
|
||||
[[nodiscard]] CacheBackgroundRequest currentCacheRequest(
|
||||
QSize area,
|
||||
int addRotation = 0) const;
|
||||
[[nodiscard]] bool readyForBackgroundRotation() const;
|
||||
void generateNextBackgroundRotation();
|
||||
void cacheChatTheme(const Data::CloudTheme &data);
|
||||
|
||||
const not_null<Controller*> _window;
|
||||
|
||||
@@ -531,19 +478,11 @@ private:
|
||||
|
||||
rpl::event_stream<> _filtersMenuChanged;
|
||||
|
||||
BackgroundState _backgroundState;
|
||||
Ui::Animations::Simple _backgroundFade;
|
||||
CacheBackgroundRequest _backgroundCachingRequest;
|
||||
CacheBackgroundResult _backgroundNext;
|
||||
int _backgroundAddRotation = 0;
|
||||
QSize _willCacheForArea;
|
||||
crl::time _lastAreaChangeTime = 0;
|
||||
base::Timer _cacheBackgroundTimer;
|
||||
CachedBackground _bubblesBackground;
|
||||
QImage _bubblesBackgroundPrepared;
|
||||
std::unique_ptr<Ui::BubblePattern> _bubblesBackgroundPattern;
|
||||
|
||||
rpl::event_stream<> _repaintBackgroundRequests;
|
||||
std::shared_ptr<Theme::ChatTheme> _defaultChatTheme;
|
||||
base::flat_map<
|
||||
uint64,
|
||||
std::shared_ptr<Theme::ChatTheme>> _customChatThemes;
|
||||
rpl::event_stream<std::shared_ptr<Theme::ChatTheme>> _cachedThemesStream;
|
||||
|
||||
rpl::lifetime _lifetime;
|
||||
|
||||
|
Reference in New Issue
Block a user