Allow using any interface scale between 100%-300%.

This commit is contained in:
John Preston 2018-10-15 14:44:48 +03:00
parent 149639a53d
commit 19a9a990b6
30 changed files with 207 additions and 242 deletions

View File

@ -459,15 +459,16 @@ void connect(const char *signal, QObject *object, const char *method) {
void launch() { void launch() {
Assert(application() != 0); Assert(application() != 0);
float64 dpi = Application::primaryScreen()->logicalDotsPerInch(); const auto dpi = Application::primaryScreen()->logicalDotsPerInch();
LOG(("Primary screen DPI: %1").arg(dpi));
if (dpi <= 108) { // 0-96-108 if (dpi <= 108) { // 0-96-108
cSetScreenScale(dbisOne); cSetScreenScale(100);
} else if (dpi <= 132) { // 108-120-132 } else if (dpi <= 132) { // 108-120-132
cSetScreenScale(dbisOneAndQuarter); cSetScreenScale(125);
} else if (dpi <= 168) { // 132-144-168 } else if (dpi <= 168) { // 132-144-168
cSetScreenScale(dbisOneAndHalf); cSetScreenScale(150);
} else { // 168-192-inf } else { // 168-192-inf
cSetScreenScale(dbisTwo); cSetScreenScale(200);
} }
auto devicePixelRatio = application()->devicePixelRatio(); auto devicePixelRatio = application()->devicePixelRatio();
@ -482,8 +483,8 @@ void launch() {
cSetRetina(true); cSetRetina(true);
cSetRetinaFactor(devicePixelRatio); cSetRetinaFactor(devicePixelRatio);
cSetIntRetinaFactor(int32(cRetinaFactor())); cSetIntRetinaFactor(int32(cRetinaFactor()));
cSetConfigScale(dbisOne); cSetConfigScale(100);
cSetRealScale(dbisOne); cSetRealScale(100);
} }
application()->createMessenger(); application()->createMessenger();

View File

@ -60,8 +60,8 @@ private:
}; };
QCursor EditColorBox::Picker::generateCursor() { QCursor EditColorBox::Picker::generateCursor() {
auto diameter = convertScale(16); auto diameter = ConvertScale(16);
auto line = convertScale(1); auto line = ConvertScale(1);
auto size = ((diameter + 2 * line) >= 32) ? 64 : 32; auto size = ((diameter + 2 * line) >= 32) ? 64 : 32;
auto cursor = QImage(QSize(size, size) * cIntRetinaFactor(), QImage::Format_ARGB32_Premultiplied); auto cursor = QImage(QSize(size, size) * cIntRetinaFactor(), QImage::Format_ARGB32_Premultiplied);
cursor.setDevicePixelRatio(cRetinaFactor()); cursor.setDevicePixelRatio(cRetinaFactor());

View File

@ -312,7 +312,7 @@ void InitMessageField(
field->setTagMimeProcessor(std::make_unique<FieldTagMimeProcessor>()); field->setTagMimeProcessor(std::make_unique<FieldTagMimeProcessor>());
field->document()->setDocumentMargin(4.); field->document()->setDocumentMargin(4.);
field->setAdditionalMargin(convertScale(4) - 4); field->setAdditionalMargin(ConvertScale(4) - 4);
field->customTab(true); field->customTab(true);
field->setInstantReplaces(Ui::InstantReplaces::Default()); field->setInstantReplaces(Ui::InstantReplaces::Default());

View File

@ -1123,20 +1123,12 @@ bool Generator::writePxValuesInit() {
void initPxValues() {\n\ void initPxValues() {\n\
if (cRetina()) return;\n\ if (cRetina()) return;\n\
\n\ \n\
switch (cScale()) {\n"; const auto scale = cScale();\n";
for (int i = 1, scalesCount = _scales.size(); i < scalesCount; ++i) { for (auto it = pxValues_.cbegin(), e = pxValues_.cend(); it != e; ++it) {
source_->stream() << "\tcase " << _scaleNames.at(i) << ":\n"; auto value = it.key();
for (auto it = pxValues_.cbegin(), e = pxValues_.cend(); it != e; ++it) { source_->stream() << "\t" << pxValueName(value) << " = ConvertScale(" << value << ", scale);\n";
auto value = it.key();
int adjusted = structure::data::pxAdjust(value, _scales.at(i));
if (adjusted != value) {
source_->stream() << "\t\t" << pxValueName(value) << " = " << adjusted << ";\n";
}
}
source_->stream() << "\tbreak;\n";
} }
source_->stream() << "\ source_->stream() << "\
}\n\
}\n\n"; }\n\n";
return true; return true;
} }

View File

@ -64,9 +64,6 @@ private:
QMap<QString, int> iconMasks_; // icon file -> index QMap<QString, int> iconMasks_; // icon file -> index
std::map<QString, int, std::greater<QString>> paletteIndices_; std::map<QString, int, std::greater<QString>> paletteIndices_;
std::vector<int> _scales = { 4, 5, 6, 8 }; // scale / 4 gives our 1.00, 1.25, 1.50, 2.00
std::vector<const char *> _scaleNames = { "dbisOne", "dbisOneAndQuarter", "dbisOneAndHalf", "dbisTwo" };
}; };
} // namespace style } // namespace style

View File

@ -59,13 +59,6 @@ inline bool operator!=(const Type &a, const Type &b) {
namespace data { namespace data {
inline int pxAdjust(int value, int scale) {
if (value < 0) {
return -pxAdjust(-value, scale);
}
return qFloor((value * scale / 4.) + 0.1);
}
struct point { struct point {
int x, y; int x, y;
}; };

View File

@ -388,16 +388,6 @@ struct ProxyData {
ProxyData ToDirectIpProxy(const ProxyData &proxy, int ipIndex = 0); ProxyData ToDirectIpProxy(const ProxyData &proxy, int ipIndex = 0);
QNetworkProxy ToNetworkProxy(const ProxyData &proxy); QNetworkProxy ToNetworkProxy(const ProxyData &proxy);
enum DBIScale {
dbisAuto = 0,
dbisOne = 1,
dbisOneAndQuarter = 2,
dbisOneAndHalf = 3,
dbisTwo = 4,
dbisScaleCount = 5,
};
static const int MatrixRowShift = 40000; static const int MatrixRowShift = 40000;
enum DBIPlatform { enum DBIPlatform {

View File

@ -847,7 +847,7 @@ void DialogsInner::mousePressEvent(QMouseEvent *e) {
void DialogsInner::checkReorderPinnedStart(QPoint localPosition) { void DialogsInner::checkReorderPinnedStart(QPoint localPosition) {
if (_pressed != nullptr && !_dragging && _state == State::Default) { if (_pressed != nullptr && !_dragging && _state == State::Default) {
if (qAbs(localPosition.y() - _dragStart.y()) >= convertScale(kStartReorderThreshold)) { if (qAbs(localPosition.y() - _dragStart.y()) >= ConvertScale(kStartReorderThreshold)) {
_dragging = _pressed; _dragging = _pressed;
if (updateReorderIndexGetCount() < 2) { if (updateReorderIndexGetCount() < 2) {
_dragging = nullptr; _dragging = nullptr;

View File

@ -17,15 +17,10 @@ constexpr auto kCoordPrecision = 8;
constexpr auto kMaxHttpRedirects = 5; constexpr auto kMaxHttpRedirects = 5;
GeoPointLocation ComputeLocation(const LocationCoords &coords) { GeoPointLocation ComputeLocation(const LocationCoords &coords) {
int32 w = st::locationSize.width(), h = st::locationSize.height(); const auto scale = 1 + (cScale() * cIntRetinaFactor()) / 200;
int32 zoom = 15, scale = 1; const auto zoom = 15 + (scale - 1);
if (cScale() == dbisTwo || cRetina()) { const auto w = ConvertScale(st::locationSize.width()) / scale;
scale = 2; const auto h = ConvertScale(st::locationSize.height()) / scale;
zoom = 16;
} else {
w = convertScale(w);
h = convertScale(h);
}
auto result = GeoPointLocation(); auto result = GeoPointLocation();
result.lat = coords.lat(); result.lat = coords.lat();

View File

@ -310,8 +310,8 @@ QSize HistoryPhoto::countOptimalSize() {
auto maxWidth = 0; auto maxWidth = 0;
auto minHeight = 0; auto minHeight = 0;
auto tw = convertScale(_data->full->width()); auto tw = ConvertScale(_data->full->width());
auto th = convertScale(_data->full->height()); auto th = ConvertScale(_data->full->height());
if (!tw || !th) { if (!tw || !th) {
tw = th = 1; tw = th = 1;
} }
@ -342,7 +342,7 @@ QSize HistoryPhoto::countOptimalSize() {
} }
QSize HistoryPhoto::countCurrentSize(int newWidth) { QSize HistoryPhoto::countCurrentSize(int newWidth) {
int tw = convertScale(_data->full->width()), th = convertScale(_data->full->height()); int tw = ConvertScale(_data->full->width()), th = ConvertScale(_data->full->height());
if (tw > st::maxMediaSize) { if (tw > st::maxMediaSize) {
th = (st::maxMediaSize * th) / tw; th = (st::maxMediaSize * th) / tw;
tw = st::maxMediaSize; tw = st::maxMediaSize;
@ -714,8 +714,8 @@ void HistoryPhoto::validateGroupedCache(
return; return;
} }
const auto originalWidth = convertScale(_data->full->width()); const auto originalWidth = ConvertScale(_data->full->width());
const auto originalHeight = convertScale(_data->full->height()); const auto originalHeight = ConvertScale(_data->full->height());
const auto pixSize = Ui::GetImageScaleSizeForGeometry( const auto pixSize = Ui::GetImageScaleSizeForGeometry(
{ originalWidth, originalHeight }, { originalWidth, originalHeight },
{ width, height }); { width, height });
@ -778,8 +778,8 @@ QSize HistoryVideo::countOptimalSize() {
_parent->skipBlockHeight()); _parent->skipBlockHeight());
} }
auto tw = convertScale(_data->thumb->width()); auto tw = ConvertScale(_data->thumb->width());
auto th = convertScale(_data->thumb->height()); auto th = ConvertScale(_data->thumb->height());
if (!tw || !th) { if (!tw || !th) {
tw = th = 1; tw = th = 1;
} }
@ -809,7 +809,7 @@ QSize HistoryVideo::countOptimalSize() {
} }
QSize HistoryVideo::countCurrentSize(int newWidth) { QSize HistoryVideo::countCurrentSize(int newWidth) {
int tw = convertScale(_data->thumb->width()), th = convertScale(_data->thumb->height()); int tw = ConvertScale(_data->thumb->width()), th = ConvertScale(_data->thumb->height());
if (!tw || !th) { if (!tw || !th) {
tw = th = 1; tw = th = 1;
} }
@ -1154,8 +1154,8 @@ void HistoryVideo::validateGroupedCache(
return; return;
} }
const auto originalWidth = convertScale(_data->thumb->width()); const auto originalWidth = ConvertScale(_data->thumb->width());
const auto originalHeight = convertScale(_data->thumb->height()); const auto originalHeight = ConvertScale(_data->thumb->height());
const auto pixSize = Ui::GetImageScaleSizeForGeometry( const auto pixSize = Ui::GetImageScaleSizeForGeometry(
{ originalWidth, originalHeight }, { originalWidth, originalHeight },
{ width, height }); { width, height });
@ -1303,8 +1303,8 @@ QSize HistoryDocument::countOptimalSize() {
auto thumbed = Get<HistoryDocumentThumbed>(); auto thumbed = Get<HistoryDocumentThumbed>();
if (thumbed) { if (thumbed) {
_data->thumb->load(_realParent->fullId()); _data->thumb->load(_realParent->fullId());
auto tw = convertScale(_data->thumb->width()); auto tw = ConvertScale(_data->thumb->width());
auto th = convertScale(_data->thumb->height()); auto th = ConvertScale(_data->thumb->height());
if (tw > th) { if (tw > th) {
thumbed->_thumbw = (tw * st::msgFileThumbSize) / th; thumbed->_thumbw = (tw * st::msgFileThumbSize) / th;
} else { } else {
@ -1978,13 +1978,13 @@ QSize HistoryGif::countOptimalSize() {
const auto reader = currentReader(); const auto reader = currentReader();
if (reader) { if (reader) {
tw = convertScale(reader->width()); tw = ConvertScale(reader->width());
th = convertScale(reader->height()); th = ConvertScale(reader->height());
} else { } else {
tw = convertScale(_data->dimensions.width()), th = convertScale(_data->dimensions.height()); tw = ConvertScale(_data->dimensions.width()), th = ConvertScale(_data->dimensions.height());
if (!tw || !th) { if (!tw || !th) {
tw = convertScale(_data->thumb->width()); tw = ConvertScale(_data->thumb->width());
th = convertScale(_data->thumb->height()); th = ConvertScale(_data->thumb->height());
} }
} }
if (tw > st::maxGifSize) { if (tw > st::maxGifSize) {
@ -2033,13 +2033,13 @@ QSize HistoryGif::countCurrentSize(int newWidth) {
int tw = 0, th = 0; int tw = 0, th = 0;
const auto reader = currentReader(); const auto reader = currentReader();
if (reader) { if (reader) {
tw = convertScale(reader->width()); tw = ConvertScale(reader->width());
th = convertScale(reader->height()); th = ConvertScale(reader->height());
} else { } else {
tw = convertScale(_data->dimensions.width()), th = convertScale(_data->dimensions.height()); tw = ConvertScale(_data->dimensions.width()), th = ConvertScale(_data->dimensions.height());
if (!tw || !th) { if (!tw || !th) {
tw = convertScale(_data->thumb->width()); tw = ConvertScale(_data->thumb->width());
th = convertScale(_data->thumb->height()); th = ConvertScale(_data->thumb->height());
} }
} }
if (tw > st::maxGifSize) { if (tw > st::maxGifSize) {
@ -3635,7 +3635,7 @@ void HistoryWebPage::draw(Painter &p, const QRect &r, TextSelection selection, T
auto pw = qMax(_pixw, lineHeight); auto pw = qMax(_pixw, lineHeight);
auto ph = _pixh; auto ph = _pixh;
auto pixw = _pixw, pixh = articleThumbHeight(_data->photo, _pixw); auto pixw = _pixw, pixh = articleThumbHeight(_data->photo, _pixw);
auto maxw = convertScale(_data->photo->medium->width()), maxh = convertScale(_data->photo->medium->height()); auto maxw = ConvertScale(_data->photo->medium->width()), maxh = ConvertScale(_data->photo->medium->height());
if (pixw * ph != pixh * pw) { if (pixw * ph != pixh * pw) {
float64 coef = (pixw * ph > pixh * pw) ? qMin(ph / float64(pixh), maxh / float64(pixh)) : qMin(pw / float64(pixw), maxw / float64(pixw)); float64 coef = (pixw * ph > pixh * pw) ? qMin(ph / float64(pixh), maxh / float64(pixh)) : qMin(pw / float64(pixw), maxw / float64(pixw));
pixh = qRound(pixh * coef); pixh = qRound(pixh * coef);

View File

@ -52,7 +52,7 @@ int FileBase::content_width() const {
return document->dimensions.width(); return document->dimensions.width();
} }
if (!document->thumb->isNull()) { if (!document->thumb->isNull()) {
return convertScale(document->thumb->width()); return ConvertScale(document->thumb->width());
} }
return 0; return 0;
} }
@ -63,7 +63,7 @@ int FileBase::content_height() const {
return document->dimensions.height(); return document->dimensions.height();
} }
if (!document->thumb->isNull()) { if (!document->thumb->isNull()) {
return convertScale(document->thumb->height()); return ConvertScale(document->thumb->height());
} }
return 0; return 0;
} }
@ -665,7 +665,7 @@ void Video::prepareThumb(int32 width, int32 height) const {
const auto origin = fileOrigin(); const auto origin = fileOrigin();
if (thumb->loaded()) { if (thumb->loaded()) {
if (_thumb.width() != width * cIntRetinaFactor() || _thumb.height() != height * cIntRetinaFactor()) { if (_thumb.width() != width * cIntRetinaFactor() || _thumb.height() != height * cIntRetinaFactor()) {
int32 w = qMax(convertScale(thumb->width()), 1), h = qMax(convertScale(thumb->height()), 1); int32 w = qMax(ConvertScale(thumb->width()), 1), h = qMax(ConvertScale(thumb->height()), 1);
if (w * height > h * width) { if (w * height > h * width) {
if (height < h) { if (height < h) {
w = w * height / h; w = w * height / h;
@ -989,7 +989,7 @@ void Contact::prepareThumb(int width, int height) const {
const auto origin = fileOrigin(); const auto origin = fileOrigin();
if (thumb->loaded()) { if (thumb->loaded()) {
if (_thumb.width() != width * cIntRetinaFactor() || _thumb.height() != height * cIntRetinaFactor()) { if (_thumb.width() != width * cIntRetinaFactor() || _thumb.height() != height * cIntRetinaFactor()) {
int w = qMax(convertScale(thumb->width()), 1), h = qMax(convertScale(thumb->height()), 1); int w = qMax(ConvertScale(thumb->width()), 1), h = qMax(ConvertScale(thumb->height()), 1);
if (w * height > h * width) { if (w * height > h * width) {
if (height < h) { if (height < h) {
w = w * height / h; w = w * height / h;
@ -1137,7 +1137,7 @@ void Article::prepareThumb(int width, int height) const {
const auto origin = fileOrigin(); const auto origin = fileOrigin();
if (thumb->loaded()) { if (thumb->loaded()) {
if (_thumb.width() != width * cIntRetinaFactor() || _thumb.height() != height * cIntRetinaFactor()) { if (_thumb.width() != width * cIntRetinaFactor() || _thumb.height() != height * cIntRetinaFactor()) {
int w = qMax(convertScale(thumb->width()), 1), h = qMax(convertScale(thumb->height()), 1); int w = qMax(ConvertScale(thumb->width()), 1), h = qMax(ConvertScale(thumb->height()), 1);
if (w * height > h * width) { if (w * height > h * width) {
if (height < h) { if (height < h) {
w = w * height / h; w = w * height / h;
@ -1317,7 +1317,7 @@ void Game::prepareThumb(int width, int height) const {
const auto origin = fileOrigin(); const auto origin = fileOrigin();
if (thumb->loaded()) { if (thumb->loaded()) {
if (_thumb.width() != width * cIntRetinaFactor() || _thumb.height() != height * cIntRetinaFactor()) { if (_thumb.width() != width * cIntRetinaFactor() || _thumb.height() != height * cIntRetinaFactor()) {
int w = qMax(convertScale(thumb->width()), 1), h = qMax(convertScale(thumb->height()), 1); int w = qMax(ConvertScale(thumb->width()), 1), h = qMax(ConvertScale(thumb->height()), 1);
auto resizeByHeight1 = (w * height > h * width) && (h >= height); auto resizeByHeight1 = (w * height > h * width) && (h >= height);
auto resizeByHeight2 = (h * width >= w * height) && (w < width); auto resizeByHeight2 = (h * width >= w * height) && (w < width);
if (resizeByHeight1 || resizeByHeight2) { if (resizeByHeight1 || resizeByHeight2) {

View File

@ -221,18 +221,22 @@ std::unique_ptr<Result> Result::create(uint64 queryId, const MTPBotInlineResult
return nullptr; return nullptr;
} }
LocationCoords location; LocationCoords coords;
if (result->getLocationCoords(&location)) { if (result->getLocationCoords(&coords)) {
int32 w = st::inlineThumbSize, h = st::inlineThumbSize; const auto scale = 1 + (cScale() * cIntRetinaFactor()) / 200;
int32 zoom = 13, scale = 1; const auto zoom = 15 + (scale - 1);
if (cScale() == dbisTwo || cRetina()) { const auto w = ConvertScale(st::inlineThumbSize) / scale;
scale = 2; const auto h = ConvertScale(st::inlineThumbSize) / scale;
w /= 2;
h /= 2; auto location = GeoPointLocation();
} location.lat = coords.lat();
auto coords = location.latAsString() + ',' + location.lonAsString(); location.lon = coords.lon();
QString url = qsl("https://maps.googleapis.com/maps/api/staticmap?center=") + coords + qsl("&zoom=%1&size=%2x%3&maptype=roadmap&scale=%4&markers=color:red|size:big|").arg(zoom).arg(w).arg(h).arg(scale) + coords + qsl("&sensor=false"); location.access = coords.accessHash();
result->_locationThumb = ImagePtr(url); location.width = w;
location.height = h;
location.zoom = zoom;
location.scale = scale;
result->_locationThumb = ImagePtr(location);
} }
return result; return result;

View File

@ -1455,8 +1455,8 @@ void MediaView::displayPhoto(not_null<PhotoData*> photo, HistoryItem *item) {
_full = -1; _full = -1;
_current = QPixmap(); _current = QPixmap();
_down = OverNone; _down = OverNone;
_w = convertScale(photo->full->width()); _w = ConvertScale(photo->full->width());
_h = convertScale(photo->full->height()); _h = ConvertScale(photo->full->height());
if (isHidden()) { if (isHidden()) {
moveToScreen(); moveToScreen();
} }
@ -1600,11 +1600,11 @@ void MediaView::displayDocument(DocumentData *doc, HistoryItem *item) { // empty
updateThemePreviewGeometry(); updateThemePreviewGeometry();
} else if (!_current.isNull()) { } else if (!_current.isNull()) {
_current.setDevicePixelRatio(cRetinaFactor()); _current.setDevicePixelRatio(cRetinaFactor());
_w = convertScale(_current.width()); _w = ConvertScale(_current.width());
_h = convertScale(_current.height()); _h = ConvertScale(_current.height());
} else { } else {
_w = convertScale(_gif->width()); _w = ConvertScale(_gif->width());
_h = convertScale(_gif->height()); _h = ConvertScale(_gif->height());
} }
if (isHidden()) { if (isHidden()) {
moveToScreen(); moveToScreen();
@ -2437,8 +2437,8 @@ void MediaView::setZoomLevel(int newZoom) {
if (_zoom == newZoom) return; if (_zoom == newZoom) return;
float64 nx, ny, z = (_zoom == ZoomToScreenLevel) ? _zoomToScreen : _zoom; float64 nx, ny, z = (_zoom == ZoomToScreenLevel) ? _zoomToScreen : _zoom;
_w = gifShown() ? convertScale(_gif->width()) : (convertScale(_current.width()) / cIntRetinaFactor()); _w = gifShown() ? ConvertScale(_gif->width()) : (ConvertScale(_current.width()) / cIntRetinaFactor());
_h = gifShown() ? convertScale(_gif->height()) : (convertScale(_current.height()) / cIntRetinaFactor()); _h = gifShown() ? ConvertScale(_gif->height()) : (ConvertScale(_current.height()) / cIntRetinaFactor());
if (z >= 0) { if (z >= 0) {
nx = (_x - width() / 2.) / (z + 1); nx = (_x - width() / 2.) / (z + 1);
ny = (_y - height() / 2.) / (z + 1); ny = (_y - height() / 2.) / (z + 1);

View File

@ -109,8 +109,8 @@ Messenger::Messenger(not_null<Core::Launcher*> launcher)
} }
if (cRetina()) { if (cRetina()) {
cSetConfigScale(dbisOne); cSetConfigScale(100);
cSetRealScale(dbisOne); cSetRealScale(100);
} }
_translator = std::make_unique<Lang::Translator>(); _translator = std::make_unique<Lang::Translator>();

View File

@ -838,7 +838,7 @@ Document::Document(
if (withThumb()) { if (withThumb()) {
_data->thumb->load(parent->fullId()); _data->thumb->load(parent->fullId());
int32 tw = convertScale(_data->thumb->width()), th = convertScale(_data->thumb->height()); int32 tw = ConvertScale(_data->thumb->width()), th = ConvertScale(_data->thumb->height());
if (tw > th) { if (tw > th) {
_thumbw = (tw * _st.fileThumbSize) / th; _thumbw = (tw * _st.fileThumbSize) / th;
} else { } else {
@ -1275,15 +1275,15 @@ Link::Link(
_page->photo->thumb->load(parent->fullId(), false, false); _page->photo->thumb->load(parent->fullId(), false, false);
} }
tw = convertScale(_page->photo->thumb->width()); tw = ConvertScale(_page->photo->thumb->width());
th = convertScale(_page->photo->thumb->height()); th = ConvertScale(_page->photo->thumb->height());
} else if (_page && _page->document) { } else if (_page && _page->document) {
if (!_page->document->thumb->loaded()) { if (!_page->document->thumb->loaded()) {
_page->document->thumb->load(parent->fullId(), false, false); _page->document->thumb->load(parent->fullId(), false, false);
} }
tw = convertScale(_page->document->thumb->width()); tw = ConvertScale(_page->document->thumb->width());
th = convertScale(_page->document->thumb->height()); th = ConvertScale(_page->document->thumb->height());
} }
if (tw > st::linksPhotoSize) { if (tw > st::linksPhotoSize) {
if (th > tw) { if (th > tw) {

View File

@ -379,8 +379,8 @@ MainWindow::MainWindow()
auto forceOpenGL = std::make_unique<QOpenGLWidget>(this); auto forceOpenGL = std::make_unique<QOpenGLWidget>(this);
#endif // !OS_MAC_OLD #endif // !OS_MAC_OLD
trayImg = st::macTrayIcon.instance(QColor(0, 0, 0, 180), dbisOne); trayImg = st::macTrayIcon.instance(QColor(0, 0, 0, 180), 100);
trayImgSel = st::macTrayIcon.instance(QColor(255, 255, 255), dbisOne); trayImgSel = st::macTrayIcon.instance(QColor(255, 255, 255), 100);
_hideAfterFullScreenTimer.setCallback([this] { hideAndDeactivate(); }); _hideAfterFullScreenTimer.setCallback([this] { hideAndDeactivate(); });

View File

@ -76,7 +76,7 @@ object_ptr<Window::TitleWidget> CreateTitleWidget(QWidget *parent) {
} }
// All the window decorations preview is done without taking cScale() into // All the window decorations preview is done without taking cScale() into
// account, with dbisOne scale and without "px" dimensions, because thats // account, with 100% scale and without "px" dimensions, because thats
// how it will look in real launched macOS app. // how it will look in real launched macOS app.
int PreviewTitleHeight() { int PreviewTitleHeight() {
if (auto window = qobject_cast<Platform::MainWindow*>(App::wnd())) { if (auto window = qobject_cast<Platform::MainWindow*>(App::wnd())) {
@ -185,7 +185,7 @@ void PreviewWindowFramePaint(QImage &preview, const style::palette &palette, QRe
Images::prepareRound(rounded, corners); Images::prepareRound(rounded, corners);
preview.fill(st::themePreviewBg->c); preview.fill(st::themePreviewBg->c);
auto topLeft = st::macWindowShadowTopLeft.instance(QColor(0, 0, 0), dbisOne); auto topLeft = st::macWindowShadowTopLeft.instance(QColor(0, 0, 0), 100);
auto topRight = topLeft.mirrored(true, false); auto topRight = topLeft.mirrored(true, false);
auto bottomLeft = topLeft.mirrored(false, true); auto bottomLeft = topLeft.mirrored(false, true);
auto bottomRight = bottomLeft.mirrored(true, false); auto bottomRight = bottomLeft.mirrored(true, false);

View File

@ -44,9 +44,9 @@ uint32 gConnectionsInSession = 1;
QString gLoggedPhoneNumber; QString gLoggedPhoneNumber;
QByteArray gLocalSalt; QByteArray gLocalSalt;
DBIScale gRealScale = dbisAuto; int gRealScale = kInterfaceScaleAuto;
DBIScale gScreenScale = dbisOne; int gScreenScale = kInterfaceScaleAuto;
DBIScale gConfigScale = dbisAuto; int gConfigScale = kInterfaceScaleAuto;
QString gTimeFormat = qsl("hh:mm"); QString gTimeFormat = qsl("hh:mm");

View File

@ -90,30 +90,35 @@ DeclareSetting(bool, StartToSettings);
DeclareReadSetting(bool, ManyInstance); DeclareReadSetting(bool, ManyInstance);
DeclareSetting(QByteArray, LocalSalt); DeclareSetting(QByteArray, LocalSalt);
DeclareSetting(DBIScale, RealScale); DeclareSetting(int, RealScale);
DeclareSetting(DBIScale, ScreenScale); DeclareSetting(int, ScreenScale);
DeclareSetting(DBIScale, ConfigScale); DeclareSetting(int, ConfigScale);
DeclareSetting(QString, TimeFormat); DeclareSetting(QString, TimeFormat);
inline void cChangeTimeFormat(const QString &newFormat) { constexpr auto kInterfaceScaleAuto = 0;
if (!newFormat.isEmpty()) cSetTimeFormat(newFormat);
inline int cEvalScale(int scale) {
return (scale == kInterfaceScaleAuto) ? cScreenScale() : scale;
} }
inline DBIScale cEvalScale(DBIScale scale) { inline int cScale() {
return (scale == dbisAuto) ? cScreenScale() : scale;
}
inline DBIScale cScale() {
return cEvalScale(cRealScale()); return cEvalScale(cRealScale());
} }
template <typename T> template <typename T>
T convertScale(T v) { inline T ConvertScale(T value, int scale) {
switch (cScale()) { return (value < 0.)
case dbisOneAndQuarter: return qRound(float64(v) * 1.25 - 0.01); ? (-ConvertScale(-value, scale))
case dbisOneAndHalf: return qRound(float64(v) * 1.5 - 0.01); : T(std::round((float64(value) * scale / 100.) - 0.01));
case dbisTwo: return v * 2; }
}
return v; template <typename T>
inline T ConvertScale(T value) {
return ConvertScale(value, cScale());
}
inline void cChangeTimeFormat(const QString &newFormat) {
if (!newFormat.isEmpty()) cSetTimeFormat(newFormat);
} }
namespace Ui { namespace Ui {

View File

@ -112,7 +112,7 @@ void SetupInterfaceScale(
container, container,
rpl::event_stream<bool>()); rpl::event_stream<bool>());
const auto switched = (cConfigScale() == dbisAuto) const auto switched = (cConfigScale() == kInterfaceScaleAuto)
|| (cConfigScale() == cScreenScale()); || (cConfigScale() == cScreenScale());
const auto button = AddButton( const auto button = AddButton(
container, container,
@ -125,22 +125,33 @@ void SetupInterfaceScale(
object_ptr<Ui::SettingsSlider>(container, st::settingsSlider), object_ptr<Ui::SettingsSlider>(container, st::settingsSlider),
icon ? st::settingsScalePadding : st::settingsBigScalePadding); icon ? st::settingsScalePadding : st::settingsBigScalePadding);
static const auto ScaleValues = { 100, 125, 150, 200, 300 };
const auto sectionFromScale = [](int scale) {
auto result = 0;
for (const auto value : ScaleValues) {
if (scale <= value) {
break;
}
++result;
}
return (result == ScaleValues.size()) ? (result - 1) : result;
};
const auto inSetScale = Ui::AttachAsChild(container, false); const auto inSetScale = Ui::AttachAsChild(container, false);
const auto setScale = std::make_shared<Fn<void(DBIScale)>>(); const auto setScale = std::make_shared<Fn<void(int)>>();
*setScale = [=](DBIScale scale) { *setScale = [=](int scale) {
if (*inSetScale) return; if (*inSetScale) return;
*inSetScale = true; *inSetScale = true;
const auto guard = gsl::finally([=] { *inSetScale = false; }); const auto guard = gsl::finally([=] { *inSetScale = false; });
if (scale == cScreenScale()) { if (scale == cScreenScale()) {
scale = dbisAuto; scale = kInterfaceScaleAuto;
} }
toggled->fire(scale == dbisAuto); toggled->fire(scale == kInterfaceScaleAuto);
const auto applying = scale; const auto applying = scale;
if (scale == dbisAuto) { if (scale == kInterfaceScaleAuto) {
scale = cScreenScale(); scale = cScreenScale();
} }
slider->setActiveSection(scale - 1); slider->setActiveSection(sectionFromScale(scale));
if (cEvalScale(scale) != cEvalScale(cRealScale())) { if (cEvalScale(scale) != cEvalScale(cRealScale())) {
const auto confirmed = crl::guard(button, [=] { const auto confirmed = crl::guard(button, [=] {
@ -166,46 +177,31 @@ void SetupInterfaceScale(
}; };
button->toggledValue( button->toggledValue(
) | rpl::start_with_next([=](bool checked) { ) | rpl::start_with_next([=](bool checked) {
auto scale = checked ? dbisAuto : cEvalScale(cConfigScale()); auto scale = checked ? kInterfaceScaleAuto : cEvalScale(cConfigScale());
if (scale == cScreenScale()) { if (scale == cScreenScale()) {
if (scale != cScale()) { if (scale != cScale()) {
scale = cScale(); scale = cScale();
} else { } else {
switch (scale) { scale -= 25;
case dbisOne: scale = dbisOneAndQuarter; break; if (scale < 100) {
case dbisOneAndQuarter: scale = dbisOne; break; scale = 125;
case dbisOneAndHalf: scale = dbisOneAndQuarter; break;
case dbisTwo: scale = dbisOneAndHalf; break;
} }
} }
} }
(*setScale)(scale); (*setScale)(scale);
}, button->lifetime()); }, button->lifetime());
const auto label = [](DBIScale scale) { const auto label = [](int scale) {
switch (scale) { return QString::number(scale) + '%';
case dbisOne: return qsl("100%");
case dbisOneAndQuarter: return qsl("125%");
case dbisOneAndHalf: return qsl("150%");
case dbisTwo: return qsl("200%");
}
Unexpected("Value in scale label.");
}; };
const auto scaleByIndex = [](int index) { const auto scaleByIndex = [](int index) {
switch (index) { return *(ScaleValues.begin() + index);
case 0: return dbisOne;
case 1: return dbisOneAndQuarter;
case 2: return dbisOneAndHalf;
case 3: return dbisTwo;
}
Unexpected("Index in scaleByIndex.");
}; };
slider->addSection(label(dbisOne)); for (const auto value : ScaleValues) {
slider->addSection(label(dbisOneAndQuarter)); slider->addSection(label(value));
slider->addSection(label(dbisOneAndHalf)); }
slider->addSection(label(dbisTwo)); slider->setActiveSectionFast(sectionFromScale(cConfigScale()));
slider->setActiveSectionFast(cEvalScale(cConfigScale()) - 1);
slider->sectionActivated( slider->sectionActivated(
) | rpl::start_with_next([=](int section) { ) | rpl::start_with_next([=](int section) {
(*setScale)(scaleByIndex(section)); (*setScale)(scaleByIndex(section));

View File

@ -541,7 +541,7 @@ enum {
dbiReplaceEmoji = 0x13, dbiReplaceEmoji = 0x13,
dbiAskDownloadPath = 0x14, dbiAskDownloadPath = 0x14,
dbiDownloadPathOld = 0x15, dbiDownloadPathOld = 0x15,
dbiScale = 0x16, dbiScaleOld = 0x16,
dbiEmojiTabOld = 0x17, dbiEmojiTabOld = 0x17,
dbiRecentEmojiOldOld = 0x18, dbiRecentEmojiOldOld = 0x18,
dbiLoggedPhoneNumber = 0x19, dbiLoggedPhoneNumber = 0x19,
@ -597,6 +597,7 @@ enum {
dbiTileBackground = 0x55, dbiTileBackground = 0x55,
dbiCacheSettings = 0x56, dbiCacheSettings = 0x56,
dbiAnimationsDisabled = 0x57, dbiAnimationsDisabled = 0x57,
dbiScalePercent = 0x58,
dbiEncryptedWithSalt = 333, dbiEncryptedWithSalt = 333,
dbiEncrypted = 444, dbiEncrypted = 444,
@ -1364,24 +1365,45 @@ bool _readSetting(quint32 blockId, QDataStream &stream, int version, ReadSetting
cSetLastUpdateCheck(v); cSetLastUpdateCheck(v);
} break; } break;
case dbiScale: { case dbiScaleOld: {
qint32 v; qint32 v;
stream >> v; stream >> v;
if (!_checkStreamStatus(stream)) return false; if (!_checkStreamStatus(stream)) return false;
DBIScale s = cRealScale(); const auto s = [&] {
switch (v) { if (cRetina()) {
case dbisAuto: s = dbisAuto; break; return 100;
case dbisOne: s = dbisOne; break; }
case dbisOneAndQuarter: s = dbisOneAndQuarter; break;
case dbisOneAndHalf: s = dbisOneAndHalf; break; constexpr auto kAuto = 0;
case dbisTwo: s = dbisTwo; break; constexpr auto kOne = 1;
} constexpr auto kOneAndQuarter = 2;
if (cRetina()) s = dbisOne; constexpr auto kOneAndHalf = 3;
constexpr auto kTwo = 4;
switch (v) {
case kAuto: return kInterfaceScaleAuto;
case kOne: return 100;
case kOneAndQuarter: return 125;
case kOneAndHalf: return 150;
case kTwo: return 200;
}
return cRealScale();
}();
cSetConfigScale(s); cSetConfigScale(s);
cSetRealScale(s); cSetRealScale(s);
} break; } break;
case dbiScalePercent: {
qint32 v;
stream >> v;
if (!_checkStreamStatus(stream)) return false;
if (!v || (v >= 100 && v <= (cRetina() ? 150 : 300) && !(v % 25))) {
cSetConfigScale(v);
cSetRealScale(v);
}
} break;
case dbiLangOld: { case dbiLangOld: {
qint32 v; qint32 v;
stream >> v; stream >> v;
@ -2555,7 +2577,7 @@ void writeSettings() {
data.stream << quint32(dbiSeenTrayTooltip) << qint32(cSeenTrayTooltip()); data.stream << quint32(dbiSeenTrayTooltip) << qint32(cSeenTrayTooltip());
data.stream << quint32(dbiAutoUpdate) << qint32(cAutoUpdate()); data.stream << quint32(dbiAutoUpdate) << qint32(cAutoUpdate());
data.stream << quint32(dbiLastUpdateCheck) << qint32(cLastUpdateCheck()); data.stream << quint32(dbiLastUpdateCheck) << qint32(cLastUpdateCheck());
data.stream << quint32(dbiScale) << qint32(cConfigScale()); data.stream << quint32(dbiScalePercent) << qint32(cConfigScale());
data.stream << quint32(dbiDcOptions) << dcOptionsSerialized; data.stream << quint32(dbiDcOptions) << dcOptionsSerialized;
data.stream << quint32(dbiLoggedPhoneNumber) << cLoggedPhoneNumber(); data.stream << quint32(dbiLoggedPhoneNumber) << cLoggedPhoneNumber();
data.stream << quint32(dbiTxtDomainString) << Global::TxtDomainString(); data.stream << quint32(dbiTxtDomainString) << Global::TxtDomainString();

View File

@ -81,7 +81,7 @@ bool PrepareAlbumMediaIsWaiting(
if (ValidPhotoForAlbum(*image)) { if (ValidPhotoForAlbum(*image)) {
file.shownDimensions = PrepareShownDimensions(image->data); file.shownDimensions = PrepareShownDimensions(image->data);
file.preview = Images::prepareOpaque(image->data.scaledToWidth( file.preview = Images::prepareOpaque(image->data.scaledToWidth(
std::min(previewWidth, convertScale(image->data.width())) std::min(previewWidth, ConvertScale(image->data.width()))
* cIntRetinaFactor(), * cIntRetinaFactor(),
Qt::SmoothTransformation)); Qt::SmoothTransformation));
Assert(!file.preview.isNull()); Assert(!file.preview.isNull());

View File

@ -40,7 +40,6 @@ private:
}; };
auto Scale = -1.;
auto SizeNormal = -1; auto SizeNormal = -1;
auto SizeLarge = -1; auto SizeLarge = -1;
auto SpritesCount = -1; auto SpritesCount = -1;
@ -292,20 +291,8 @@ void ClearUniversalChecked() {
void Init() { void Init() {
internal::Init(); internal::Init();
Scale = [] { SizeNormal = ConvertScale(18) * cIntRetinaFactor();
if (cRetina()) { SizeLarge = int(ConvertScale(18 * 4 / 3.)) * cIntRetinaFactor();
return 2.;
}
switch (cScale()) {
case dbisOne: return 1.;
case dbisOneAndQuarter: return 1.25;
case dbisOneAndHalf: return 1.5;
case dbisTwo: return 2.;
}
Unexpected("cScale() in Ui::Emoji::Init.");
}();
SizeNormal = int(std::round(Scale * 18));
SizeLarge = int(std::round(Scale * 18 * 4 / 3.));
const auto count = internal::FullCount(); const auto count = internal::FullCount();
const auto persprite = kImagesPerRow * kImageRowsPerSprite; const auto persprite = kImagesPerRow * kImageRowsPerSprite;
SpritesCount = (count / persprite) + ((count % persprite) ? 1 : 0); SpritesCount = (count / persprite) + ((count % persprite) ? 1 : 0);
@ -334,12 +321,6 @@ int GetSizeLarge() {
return SizeLarge; return SizeLarge;
} }
float64 GetScale() {
Expects(Scale > 0.);
return Scale;
}
int One::variantsCount() const { int One::variantsCount() const {
return hasVariants() ? 5 : 0; return hasVariants() ? 5 : 0;
} }

View File

@ -20,7 +20,6 @@ void Clear();
int GetSizeNormal(); int GetSizeNormal();
int GetSizeLarge(); int GetSizeLarge();
float64 GetScale();
class One { class One {
struct CreationTag { struct CreationTag {

View File

@ -48,7 +48,7 @@ void unregisterModule(ModuleBase *module) {
void startManager() { void startManager() {
if (cRetina()) { if (cRetina()) {
cSetRealScale(dbisOne); cSetRealScale(100);
} }
internal::registerFontFamily(qsl("Open Sans")); internal::registerFontFamily(qsl("Open Sans"));

View File

@ -22,14 +22,7 @@ NeverFreedPointer<IconMasks> iconMasks;
NeverFreedPointer<IconPixmaps> iconPixmaps; NeverFreedPointer<IconPixmaps> iconPixmaps;
NeverFreedPointer<IconDatas> iconData; NeverFreedPointer<IconDatas> iconData;
inline int pxAdjust(int value, int scale) { QImage createIconMask(const IconMask *mask, int scale) {
if (value < 0) {
return -pxAdjust(-value, scale);
}
return qFloor((value * scale / 4.) + 0.1);
}
QImage createIconMask(const IconMask *mask, DBIScale scale) {
auto maskImage = QImage::fromData(mask->data(), mask->size(), "PNG"); auto maskImage = QImage::fromData(mask->data(), mask->size(), "PNG");
maskImage.setDevicePixelRatio(cRetinaFactor()); maskImage.setDevicePixelRatio(cRetinaFactor());
Assert(!maskImage.isNull()); Assert(!maskImage.isNull());
@ -37,26 +30,31 @@ QImage createIconMask(const IconMask *mask, DBIScale scale) {
// images are layouted like this: // images are layouted like this:
// 100x 200x // 100x 200x
// 300x // 300x
if (cRetina()) {
scale *= 2;
}
const auto width = maskImage.width() / 3; const auto width = maskImage.width() / 3;
const auto height = maskImage.height() / 5; const auto height = maskImage.height() / 5;
const auto one = QRect(0, 0, width, height);
const auto two = QRect(width, 0, width * 2, height * 2); const auto two = QRect(width, 0, width * 2, height * 2);
if (cRetina() || scale == dbisTwo) { const auto three = QRect(0, height * 2, width * 3, height * 3);
if (scale == 100) {
return maskImage.copy(one);
} else if (scale == 200) {
return maskImage.copy(two); return maskImage.copy(two);
} else if (scale == dbisOne) { } else if (scale == 300) {
return maskImage.copy(QRect(0, 0, width, height)); return maskImage.copy(three);
} }
const auto width125 = pxAdjust(width, 5); return maskImage.copy(
const auto height125 = pxAdjust(height, 5); (scale > 200) ? three : two
const auto width150 = pxAdjust(width, 6); ).scaled(
const auto height150 = pxAdjust(height, 6); ConvertScale(width, scale),
return maskImage.copy(two).scaled( ConvertScale(height, scale),
(scale == dbisOneAndQuarter) ? width125 : width150,
(scale == dbisOneAndQuarter) ? height125 : height150,
Qt::IgnoreAspectRatio, Qt::IgnoreAspectRatio,
Qt::SmoothTransformation); Qt::SmoothTransformation);
} }
QSize readGeneratedSize(const IconMask *mask, DBIScale scale) { QSize readGeneratedSize(const IconMask *mask, int scale) {
auto data = mask->data(); auto data = mask->data();
auto size = mask->size(); auto size = mask->size();
@ -76,12 +74,9 @@ QSize readGeneratedSize(const IconMask *mask, DBIScale scale) {
stream >> width >> height; stream >> width >> height;
Assert(stream.status() == QDataStream::Ok); Assert(stream.status() == QDataStream::Ok);
switch (scale) { return QSize(
case dbisOne: return QSize(width, height); ConvertScale(width, scale),
case dbisOneAndQuarter: return QSize(pxAdjust(width, 5), pxAdjust(height, 5)); ConvertScale(height, scale));
case dbisOneAndHalf: return QSize(pxAdjust(width, 6), pxAdjust(height, 6));
case dbisTwo: return QSize(width * 2, height * 2);
}
} else { } else {
Unexpected("Bad data in generated icon!"); Unexpected("Bad data in generated icon!");
} }
@ -219,8 +214,8 @@ void MonoIcon::fill(
} }
} }
QImage MonoIcon::instance(QColor colorOverride, DBIScale scale) const { QImage MonoIcon::instance(QColor colorOverride, int scale) const {
if (scale == dbisAuto) { if (scale == kInterfaceScaleAuto) {
ensureLoaded(); ensureLoaded();
auto result = QImage(size() * cIntRetinaFactor(), QImage::Format_ARGB32_Premultiplied); auto result = QImage(size() * cIntRetinaFactor(), QImage::Format_ARGB32_Premultiplied);
result.setDevicePixelRatio(cRetinaFactor()); result.setDevicePixelRatio(cRetinaFactor());
@ -311,7 +306,7 @@ void IconData::fill(QPainter &p, const QRect &rect, QColor colorOverride) const
} }
} }
QImage IconData::instance(QColor colorOverride, DBIScale scale) const { QImage IconData::instance(QColor colorOverride, int scale) const {
Assert(_parts.size() == 1); Assert(_parts.size() == 1);
auto &part = _parts[0]; auto &part = _parts[0];
Assert(part.offset() == QPoint(0, 0)); Assert(part.offset() == QPoint(0, 0));

View File

@ -58,7 +58,7 @@ public:
void paint(QPainter &p, const QPoint &pos, int outerw, const style::palette &paletteOverride) const; void paint(QPainter &p, const QPoint &pos, int outerw, const style::palette &paletteOverride) const;
void fill(QPainter &p, const QRect &rect, const style::palette &paletteOverride) const; void fill(QPainter &p, const QRect &rect, const style::palette &paletteOverride) const;
QImage instance(QColor colorOverride, DBIScale scale) const; QImage instance(QColor colorOverride, int scale) const;
~MonoIcon() { ~MonoIcon() {
} }
@ -116,7 +116,7 @@ public:
} }
void fill(QPainter &p, const QRect &rect, const style::palette &paletteOverride) const; void fill(QPainter &p, const QRect &rect, const style::palette &paletteOverride) const;
QImage instance(QColor colorOverride, DBIScale scale) const; QImage instance(QColor colorOverride, int scale) const;
int width() const; int width() const;
int height() const; int height() const;
@ -205,7 +205,7 @@ public:
return _data->fill(p, rect, colorOverride); return _data->fill(p, rect, colorOverride);
} }
QImage instance(QColor colorOverride, DBIScale scale = dbisAuto) const { QImage instance(QColor colorOverride, int scale = kInterfaceScaleAuto) const {
return _data->instance(colorOverride, scale); return _data->instance(colorOverride, scale);
} }

View File

@ -988,7 +988,7 @@ QSize MediaPreviewWidget::currentDimensions() const {
box = QSize(2 * st::maxStickerSize, 2 * st::maxStickerSize); box = QSize(2 * st::maxStickerSize, 2 * st::maxStickerSize);
} }
} }
result = QSize(qMax(convertScale(result.width()), 1), qMax(convertScale(result.height()), 1)); result = QSize(qMax(ConvertScale(result.width()), 1), qMax(ConvertScale(result.height()), 1));
if (result.width() > box.width()) { if (result.width() > box.width()) {
result.setHeight(qMax((box.width() * result.height()) / result.width(), 1)); result.setHeight(qMax((box.width() * result.height()) / result.width(), 1));
result.setWidth(box.width()); result.setWidth(box.width());

View File

@ -411,8 +411,8 @@ void ChatBackground::setImage(int32 id, QImage &&image) {
image.load(qsl(":/gui/art/bg_initial.jpg")); image.load(qsl(":/gui/art/bg_initial.jpg"));
if (cRetina()) { if (cRetina()) {
image = image.scaledToWidth(image.width() * 2, Qt::SmoothTransformation); image = image.scaledToWidth(image.width() * 2, Qt::SmoothTransformation);
} else if (cScale() != dbisOne) { } else if (cScale() != 100) {
image = image.scaledToWidth(convertScale(image.width()), Qt::SmoothTransformation); image = image.scaledToWidth(ConvertScale(image.width()), Qt::SmoothTransformation);
} }
} else if (_id == kDefaultBackground || image.isNull()) { } else if (_id == kDefaultBackground || image.isNull()) {
_id = kDefaultBackground; _id = kDefaultBackground;

View File

@ -278,8 +278,8 @@ void Generator::addDateBubble(QString date) {
void Generator::addPhotoBubble(QString image, QString caption, QString date, Status status) { void Generator::addPhotoBubble(QString image, QString caption, QString date, Status status) {
Bubble bubble; Bubble bubble;
bubble.photo.load(image); bubble.photo.load(image);
bubble.photoWidth = convertScale(bubble.photo.width() / 2); bubble.photoWidth = ConvertScale(bubble.photo.width() / 2);
bubble.photoHeight = convertScale(bubble.photo.height() / 2); bubble.photoHeight = ConvertScale(bubble.photo.height() / 2);
auto skipBlock = computeSkipBlock(status, date); auto skipBlock = computeSkipBlock(status, date);
bubble.text.setRichText(st::messageTextStyle, caption + textcmdSkipBlock(skipBlock.width(), skipBlock.height()), Ui::ItemTextDefaultOptions()); bubble.text.setRichText(st::messageTextStyle, caption + textcmdSkipBlock(skipBlock.width(), skipBlock.height()), Ui::ItemTextDefaultOptions());
@ -490,12 +490,7 @@ void Generator::paintComposeArea() {
auto inner = QRect(QPoint(attachEmojiLeft + (st::historyAttachEmoji.width - st::historyEmojiCircle.width()) / 2, controlsTop + st::historyEmojiCircleTop), st::historyEmojiCircle); auto inner = QRect(QPoint(attachEmojiLeft + (st::historyAttachEmoji.width - st::historyEmojiCircle.width()) / 2, controlsTop + st::historyEmojiCircleTop), st::historyEmojiCircle);
_p->drawEllipse(inner); _p->drawEllipse(inner);
auto fakeMargin = 0; const auto fakeMargin = (cScale() - 100) / 25;
switch (cScale()) {
case dbisOneAndQuarter: fakeMargin = 1; break;
case dbisOneAndHalf: fakeMargin = 2; break;
case dbisTwo: fakeMargin = 4; break;
}
auto fieldLeft = _composeArea.x() + st::historyAttach.width + fakeMargin; auto fieldLeft = _composeArea.x() + st::historyAttach.width + fakeMargin;
auto fieldTop = _composeArea.y() + _composeArea.height() - st::historyAttach.height + st::historySendPadding + fakeMargin; auto fieldTop = _composeArea.y() + _composeArea.height() - st::historyAttach.height + st::historySendPadding + fakeMargin;