tdesktop/Telegram/SourceFiles/ui/style/style_core.h

81 lines
2.2 KiB
C
Raw Normal View History

/*
This file is part of Telegram Desktop,
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
*/
#pragma once
2019-09-13 13:24:06 +03:00
#include "ui/style/style_core_scale.h"
#include "ui/style/style_core_types.h"
2019-09-13 15:22:54 +03:00
#include "ui/style/style_core_direction.h"
2019-09-13 19:45:48 +03:00
#include <rpl/producer.h>
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;
virtual ~ModuleBase() = default;
};
void registerModule(ModuleBase *module);
[[nodiscard]] QColor EnsureContrast(const QColor &over, const QColor &under);
void EnsureContrast(ColorData &over, const ColorData &under);
2019-09-13 19:45:48 +03:00
void StartShortAnimation();
void StopShortAnimation();
} // namespace internal
2019-09-13 13:24:06 +03:00
void startManager(int scale);
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();
// *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);
return result;
}
inline QImage colorizeImage(const QImage &src, const color &c, QRect srcRect = QRect()) {
return colorizeImage(src, c->c, srcRect);
}
QBrush transparentPlaceholderBrush();
namespace internal {
QImage createCircleMask(int size, QColor bg, QColor fg);
} // 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));
}
} // namespace style