mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-18 07:07:08 +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
Telegram
Resources/icons
SourceFiles
BIN
Telegram/Resources/icons/calendar_down.png
Normal file
BIN
Telegram/Resources/icons/calendar_down.png
Normal file
Binary file not shown.
After ![]() (image error) 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 ![]() (image error) 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 ![]() (image error) Size: 867 B |
|
@ -492,8 +492,8 @@ calendarPrevious: IconButton {
|
|||
width: calendarTitleHeight;
|
||||
height: calendarTitleHeight;
|
||||
|
||||
icon: icon {{ "title_back", boxTitleFg }};
|
||||
iconPosition: point(20px, 20px);
|
||||
icon: icon {{ "calendar_down-flip_vertical", boxTitleFg }};
|
||||
iconPosition: point(-1px, -1px);
|
||||
|
||||
rippleAreaPosition: point(6px, 6px);
|
||||
rippleAreaSize: 44px;
|
||||
|
@ -501,9 +501,9 @@ calendarPrevious: IconButton {
|
|||
color: windowBgOver;
|
||||
}
|
||||
}
|
||||
calendarPreviousDisabled: icon {{ "title_back", menuIconFg }};
|
||||
calendarPreviousDisabled: icon {{ "calendar_down-flip_vertical", menuIconFg }};
|
||||
calendarNext: IconButton(calendarPrevious) {
|
||||
icon: icon {{ "title_back-flip_horizontal", boxTitleFg }};
|
||||
icon: icon {{ "calendar_down", boxTitleFg }};
|
||||
}
|
||||
CalendarSizes {
|
||||
width: pixels;
|
||||
|
@ -512,7 +512,7 @@ CalendarSizes {
|
|||
cellInner: pixels;
|
||||
padding: margins;
|
||||
}
|
||||
calendarNextDisabled: icon {{ "title_back-flip_horizontal", menuIconFg }};
|
||||
calendarNextDisabled: icon {{ "calendar_down", menuIconFg }};
|
||||
calendarTitleFont: boxTitleFont;
|
||||
defaultCalendarSizes: CalendarSizes {
|
||||
width: boxWideWidth;
|
||||
|
|
|
@ -504,6 +504,7 @@ private:
|
|||
|
||||
QString _text;
|
||||
int _textWidth = 0;
|
||||
int _textLeft = 0;
|
||||
|
||||
};
|
||||
|
||||
|
@ -514,6 +515,9 @@ CalendarBox::Title::Title(
|
|||
: RpWidget(parent)
|
||||
, _st(st)
|
||||
, _context(context) {
|
||||
const auto dayWidth = st::calendarDaysFont->width(langDayOfWeek(1));
|
||||
_textLeft = _st.padding.left() + (_st.cellSize.width() - dayWidth) / 2;
|
||||
|
||||
_context->monthValue(
|
||||
) | rpl::start_with_next([=](QDate date) {
|
||||
monthChanged(date);
|
||||
|
@ -533,7 +537,12 @@ void CalendarBox::Title::paintEvent(QPaintEvent *e) {
|
|||
|
||||
p.setFont(st::calendarTitleFont);
|
||||
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);
|
||||
}
|
||||
|
@ -614,6 +623,7 @@ bool CalendarBox::isNextEnabled() const {
|
|||
|
||||
void CalendarBox::goPreviousMonth() {
|
||||
if (isPreviousEnabled()) {
|
||||
_watchScroll = false;
|
||||
_context->skipMonth(-1);
|
||||
setExactScroll();
|
||||
}
|
||||
|
@ -621,6 +631,7 @@ void CalendarBox::goPreviousMonth() {
|
|||
|
||||
void CalendarBox::goNextMonth() {
|
||||
if (isNextEnabled()) {
|
||||
_watchScroll = false;
|
||||
_context->skipMonth(1);
|
||||
setExactScroll();
|
||||
}
|
||||
|
@ -668,8 +679,17 @@ void CalendarBox::monthChanged(QDate month) {
|
|||
}
|
||||
|
||||
void CalendarBox::resizeEvent(QResizeEvent *e) {
|
||||
_previous->moveToLeft(0, 0);
|
||||
_next->moveToRight(0, 0);
|
||||
const auto dayWidth = st::calendarDaysFont->width(langDayOfWeek(7));
|
||||
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;
|
||||
_title->setGeometryToLeft(0, 0, width(), 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;
|
||||
|
||||
} // namespace Ui
|
||||
|
|
|
@ -48,7 +48,6 @@ protected:
|
|||
|
||||
void keyPressEvent(QKeyEvent *e) override;
|
||||
void resizeEvent(QResizeEvent *e) override;
|
||||
void wheelEvent(QWheelEvent *e) override;
|
||||
|
||||
private:
|
||||
void monthChanged(QDate month);
|
||||
|
|
Loading…
Add table
Reference in a new issue