mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Improve CalendarBox title design for vertical layout.
This commit is contained in:
parent
b9b609f445
commit
15dc6064ef
6 changed files with 28 additions and 19 deletions
BIN
Telegram/Resources/icons/calendar_down.png
Normal file
BIN
Telegram/Resources/icons/calendar_down.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 188 B |
BIN
Telegram/Resources/icons/calendar_down@2x.png
Normal file
BIN
Telegram/Resources/icons/calendar_down@2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 291 B |
BIN
Telegram/Resources/icons/calendar_down@3x.png
Normal file
BIN
Telegram/Resources/icons/calendar_down@3x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 867 B |
|
@ -492,8 +492,8 @@ calendarPrevious: IconButton {
|
||||||
width: calendarTitleHeight;
|
width: calendarTitleHeight;
|
||||||
height: calendarTitleHeight;
|
height: calendarTitleHeight;
|
||||||
|
|
||||||
icon: icon {{ "title_back", boxTitleFg }};
|
icon: icon {{ "calendar_down-flip_vertical", boxTitleFg }};
|
||||||
iconPosition: point(20px, 20px);
|
iconPosition: point(-1px, -1px);
|
||||||
|
|
||||||
rippleAreaPosition: point(6px, 6px);
|
rippleAreaPosition: point(6px, 6px);
|
||||||
rippleAreaSize: 44px;
|
rippleAreaSize: 44px;
|
||||||
|
@ -501,9 +501,9 @@ calendarPrevious: IconButton {
|
||||||
color: windowBgOver;
|
color: windowBgOver;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
calendarPreviousDisabled: icon {{ "title_back", menuIconFg }};
|
calendarPreviousDisabled: icon {{ "calendar_down-flip_vertical", menuIconFg }};
|
||||||
calendarNext: IconButton(calendarPrevious) {
|
calendarNext: IconButton(calendarPrevious) {
|
||||||
icon: icon {{ "title_back-flip_horizontal", boxTitleFg }};
|
icon: icon {{ "calendar_down", boxTitleFg }};
|
||||||
}
|
}
|
||||||
CalendarSizes {
|
CalendarSizes {
|
||||||
width: pixels;
|
width: pixels;
|
||||||
|
@ -512,7 +512,7 @@ CalendarSizes {
|
||||||
cellInner: pixels;
|
cellInner: pixels;
|
||||||
padding: margins;
|
padding: margins;
|
||||||
}
|
}
|
||||||
calendarNextDisabled: icon {{ "title_back-flip_horizontal", menuIconFg }};
|
calendarNextDisabled: icon {{ "calendar_down", menuIconFg }};
|
||||||
calendarTitleFont: boxTitleFont;
|
calendarTitleFont: boxTitleFont;
|
||||||
defaultCalendarSizes: CalendarSizes {
|
defaultCalendarSizes: CalendarSizes {
|
||||||
width: boxWideWidth;
|
width: boxWideWidth;
|
||||||
|
|
|
@ -504,6 +504,7 @@ private:
|
||||||
|
|
||||||
QString _text;
|
QString _text;
|
||||||
int _textWidth = 0;
|
int _textWidth = 0;
|
||||||
|
int _textLeft = 0;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -514,6 +515,9 @@ CalendarBox::Title::Title(
|
||||||
: RpWidget(parent)
|
: RpWidget(parent)
|
||||||
, _st(st)
|
, _st(st)
|
||||||
, _context(context) {
|
, _context(context) {
|
||||||
|
const auto dayWidth = st::calendarDaysFont->width(langDayOfWeek(1));
|
||||||
|
_textLeft = _st.padding.left() + (_st.cellSize.width() - dayWidth) / 2;
|
||||||
|
|
||||||
_context->monthValue(
|
_context->monthValue(
|
||||||
) | rpl::start_with_next([=](QDate date) {
|
) | rpl::start_with_next([=](QDate date) {
|
||||||
monthChanged(date);
|
monthChanged(date);
|
||||||
|
@ -533,7 +537,12 @@ void CalendarBox::Title::paintEvent(QPaintEvent *e) {
|
||||||
|
|
||||||
p.setFont(st::calendarTitleFont);
|
p.setFont(st::calendarTitleFont);
|
||||||
p.setPen(st::boxTitleFg);
|
p.setPen(st::boxTitleFg);
|
||||||
p.drawTextLeft((width() - _textWidth) / 2, (st::calendarTitleHeight - st::calendarTitleFont->height) / 2, width(), _text, _textWidth);
|
p.drawTextLeft(
|
||||||
|
_textLeft,
|
||||||
|
(st::calendarTitleHeight - st::calendarTitleFont->height) / 2,
|
||||||
|
width(),
|
||||||
|
_text,
|
||||||
|
_textWidth);
|
||||||
|
|
||||||
paintDayNames(p, clip);
|
paintDayNames(p, clip);
|
||||||
}
|
}
|
||||||
|
@ -614,6 +623,7 @@ bool CalendarBox::isNextEnabled() const {
|
||||||
|
|
||||||
void CalendarBox::goPreviousMonth() {
|
void CalendarBox::goPreviousMonth() {
|
||||||
if (isPreviousEnabled()) {
|
if (isPreviousEnabled()) {
|
||||||
|
_watchScroll = false;
|
||||||
_context->skipMonth(-1);
|
_context->skipMonth(-1);
|
||||||
setExactScroll();
|
setExactScroll();
|
||||||
}
|
}
|
||||||
|
@ -621,6 +631,7 @@ void CalendarBox::goPreviousMonth() {
|
||||||
|
|
||||||
void CalendarBox::goNextMonth() {
|
void CalendarBox::goNextMonth() {
|
||||||
if (isNextEnabled()) {
|
if (isNextEnabled()) {
|
||||||
|
_watchScroll = false;
|
||||||
_context->skipMonth(1);
|
_context->skipMonth(1);
|
||||||
setExactScroll();
|
setExactScroll();
|
||||||
}
|
}
|
||||||
|
@ -668,8 +679,17 @@ void CalendarBox::monthChanged(QDate month) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CalendarBox::resizeEvent(QResizeEvent *e) {
|
void CalendarBox::resizeEvent(QResizeEvent *e) {
|
||||||
_previous->moveToLeft(0, 0);
|
const auto dayWidth = st::calendarDaysFont->width(langDayOfWeek(7));
|
||||||
_next->moveToRight(0, 0);
|
const auto skip = _st.padding.left()
|
||||||
|
+ _st.cellSize.width() * (kDaysInWeek - 1)
|
||||||
|
+ (_st.cellSize.width() - dayWidth) / 2
|
||||||
|
+ dayWidth;
|
||||||
|
const auto right = width() - skip;
|
||||||
|
const auto shift = _next->width()
|
||||||
|
- (_next->width() - st::calendarPrevious.icon.width()) / 2
|
||||||
|
- st::calendarPrevious.icon.width();
|
||||||
|
_next->moveToRight(right - shift, 0);
|
||||||
|
_previous->moveToRight(right - shift + _next->width(), 0);
|
||||||
const auto title = st::calendarTitleHeight + _st.daysHeight;
|
const auto title = st::calendarTitleHeight + _st.daysHeight;
|
||||||
_title->setGeometryToLeft(0, 0, width(), title);
|
_title->setGeometryToLeft(0, 0, width(), title);
|
||||||
_scroll->setGeometryToLeft(0, title, width(), height() - title);
|
_scroll->setGeometryToLeft(0, title, width(), height() - title);
|
||||||
|
@ -688,16 +708,6 @@ void CalendarBox::keyPressEvent(QKeyEvent *e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CalendarBox::wheelEvent(QWheelEvent *e) {
|
|
||||||
const auto direction = Ui::WheelDirection(e);
|
|
||||||
|
|
||||||
if (direction < 0) {
|
|
||||||
goPreviousMonth();
|
|
||||||
} else if (direction > 0) {
|
|
||||||
goNextMonth();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CalendarBox::~CalendarBox() = default;
|
CalendarBox::~CalendarBox() = default;
|
||||||
|
|
||||||
} // namespace Ui
|
} // namespace Ui
|
||||||
|
|
|
@ -48,7 +48,6 @@ protected:
|
||||||
|
|
||||||
void keyPressEvent(QKeyEvent *e) override;
|
void keyPressEvent(QKeyEvent *e) override;
|
||||||
void resizeEvent(QResizeEvent *e) override;
|
void resizeEvent(QResizeEvent *e) override;
|
||||||
void wheelEvent(QWheelEvent *e) override;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void monthChanged(QDate month);
|
void monthChanged(QDate month);
|
||||||
|
|
Loading…
Add table
Reference in a new issue