~alextee/zrythm-devel

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
1

[PATCH] Popover menu position fix on bottom bar

Robert Panovics <robert.panovics@gmail.com>
Details
Message ID
<20220413190001.37084-1-robert.panovics@gmail.com>
DKIM signature
pass
Download raw message
Patch: +30 -2
Reparenting of popover menu for transport playhead and
BPM for positioning

Fixes https://todo.sr.ht/~alextee/zrythm-bug/860

Signed-off-by: Robert Panovics <robert.panovics@gmail.com>
---
 src/gui/widgets/bot_bar.c | 32 ++++++++++++++++++++++++++++++--
 1 file changed, 30 insertions(+), 2 deletions(-)

diff --git a/src/gui/widgets/bot_bar.c b/src/gui/widgets/bot_bar.c
index dc3cec839..fd41fd89b 100644
--- a/src/gui/widgets/bot_bar.c
+++ b/src/gui/widgets/bot_bar.c
@@ -125,6 +125,18 @@ activate_jack_mode (
}
#endif

static void
popover_menu_set_parent (
  GtkWidget *      parent,
  GtkPopoverMenu * self)
{
  GtkWidget * ref =
    g_object_ref (GTK_WIDGET (self));
  gtk_widget_unparent (ref);
  gtk_widget_set_parent (GTK_WIDGET (ref), parent);
  g_object_unref (ref);
}

static void
on_bpm_right_click (
  GtkGestureClick * gesture,
@@ -147,8 +159,16 @@ on_bpm_right_click (
    _ ("Tap"), NULL, "app.tap-bpm");
  g_menu_append_item (menu, menuitem);

  popover_menu_set_parent (
    GTK_WIDGET (self->digital_bpm),
    self->popover_menu);

  z_gtk_show_context_menu_from_g_menu (
    self->popover_menu, x, y, menu);
    self->popover_menu,
    gtk_widget_get_allocated_width (
      GTK_WIDGET (self->digital_bpm))
      / 2.0,
    0.0, menu);
}

static void
@@ -217,8 +237,16 @@ on_transport_playhead_right_click (
    GTK_WIDGET (self), "bot-bar",
    G_ACTION_GROUP (action_group));

  popover_menu_set_parent (
    GTK_WIDGET (self->digital_transport),
    self->popover_menu);

  z_gtk_show_context_menu_from_g_menu (
    self->popover_menu, x, y, menu);
    self->popover_menu,
    gtk_widget_get_allocated_width (
      GTK_WIDGET (self->digital_transport))
      / 2.0,
    0.0, menu);
}

void
-- 
2.35.1
Details
Message ID
<ec5ffc29f6fcfd6ff774b3af9511dea9ddd419ff.camel@zrythm.org>
In-Reply-To
<20220413190001.37084-1-robert.panovics@gmail.com> (view parent)
DKIM signature
missing
Download raw message
Thanks! I think this needs changes/refactoring.

2022-04-13 (水) の 21:00 +0200 に Robert Panovics さんは書きました:
> Reparenting of popover menu for transport playhead and
> BPM for positioning
> 
> Fixes https://todo.sr.ht/~alextee/zrythm-bug/860
> 
> Signed-off-by: Robert Panovics <robert.panovics@gmail.com>
> ---
>  src/gui/widgets/bot_bar.c | 32 ++++++++++++++++++++++++++++++--
>  1 file changed, 30 insertions(+), 2 deletions(-)
> 
> diff --git a/src/gui/widgets/bot_bar.c b/src/gui/widgets/bot_bar.c
> index dc3cec839..fd41fd89b 100644
> --- a/src/gui/widgets/bot_bar.c
> +++ b/src/gui/widgets/bot_bar.c
> @@ -125,6 +125,18 @@ activate_jack_mode (
>  }
>  #endif
>  
> +static void
> +popover_menu_set_parent (
> +  GtkWidget *      parent,
> +  GtkPopoverMenu * self)

As a convention, the "subject" of a function (usually something called
"self") should be the first argument.

> +{
> +  GtkWidget * ref =
> +    g_object_ref (GTK_WIDGET (self));
> +  gtk_widget_unparent (ref);
> +  gtk_widget_set_parent (GTK_WIDGET (ref), parent);
> +  g_object_unref (ref);
> +}
> +
>  static void
>  on_bpm_right_click (
>    GtkGestureClick * gesture,
> @@ -147,8 +159,16 @@ on_bpm_right_click (
>      _ ("Tap"), NULL, "app.tap-bpm");
>    g_menu_append_item (menu, menuitem);
>  
> +  popover_menu_set_parent (
> +    GTK_WIDGET (self->digital_bpm),
> +    self->popover_menu);

I don't think it's a good idea to keep reusing a single popover in many
different widgets. Each right-clickable widget should have its own
popover in its own code, so this should go to DigitalMeterWidget. I
would add a Bin layout on DigitalMeterWidget's widget class (see gtk
docs for GtkBinLayout or grep the code for `BIN_LAYOUT` for examples)
and add a popover in there instead of in this file (note you need to
unparent it during `dispose()`). BotBarWidget should have no popover at
all.

> +
>    z_gtk_show_context_menu_from_g_menu (
> -    self->popover_menu, x, y, menu);
> +    self->popover_menu,
> +    gtk_widget_get_allocated_width (
> +      GTK_WIDGET (self->digital_bpm))
> +      / 2.0,
> +    0.0, menu);
>  }
>  
>  static void
> @@ -217,8 +237,16 @@ on_transport_playhead_right_click (
>      GTK_WIDGET (self), "bot-bar",
>      G_ACTION_GROUP (action_group));

Same as above, this should be handled inside DigitalMeterWidget and all
popover logic should be removed from this file.

>  
> +  popover_menu_set_parent (
> +    GTK_WIDGET (self->digital_transport),
> +    self->popover_menu);
> +
>    z_gtk_show_context_menu_from_g_menu (
> -    self->popover_menu, x, y, menu);
> +    self->popover_menu,
> +    gtk_widget_get_allocated_width (
> +      GTK_WIDGET (self->digital_transport))
> +      / 2.0,
> +    0.0, menu);
>  }
>  
>  void
Reply to thread Export thread (mbox)