mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 10:17:35 +00:00
Calendar: Support preferred first day of the week
This commit is contained in:
parent
aa4dd6c1bc
commit
9414525d75
2 changed files with 14 additions and 2 deletions
|
@ -271,7 +271,7 @@ void Calendar::update_tiles(unsigned view_year, unsigned view_month)
|
||||||
view_month = i + 1;
|
view_month = i + 1;
|
||||||
|
|
||||||
auto first_day_of_current_month = Core::DateTime::create(view_year, view_month, 1);
|
auto first_day_of_current_month = Core::DateTime::create(view_year, view_month, 1);
|
||||||
unsigned start_of_month = first_day_of_current_month.weekday();
|
unsigned start_of_month = (first_day_of_current_month.weekday() - to_underlying(m_first_day_of_week) + 7) % 7;
|
||||||
unsigned days_from_previous_month_to_show = start_of_month == 0 ? 7 : start_of_month;
|
unsigned days_from_previous_month_to_show = start_of_month == 0 ? 7 : start_of_month;
|
||||||
|
|
||||||
for (unsigned j = 0; j < 42; j++) {
|
for (unsigned j = 0; j < 42; j++) {
|
||||||
|
@ -425,7 +425,8 @@ void Calendar::paint_event(GUI::PaintEvent& event)
|
||||||
y_offset,
|
y_offset,
|
||||||
m_days[i].width,
|
m_days[i].width,
|
||||||
16);
|
16);
|
||||||
painter.draw_text(day_rect, m_days[i].name, small_font->bold_variant(), Gfx::TextAlignment::Center, palette().base_text());
|
auto const& day_name = m_days[(i + to_underlying(m_first_day_of_week)) % 7].name;
|
||||||
|
painter.draw_text(day_rect, day_name, small_font->bold_variant(), Gfx::TextAlignment::Center, palette().base_text());
|
||||||
}
|
}
|
||||||
y_offset += days_of_the_week_rect.height();
|
y_offset += days_of_the_week_rect.height();
|
||||||
painter.draw_line({ 0, y_offset }, { frame_inner_rect().width(), y_offset }, palette().threed_shadow2(), 1);
|
painter.draw_line({ 0, y_offset }, { frame_inner_rect().width(), y_offset }, palette().threed_shadow2(), 1);
|
||||||
|
|
|
@ -128,6 +128,17 @@ private:
|
||||||
Gfx::IntSize m_event_size;
|
Gfx::IntSize m_event_size;
|
||||||
Gfx::IntSize m_month_size[12];
|
Gfx::IntSize m_month_size[12];
|
||||||
Mode m_mode { Month };
|
Mode m_mode { Month };
|
||||||
|
|
||||||
|
enum class DayOfWeek {
|
||||||
|
Sunday,
|
||||||
|
Monday,
|
||||||
|
Tuesday,
|
||||||
|
Wednesday,
|
||||||
|
Thursday,
|
||||||
|
Friday,
|
||||||
|
Saturday
|
||||||
|
};
|
||||||
|
DayOfWeek m_first_day_of_week { DayOfWeek::Sunday };
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue