mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-18 07:07:08 +02:00
Moved constants of arc angles to td_ui.
This commit is contained in:
parent
cdfdccbb66
commit
58ed30d30e
17 changed files with 38 additions and 29 deletions
Telegram
SourceFiles
boxes
chat_helpers
core
dialogs
history/view
media/player
stdafx.hui
cmake
|
@ -459,7 +459,7 @@ void ProxyRow::paintEvent(QPaintEvent *e) {
|
|||
void ProxyRow::paintCheck(Painter &p) {
|
||||
const auto loading = _progress
|
||||
? _progress->computeState()
|
||||
: Ui::RadialState{ 0., 0, FullArcLength };
|
||||
: Ui::RadialState{ 0., 0, arc::kFullLength };
|
||||
const auto toggled = _toggled.value(_view.selected ? 1. : 0.)
|
||||
* (1. - loading.shown);
|
||||
const auto _st = &st::defaultRadio;
|
||||
|
@ -484,7 +484,7 @@ void ProxyRow::paintCheck(Painter &p) {
|
|||
_st->thickness,
|
||||
pen.color(),
|
||||
_st->bg);
|
||||
} else if (loading.arcLength < FullArcLength) {
|
||||
} else if (loading.arcLength < arc::kFullLength) {
|
||||
p.drawArc(rect, loading.arcFrom, loading.arcLength);
|
||||
} else {
|
||||
p.drawEllipse(rect);
|
||||
|
|
|
@ -35,8 +35,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
|
||||
namespace {
|
||||
|
||||
constexpr auto kFullArcLength = 360 * 16;
|
||||
|
||||
enum class Color {
|
||||
Permanent,
|
||||
Expiring,
|
||||
|
@ -740,7 +738,7 @@ void LinksController::rowPaintIcon(
|
|||
margins,
|
||||
margins,
|
||||
margins,
|
||||
}), (kFullArcLength / 4), kFullArcLength * (1. - progress));
|
||||
}), arc::kQuarterLength, arc::kFullLength * (1. - progress));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -262,7 +262,7 @@ void Row::paintRadio(QPainter &p) {
|
|||
}
|
||||
const auto loading = _loading
|
||||
? _loading->computeState()
|
||||
: Ui::RadialState{ 0., 0, FullArcLength };
|
||||
: Ui::RadialState{ 0., 0, arc::kFullLength };
|
||||
const auto isToggledSet = v::is<Active>(_state.current());
|
||||
const auto isActiveSet = isToggledSet || v::is<Loading>(_state.current());
|
||||
const auto toggled = _toggled.value(isToggledSet ? 1. : 0.);
|
||||
|
@ -301,7 +301,7 @@ void Row::paintRadio(QPainter &p) {
|
|||
_st->thickness,
|
||||
pen.color(),
|
||||
_st->bg);
|
||||
} else if (loading.arcLength < FullArcLength) {
|
||||
} else if (loading.arcLength < arc::kFullLength) {
|
||||
p.drawArc(rect, loading.arcFrom, loading.arcLength);
|
||||
} else {
|
||||
p.drawEllipse(rect);
|
||||
|
|
|
@ -175,8 +175,3 @@ inline int ceilclamp(float64 value, int32 step, int32 lowest, int32 highest) {
|
|||
lowest,
|
||||
highest);
|
||||
}
|
||||
|
||||
static int32 FullArcLength = 360 * 16;
|
||||
static int32 QuarterArcLength = (FullArcLength / 4);
|
||||
static int32 MinArcLength = (FullArcLength / 360);
|
||||
static int32 AlmostFullArcLength = (FullArcLength - MinArcLength);
|
||||
|
|
|
@ -10,7 +10,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "dialogs/dialogs_entry.h"
|
||||
#include "dialogs/ui/dialogs_layout.h"
|
||||
#include "data/data_session.h"
|
||||
#include "mainwidget.h"
|
||||
|
||||
namespace Dialogs {
|
||||
|
||||
|
|
|
@ -91,8 +91,6 @@ constexpr auto kNoneLayer = 0;
|
|||
style::al_center);
|
||||
|
||||
constexpr auto kPenWidth = 1.5;
|
||||
constexpr auto kAngleStart = 90 * 16;
|
||||
constexpr auto kAngleSpan = 180 * 16;
|
||||
|
||||
const auto penWidth = style::ConvertScaleExact(kPenWidth);
|
||||
auto pen = QPen(st::premiumButtonFg);
|
||||
|
@ -102,7 +100,7 @@ constexpr auto kNoneLayer = 0;
|
|||
|
||||
q.setPen(pen);
|
||||
q.setBrush(Qt::NoBrush);
|
||||
q.drawArc(innerRect, kAngleStart, kAngleSpan);
|
||||
q.drawArc(innerRect, arc::kQuarterLength, arc::kHalfLength);
|
||||
|
||||
q.setClipRect(innerRect
|
||||
- QMargins(innerRect.width() / 2, 0, -penWidth, -penWidth));
|
||||
|
|
|
@ -837,7 +837,7 @@ void RecordLock::drawProgress(Painter &p) {
|
|||
arcWidth,
|
||||
arcHeight * 2,
|
||||
0,
|
||||
180 * 16);
|
||||
arc::kHalfLength);
|
||||
|
||||
const auto lockProgress = 1. - _lockToStopProgress;
|
||||
if (progress == 1. && lockProgress < 1.) {
|
||||
|
|
|
@ -106,7 +106,7 @@ void TranscribeButton::paint(
|
|||
_st->thickness,
|
||||
pen.color(),
|
||||
_st->bg);
|
||||
} else if (state.arcLength < FullArcLength) {
|
||||
} else if (state.arcLength < arc::kFullLength) {
|
||||
const auto opacity = p.opacity();
|
||||
p.setOpacity(state.shown * (1. - opened));
|
||||
p.drawArc(r, state.arcFrom, state.arcLength);
|
||||
|
|
|
@ -486,8 +486,8 @@ void Gif::draw(Painter &p, const PaintContext &context) const {
|
|||
p.setPen(pen);
|
||||
p.setOpacity(st::historyVideoMessageProgressOpacity);
|
||||
|
||||
auto from = QuarterArcLength;
|
||||
auto len = -qRound(FullArcLength * value);
|
||||
auto from = arc::kQuarterLength;
|
||||
auto len = -qRound(arc::kFullLength * value);
|
||||
auto stepInside = st::radialLine / 2;
|
||||
{
|
||||
PainterHighQualityEnabler hq(p);
|
||||
|
|
|
@ -971,8 +971,8 @@ void Poll::paintCloseByTimer(
|
|||
auto hq = PainterHighQualityEnabler(p);
|
||||
const auto part = std::max(
|
||||
left / float64(radial),
|
||||
1. / FullArcLength);
|
||||
const auto length = int(base::SafeRound(FullArcLength * part));
|
||||
1. / arc::kFullLength);
|
||||
const auto length = int(base::SafeRound(arc::kFullLength * part));
|
||||
auto pen = regular->p;
|
||||
pen.setWidth(st::historyPollRadio.thickness);
|
||||
pen.setCapStyle(Qt::RoundCap);
|
||||
|
@ -980,7 +980,7 @@ void Poll::paintCloseByTimer(
|
|||
const auto size = icon.width() / 2;
|
||||
const auto left = (x + (icon.width() - size) / 2);
|
||||
const auto top = (y + (icon.height() - size) / 2) + st::lineWidth;
|
||||
p.drawArc(left, top, size, size, (FullArcLength / 4), length);
|
||||
p.drawArc(left, top, size, size, (arc::kFullLength / 4), length);
|
||||
} else {
|
||||
icon.paint(p, x, y, width());
|
||||
}
|
||||
|
|
|
@ -261,8 +261,8 @@ void Float::paintEvent(QPaintEvent *e) {
|
|||
p.setPen(pen);
|
||||
p.setOpacity(_opacity * st::historyVideoMessageProgressOpacity);
|
||||
|
||||
auto from = QuarterArcLength;
|
||||
auto len = -qRound(FullArcLength * progress);
|
||||
auto from = arc::kQuarterLength;
|
||||
auto len = -qRound(arc::kFullLength * progress);
|
||||
auto stepInside = st::radialLine / 2;
|
||||
{
|
||||
PainterHighQualityEnabler hq(p);
|
||||
|
|
|
@ -129,6 +129,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "styles/palette.h"
|
||||
#include "styles/style_basic.h"
|
||||
|
||||
#include "ui/arc_angles.h"
|
||||
#include "ui/image/image_location.h"
|
||||
#include "ui/text/text.h"
|
||||
|
||||
|
|
16
Telegram/SourceFiles/ui/arc_angles.h
Normal file
16
Telegram/SourceFiles/ui/arc_angles.h
Normal file
|
@ -0,0 +1,16 @@
|
|||
/*
|
||||
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
|
||||
|
||||
namespace arc {
|
||||
|
||||
constexpr auto kFullLength = 360 * 16;
|
||||
constexpr auto kQuarterLength = (kFullLength / 4);
|
||||
constexpr auto kHalfLength = (kFullLength / 2);
|
||||
|
||||
} // namespace arc
|
|
@ -18,8 +18,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
namespace Ui {
|
||||
namespace {
|
||||
|
||||
constexpr auto kFullArcLength = 360 * 16;
|
||||
|
||||
[[nodiscard]] QImage Make(const QImage &image, int size) {
|
||||
if (image.isNull()) {
|
||||
return QImage();
|
||||
|
@ -209,7 +207,7 @@ void DownloadBar::paint(Painter &p, QRect clip) {
|
|||
p.setBrush(Qt::NoBrush);
|
||||
const auto m = added / 2.;
|
||||
auto rect = QRectF(full).marginsRemoved({ m, m, m, m });
|
||||
if (loading.arcLength < kFullArcLength) {
|
||||
if (loading.arcLength < arc::kFullLength) {
|
||||
p.drawArc(rect, loading.arcFrom, loading.arcLength);
|
||||
} else {
|
||||
p.drawEllipse(rect);
|
||||
|
|
|
@ -213,6 +213,8 @@ void RecordAnimation::paint(
|
|||
auto size = st::historySendActionRecordPosition.x()
|
||||
+ st::historySendActionRecordDelta * progress;
|
||||
y += st::historySendActionRecordPosition.y();
|
||||
constexpr auto kAngleStart = -arc::kFullLength / 24;
|
||||
constexpr auto kAngleSpan = arc::kFullLength / 12;
|
||||
for (auto i = 0; i != kRecordArcsCount; ++i) {
|
||||
p.setOpacity((i == 0)
|
||||
? progress
|
||||
|
@ -220,7 +222,7 @@ void RecordAnimation::paint(
|
|||
? (1. - progress)
|
||||
: 1.);
|
||||
auto rect = QRectF(x - size, y - size, 2 * size, 2 * size);
|
||||
p.drawArc(rect, -FullArcLength / 24, FullArcLength / 12);
|
||||
p.drawArc(rect, kAngleStart, kAngleSpan);
|
||||
size += st::historySendActionRecordDelta;
|
||||
}
|
||||
p.setOpacity(1.);
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include "base/flat_map.h"
|
||||
#include "base/flat_set.h"
|
||||
|
||||
#include "ui/arc_angles.h"
|
||||
#include "ui/text/text.h"
|
||||
#include "ui/effects/animations.h"
|
||||
#include "styles/palette.h"
|
||||
|
|
|
@ -277,6 +277,7 @@ PRIVATE
|
|||
ui/widgets/vertical_drum_picker.cpp
|
||||
ui/widgets/vertical_drum_picker.h
|
||||
|
||||
ui/arc_angles.h
|
||||
ui/cached_round_corners.cpp
|
||||
ui/cached_round_corners.h
|
||||
ui/color_contrast.cpp
|
||||
|
|
Loading…
Add table
Reference in a new issue