mirror of
https://github.com/vale981/tdesktop
synced 2025-03-06 02:01:40 -05:00
Improve theme selector design.
This commit is contained in:
parent
6343221d7b
commit
534772722e
5 changed files with 61 additions and 22 deletions
|
@ -174,7 +174,7 @@ settingsTheme: Checkbox(defaultCheckbox) {
|
||||||
width: 80px;
|
width: 80px;
|
||||||
margin: margins(0px, 0px, 0px, 0px);
|
margin: margins(0px, 0px, 0px, 0px);
|
||||||
|
|
||||||
textPosition: point(0px, 86px);
|
textPosition: point(0px, 99px);
|
||||||
checkPosition: point(0px, 0px);
|
checkPosition: point(0px, 0px);
|
||||||
|
|
||||||
style: defaultTextStyle;
|
style: defaultTextStyle;
|
||||||
|
@ -182,12 +182,12 @@ settingsTheme: Checkbox(defaultCheckbox) {
|
||||||
disabledOpacity: 0.5;
|
disabledOpacity: 0.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
settingsThemePreviewSize: size(80px, 80px);
|
settingsThemePreviewSize: size(80px, 92px);
|
||||||
settingsThemeBubbleSize: size(40px, 14px);
|
settingsThemeBubbleSize: size(40px, 14px);
|
||||||
settingsThemeBubbleRadius: 2px;
|
settingsThemeBubbleRadius: 2px;
|
||||||
settingsThemeBubblePosition: point(6px, 8px);
|
settingsThemeBubblePosition: point(6px, 8px);
|
||||||
settingsThemeBubbleSkip: 4px;
|
settingsThemeBubbleSkip: 6px;
|
||||||
settingsThemeRadioBottom: 8px;
|
settingsThemeRadioBottom: 12px;
|
||||||
settingsThemeMinSkip: 4px;
|
settingsThemeMinSkip: 4px;
|
||||||
|
|
||||||
autoDownloadLimitButton: InfoProfileButton(settingsButton) {
|
autoDownloadLimitButton: InfoProfileButton(settingsButton) {
|
||||||
|
|
|
@ -1102,37 +1102,29 @@ void SetupDefaultThemes(not_null<Ui::VerticalLayout*> container) {
|
||||||
) | rpl::start_with_next([buttons = std::move(buttons)](int width) {
|
) | rpl::start_with_next([buttons = std::move(buttons)](int width) {
|
||||||
Expects(!buttons.empty());
|
Expects(!buttons.empty());
|
||||||
|
|
||||||
// |------| |---------| |-------| |-------|
|
|
||||||
// pad | blue | skip | classic | 3*skip | night | skip | night | pad
|
|
||||||
// |------| |---------| |-------| |-------|
|
|
||||||
const auto padding = st::settingsButton.padding;
|
const auto padding = st::settingsButton.padding;
|
||||||
width -= padding.left() + padding.right();
|
width -= padding.left() + padding.right();
|
||||||
const auto desired = st::settingsThemePreviewSize.width();
|
const auto desired = st::settingsThemePreviewSize.width();
|
||||||
const auto count = int(buttons.size());
|
const auto count = int(buttons.size());
|
||||||
const auto smallSkips = (count / 2);
|
const auto skips = count - 1;
|
||||||
const auto bigSkips = ((count - 1) / 2);
|
|
||||||
const auto skipRatio = 3;
|
|
||||||
const auto skipSegments = smallSkips + bigSkips * skipRatio;
|
|
||||||
const auto minSkip = st::settingsThemeMinSkip;
|
const auto minSkip = st::settingsThemeMinSkip;
|
||||||
const auto single = [&] {
|
const auto single = [&] {
|
||||||
if (width >= skipSegments * minSkip + count * desired) {
|
if (width >= skips * minSkip + count * desired) {
|
||||||
return desired;
|
return desired;
|
||||||
}
|
}
|
||||||
return (width - skipSegments * minSkip) / count;
|
return (width - skips * minSkip) / count;
|
||||||
}();
|
}();
|
||||||
if (single <= 0) {
|
if (single <= 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const auto fullSkips = width - count * single;
|
const auto fullSkips = width - count * single;
|
||||||
const auto segment = fullSkips / float64(skipSegments);
|
const auto skip = fullSkips / float64(skips);
|
||||||
const auto smallSkip = segment;
|
|
||||||
const auto bigSkip = segment * skipRatio;
|
|
||||||
auto left = padding.left() + 0.;
|
auto left = padding.left() + 0.;
|
||||||
auto index = 0;
|
auto index = 0;
|
||||||
for (const auto button : buttons) {
|
for (const auto button : buttons) {
|
||||||
button->resizeToWidth(single);
|
button->resizeToWidth(single);
|
||||||
button->moveToLeft(int(std::round(left)), 0);
|
button->moveToLeft(int(std::round(left)), 0);
|
||||||
left += button->width() + ((index++ % 2) ? bigSkip : smallSkip);
|
left += button->width() + skip;
|
||||||
}
|
}
|
||||||
}, block->lifetime());
|
}, block->lifetime());
|
||||||
|
|
||||||
|
@ -1180,10 +1172,25 @@ void SetupThemeOptions(
|
||||||
&controller->window()));
|
&controller->window()));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
AddSkip(container);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetupCloudThemes(
|
||||||
|
not_null<Window::SessionController*> controller,
|
||||||
|
not_null<Ui::VerticalLayout*> container) {
|
||||||
const auto wrap = container->add(
|
const auto wrap = container->add(
|
||||||
object_ptr<Ui::SlideWrap<Ui::VerticalLayout>>(
|
object_ptr<Ui::SlideWrap<Ui::VerticalLayout>>(
|
||||||
container,
|
container,
|
||||||
object_ptr<Ui::VerticalLayout>(container)));
|
object_ptr<Ui::VerticalLayout>(container)));
|
||||||
|
const auto inner = wrap->entity();
|
||||||
|
|
||||||
|
AddDivider(inner);
|
||||||
|
AddSkip(inner, st::settingsPrivacySkip);
|
||||||
|
|
||||||
|
AddSubsectionTitle(inner, tr::lng_settings_bg_cloud_themes());
|
||||||
|
|
||||||
|
AddSkip(inner, st::settingsThemesTopSkip);
|
||||||
|
|
||||||
const auto list = std::make_shared<std::vector<Data::CloudTheme>>();
|
const auto list = std::make_shared<std::vector<Data::CloudTheme>>();
|
||||||
AddButton(
|
AddButton(
|
||||||
wrap->entity(),
|
wrap->entity(),
|
||||||
|
@ -1197,6 +1204,9 @@ void SetupThemeOptions(
|
||||||
controller,
|
controller,
|
||||||
*list));
|
*list));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
AddSkip(inner, st::settingsThemesTopSkip);
|
||||||
|
|
||||||
auto shown = rpl::single(
|
auto shown = rpl::single(
|
||||||
rpl::empty_value()
|
rpl::empty_value()
|
||||||
) | rpl::then(
|
) | rpl::then(
|
||||||
|
@ -1206,8 +1216,6 @@ void SetupThemeOptions(
|
||||||
return !list->empty();
|
return !list->empty();
|
||||||
});
|
});
|
||||||
wrap->setDuration(0)->toggleOn(std::move(shown));
|
wrap->setDuration(0)->toggleOn(std::move(shown));
|
||||||
|
|
||||||
AddSkip(container);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetupSupportSwitchSettings(
|
void SetupSupportSwitchSettings(
|
||||||
|
@ -1331,6 +1339,7 @@ void Chat::setupContent(not_null<Window::SessionController*> controller) {
|
||||||
const auto content = Ui::CreateChild<Ui::VerticalLayout>(this);
|
const auto content = Ui::CreateChild<Ui::VerticalLayout>(this);
|
||||||
|
|
||||||
SetupThemeOptions(controller, content);
|
SetupThemeOptions(controller, content);
|
||||||
|
SetupCloudThemes(controller, content);
|
||||||
SetupChatBackground(controller, content);
|
SetupChatBackground(controller, content);
|
||||||
SetupStickersEmoji(controller, content);
|
SetupStickersEmoji(controller, content);
|
||||||
SetupMessages(controller, content);
|
SetupMessages(controller, content);
|
||||||
|
|
|
@ -14,6 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "data/data_file_origin.h"
|
#include "data/data_file_origin.h"
|
||||||
#include "data/data_document.h"
|
#include "data/data_document.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
|
#include "ui/image/image_prepare.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
#include "styles/style_settings.h"
|
#include "styles/style_settings.h"
|
||||||
|
@ -121,6 +122,14 @@ void CloudListCheck::setColors(const Colors &colors) {
|
||||||
_colors = colors;
|
_colors = colors;
|
||||||
_radio.setToggledOverride(_colors.radiobuttonActive);
|
_radio.setToggledOverride(_colors.radiobuttonActive);
|
||||||
_radio.setUntoggledOverride(_colors.radiobuttonInactive);
|
_radio.setUntoggledOverride(_colors.radiobuttonInactive);
|
||||||
|
const auto size = st::settingsThemePreviewSize * cIntRetinaFactor();
|
||||||
|
_backgroundFull = (_colors.background.size() == size)
|
||||||
|
? _colors.background
|
||||||
|
: _colors.background.scaled(
|
||||||
|
size,
|
||||||
|
Qt::IgnoreAspectRatio,
|
||||||
|
Qt::SmoothTransformation);
|
||||||
|
_backgroundCacheWidth = -1;
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,6 +137,22 @@ QSize CloudListCheck::getSize() const {
|
||||||
return st::settingsThemePreviewSize;
|
return st::settingsThemePreviewSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CloudListCheck::validateBackgroundCache(int width) {
|
||||||
|
if (_backgroundCacheWidth == width || width <= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_backgroundCacheWidth = width;
|
||||||
|
const auto imageWidth = width * cIntRetinaFactor();
|
||||||
|
_backgroundCache = (width == st::settingsThemePreviewSize.width())
|
||||||
|
? _backgroundFull
|
||||||
|
: _backgroundFull.copy(
|
||||||
|
(_backgroundFull.width() - imageWidth) / 2,
|
||||||
|
0,
|
||||||
|
imageWidth,
|
||||||
|
_backgroundFull.height());
|
||||||
|
Images::prepareRound(_backgroundCache, ImageRoundRadius::Large);
|
||||||
|
}
|
||||||
|
|
||||||
void CloudListCheck::paint(
|
void CloudListCheck::paint(
|
||||||
Painter &p,
|
Painter &p,
|
||||||
int left,
|
int left,
|
||||||
|
@ -150,9 +175,10 @@ void CloudListCheck::paint(
|
||||||
PainterHighQualityEnabler hq(p);
|
PainterHighQualityEnabler hq(p);
|
||||||
p.setPen(Qt::NoPen);
|
p.setPen(Qt::NoPen);
|
||||||
|
|
||||||
|
validateBackgroundCache(outerWidth);
|
||||||
p.drawImage(
|
p.drawImage(
|
||||||
QRect(QPoint(), st::settingsThemePreviewSize),
|
QRect(0, 0, outerWidth, st::settingsThemePreviewSize.height()),
|
||||||
_colors.background);
|
_backgroundCache);
|
||||||
|
|
||||||
p.setBrush(_colors.received);
|
p.setBrush(_colors.received);
|
||||||
p.drawRoundedRect(rtlrect(received, outerWidth), radius, radius);
|
p.drawRoundedRect(rtlrect(received, outerWidth), radius, radius);
|
||||||
|
|
|
@ -55,9 +55,13 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void checkedChangedHook(anim::type animated) override;
|
void checkedChangedHook(anim::type animated) override;
|
||||||
|
void validateBackgroundCache(int width);
|
||||||
|
|
||||||
Colors _colors;
|
Colors _colors;
|
||||||
Ui::RadioView _radio;
|
Ui::RadioView _radio;
|
||||||
|
QImage _backgroundFull;
|
||||||
|
QImage _backgroundCache;
|
||||||
|
int _backgroundCacheWidth = -1;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -369,7 +369,7 @@ std::vector<EmbeddedScheme> EmbeddedThemes() {
|
||||||
return {
|
return {
|
||||||
EmbeddedScheme{
|
EmbeddedScheme{
|
||||||
EmbeddedType::Default,
|
EmbeddedType::Default,
|
||||||
qColor("90ce89"),
|
qColor("9bd494"),
|
||||||
qColor("eaffdc"),
|
qColor("eaffdc"),
|
||||||
qColor("ffffff"),
|
qColor("ffffff"),
|
||||||
qColor("eaffdc"),
|
qColor("eaffdc"),
|
||||||
|
|
Loading…
Add table
Reference in a new issue