Custom colors in historyDown/unreadMentions buttons.

This commit is contained in:
John Preston 2021-09-03 18:51:48 +03:00
parent 64457cd6cb
commit 241798ac29
10 changed files with 90 additions and 34 deletions

View file

@ -803,7 +803,8 @@ void ReplyKeyboard::Style::paintButton(
const QRect &rect = button.rect; const QRect &rect = button.rect;
paintButtonBg(p, st, rect, button.howMuchOver); paintButtonBg(p, st, rect, button.howMuchOver);
if (button.ripple) { if (button.ripple) {
button.ripple->paint(p, rect.x(), rect.y(), outerWidth); const auto color = st ? &st->msgBotKbRippleBg()->c : nullptr;
button.ripple->paint(p, rect.x(), rect.y(), outerWidth, color);
if (button.ripple->empty()) { if (button.ripple->empty()) {
button.ripple.reset(); button.ripple.reset();
} }

View file

@ -180,6 +180,11 @@ const auto kPsaAboutPrefix = "cloud_lng_about_psa_";
} // namespace } // namespace
struct HistoryWidget::CustomStyles {
style::TwoIconButton historyToDown;
style::TwoIconButton historyUnreadMentions;
};
HistoryWidget::HistoryWidget( HistoryWidget::HistoryWidget(
QWidget *parent, QWidget *parent,
not_null<Window::SessionController*> controller) not_null<Window::SessionController*> controller)
@ -187,6 +192,7 @@ HistoryWidget::HistoryWidget(
parent, parent,
controller, controller,
ActivePeerValue(controller)) ActivePeerValue(controller))
, _styles(MakeCustomStyles(controller))
, _api(&controller->session().mtp()) , _api(&controller->session().mtp())
, _updateEditTimeLeftDisplay([=] { updateField(); }) , _updateEditTimeLeftDisplay([=] { updateField(); })
, _fieldBarCancel(this, st::historyReplyCancel) , _fieldBarCancel(this, st::historyReplyCancel)
@ -195,8 +201,8 @@ HistoryWidget::HistoryWidget(
, _topBar(this, controller) , _topBar(this, controller)
, _scroll(this, st::historyScroll, false) , _scroll(this, st::historyScroll, false)
, _updateHistoryItems([=] { updateHistoryItemsByTimer(); }) , _updateHistoryItems([=] { updateHistoryItemsByTimer(); })
, _historyDown(_scroll, st::historyToDown) , _historyDown(_scroll, _styles->historyToDown)
, _unreadMentions(_scroll, st::historyUnreadMentions) , _unreadMentions(_scroll, _styles->historyUnreadMentions)
, _fieldAutocomplete(this, controller) , _fieldAutocomplete(this, controller)
, _supportAutocomplete(session().supportMode() , _supportAutocomplete(session().supportMode()
? object_ptr<Support::Autocomplete>(this, &session()) ? object_ptr<Support::Autocomplete>(this, &session())
@ -3984,6 +3990,17 @@ bool HistoryWidget::kbWasHidden() const {
return _history && (_keyboard->forMsgId() == FullMsgId(_history->channelId(), _history->lastKeyboardHiddenId)); return _history && (_keyboard->forMsgId() == FullMsgId(_history->channelId(), _history->lastKeyboardHiddenId));
} }
auto HistoryWidget::MakeCustomStyles(
not_null<Window::SessionController*> controller)
-> std::unique_ptr<CustomStyles> {
const auto st = controller->chatStyle();
auto result = std::make_unique<CustomStyles>();
result->historyToDown = st->value(st::historyToDown);
result->historyUnreadMentions = st->value(st::historyUnreadMentions);
return result;
}
void HistoryWidget::toggleKeyboard(bool manual) { void HistoryWidget::toggleKeyboard(bool manual) {
auto fieldEnabled = canWriteMessage() && !_a_show.animating(); auto fieldEnabled = canWriteMessage() && !_a_show.animating();
if (_kbShown || _kbReplyTo) { if (_kbShown || _kbReplyTo) {

View file

@ -300,6 +300,7 @@ protected:
private: private:
using TabbedPanel = ChatHelpers::TabbedPanel; using TabbedPanel = ChatHelpers::TabbedPanel;
using TabbedSelector = ChatHelpers::TabbedSelector; using TabbedSelector = ChatHelpers::TabbedSelector;
struct CustomStyles;
enum ScrollChangeType { enum ScrollChangeType {
ScrollChangeNone, ScrollChangeNone,
@ -603,6 +604,11 @@ private:
bool kbWasHidden() const; bool kbWasHidden() const;
[[nodiscard]] static std::unique_ptr<CustomStyles> MakeCustomStyles(
not_null<Window::SessionController*> controller);
const std::unique_ptr<CustomStyles> _styles;
MTP::Sender _api; MTP::Sender _api;
MsgId _replyToId = 0; MsgId _replyToId = 0;
Ui::Text::String _replyToName; Ui::Text::String _replyToName;

View file

@ -727,7 +727,8 @@ void Message::paintCommentsButton(
if (_comments->ripple) { if (_comments->ripple) {
p.setOpacity(st::historyPollRippleOpacity); p.setOpacity(st::historyPollRippleOpacity);
_comments->ripple->paint(p, left, top, width); const auto colorOverride = &stm->msgWaveformInactive->c;
_comments->ripple->paint(p, left, top, width, colorOverride);
if (_comments->ripple->empty()) { if (_comments->ripple->empty()) {
_comments->ripple.reset(); _comments->ripple.reset();
} }
@ -1098,9 +1099,7 @@ void Message::toggleCommentsButtonRipple(bool pressed) {
false, false,
drawMask); drawMask);
_comments->ripple = std::make_unique<Ui::RippleAnimation>( _comments->ripple = std::make_unique<Ui::RippleAnimation>(
(hasOutLayout() st::defaultRippleAnimation,
? st::historyPollRippleOut
: st::historyPollRippleIn),
std::move(mask), std::move(mask),
[=] { history()->owner().requestViewRepaint(this); }); [=] { history()->owner().requestViewRepaint(this); });
} }

View file

@ -806,7 +806,9 @@ void Poll::paintBottom(
int top, int top,
int paintw, int paintw,
const PaintContext &context) const { const PaintContext &context) const {
const auto stringtop = top + st::msgPadding.bottom() + st::historyPollBottomButtonTop; const auto stringtop = top
+ st::msgPadding.bottom()
+ st::historyPollBottomButtonTop;
const auto stm = context.messageStyle(); const auto stm = context.messageStyle();
if (showVotersCount()) { if (showVotersCount()) {
p.setPen(stm->msgDateFg); p.setPen(stm->msgDateFg);
@ -820,7 +822,12 @@ void Poll::paintBottom(
if (_linkRipple) { if (_linkRipple) {
const auto linkHeight = bottomButtonHeight(); const auto linkHeight = bottomButtonHeight();
p.setOpacity(st::historyPollRippleOpacity); p.setOpacity(st::historyPollRippleOpacity);
_linkRipple->paint(p, left - st::msgPadding.left(), height() - linkHeight, width()); _linkRipple->paint(
p,
left - st::msgPadding.left(),
height() - linkHeight,
width(),
&stm->msgWaveformInactive->c);
if (_linkRipple->empty()) { if (_linkRipple->empty()) {
_linkRipple.reset(); _linkRipple.reset();
} }
@ -832,7 +839,12 @@ void Poll::paintBottom(
? tr::lng_polls_view_results(tr::now, Ui::Text::Upper) ? tr::lng_polls_view_results(tr::now, Ui::Text::Upper)
: tr::lng_polls_submit_votes(tr::now, Ui::Text::Upper); : tr::lng_polls_submit_votes(tr::now, Ui::Text::Upper);
const auto stringw = st::semiboldFont->width(string); const auto stringw = st::semiboldFont->width(string);
p.drawTextLeft(left + (paintw - stringw) / 2, stringtop, width(), string, stringw); p.drawTextLeft(
left + (paintw - stringw) / 2,
stringtop,
width(),
string,
stringw);
} }
} }
@ -1018,7 +1030,12 @@ int Poll::paintAnswer(
if (answer.ripple) { if (answer.ripple) {
p.setOpacity(st::historyPollRippleOpacity); p.setOpacity(st::historyPollRippleOpacity);
answer.ripple->paint(p, left - st::msgPadding.left(), top, outerWidth); answer.ripple->paint(
p,
left - st::msgPadding.left(),
top,
outerWidth,
&stm->msgWaveformInactive->c);
if (answer.ripple->empty()) { if (answer.ripple->empty()) {
answer.ripple.reset(); answer.ripple.reset();
} }
@ -1445,9 +1462,7 @@ void Poll::toggleRipple(Answer &answer, bool pressed) {
outerWidth, outerWidth,
countAnswerHeight(answer, innerWidth))); countAnswerHeight(answer, innerWidth)));
answer.ripple = std::make_unique<Ui::RippleAnimation>( answer.ripple = std::make_unique<Ui::RippleAnimation>(
(_parent->hasOutLayout() st::defaultRippleAnimation,
? st::historyPollRippleOut
: st::historyPollRippleIn),
std::move(mask), std::move(mask),
[=] { history()->owner().requestViewRepaint(_parent); }); [=] { history()->owner().requestViewRepaint(_parent); });
} }
@ -1510,9 +1525,7 @@ void Poll::toggleLinkRipple(bool pressed) {
drawMask) drawMask)
: Ui::RippleAnimation::rectMask({ linkWidth, linkHeight }); : Ui::RippleAnimation::rectMask({ linkWidth, linkHeight });
_linkRipple = std::make_unique<Ui::RippleAnimation>( _linkRipple = std::make_unique<Ui::RippleAnimation>(
(_parent->hasOutLayout() st::defaultRippleAnimation,
? st::historyPollRippleOut
: st::historyPollRippleIn),
std::move(mask), std::move(mask),
[=] { history()->owner().requestViewRepaint(_parent); }); [=] { history()->owner().requestViewRepaint(_parent); });
} }

View file

@ -461,9 +461,7 @@ msgBotKbButton: BotKeyboardButton {
padding: 10px; padding: 10px;
height: 36px; height: 36px;
textTop: 8px; textTop: 8px;
ripple: RippleAnimation(defaultRippleAnimation) { ripple: defaultRippleAnimation;
color: msgBotKbRippleBg;
}
} }
botKbDuration: 200; botKbDuration: 200;
@ -738,12 +736,6 @@ historyPollRadialAnimation: InfiniteRadialAnimation(defaultInfiniteRadialAnimati
thickness: 2px; thickness: 2px;
size: size(18px, 18px); size: size(18px, 18px);
} }
historyPollRippleIn: RippleAnimation(defaultRippleAnimation) {
color: msgWaveformInInactive;
}
historyPollRippleOut: RippleAnimation(defaultRippleAnimation) {
color: msgWaveformOutInactive;
}
historyPollRippleOpacity: 0.3; historyPollRippleOpacity: 0.3;
historyPollRecentVotersSkip: 4px; historyPollRecentVotersSkip: 4px;
historyPollRecentVoterSize: 18px; historyPollRecentVoterSize: 18px;

View file

@ -12,6 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/ui_utility.h" #include "ui/ui_utility.h"
#include "styles/style_chat.h" #include "styles/style_chat.h"
#include "styles/style_dialogs.h" #include "styles/style_dialogs.h"
#include "styles/style_widgets.h"
namespace Ui { namespace Ui {
namespace { namespace {
@ -596,17 +597,17 @@ MessageImageStyle &ChatStyle::imageSelected() {
return imageStyleRaw(true); return imageStyleRaw(true);
} }
void ChatStyle::make(style::color &my, const style::color &original) { void ChatStyle::make(style::color &my, const style::color &original) const {
my = _colors[style::main_palette::indexOfColor(original)]; my = _colors[style::main_palette::indexOfColor(original)];
} }
void ChatStyle::make(style::icon &my, const style::icon &original) { void ChatStyle::make(style::icon &my, const style::icon &original) const {
my = original.withPalette(*this); my = original.withPalette(*this);
} }
void ChatStyle::make( void ChatStyle::make(
style::TextPalette &my, style::TextPalette &my,
const style::TextPalette &original) { const style::TextPalette &original) const {
make(my.linkFg, original.linkFg); make(my.linkFg, original.linkFg);
make(my.monoFg, original.monoFg); make(my.monoFg, original.monoFg);
make(my.selectBg, original.selectBg); make(my.selectBg, original.selectBg);
@ -616,6 +617,17 @@ void ChatStyle::make(
make(my.selectOverlay, original.selectOverlay); make(my.selectOverlay, original.selectOverlay);
} }
void ChatStyle::make(
style::TwoIconButton &my,
const style::TwoIconButton &original) const {
my = original;
make(my.iconBelow, original.iconBelow);
make(my.iconAbove, original.iconAbove);
make(my.iconBelowOver, original.iconBelowOver);
make(my.iconAboveOver, original.iconAboveOver);
make(my.ripple.color, original.ripple.color);
}
template <typename Type> template <typename Type>
void ChatStyle::make( void ChatStyle::make(
Type MessageStyle::*my, Type MessageStyle::*my,

View file

@ -13,6 +13,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
enum class ImageRoundRadius; enum class ImageRoundRadius;
namespace style {
struct TwoIconButton;
} // namespace style
namespace Ui { namespace Ui {
class ChatTheme; class ChatTheme;
@ -136,6 +140,13 @@ public:
void apply(not_null<ChatTheme*> theme); void apply(not_null<ChatTheme*> theme);
template <typename Type>
[[nodiscard]] Type value(const Type &original) const {
auto my = Type();
make(my, original);
return my;
}
[[nodiscard]] const CornersPixmaps &serviceBgCornersNormal() const; [[nodiscard]] const CornersPixmaps &serviceBgCornersNormal() const;
[[nodiscard]] const CornersPixmaps &serviceBgCornersInverted() const; [[nodiscard]] const CornersPixmaps &serviceBgCornersInverted() const;
@ -224,9 +235,14 @@ public:
private: private:
void assignPalette(not_null<const style::palette*> palette); void assignPalette(not_null<const style::palette*> palette);
void make(style::color &my, const style::color &original); void make(style::color &my, const style::color &original) const;
void make(style::icon &my, const style::icon &original); void make(style::icon &my, const style::icon &original) const;
void make(style::TextPalette &my, const style::TextPalette &original); void make(
style::TextPalette &my,
const style::TextPalette &original) const;
void make(
style::TwoIconButton &my,
const style::TwoIconButton &original) const;
[[nodiscard]] MessageStyle &messageStyleRaw( [[nodiscard]] MessageStyle &messageStyleRaw(
bool outbg, bool outbg,

@ -1 +1 @@
Subproject commit aaa64e67cb247112dad396fd75f8ef3c1849aed3 Subproject commit b1c206550eeba4bac6f4f5a1699a6b199f7af4ac

@ -1 +1 @@
Subproject commit 1180d13a5c654b517901d6bdab030f17ff314ff6 Subproject commit a8ce22fd75d8f53449aae6319d5503f7e8967f5e