Moved paint of toggle up-down arrow from main menu to td_ui.
This commit is contained in:
parent
21cd1555f0
commit
4598fc3d53
|
@ -0,0 +1,51 @@
|
||||||
|
/*
|
||||||
|
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
|
||||||
|
*/
|
||||||
|
#include "ui/effects/toggle_arrow.h"
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
|
||||||
|
[[nodiscard]] QPainterPath ToggleUpDownArrowPath(
|
||||||
|
float64 x,
|
||||||
|
float64 y,
|
||||||
|
float64 size,
|
||||||
|
float64 fourStrokes,
|
||||||
|
float64 progress) {
|
||||||
|
const auto size2 = size / 2.;
|
||||||
|
const auto stroke = (fourStrokes / 4.) / M_SQRT2;
|
||||||
|
const auto left = x - size;
|
||||||
|
const auto right = x + size;
|
||||||
|
const auto bottom = y + size2;
|
||||||
|
constexpr auto kPointCount = 6;
|
||||||
|
auto points = std::array<QPointF, kPointCount>{ {
|
||||||
|
{ left - stroke, bottom - stroke },
|
||||||
|
{ x, bottom - stroke - size - stroke },
|
||||||
|
{ right + stroke, bottom - stroke },
|
||||||
|
{ right - stroke, bottom + stroke },
|
||||||
|
{ x, bottom + stroke - size + stroke },
|
||||||
|
{ left + stroke, bottom + stroke }
|
||||||
|
} };
|
||||||
|
const auto alpha = (progress - 1.) * M_PI;
|
||||||
|
const auto cosalpha = cos(alpha);
|
||||||
|
const auto sinalpha = sin(alpha);
|
||||||
|
for (auto &point : points) {
|
||||||
|
auto px = point.x() - x;
|
||||||
|
auto py = point.y() - y;
|
||||||
|
point.setX(x + px * cosalpha - py * sinalpha);
|
||||||
|
point.setY(y + py * cosalpha + px * sinalpha);
|
||||||
|
}
|
||||||
|
auto path = QPainterPath();
|
||||||
|
path.moveTo(points.front());
|
||||||
|
for (int i = 1; i != kPointCount; ++i) {
|
||||||
|
path.lineTo(points[i]);
|
||||||
|
}
|
||||||
|
path.lineTo(points.front());
|
||||||
|
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Ui
|
|
@ -0,0 +1,19 @@
|
||||||
|
/*
|
||||||
|
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 Ui {
|
||||||
|
|
||||||
|
[[nodiscard]] QPainterPath ToggleUpDownArrowPath(
|
||||||
|
float64 x,
|
||||||
|
float64 y,
|
||||||
|
float64 size,
|
||||||
|
float64 fourStrokes,
|
||||||
|
float64 progress);
|
||||||
|
|
||||||
|
} // namespace Ui
|
|
@ -14,6 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/chat/chat_theme.h"
|
#include "ui/chat/chat_theme.h"
|
||||||
#include "ui/controls/userpic_button.h"
|
#include "ui/controls/userpic_button.h"
|
||||||
#include "ui/effects/snowflakes.h"
|
#include "ui/effects/snowflakes.h"
|
||||||
|
#include "ui/effects/toggle_arrow.h"
|
||||||
#include "ui/widgets/buttons.h"
|
#include "ui/widgets/buttons.h"
|
||||||
#include "ui/widgets/labels.h"
|
#include "ui/widgets/labels.h"
|
||||||
#include "ui/widgets/popup_menu.h"
|
#include "ui/widgets/popup_menu.h"
|
||||||
|
@ -267,39 +268,12 @@ MainMenu::ToggleAccountsButton::ToggleAccountsButton(QWidget *parent)
|
||||||
void MainMenu::ToggleAccountsButton::paintEvent(QPaintEvent *e) {
|
void MainMenu::ToggleAccountsButton::paintEvent(QPaintEvent *e) {
|
||||||
auto p = Painter(this);
|
auto p = Painter(this);
|
||||||
|
|
||||||
const auto toggled = _toggledAnimation.value(_toggled ? 1. : 0.);
|
const auto path = Ui::ToggleUpDownArrowPath(
|
||||||
const auto x = 0. + width() - st::mainMenuTogglePosition.x();
|
0. + width() - st::mainMenuTogglePosition.x(),
|
||||||
const auto y = 0. + height() - st::mainMenuTogglePosition.y();
|
0. + height() - st::mainMenuTogglePosition.y(),
|
||||||
const auto size = st::mainMenuToggleSize;
|
st::mainMenuToggleSize,
|
||||||
const auto size2 = size / 2.;
|
st::mainMenuToggleFourStrokes,
|
||||||
const auto stroke = (st::mainMenuToggleFourStrokes / 4.) / M_SQRT2;
|
_toggledAnimation.value(_toggled ? 1. : 0.));
|
||||||
const auto left = x - size;
|
|
||||||
const auto right = x + size;
|
|
||||||
const auto bottom = y + size2;
|
|
||||||
constexpr auto kPointCount = 6;
|
|
||||||
std::array<QPointF, kPointCount> points = { {
|
|
||||||
{ left - stroke, bottom - stroke },
|
|
||||||
{ x, bottom - stroke - size - stroke },
|
|
||||||
{ right + stroke, bottom - stroke },
|
|
||||||
{ right - stroke, bottom + stroke },
|
|
||||||
{ x, bottom + stroke - size + stroke },
|
|
||||||
{ left + stroke, bottom + stroke }
|
|
||||||
} };
|
|
||||||
const auto alpha = (toggled - 1.) * M_PI;
|
|
||||||
const auto cosalpha = cos(alpha);
|
|
||||||
const auto sinalpha = sin(alpha);
|
|
||||||
for (auto &point : points) {
|
|
||||||
auto px = point.x() - x;
|
|
||||||
auto py = point.y() - y;
|
|
||||||
point.setX(x + px * cosalpha - py * sinalpha);
|
|
||||||
point.setY(y + py * cosalpha + px * sinalpha);
|
|
||||||
}
|
|
||||||
QPainterPath path;
|
|
||||||
path.moveTo(points[0]);
|
|
||||||
for (int i = 1; i != kPointCount; ++i) {
|
|
||||||
path.lineTo(points[i]);
|
|
||||||
}
|
|
||||||
path.lineTo(points[0]);
|
|
||||||
|
|
||||||
auto hq = PainterHighQualityEnabler(p);
|
auto hq = PainterHighQualityEnabler(p);
|
||||||
p.fillPath(path, st::windowSubTextFg);
|
p.fillPath(path, st::windowSubTextFg);
|
||||||
|
|
|
@ -268,6 +268,8 @@ PRIVATE
|
||||||
ui/effects/scroll_content_shadow.h
|
ui/effects/scroll_content_shadow.h
|
||||||
ui/effects/snowflakes.cpp
|
ui/effects/snowflakes.cpp
|
||||||
ui/effects/snowflakes.h
|
ui/effects/snowflakes.h
|
||||||
|
ui/effects/toggle_arrow.cpp
|
||||||
|
ui/effects/toggle_arrow.h
|
||||||
ui/text/format_song_name.cpp
|
ui/text/format_song_name.cpp
|
||||||
ui/text/format_song_name.h
|
ui/text/format_song_name.h
|
||||||
ui/text/format_values.cpp
|
ui/text/format_values.cpp
|
||||||
|
|
Loading…
Reference in New Issue