mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-08-31 06:26:18 +00:00
Improve narrow participants column design.
This commit is contained in:
@@ -35,9 +35,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
namespace Settings {
|
||||
|
||||
object_ptr<Section> CreateSection(
|
||||
Type type,
|
||||
not_null<QWidget*> parent,
|
||||
not_null<Window::SessionController*> controller) {
|
||||
Type type,
|
||||
not_null<QWidget*> parent,
|
||||
not_null<Window::SessionController*> controller) {
|
||||
switch (type) {
|
||||
case Type::Main:
|
||||
return object_ptr<Main>(parent, controller);
|
||||
@@ -74,8 +74,8 @@ void AddDivider(not_null<Ui::VerticalLayout*> container) {
|
||||
}
|
||||
|
||||
void AddDividerText(
|
||||
not_null<Ui::VerticalLayout*> container,
|
||||
rpl::producer<QString> text) {
|
||||
not_null<Ui::VerticalLayout*> container,
|
||||
rpl::producer<QString> text) {
|
||||
container->add(object_ptr<Ui::DividerLabel>(
|
||||
container,
|
||||
object_ptr<Ui::FlatLabel>(
|
||||
@@ -85,37 +85,49 @@ void AddDividerText(
|
||||
st::settingsDividerLabelPadding));
|
||||
}
|
||||
|
||||
not_null<Ui::RpWidget*> AddButtonIcon(
|
||||
not_null<Ui::AbstractButton*> button,
|
||||
const style::icon *leftIcon,
|
||||
int iconLeft,
|
||||
const style::color *leftIconOver) {
|
||||
const auto icon = Ui::CreateChild<Ui::RpWidget>(button.get());
|
||||
icon->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||
icon->resize(leftIcon->size());
|
||||
button->sizeValue(
|
||||
) | rpl::start_with_next([=](QSize size) {
|
||||
icon->moveToLeft(
|
||||
iconLeft ? iconLeft : st::settingsSectionIconLeft,
|
||||
(size.height() - icon->height()) / 2,
|
||||
size.width());
|
||||
}, icon->lifetime());
|
||||
icon->paintRequest(
|
||||
) | rpl::start_with_next([=] {
|
||||
Painter p(icon);
|
||||
const auto width = icon->width();
|
||||
const auto paintOver = (button->isOver() || button->isDown())
|
||||
&& !button->isDisabled();
|
||||
if (!paintOver) {
|
||||
leftIcon->paint(p, QPoint(), width);
|
||||
} else if (leftIconOver) {
|
||||
leftIcon->paint(p, QPoint(), width, (*leftIconOver)->c);
|
||||
} else {
|
||||
leftIcon->paint(p, QPoint(), width, st::menuIconFgOver->c);
|
||||
}
|
||||
}, icon->lifetime());
|
||||
return icon;
|
||||
}
|
||||
|
||||
object_ptr<Button> CreateButton(
|
||||
not_null<QWidget*> parent,
|
||||
rpl::producer<QString> text,
|
||||
const style::SettingsButton &st,
|
||||
const style::icon *leftIcon,
|
||||
int iconLeft) {
|
||||
int iconLeft,
|
||||
const style::color *leftIconOver) {
|
||||
auto result = object_ptr<Button>(parent, std::move(text), st);
|
||||
const auto button = result.data();
|
||||
if (leftIcon) {
|
||||
const auto icon = Ui::CreateChild<Ui::RpWidget>(button);
|
||||
icon->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||
icon->resize(leftIcon->size());
|
||||
button->sizeValue(
|
||||
) | rpl::start_with_next([=](QSize size) {
|
||||
icon->moveToLeft(
|
||||
iconLeft ? iconLeft : st::settingsSectionIconLeft,
|
||||
(size.height() - icon->height()) / 2,
|
||||
size.width());
|
||||
}, icon->lifetime());
|
||||
icon->paintRequest(
|
||||
) | rpl::start_with_next([=] {
|
||||
Painter p(icon);
|
||||
const auto width = icon->width();
|
||||
const auto paintOver = (button->isOver() || button->isDown())
|
||||
&& !button->isDisabled();
|
||||
if (paintOver) {
|
||||
leftIcon->paint(p, QPoint(), width, st::menuIconFgOver->c);
|
||||
} else {
|
||||
leftIcon->paint(p, QPoint(), width);
|
||||
}
|
||||
}, icon->lifetime());
|
||||
AddButtonIcon(button, leftIcon, iconLeft, leftIconOver);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@@ -18,6 +18,7 @@ namespace Ui {
|
||||
class VerticalLayout;
|
||||
class FlatLabel;
|
||||
class SettingsButton;
|
||||
class AbstractButton;
|
||||
} // namespace Ui
|
||||
|
||||
namespace Window {
|
||||
@@ -70,12 +71,18 @@ void AddDivider(not_null<Ui::VerticalLayout*> container);
|
||||
void AddDividerText(
|
||||
not_null<Ui::VerticalLayout*> container,
|
||||
rpl::producer<QString> text);
|
||||
not_null<Ui::RpWidget*> AddButtonIcon(
|
||||
not_null<Ui::AbstractButton*> button,
|
||||
const style::icon *leftIcon,
|
||||
int iconLeft,
|
||||
const style::color *leftIconOver);
|
||||
object_ptr<Button> CreateButton(
|
||||
not_null<QWidget*> parent,
|
||||
rpl::producer<QString> text,
|
||||
const style::SettingsButton &st,
|
||||
const style::icon *leftIcon = nullptr,
|
||||
int iconLeft = 0);
|
||||
int iconLeft = 0,
|
||||
const style::color *leftIconOver = nullptr);
|
||||
not_null<Button*> AddButton(
|
||||
not_null<Ui::VerticalLayout*> container,
|
||||
rpl::producer<QString> text,
|
||||
|
Reference in New Issue
Block a user