2016-04-21 20:57:29 +03:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 13:23:14 +03:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2016-04-21 20:57:29 +03:00
|
|
|
|
2018-01-03 13:23:14 +03:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2016-04-21 20:57:29 +03:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2019-09-13 13:24:06 +03:00
|
|
|
#include "ui/style/style_core_scale.h"
|
2016-04-21 20:57:29 +03:00
|
|
|
#include "ui/style/style_core_types.h"
|
2019-09-13 15:22:54 +03:00
|
|
|
#include "ui/style/style_core_direction.h"
|
2016-04-21 20:57:29 +03:00
|
|
|
|
2019-09-13 19:45:48 +03:00
|
|
|
#include <rpl/producer.h>
|
|
|
|
|
2016-04-21 20:57:29 +03:00
|
|
|
namespace style {
|
|
|
|
namespace internal {
|
|
|
|
|
|
|
|
// Objects of derived classes are created in global scope.
|
|
|
|
// They call [un]registerModule() in [de|con]structor.
|
|
|
|
class ModuleBase {
|
|
|
|
public:
|
2019-09-13 13:24:06 +03:00
|
|
|
virtual void start(int scale) = 0;
|
2019-02-15 15:24:58 +04:00
|
|
|
|
|
|
|
virtual ~ModuleBase() = default;
|
|
|
|
|
2016-04-21 20:57:29 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
void registerModule(ModuleBase *module);
|
|
|
|
|
2019-09-09 23:25:54 +03:00
|
|
|
[[nodiscard]] QColor EnsureContrast(const QColor &over, const QColor &under);
|
2019-09-09 21:35:06 +03:00
|
|
|
void EnsureContrast(ColorData &over, const ColorData &under);
|
|
|
|
|
2019-09-13 19:45:48 +03:00
|
|
|
void StartShortAnimation();
|
|
|
|
void StopShortAnimation();
|
|
|
|
|
2016-04-21 20:57:29 +03:00
|
|
|
} // namespace internal
|
|
|
|
|
2019-09-13 13:24:06 +03:00
|
|
|
void startManager(int scale);
|
2016-04-21 20:57:29 +03:00
|
|
|
void stopManager();
|
|
|
|
|
2019-09-13 19:45:48 +03:00
|
|
|
[[nodiscard]] rpl::producer<> PaletteChanged();
|
|
|
|
void NotifyPaletteChanged();
|
|
|
|
|
|
|
|
[[nodiscard]] rpl::producer<bool> ShortAnimationPlaying();
|
|
|
|
|
2019-09-16 14:14:06 +03:00
|
|
|
const style::font &MonospaceFont();
|
|
|
|
|
2016-11-02 17:44:33 +03:00
|
|
|
// *outResult must be r.width() x r.height(), ARGB32_Premultiplied.
|
|
|
|
// QRect(0, 0, src.width(), src.height()) must contain r.
|
|
|
|
void colorizeImage(const QImage &src, QColor c, QImage *outResult, QRect srcRect = QRect(), QPoint dstPoint = QPoint(0, 0));
|
|
|
|
|
|
|
|
inline QImage colorizeImage(const QImage &src, QColor c, QRect srcRect = QRect()) {
|
|
|
|
if (srcRect.isNull()) srcRect = src.rect();
|
|
|
|
auto result = QImage(srcRect.size(), QImage::Format_ARGB32_Premultiplied);
|
|
|
|
colorizeImage(src, c, &result, srcRect);
|
2017-02-21 17:37:53 +03:00
|
|
|
return result;
|
2016-11-02 17:44:33 +03:00
|
|
|
}
|
2016-11-01 15:46:34 +03:00
|
|
|
|
2016-11-02 17:44:33 +03:00
|
|
|
inline QImage colorizeImage(const QImage &src, const color &c, QRect srcRect = QRect()) {
|
|
|
|
return colorizeImage(src, c->c, srcRect);
|
2016-11-01 15:46:34 +03:00
|
|
|
}
|
2016-04-21 20:57:29 +03:00
|
|
|
|
2017-02-03 23:07:26 +03:00
|
|
|
QBrush transparentPlaceholderBrush();
|
|
|
|
|
2016-06-09 14:51:24 +03:00
|
|
|
namespace internal {
|
|
|
|
|
2016-11-01 15:46:34 +03:00
|
|
|
QImage createCircleMask(int size, QColor bg, QColor fg);
|
2016-06-09 14:51:24 +03:00
|
|
|
|
|
|
|
} // namespace internal
|
|
|
|
|
|
|
|
inline QImage createCircleMask(int size) {
|
|
|
|
return internal::createCircleMask(size, QColor(0, 0, 0), QColor(255, 255, 255));
|
|
|
|
}
|
|
|
|
|
|
|
|
inline QImage createInvertedCircleMask(int size) {
|
|
|
|
return internal::createCircleMask(size, QColor(255, 255, 255), QColor(0, 0, 0));
|
|
|
|
}
|
|
|
|
|
2016-04-21 20:57:29 +03:00
|
|
|
} // namespace style
|