Improve box rounding and buttons.

This commit is contained in:
John Preston 2022-02-07 17:46:24 +03:00
parent f93c2bb5e5
commit 681da392eb
4 changed files with 27 additions and 20 deletions

View file

@ -42,7 +42,7 @@ BoxLayerWidget::BoxLayerWidget(
: LayerWidget(layer) : LayerWidget(layer)
, _layer(layer) , _layer(layer)
, _content(std::move(content)) , _content(std::move(content))
, _roundRect(ImageRoundRadius::Small, st().bg) { , _roundRect(st::boxRadius, st().bg) {
_content->setParent(this); _content->setParent(this);
_content->setDelegate(this); _content->setDelegate(this);
@ -270,6 +270,7 @@ QPointer<RoundButton> BoxLayerWidget::addButton(
const style::RoundButton &st) { const style::RoundButton &st) {
_buttons.emplace_back(this, std::move(text), st); _buttons.emplace_back(this, std::move(text), st);
auto result = QPointer<RoundButton>(_buttons.back()); auto result = QPointer<RoundButton>(_buttons.back());
result->setTextTransform(RoundButton::TextTransform::NoTransform);
result->setClickedCallback(std::move(clickCallback)); result->setClickedCallback(std::move(clickCallback));
result->show(); result->show();
result->widthValue( result->widthValue(
@ -285,6 +286,7 @@ QPointer<RoundButton> BoxLayerWidget::addLeftButton(
const style::RoundButton &st) { const style::RoundButton &st) {
_leftButton = object_ptr<RoundButton>(this, std::move(text), st); _leftButton = object_ptr<RoundButton>(this, std::move(text), st);
auto result = QPointer<RoundButton>(_leftButton); auto result = QPointer<RoundButton>(_leftButton);
result->setTextTransform(RoundButton::TextTransform::NoTransform);
result->setClickedCallback(std::move(clickCallback)); result->setClickedCallback(std::move(clickCallback));
result->show(); result->show();
result->widthValue( result->widthValue(
@ -377,14 +379,19 @@ int BoxLayerWidget::countFullHeight() const {
} }
int BoxLayerWidget::contentTop() const { int BoxLayerWidget::contentTop() const {
return hasTitle() ? titleHeight() : (_noContentMargin ? 0 : st::boxTopMargin); return hasTitle()
? titleHeight()
: _noContentMargin
?
0
: st::boxTopMargin;
} }
void BoxLayerWidget::resizeEvent(QResizeEvent *e) { void BoxLayerWidget::resizeEvent(QResizeEvent *e) {
updateButtonsPositions(); updateButtonsPositions();
updateTitlePosition(); updateTitlePosition();
auto top = contentTop(); const auto top = contentTop();
_content->resize(width(), height() - top - buttonsHeight()); _content->resize(width(), height() - top - buttonsHeight());
_content->moveToLeft(0, top); _content->moveToLeft(0, top);

View file

@ -86,7 +86,7 @@ private:
LayerStackWidget::BackgroundWidget::BackgroundWidget(QWidget *parent) LayerStackWidget::BackgroundWidget::BackgroundWidget(QWidget *parent)
: TWidget(parent) : TWidget(parent)
, _roundRect(ImageRoundRadius::Small, st::boxBg) { , _roundRect(st::boxRadius, st::boxBg) {
} }
void LayerStackWidget::BackgroundWidget::setCacheImages( void LayerStackWidget::BackgroundWidget::setCacheImages(

View file

@ -32,13 +32,14 @@ Box {
} }
boxDuration: 200; boxDuration: 200;
boxRadius: 3px; boxRadius: 8px;
boxButtonFont: font(boxFontSize semibold); boxButtonFont: font(boxFontSize semibold);
defaultBoxButton: RoundButton(defaultLightButton) { defaultBoxButton: RoundButton(defaultLightButton) {
width: -24px; width: -30px;
height: 36px; height: 34px;
font: boxButtonFont; textTop: 7px;
font: font(14px semibold);
} }
boxLabelStyle: TextStyle(boxTextStyle) { boxLabelStyle: TextStyle(boxTextStyle) {
@ -74,25 +75,25 @@ boxRoundShadow: Shadow {
fallback: windowShadowFgFallback; fallback: windowShadowFgFallback;
} }
boxTitleFont: font(17px semibold); boxTitleFont: font(16px semibold);
boxTitle: FlatLabel(defaultFlatLabel) { boxTitle: FlatLabel(defaultFlatLabel) {
textFg: boxTitleFg; textFg: boxTitleFg;
maxHeight: 24px; maxHeight: 24px;
style: TextStyle(defaultTextStyle) { style: TextStyle(defaultTextStyle) {
font: boxTitleFont; font: boxTitleFont;
linkFont: boxTitleFont; linkFont: boxTitleFont;
linkFontOver: font(17px semibold underline); linkFontOver: font(16px semibold underline);
} }
} }
boxTitlePosition: point(22px, 16px); boxTitlePosition: point(24px, 18px);
boxTitleHeight: 56px; boxTitleHeight: 48px;
boxTitleAdditionalSkip: 9px; boxTitleAdditionalSkip: 9px;
boxTitleAdditionalFont: normalFont; boxTitleAdditionalFont: normalFont;
boxScroll: defaultSolidScroll; boxScroll: defaultSolidScroll;
boxRowPadding: margins(22px, 0px, 22px, 0px); boxRowPadding: margins(24px, 0px, 24px, 0px);
boxTopMargin: 6px; boxTopMargin: 8px;
boxTitleClose: IconButton(defaultIconButton) { boxTitleClose: IconButton(defaultIconButton) {
width: boxTitleHeight; width: boxTitleHeight;
@ -119,14 +120,14 @@ boxOptionInputSkip: 6px;
boxWidth: 320px; boxWidth: 320px;
boxWideWidth: 364px; boxWideWidth: 364px;
boxPadding: margins(22px, 30px, 22px, 8px); boxPadding: margins(24px, 30px, 24px, 8px);
boxMaxListHeight: 492px; boxMaxListHeight: 492px;
boxLittleSkip: 10px; boxLittleSkip: 10px;
boxMediumSkip: 20px; boxMediumSkip: 20px;
defaultBox: Box { defaultBox: Box {
buttonPadding: margins(8px, 12px, 13px, 12px); buttonPadding: margins(6px, 10px, 10px, 10px);
buttonHeight: 36px; buttonHeight: 34px;
button: defaultBoxButton; button: defaultBoxButton;
margin: margins(0px, 10px, 0px, 10px); margin: margins(0px, 10px, 0px, 10px);
bg: boxBg; bg: boxBg;
@ -134,7 +135,6 @@ defaultBox: Box {
titleAdditionalFg: boxTitleAdditionalFg; titleAdditionalFg: boxTitleAdditionalFg;
} }
layerBox: Box(defaultBox) { layerBox: Box(defaultBox) {
buttonPadding: margins(8px, 8px, 8px, 8px);
} }
boxLabel: FlatLabel(defaultFlatLabel) { boxLabel: FlatLabel(defaultFlatLabel) {
minWidth: 274px; minWidth: 274px;

View file

@ -878,7 +878,7 @@ defaultPopupMenu: PopupMenu {
defaultInputField: InputField { defaultInputField: InputField {
textBg: windowBg; textBg: windowBg;
textFg: windowFg; textFg: windowFg;
textMargins: margins(0px, 26px, 0px, 4px); textMargins: margins(0px, 28px, 0px, 4px);
textAlign: align(topleft); textAlign: align(topleft);
placeholderFg: windowSubTextFg; placeholderFg: windowSubTextFg;
@ -901,7 +901,7 @@ defaultInputField: InputField {
font: boxTextFont; font: boxTextFont;
menu: defaultPopupMenu; menu: defaultPopupMenu;
heightMin: 52px; heightMin: 55px;
heightMax: 148px; heightMax: 148px;
} }