mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 14:17:12 +02:00
Custom colors in historyDown/unreadMentions buttons.
This commit is contained in:
parent
64457cd6cb
commit
241798ac29
10 changed files with 90 additions and 34 deletions
|
@ -803,7 +803,8 @@ void ReplyKeyboard::Style::paintButton(
|
|||
const QRect &rect = button.rect;
|
||||
paintButtonBg(p, st, rect, button.howMuchOver);
|
||||
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()) {
|
||||
button.ripple.reset();
|
||||
}
|
||||
|
|
|
@ -180,6 +180,11 @@ const auto kPsaAboutPrefix = "cloud_lng_about_psa_";
|
|||
|
||||
} // namespace
|
||||
|
||||
struct HistoryWidget::CustomStyles {
|
||||
style::TwoIconButton historyToDown;
|
||||
style::TwoIconButton historyUnreadMentions;
|
||||
};
|
||||
|
||||
HistoryWidget::HistoryWidget(
|
||||
QWidget *parent,
|
||||
not_null<Window::SessionController*> controller)
|
||||
|
@ -187,6 +192,7 @@ HistoryWidget::HistoryWidget(
|
|||
parent,
|
||||
controller,
|
||||
ActivePeerValue(controller))
|
||||
, _styles(MakeCustomStyles(controller))
|
||||
, _api(&controller->session().mtp())
|
||||
, _updateEditTimeLeftDisplay([=] { updateField(); })
|
||||
, _fieldBarCancel(this, st::historyReplyCancel)
|
||||
|
@ -195,8 +201,8 @@ HistoryWidget::HistoryWidget(
|
|||
, _topBar(this, controller)
|
||||
, _scroll(this, st::historyScroll, false)
|
||||
, _updateHistoryItems([=] { updateHistoryItemsByTimer(); })
|
||||
, _historyDown(_scroll, st::historyToDown)
|
||||
, _unreadMentions(_scroll, st::historyUnreadMentions)
|
||||
, _historyDown(_scroll, _styles->historyToDown)
|
||||
, _unreadMentions(_scroll, _styles->historyUnreadMentions)
|
||||
, _fieldAutocomplete(this, controller)
|
||||
, _supportAutocomplete(session().supportMode()
|
||||
? object_ptr<Support::Autocomplete>(this, &session())
|
||||
|
@ -3984,6 +3990,17 @@ bool HistoryWidget::kbWasHidden() const {
|
|||
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) {
|
||||
auto fieldEnabled = canWriteMessage() && !_a_show.animating();
|
||||
if (_kbShown || _kbReplyTo) {
|
||||
|
|
|
@ -300,6 +300,7 @@ protected:
|
|||
private:
|
||||
using TabbedPanel = ChatHelpers::TabbedPanel;
|
||||
using TabbedSelector = ChatHelpers::TabbedSelector;
|
||||
struct CustomStyles;
|
||||
enum ScrollChangeType {
|
||||
ScrollChangeNone,
|
||||
|
||||
|
@ -603,6 +604,11 @@ private:
|
|||
|
||||
bool kbWasHidden() const;
|
||||
|
||||
[[nodiscard]] static std::unique_ptr<CustomStyles> MakeCustomStyles(
|
||||
not_null<Window::SessionController*> controller);
|
||||
|
||||
const std::unique_ptr<CustomStyles> _styles;
|
||||
|
||||
MTP::Sender _api;
|
||||
MsgId _replyToId = 0;
|
||||
Ui::Text::String _replyToName;
|
||||
|
|
|
@ -727,7 +727,8 @@ void Message::paintCommentsButton(
|
|||
|
||||
if (_comments->ripple) {
|
||||
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()) {
|
||||
_comments->ripple.reset();
|
||||
}
|
||||
|
@ -1098,9 +1099,7 @@ void Message::toggleCommentsButtonRipple(bool pressed) {
|
|||
false,
|
||||
drawMask);
|
||||
_comments->ripple = std::make_unique<Ui::RippleAnimation>(
|
||||
(hasOutLayout()
|
||||
? st::historyPollRippleOut
|
||||
: st::historyPollRippleIn),
|
||||
st::defaultRippleAnimation,
|
||||
std::move(mask),
|
||||
[=] { history()->owner().requestViewRepaint(this); });
|
||||
}
|
||||
|
|
|
@ -806,7 +806,9 @@ void Poll::paintBottom(
|
|||
int top,
|
||||
int paintw,
|
||||
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();
|
||||
if (showVotersCount()) {
|
||||
p.setPen(stm->msgDateFg);
|
||||
|
@ -820,7 +822,12 @@ void Poll::paintBottom(
|
|||
if (_linkRipple) {
|
||||
const auto linkHeight = bottomButtonHeight();
|
||||
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()) {
|
||||
_linkRipple.reset();
|
||||
}
|
||||
|
@ -832,7 +839,12 @@ void Poll::paintBottom(
|
|||
? tr::lng_polls_view_results(tr::now, Ui::Text::Upper)
|
||||
: tr::lng_polls_submit_votes(tr::now, Ui::Text::Upper);
|
||||
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) {
|
||||
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()) {
|
||||
answer.ripple.reset();
|
||||
}
|
||||
|
@ -1445,9 +1462,7 @@ void Poll::toggleRipple(Answer &answer, bool pressed) {
|
|||
outerWidth,
|
||||
countAnswerHeight(answer, innerWidth)));
|
||||
answer.ripple = std::make_unique<Ui::RippleAnimation>(
|
||||
(_parent->hasOutLayout()
|
||||
? st::historyPollRippleOut
|
||||
: st::historyPollRippleIn),
|
||||
st::defaultRippleAnimation,
|
||||
std::move(mask),
|
||||
[=] { history()->owner().requestViewRepaint(_parent); });
|
||||
}
|
||||
|
@ -1510,9 +1525,7 @@ void Poll::toggleLinkRipple(bool pressed) {
|
|||
drawMask)
|
||||
: Ui::RippleAnimation::rectMask({ linkWidth, linkHeight });
|
||||
_linkRipple = std::make_unique<Ui::RippleAnimation>(
|
||||
(_parent->hasOutLayout()
|
||||
? st::historyPollRippleOut
|
||||
: st::historyPollRippleIn),
|
||||
st::defaultRippleAnimation,
|
||||
std::move(mask),
|
||||
[=] { history()->owner().requestViewRepaint(_parent); });
|
||||
}
|
||||
|
|
|
@ -461,9 +461,7 @@ msgBotKbButton: BotKeyboardButton {
|
|||
padding: 10px;
|
||||
height: 36px;
|
||||
textTop: 8px;
|
||||
ripple: RippleAnimation(defaultRippleAnimation) {
|
||||
color: msgBotKbRippleBg;
|
||||
}
|
||||
ripple: defaultRippleAnimation;
|
||||
}
|
||||
|
||||
botKbDuration: 200;
|
||||
|
@ -738,12 +736,6 @@ historyPollRadialAnimation: InfiniteRadialAnimation(defaultInfiniteRadialAnimati
|
|||
thickness: 2px;
|
||||
size: size(18px, 18px);
|
||||
}
|
||||
historyPollRippleIn: RippleAnimation(defaultRippleAnimation) {
|
||||
color: msgWaveformInInactive;
|
||||
}
|
||||
historyPollRippleOut: RippleAnimation(defaultRippleAnimation) {
|
||||
color: msgWaveformOutInactive;
|
||||
}
|
||||
historyPollRippleOpacity: 0.3;
|
||||
historyPollRecentVotersSkip: 4px;
|
||||
historyPollRecentVoterSize: 18px;
|
||||
|
|
|
@ -12,6 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "ui/ui_utility.h"
|
||||
#include "styles/style_chat.h"
|
||||
#include "styles/style_dialogs.h"
|
||||
#include "styles/style_widgets.h"
|
||||
|
||||
namespace Ui {
|
||||
namespace {
|
||||
|
@ -596,17 +597,17 @@ MessageImageStyle &ChatStyle::imageSelected() {
|
|||
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)];
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
void ChatStyle::make(
|
||||
style::TextPalette &my,
|
||||
const style::TextPalette &original) {
|
||||
const style::TextPalette &original) const {
|
||||
make(my.linkFg, original.linkFg);
|
||||
make(my.monoFg, original.monoFg);
|
||||
make(my.selectBg, original.selectBg);
|
||||
|
@ -616,6 +617,17 @@ void ChatStyle::make(
|
|||
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>
|
||||
void ChatStyle::make(
|
||||
Type MessageStyle::*my,
|
||||
|
|
|
@ -13,6 +13,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
|
||||
enum class ImageRoundRadius;
|
||||
|
||||
namespace style {
|
||||
struct TwoIconButton;
|
||||
} // namespace style
|
||||
|
||||
namespace Ui {
|
||||
|
||||
class ChatTheme;
|
||||
|
@ -136,6 +140,13 @@ public:
|
|||
|
||||
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 &serviceBgCornersInverted() const;
|
||||
|
||||
|
@ -224,9 +235,14 @@ public:
|
|||
private:
|
||||
void assignPalette(not_null<const style::palette*> palette);
|
||||
|
||||
void make(style::color &my, const style::color &original);
|
||||
void make(style::icon &my, const style::icon &original);
|
||||
void make(style::TextPalette &my, const style::TextPalette &original);
|
||||
void make(style::color &my, const style::color &original) const;
|
||||
void make(style::icon &my, const style::icon &original) const;
|
||||
void make(
|
||||
style::TextPalette &my,
|
||||
const style::TextPalette &original) const;
|
||||
void make(
|
||||
style::TwoIconButton &my,
|
||||
const style::TwoIconButton &original) const;
|
||||
|
||||
[[nodiscard]] MessageStyle &messageStyleRaw(
|
||||
bool outbg,
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit aaa64e67cb247112dad396fd75f8ef3c1849aed3
|
||||
Subproject commit b1c206550eeba4bac6f4f5a1699a6b199f7af4ac
|
|
@ -1 +1 @@
|
|||
Subproject commit 1180d13a5c654b517901d6bdab030f17ff314ff6
|
||||
Subproject commit a8ce22fd75d8f53449aae6319d5503f7e8967f5e
|
Loading…
Add table
Reference in a new issue