Browse Source

fix crash when zooming in on audio regions

Fixes https://todo.sr.ht/~alextee/zrythm-bug/909.
libpanel_detach
Alexandros Theodotou 10 months ago
parent
commit
3062180ce3
Signed by: alex
GPG Key ID: 022EAE42313D70F3
  1. 23
      inc/utils/gtk.h
  2. 38
      src/gui/widgets/region.c
  3. 10
      src/utils/gtk.c

23
inc/utils/gtk.h

@ -1,21 +1,5 @@ @@ -1,21 +1,5 @@
/*
* Copyright (C) 2018-2022 Alexandros Theodotou <alex at zrythm dot org>
*
* This file is part of Zrythm
*
* Zrythm is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Zrythm is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Zrythm. If not, see <https://www.gnu.org/licenses/>.
*/
// SPDX-FileCopyrightText: © 2018-2022 Alexandros Theodotou <alex@zrythm.org>
// SPDX-License-Identifier: LicenseRef-ZrythmLicense
/**
* \file
@ -772,6 +756,9 @@ z_gtk_widget_find_child_of_type ( @@ -772,6 +756,9 @@ z_gtk_widget_find_child_of_type (
void
z_gtk_list_box_remove_all_children (GtkListBox * list_box);
void
z_graphene_rect_print (const graphene_rect_t * rect);
/**
* @}
*/

38
src/gui/widgets/region.c

@ -856,7 +856,7 @@ draw_fade_part ( @@ -856,7 +856,7 @@ draw_fade_part (
}
const int step = 1;
if (fade_in_px - start_px != 0)
if (vis_fade_in_px - vis_start_px > 0)
{
double local_px_diff = (double) (fade_in_px - start_px);
@ -864,11 +864,11 @@ draw_fade_part ( @@ -864,11 +864,11 @@ draw_fade_part (
cairo_t * cr = NULL;
if (use_cairo)
{
cr = gtk_snapshot_append_cairo (
snapshot,
&GRAPHENE_RECT_INIT (
vis_start_px, 0, vis_fade_in_px - vis_start_px,
height));
graphene_rect_t grect = GRAPHENE_RECT_INIT (
vis_start_px, 0, vis_fade_in_px - vis_start_px,
height);
/*z_graphene_rect_print (&grect);*/
cr = gtk_snapshot_append_cairo (snapshot, &grect);
cairo_set_source_rgba (cr, 0.2, 0.2, 0.2, 0.6);
/*cairo_set_line_width (cr, 3);*/
}
@ -916,10 +916,11 @@ draw_fade_part ( @@ -916,10 +916,11 @@ draw_fade_part (
}
else
{
graphene_rect_t grect = GRAPHENE_RECT_INIT (
(float) i, 0, (float) step, draw_y_val);
/*z_graphene_rect_print (&grect);*/
gtk_snapshot_append_color (
snapshot, &color,
&GRAPHENE_RECT_INIT (
(float) i, 0, (float) step, draw_y_val));
snapshot, &color, &grect);
}
}
@ -941,7 +942,7 @@ draw_fade_part ( @@ -941,7 +942,7 @@ draw_fade_part (
int visible_fade_out_px = MAX (fade_out_px, vis_offset_x);
int visible_end_px = MIN (end_px, vis_offset_x + vis_width);
if (end_px - fade_out_px != 0)
if (visible_end_px - visible_fade_out_px > 0)
{
double local_px_diff = (double) (end_px - fade_out_px);
@ -949,11 +950,11 @@ draw_fade_part ( @@ -949,11 +950,11 @@ draw_fade_part (
cairo_t * cr = NULL;
if (use_cairo)
{
cr = gtk_snapshot_append_cairo (
snapshot,
&GRAPHENE_RECT_INIT (
visible_fade_out_px, 0,
visible_end_px - visible_fade_out_px, height));
graphene_rect_t grect = GRAPHENE_RECT_INIT (
visible_fade_out_px, 0,
visible_end_px - visible_fade_out_px, height);
/*z_graphene_rect_print (&grect);*/
cr = gtk_snapshot_append_cairo (snapshot, &grect);
cairo_set_source_rgba (cr, 0.2, 0.2, 0.2, 0.6);
/*cairo_set_line_width (cr, 3);*/
}
@ -1001,10 +1002,11 @@ draw_fade_part ( @@ -1001,10 +1002,11 @@ draw_fade_part (
else
{
float draw_y_val = (float) (val * height);
graphene_rect_t grect = GRAPHENE_RECT_INIT (
(float) i, 0, 1, draw_y_val);
/*z_graphene_rect_print (&grect);*/
gtk_snapshot_append_color (
snapshot, &color,
&GRAPHENE_RECT_INIT (
(float) i, 0, 1, draw_y_val));
snapshot, &color, &grect);
}
}

10
src/utils/gtk.c

@ -2154,3 +2154,13 @@ z_gtk_list_box_remove_all_children (GtkListBox * list_box) @@ -2154,3 +2154,13 @@ z_gtk_list_box_remove_all_children (GtkListBox * list_box)
gtk_list_box_remove (list_box, GTK_WIDGET (row));
}
}
void
z_graphene_rect_print (const graphene_rect_t * rect)
{
g_return_if_fail (rect->size.width >= 0);
g_return_if_fail (rect->size.height >= 0);
g_message (
"graphene rect: x %f y %f w %f h %f", rect->origin.x,
rect->origin.y, rect->size.width, rect->size.height);
}

Loading…
Cancel
Save