1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 13:27:36 +00:00

LibGUI+Calendar: Move date control logic to the calendar widget

This commit is contained in:
implicitfield 2023-06-20 19:30:21 +04:00 committed by Ali Mohammad Pur
parent c625ba34fe
commit 9a1018389c
4 changed files with 39 additions and 48 deletions

View file

@ -82,6 +82,38 @@ void Calendar::toggle_mode()
invalidate_layout();
}
void Calendar::show_previous_date()
{
unsigned view_month = m_view_month;
unsigned view_year = m_view_year;
if (m_mode == GUI::Calendar::Month) {
--view_month;
if (view_month == 0) {
view_month = 12;
--view_year;
}
} else {
--view_year;
}
update_tiles(view_year, view_month);
}
void Calendar::show_next_date()
{
unsigned view_month = m_view_month;
unsigned view_year = m_view_year;
if (m_mode == GUI::Calendar::Month) {
++view_month;
if (view_month == 13) {
view_month = 1;
++view_year;
}
} else {
++view_year;
}
update_tiles(view_year, view_month);
}
void Calendar::resize_event(GUI::ResizeEvent& event)
{
m_event_size.set_width(event.size().width() - (frame_thickness() * 2));

View file

@ -64,6 +64,9 @@ public:
void set_show_days_of_the_week(bool b) { m_show_days = b; }
bool is_showing_days_of_the_week() const { return m_show_days; }
void show_previous_date();
void show_next_date();
Gfx::IntSize unadjusted_tile_size() const { return m_unadjusted_tile_size; }
void set_unadjusted_tile_size(int width, int height)
{