init
Some checks failed
Docker. / Ubuntu (push) Has been cancelled
User-agent updater. / User-agent (push) Failing after 15s
Lock Threads / lock (push) Failing after 10s
Waiting for answer. / waiting-for-answer (push) Failing after 22s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
Close stale issues and PRs / stale (push) Has been cancelled
Some checks failed
Docker. / Ubuntu (push) Has been cancelled
User-agent updater. / User-agent (push) Failing after 15s
Lock Threads / lock (push) Failing after 10s
Waiting for answer. / waiting-for-answer (push) Failing after 22s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
Close stale issues and PRs / stale (push) Has been cancelled
This commit is contained in:
73
Telegram/SourceFiles/ui/controls/button_labels.cpp
Normal file
73
Telegram/SourceFiles/ui/controls/button_labels.cpp
Normal file
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
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/controls/button_labels.h"
|
||||
|
||||
#include "ui/widgets/buttons.h"
|
||||
#include "ui/widgets/labels.h"
|
||||
|
||||
namespace Ui {
|
||||
|
||||
void SetButtonTwoLabels(
|
||||
not_null<Ui::RoundButton*> button,
|
||||
rpl::producer<TextWithEntities> title,
|
||||
rpl::producer<TextWithEntities> subtitle,
|
||||
const style::FlatLabel &st,
|
||||
const style::FlatLabel &subst,
|
||||
const style::color *textFg) {
|
||||
const auto buttonTitle = Ui::CreateChild<Ui::FlatLabel>(
|
||||
button,
|
||||
std::move(title),
|
||||
st);
|
||||
buttonTitle->show();
|
||||
const auto buttonSubtitle = Ui::CreateChild<Ui::FlatLabel>(
|
||||
button,
|
||||
rpl::duplicate(
|
||||
subtitle
|
||||
) | rpl::filter([](const TextWithEntities &text) {
|
||||
return !text.empty();
|
||||
}),
|
||||
subst);
|
||||
buttonSubtitle->setOpacity(0.6);
|
||||
if (textFg) {
|
||||
buttonTitle->setTextColorOverride((*textFg)->c);
|
||||
buttonSubtitle->setTextColorOverride((*textFg)->c);
|
||||
style::PaletteChanged() | rpl::on_next([=] {
|
||||
buttonTitle->setTextColorOverride((*textFg)->c);
|
||||
buttonSubtitle->setTextColorOverride((*textFg)->c);
|
||||
}, buttonTitle->lifetime());
|
||||
}
|
||||
rpl::combine(
|
||||
button->sizeValue(),
|
||||
buttonTitle->sizeValue(),
|
||||
buttonSubtitle->sizeValue(),
|
||||
std::move(subtitle)
|
||||
) | rpl::on_next([=](
|
||||
QSize outer,
|
||||
QSize title,
|
||||
QSize subtitle,
|
||||
const TextWithEntities &subtitleText) {
|
||||
const auto withSubtitle = !subtitleText.empty();
|
||||
buttonSubtitle->setVisible(withSubtitle);
|
||||
|
||||
const auto two = title.height() + subtitle.height();
|
||||
const auto titleTop = withSubtitle
|
||||
? (outer.height() - two) / 2
|
||||
: button->st().textTop;
|
||||
const auto subtitleTop = titleTop + title.height();
|
||||
buttonTitle->moveToLeft(
|
||||
(outer.width() - title.width()) / 2,
|
||||
titleTop);
|
||||
buttonSubtitle->moveToLeft(
|
||||
(outer.width() - subtitle.width()) / 2,
|
||||
subtitleTop);
|
||||
}, buttonTitle->lifetime());
|
||||
buttonTitle->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||
buttonSubtitle->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||
}
|
||||
|
||||
} // namespace Ui
|
||||
Reference in New Issue
Block a user