views/month-cell: Replace overlay with box and empty bin
Since we don't make use of the overlay anymore, it's best to remove it altogether. This also changes the behavior of the widgets a bit: It adds an empty AdwBin widget which expands vertically, allowing us to avoid aligning the header and overflow button. The pattern goes from reducible (where we deduct the overflow height to retrieve the content) to additive (where we add the overflow height to the content height), which requires us to adapt GcalMonthViewRow with this new behavior. Part-of: <https://gitlab.gnome.org/GNOME/gnome-calendar/-/merge_requests/743>
This commit is contained in:
@@ -27,11 +27,10 @@ template $GcalMonthCell: Widget {
|
||||
}
|
||||
}
|
||||
|
||||
child: Overlay overlay {
|
||||
[overlay]
|
||||
Adw.Bin {
|
||||
valign: start;
|
||||
child: Box {
|
||||
orientation: vertical;
|
||||
|
||||
Adw.Bin {
|
||||
child: Box header_box {
|
||||
spacing: 6;
|
||||
margin-top: 6;
|
||||
@@ -65,10 +64,11 @@ template $GcalMonthCell: Widget {
|
||||
};
|
||||
}
|
||||
|
||||
[overlay]
|
||||
Adw.Bin {
|
||||
valign: end;
|
||||
Adw.Bin content_space {
|
||||
vexpand: true;
|
||||
}
|
||||
|
||||
Adw.Bin {
|
||||
child: Button overflow_button {
|
||||
accessible-role: toggle_button;
|
||||
sensitive: false;
|
||||
|
||||
@@ -44,7 +44,7 @@ struct _GcalMonthCell
|
||||
|
||||
GtkWidget *overflow_button;
|
||||
GtkInscription *overflow_inscription;
|
||||
GtkWidget *overlay;
|
||||
GtkWidget *content_space;
|
||||
|
||||
gboolean different_month;
|
||||
gboolean selected;
|
||||
@@ -409,7 +409,7 @@ gcal_month_cell_class_init (GcalMonthCellClass *klass)
|
||||
gtk_widget_class_bind_template_child (widget_class, GcalMonthCell, header_box);
|
||||
gtk_widget_class_bind_template_child (widget_class, GcalMonthCell, overflow_button);
|
||||
gtk_widget_class_bind_template_child (widget_class, GcalMonthCell, overflow_inscription);
|
||||
gtk_widget_class_bind_template_child (widget_class, GcalMonthCell, overlay);
|
||||
gtk_widget_class_bind_template_child (widget_class, GcalMonthCell, content_space);
|
||||
gtk_widget_class_bind_template_child (widget_class, GcalMonthCell, temp_label);
|
||||
gtk_widget_class_bind_template_child (widget_class, GcalMonthCell, weather_icon);
|
||||
|
||||
@@ -538,8 +538,7 @@ gcal_month_cell_get_content_space (GcalMonthCell *self)
|
||||
{
|
||||
g_return_val_if_fail (GCAL_IS_MONTH_CELL (self), -1);
|
||||
|
||||
return gtk_widget_get_height (GTK_WIDGET (self)) -
|
||||
gcal_month_cell_get_header_height (self);
|
||||
return gtk_widget_get_height (self->content_space);
|
||||
}
|
||||
|
||||
gint
|
||||
|
||||
@@ -549,8 +549,8 @@ prepare_layout_blocks (GcalMonthViewRow *self,
|
||||
{
|
||||
GPtrArray *blocks_per_day[N_WEEKDAYS];
|
||||
gboolean cell_will_overflow[N_WEEKDAYS] = { FALSE, };
|
||||
guint available_height_without_overflow[N_WEEKDAYS] = { 0, };
|
||||
guint available_height_with_overflow[N_WEEKDAYS] = { 0, };
|
||||
guint combined_height[N_WEEKDAYS] = { 0, };
|
||||
guint content_height[N_WEEKDAYS] = { 0, };
|
||||
guint weekday_heights[N_WEEKDAYS] = { 0, };
|
||||
guint n_events;
|
||||
|
||||
@@ -568,8 +568,8 @@ prepare_layout_blocks (GcalMonthViewRow *self,
|
||||
content_space--;
|
||||
overflow_height = gcal_month_cell_get_overflow_height (GCAL_MONTH_CELL (self->day_cells[i]));
|
||||
|
||||
available_height_without_overflow[i] = content_space;
|
||||
available_height_with_overflow[i] = content_space - overflow_height;
|
||||
combined_height[i] = content_space + overflow_height;
|
||||
content_height[i] = content_space;
|
||||
blocks_per_day[i] = g_ptr_array_sized_new (n_events);
|
||||
}
|
||||
|
||||
@@ -606,7 +606,7 @@ prepare_layout_blocks (GcalMonthViewRow *self,
|
||||
|
||||
g_ptr_array_add (blocks_per_day[cell], block);
|
||||
weekday_heights[cell] += block->height;
|
||||
cell_will_overflow[cell] |= weekday_heights[cell] > available_height_without_overflow[cell];
|
||||
cell_will_overflow[cell] |= weekday_heights[cell] > combined_height[cell];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -629,9 +629,9 @@ prepare_layout_blocks (GcalMonthViewRow *self,
|
||||
gint available_height;
|
||||
|
||||
if (cell_will_overflow[block_cell])
|
||||
available_height = available_height_with_overflow[block_cell];
|
||||
available_height = content_height[block_cell];
|
||||
else
|
||||
available_height = available_height_without_overflow[block_cell];
|
||||
available_height = combined_height[block_cell];
|
||||
|
||||
block->visible &= available_height > block->height;
|
||||
}
|
||||
@@ -640,8 +640,8 @@ prepare_layout_blocks (GcalMonthViewRow *self,
|
||||
{
|
||||
if (block->visible)
|
||||
{
|
||||
available_height_with_overflow[block_cell] -= block->height;
|
||||
available_height_without_overflow[block_cell] -= block->height;
|
||||
content_height[block_cell] -= block->height;
|
||||
combined_height[block_cell] -= block->height;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user