[Visual] Custom theming (currently for top bar only)
This commit is contained in:
parent
8314fab81f
commit
c1dff6caa4
3 changed files with 101 additions and 28 deletions
|
|
@ -36,6 +36,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/boxes/report_box.h" // Ui::ReportReason
|
#include "ui/boxes/report_box.h" // Ui::ReportReason
|
||||||
#include "ui/text/text.h"
|
#include "ui/text/text.h"
|
||||||
#include "ui/text/text_options.h"
|
#include "ui/text/text_options.h"
|
||||||
|
#include "ui/text/text_options.h"
|
||||||
#include "ui/painter.h"
|
#include "ui/painter.h"
|
||||||
#include "ui/unread_badge.h"
|
#include "ui/unread_badge.h"
|
||||||
#include "ui/ui_utility.h"
|
#include "ui/ui_utility.h"
|
||||||
|
|
@ -94,17 +95,17 @@ TopBarWidget::TopBarWidget(
|
||||||
: RpWidget(parent)
|
: RpWidget(parent)
|
||||||
, _controller(controller)
|
, _controller(controller)
|
||||||
, _primaryWindow(controller->isPrimary())
|
, _primaryWindow(controller->isPrimary())
|
||||||
, _clear(this, tr::lng_selected_clear(), st::topBarClearButton)
|
, _clear(this, tr::lng_selected_clear(), st::ktgTopBarClearButton)
|
||||||
, _forward(this, tr::lng_selected_forward(), st::defaultActiveButton)
|
, _forward(this, tr::lng_selected_forward(), st::ktgTopBarActiveButton)
|
||||||
, _sendNow(this, tr::lng_selected_send_now(), st::defaultActiveButton)
|
, _sendNow(this, tr::lng_selected_send_now(), st::ktgTopBarActiveButton)
|
||||||
, _delete(this, tr::lng_selected_delete(), st::defaultActiveButton)
|
, _delete(this, tr::lng_selected_delete(), st::ktgTopBarActiveButton)
|
||||||
, _back(this, st::historyTopBarBack)
|
, _back(this, st::ktgHistoryTopBarBack)
|
||||||
, _cancelChoose(this, st::topBarCloseChoose)
|
, _cancelChoose(this, st::topBarCloseChoose)
|
||||||
, _call(this, st::topBarCall)
|
, _call(this, st::ktgTopBarCall)
|
||||||
, _groupCall(this, st::topBarGroupCall)
|
, _groupCall(this, st::topBarGroupCall)
|
||||||
, _search(this, st::topBarSearch)
|
, _search(this, st::ktgTopBarSearch)
|
||||||
, _infoToggle(this, st::topBarInfo)
|
, _infoToggle(this, st::ktgTopBarInfo)
|
||||||
, _menuToggle(this, st::topBarMenuToggle)
|
, _menuToggle(this, st::ktgTopBarMenuToggle)
|
||||||
, _titlePeerText(st::windowMinWidth / 3)
|
, _titlePeerText(st::windowMinWidth / 3)
|
||||||
, _onlineUpdater([=] { updateOnlineDisplay(); }) {
|
, _onlineUpdater([=] { updateOnlineDisplay(); }) {
|
||||||
setAttribute(Qt::WA_OpaquePaintEvent);
|
setAttribute(Qt::WA_OpaquePaintEvent);
|
||||||
|
|
@ -429,7 +430,7 @@ void TopBarWidget::paintEvent(QPaintEvent *e) {
|
||||||
: -st::topBarHeight;
|
: -st::topBarHeight;
|
||||||
const auto slidingTop = std::max(selectedButtonsTop, searchFieldTop);
|
const auto slidingTop = std::max(selectedButtonsTop, searchFieldTop);
|
||||||
|
|
||||||
p.fillRect(QRect(0, 0, width(), st::topBarHeight), st::topBarBg);
|
p.fillRect(QRect(0, 0, width(), st::topBarHeight), st::ktgTopBarBg);
|
||||||
if (slidingTop < 0) {
|
if (slidingTop < 0) {
|
||||||
p.translate(0, slidingTop + st::topBarHeight);
|
p.translate(0, slidingTop + st::topBarHeight);
|
||||||
paintTopBar(p);
|
paintTopBar(p);
|
||||||
|
|
@ -517,7 +518,7 @@ void TopBarWidget::paintTopBar(Painter &p) {
|
||||||
if (availableWidth < textWidth) {
|
if (availableWidth < textWidth) {
|
||||||
text = st::historySavedFont->elided(text, availableWidth);
|
text = st::historySavedFont->elided(text, availableWidth);
|
||||||
}
|
}
|
||||||
p.setPen(st::dialogsNameFg);
|
p.setPen(st::ktgTopBarNameFg);
|
||||||
p.setFont(st::historySavedFont);
|
p.setFont(st::historySavedFont);
|
||||||
p.drawTextLeft(
|
p.drawTextLeft(
|
||||||
nameleft,
|
nameleft,
|
||||||
|
|
@ -527,7 +528,7 @@ void TopBarWidget::paintTopBar(Painter &p) {
|
||||||
} else if (_activeChat.section == Section::Replies
|
} else if (_activeChat.section == Section::Replies
|
||||||
|| _activeChat.section == Section::Scheduled
|
|| _activeChat.section == Section::Scheduled
|
||||||
|| _activeChat.section == Section::Pinned) {
|
|| _activeChat.section == Section::Pinned) {
|
||||||
p.setPen(st::dialogsNameFg);
|
p.setPen(st::ktgTopBarNameFg);
|
||||||
|
|
||||||
Ui::Text::String textStr;
|
Ui::Text::String textStr;
|
||||||
textStr.setText(
|
textStr.setText(
|
||||||
|
|
@ -536,7 +537,7 @@ void TopBarWidget::paintTopBar(Painter &p) {
|
||||||
? tr::lng_manage_discussion_group(tr::now)
|
? tr::lng_manage_discussion_group(tr::now)
|
||||||
: history->peer->isSelf()
|
: history->peer->isSelf()
|
||||||
? tr::lng_saved_messages(tr::now)
|
? tr::lng_saved_messages(tr::now)
|
||||||
: history->peer->topBarNameText().toString()),
|
: history->peer->topBarNameText()),
|
||||||
Ui::NameTextOptions());
|
Ui::NameTextOptions());
|
||||||
textStr.drawElided(p, nameleft, nametop, width());
|
textStr.drawElided(p, nameleft, nametop, width());
|
||||||
|
|
||||||
|
|
@ -549,9 +550,9 @@ void TopBarWidget::paintTopBar(Painter &p) {
|
||||||
statustop,
|
statustop,
|
||||||
availableWidth,
|
availableWidth,
|
||||||
width(),
|
width(),
|
||||||
st::historyStatusFgTyping,
|
st::ktgTopBarStatusFgActive,
|
||||||
now))) {
|
now))) {
|
||||||
p.setPen(st::historyStatusFg);
|
p.setPen(st::ktgTopBarStatusFg);
|
||||||
p.drawTextLeft(nameleft, statustop, width(), _customTitleText);
|
p.drawTextLeft(nameleft, statustop, width(), _customTitleText);
|
||||||
}
|
}
|
||||||
} else if (const auto history = _activeChat.key.history()) {
|
} else if (const auto history = _activeChat.key.history()) {
|
||||||
|
|
@ -585,7 +586,7 @@ void TopBarWidget::paintTopBar(Painter &p) {
|
||||||
});
|
});
|
||||||
const auto namewidth = availableWidth - badgeWidth;
|
const auto namewidth = availableWidth - badgeWidth;
|
||||||
|
|
||||||
p.setPen(st::dialogsNameFg);
|
p.setPen(st::ktgTopBarNameFg);
|
||||||
_title.drawElided(
|
_title.drawElided(
|
||||||
p,
|
p,
|
||||||
nameleft,
|
nameleft,
|
||||||
|
|
@ -600,7 +601,7 @@ void TopBarWidget::paintTopBar(Painter &p) {
|
||||||
statustop,
|
statustop,
|
||||||
availableWidth,
|
availableWidth,
|
||||||
width(),
|
width(),
|
||||||
st::historyStatusFgTyping,
|
st::ktgTopBarStatusFgActive,
|
||||||
now)) {
|
now)) {
|
||||||
paintStatus(p, nameleft, statustop, availableWidth, width());
|
paintStatus(p, nameleft, statustop, availableWidth, width());
|
||||||
}
|
}
|
||||||
|
|
@ -654,7 +655,7 @@ bool TopBarWidget::paintConnectingState(
|
||||||
left += st::topBarConnectingPosition.x()
|
left += st::topBarConnectingPosition.x()
|
||||||
+ st::topBarConnectingAnimation.size.width()
|
+ st::topBarConnectingAnimation.size.width()
|
||||||
+ st::topBarConnectingSkip;
|
+ st::topBarConnectingSkip;
|
||||||
p.setPen(st::historyStatusFg);
|
p.setPen(st::ktgTopBarStatusFg);
|
||||||
p.drawTextLeft(left, top, outerWidth, tr::lng_status_connecting(tr::now));
|
p.drawTextLeft(left, top, outerWidth, tr::lng_status_connecting(tr::now));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -666,8 +667,8 @@ void TopBarWidget::paintStatus(
|
||||||
int availableWidth,
|
int availableWidth,
|
||||||
int outerWidth) {
|
int outerWidth) {
|
||||||
p.setPen(_titlePeerTextOnline
|
p.setPen(_titlePeerTextOnline
|
||||||
? st::historyStatusFgActive
|
? st::ktgTopBarStatusFgActive
|
||||||
: st::historyStatusFg);
|
: st::ktgTopBarStatusFg);
|
||||||
_titlePeerText.drawLeftElided(p, left, top, availableWidth, outerWidth);
|
_titlePeerText.drawLeftElided(p, left, top, availableWidth, outerWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1475,10 +1476,10 @@ void TopBarWidget::updateInfoToggleActive() {
|
||||||
&& (Core::App().settings().thirdSectionInfoEnabled()
|
&& (Core::App().settings().thirdSectionInfoEnabled()
|
||||||
|| Core::App().settings().tabbedReplacedWithInfo());
|
|| Core::App().settings().tabbedReplacedWithInfo());
|
||||||
auto iconOverride = infoThirdActive
|
auto iconOverride = infoThirdActive
|
||||||
? &st::topBarInfoActive
|
? &st::ktgTopBarInfoActive
|
||||||
: nullptr;
|
: nullptr;
|
||||||
auto rippleOverride = infoThirdActive
|
auto rippleOverride = infoThirdActive
|
||||||
? &st::lightButtonBgOver
|
? &st::ktgTopBarIconBgActiveRipple
|
||||||
: nullptr;
|
: nullptr;
|
||||||
_infoToggle->setIconOverride(iconOverride, iconOverride);
|
_infoToggle->setIconOverride(iconOverride, iconOverride);
|
||||||
_infoToggle->setRippleColorOverride(rippleOverride);
|
_infoToggle->setRippleColorOverride(rippleOverride);
|
||||||
|
|
|
||||||
|
|
@ -920,3 +920,75 @@ reportReasonButton: SettingsButton(infoProfileButton) {
|
||||||
}
|
}
|
||||||
|
|
||||||
permissionsExpandIcon: icon{{ "info/edit/expand_arrow_small", windowBoldFg }};
|
permissionsExpandIcon: icon{{ "info/edit/expand_arrow_small", windowBoldFg }};
|
||||||
|
ktgHistoryTopBarBack: IconButton(historyTopBarBack) {
|
||||||
|
icon: icon {{ "info/info_back", ktgTopBarBackIconFg }};
|
||||||
|
iconOver: icon {{ "info/info_back", ktgTopBarBackIconFgOver }};
|
||||||
|
|
||||||
|
ripple: RippleAnimation(defaultRippleAnimation) {
|
||||||
|
color: ktgTopBarBackIconBgRipple;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ktgTopBarCall: IconButton(topBarCall) {
|
||||||
|
icon: icon {{ "top_bar_call", ktgTopBarIconFg }};
|
||||||
|
iconOver: icon {{ "top_bar_call", ktgTopBarIconFgOver }};
|
||||||
|
|
||||||
|
ripple: RippleAnimation(defaultRippleAnimation) {
|
||||||
|
color: ktgTopBarIconBgRipple;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ktgTopBarSearch: IconButton(topBarSearch) {
|
||||||
|
icon: icon {{ "top_bar_search", ktgTopBarIconFg }};
|
||||||
|
iconOver: icon {{ "top_bar_search", ktgTopBarIconFgOver }};
|
||||||
|
|
||||||
|
ripple: RippleAnimation(defaultRippleAnimation) {
|
||||||
|
color: ktgTopBarIconBgRipple;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ktgTopBarInfo: IconButton(topBarInfo) {
|
||||||
|
icon: icon {{ "top_bar_profile", ktgTopBarIconFg }};
|
||||||
|
iconOver: icon {{ "top_bar_profile", ktgTopBarIconFgOver }};
|
||||||
|
|
||||||
|
ripple: RippleAnimation(defaultRippleAnimation) {
|
||||||
|
color: ktgTopBarIconBgRipple;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ktgTopBarInfoActive: icon {{ "top_bar_profile", ktgTopBarIconFgActive }};
|
||||||
|
|
||||||
|
ktgTopBarMenuToggle: IconButton(topBarMenuToggle) {
|
||||||
|
icon: icon {{ "title_menu_dots", ktgTopBarIconFg }};
|
||||||
|
iconOver: icon {{ "title_menu_dots", ktgTopBarIconFgOver }};
|
||||||
|
|
||||||
|
ripple: RippleAnimation(defaultRippleAnimation) {
|
||||||
|
color: ktgTopBarIconBgRipple;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ktgTopBarActiveButton: RoundButton(defaultActiveButton) {
|
||||||
|
textFg: ktgTopBarActiveButtonFg;
|
||||||
|
textFgOver: ktgTopBarActiveButtonFgOver;
|
||||||
|
numbersTextFg: ktgTopBarActiveButtonSecondaryFg;
|
||||||
|
numbersTextFgOver: ktgTopBarActiveButtonSecondaryFgOver;
|
||||||
|
textBg: ktgTopBarActiveButtonBg;
|
||||||
|
textBgOver: ktgTopBarActiveButtonBgOver;
|
||||||
|
|
||||||
|
ripple: RippleAnimation(defaultRippleAnimation) {
|
||||||
|
color: ktgTopBarActiveButtonBgRipple;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ktgTopBarClearButton: RoundButton(topBarClearButton) {
|
||||||
|
textFg: ktgTopBarClearButtonFg;
|
||||||
|
textFgOver: ktgTopBarClearButtonFgOver;
|
||||||
|
numbersTextFg: ktgTopBarClearButtonFg;
|
||||||
|
numbersTextFgOver: ktgTopBarClearButtonFgOver;
|
||||||
|
textBg: ktgTopBarClearButtonBg;
|
||||||
|
textBgOver: ktgTopBarClearButtonBgOver;
|
||||||
|
|
||||||
|
ripple: RippleAnimation(defaultRippleAnimation) {
|
||||||
|
color: ktgTopBarClearButtonBgRipple;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -537,14 +537,14 @@ void Generator::paintHistoryBackground() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Generator::paintTopBar() {
|
void Generator::paintTopBar() {
|
||||||
_p->fillRect(_topBar, st::topBarBg[_palette]);
|
_p->fillRect(_topBar, st::ktgTopBarBg[_palette]);
|
||||||
|
|
||||||
auto right = st::topBarMenuToggle.width;
|
auto right = st::topBarMenuToggle.width;
|
||||||
st::topBarMenuToggle.icon[_palette].paint(*_p, _topBar.x() + _topBar.width() - right + st::topBarMenuToggle.iconPosition.x(), _topBar.y() + st::topBarMenuToggle.iconPosition.y(), _rect.width());
|
st::ktgTopBarMenuToggle.icon[_palette].paint(*_p, _topBar.x() + _topBar.width() - right + st::topBarMenuToggle.iconPosition.x(), _topBar.y() + st::topBarMenuToggle.iconPosition.y(), _rect.width());
|
||||||
right += st::topBarSkip + st::topBarCall.width;
|
right += st::topBarSkip + st::topBarCall.width;
|
||||||
st::topBarCall.icon[_palette].paint(*_p, _topBar.x() + _topBar.width() - right + st::topBarCall.iconPosition.x(), _topBar.y() + st::topBarCall.iconPosition.y(), _rect.width());
|
st::ktgTopBarCall.icon[_palette].paint(*_p, _topBar.x() + _topBar.width() - right + st::topBarCall.iconPosition.x(), _topBar.y() + st::topBarCall.iconPosition.y(), _rect.width());
|
||||||
right += st::topBarSearch.width;
|
right += st::topBarSearch.width;
|
||||||
st::topBarSearch.icon[_palette].paint(*_p, _topBar.x() + _topBar.width() - right + st::topBarSearch.iconPosition.x(), _topBar.y() + st::topBarSearch.iconPosition.y(), _rect.width());
|
st::ktgTopBarSearch.icon[_palette].paint(*_p, _topBar.x() + _topBar.width() - right + st::topBarSearch.iconPosition.x(), _topBar.y() + st::topBarSearch.iconPosition.y(), _rect.width());
|
||||||
|
|
||||||
auto decreaseWidth = st::topBarCall.width + st::topBarCallSkip + st::topBarSearch.width + st::topBarMenuToggle.width;
|
auto decreaseWidth = st::topBarCall.width + st::topBarCallSkip + st::topBarSearch.width + st::topBarMenuToggle.width;
|
||||||
auto nameleft = _topBar.x() + st::topBarArrowPadding.right();
|
auto nameleft = _topBar.x() + st::topBarArrowPadding.right();
|
||||||
|
|
@ -552,10 +552,10 @@ void Generator::paintTopBar() {
|
||||||
auto statustop = _topBar.y() + st::topBarHeight - st::topBarArrowPadding.bottom() - st::dialogsTextFont->height;
|
auto statustop = _topBar.y() + st::topBarHeight - st::topBarArrowPadding.bottom() - st::dialogsTextFont->height;
|
||||||
auto namewidth = _topBar.x() + _topBar.width() - decreaseWidth - nameleft - st::topBarArrowPadding.right();
|
auto namewidth = _topBar.x() + _topBar.width() - decreaseWidth - nameleft - st::topBarArrowPadding.right();
|
||||||
_p->setFont(st::dialogsTextFont);
|
_p->setFont(st::dialogsTextFont);
|
||||||
_p->setPen(_topBarStatusActive ? st::historyStatusFgActive[_palette] : st::historyStatusFg[_palette]);
|
_p->setPen(_topBarStatusActive ? st::ktgTopBarStatusFgActive[_palette] : st::ktgTopBarStatusFg[_palette]);
|
||||||
_p->drawText(nameleft, statustop + st::dialogsTextFont->ascent, _topBarStatus);
|
_p->drawText(nameleft, statustop + st::dialogsTextFont->ascent, _topBarStatus);
|
||||||
|
|
||||||
_p->setPen(st::dialogsNameFg[_palette]);
|
_p->setPen(st::ktgTopBarNameFg[_palette]);
|
||||||
_topBarName.drawElided(*_p, nameleft, nametop, namewidth);
|
_topBarName.drawElided(*_p, nameleft, nametop, namewidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue