Skip to content
Snippets Groups Projects

leaflet: Add the over and under mode transitions

Merged Adrien Plazas requested to merge adrien.plazas/libhandy:leaflet-mode-over-under into master
All threads resolved!

This allows the mode transition animation to match the semantic of the over and under child transitions.

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • @guido.gunther mode transitions are completely different from child transitions, so nope. :) But it's pretty straightforward (and messy at the same time), since it's just drawing.

  • The bottom child moves a bit when the transition starts.

    Screenshot_from_2019-02-27_20-02-14

    Edited by Alexander Mikhaylenko
  • The issue you are mentionning is orthogonal (it was already there and visible with the sliding animation) and is solved by !240 (merged).

  • Adrien Plazas added 8 commits

    added 8 commits

    • 538bea30...96c040ca - 5 commits from branch Librem5:master
    • c71bc355 - leaflet: Clip children when drawing unfolded
    • 5de466ee - leaflet: Clip the end surface when drawing folded
    • a9a3e196 - leaflet: Add the over and under mode transition animations

    Compare with previous version

  • @exalm: I will merge this MR if you approve it.

  • @adrien.plazas nope. I should have attached an animation. This is with this MR applied on top of !240 (merged).

    Peek_2019-03-02_13-52

    This is over transition. The left pane should not move here.

    under:

    Peek_2019-03-02_13-56

    it's hard to see here, it seems the issue is there as well, but just less consistent.

    slide is fine because both panes move anyway. :)

    Edited by Alexander Mikhaylenko
  • Adrien Plazas changed milestone to %1.0

    changed milestone to %1.0

  • Adrien Plazas added 13 commits

    added 13 commits

    • a9a3e196...56b0aa62 - 10 commits from branch Librem5:master
    • afb0c9f0 - leaflet: Clip children when drawing unfolded
    • 40a979ff - leaflet: Clip the end surface when drawing folded
    • 37ce1b9c - leaflet: Add the over and under mode transition animations

    Compare with previous version

  • mentioned in issue #154 (closed)

  • Ok, so this indeed happens because the first draw(), where start/end surfaces are filled, is done already after the first allocation in transition. Either it needs to be done earlier, or it should specifically shift the widgets back, since e.g. alloc.x of the startmost child is not 0 at that point.

    • Resolved by Alexander Mikhaylenko

      A crude way to fix it:

      diff --git a/src/hdy-leaflet.c b/src/hdy-leaflet.c
      index 31aea12..c3c3419 100644
      --- a/src/hdy-leaflet.c
      +++ b/src/hdy-leaflet.c
      @@ -1508,13 +1508,11 @@ hdy_leaflet_size_allocate_folded (GtkWidget     *widget,
                     (mode_transition_type == HDY_LEAFLET_MODE_TRANSITION_TYPE_UNDER && direction == GTK_TEXT_DIR_RTL);
             priv->mode_transition.start_surface_allocation.width = under ? remaining_size : start_size;
             priv->mode_transition.start_surface_allocation.height = allocation->height;
      -      priv->mode_transition.start_surface_allocation.x = under ? 0 : remaining_start_size - start_size;
      +      priv->mode_transition.start_surface_allocation.x = remaining_start_size - start_size;
             priv->mode_transition.start_surface_allocation.y = 0;
      -      under = (mode_transition_type == HDY_LEAFLET_MODE_TRANSITION_TYPE_UNDER && direction == GTK_TEXT_DIR_LTR) ||
      -              (mode_transition_type == HDY_LEAFLET_MODE_TRANSITION_TYPE_OVER && direction == GTK_TEXT_DIR_RTL);
             priv->mode_transition.end_surface_allocation.width = end_size;
             priv->mode_transition.end_surface_allocation.height = allocation->height;
      -      priv->mode_transition.end_surface_allocation.x = under ? allocation->width - end_size : remaining_start_size + visible_size;
      +      priv->mode_transition.end_surface_allocation.x = remaining_start_size + visible_size;
             priv->mode_transition.end_surface_allocation.y = 0;
             priv->mode_transition.end_surface_clip.width = end_size;
             priv->mode_transition.end_surface_clip.height = priv->mode_transition.end_surface_allocation.height;
      @@ -1526,8 +1524,7 @@ hdy_leaflet_size_allocate_folded (GtkWidget     *widget,
             priv->mode_transition.start_surface_allocation.width = allocation->width;
             priv->mode_transition.start_surface_allocation.height = under ? remaining_size : start_size;
             priv->mode_transition.start_surface_allocation.x = 0;
      -      priv->mode_transition.start_surface_allocation.y = under ? 0 : remaining_start_size - start_size;
      -      under = mode_transition_type == HDY_LEAFLET_MODE_TRANSITION_TYPE_UNDER;
      +      priv->mode_transition.start_surface_allocation.y = remaining_start_size - start_size;
             priv->mode_transition.end_surface_allocation.width = allocation->width;
             priv->mode_transition.end_surface_allocation.height = end_size;
             priv->mode_transition.end_surface_allocation.x = 0;
      @@ -2280,6 +2277,12 @@ hdy_leaflet_draw (GtkWidget *widget,
         if (priv->visible_child) {
           if (gtk_progress_tracker_get_state (&priv->mode_transition.tracker) != GTK_PROGRESS_STATE_AFTER &&
               priv->fold == HDY_FOLD_FOLDED) {
      +      GtkTextDirection direction;
      +      gboolean is_horizontal;
      +
      +      is_horizontal = gtk_orientable_get_orientation (GTK_ORIENTABLE (widget)) == GTK_ORIENTATION_HORIZONTAL;
      +      direction = gtk_widget_get_direction (widget);
      +
             if (priv->mode_transition.start_surface == NULL &&
                 priv->mode_transition.start_surface_allocation.width != 0 &&
                 priv->mode_transition.start_surface_allocation.height != 0) {
      @@ -2350,30 +2353,54 @@ hdy_leaflet_draw (GtkWidget *widget,
       
             cairo_save (cr);
             if (priv->mode_transition.start_surface != NULL) {
      -        cairo_rectangle (cr,
      -                         priv->mode_transition.start_surface_allocation.x,
      -                         priv->mode_transition.start_surface_allocation.y,
      +        gint x, y;
      +
      +        x = priv->mode_transition.start_surface_allocation.x;
      +        y = priv->mode_transition.start_surface_allocation.y;
      +
      +        if (is_horizontal) {
      +          if ((priv->mode_transition.type == HDY_LEAFLET_MODE_TRANSITION_TYPE_OVER && direction == GTK_TEXT_DIR_LTR) ||
      +              (priv->mode_transition.type == HDY_LEAFLET_MODE_TRANSITION_TYPE_UNDER && direction == GTK_TEXT_DIR_RTL))
      +            x = 0;
      +        } else {
      +          if (priv->mode_transition.type == HDY_LEAFLET_MODE_TRANSITION_TYPE_UNDER)
      +            y = 0;
      +        }
      +
      +        cairo_rectangle (cr, x, y,
                                priv->mode_transition.start_surface_allocation.width,
                                priv->mode_transition.start_surface_allocation.height);
               cairo_clip (cr);
      -        cairo_set_source_surface (cr, priv->mode_transition.start_surface,
      -                                  priv->mode_transition.start_surface_allocation.x,
      -                                  priv->mode_transition.start_surface_allocation.y);
      +        cairo_set_source_surface (cr, priv->mode_transition.start_surface, x, y);
               cairo_paint (cr);
             }
             cairo_restore (cr);
       
             cairo_save (cr);
             if (priv->mode_transition.end_surface != NULL) {
      +        gint x, y;
      +        GtkAllocation alloc;
      +
      +        x = priv->mode_transition.end_surface_allocation.x;
      +        y = priv->mode_transition.end_surface_allocation.y;
      +        gtk_widget_get_allocation (widget, &alloc);
      +
      +        if (is_horizontal) {
      +          if ((priv->mode_transition.type == HDY_LEAFLET_MODE_TRANSITION_TYPE_UNDER && direction == GTK_TEXT_DIR_LTR) ||
      +              (priv->mode_transition.type == HDY_LEAFLET_MODE_TRANSITION_TYPE_OVER && direction == GTK_TEXT_DIR_RTL))
      +            x = alloc.width - priv->mode_transition.end_surface_allocation.width;
      +        } else {
      +          if (priv->mode_transition.type == HDY_LEAFLET_MODE_TRANSITION_TYPE_OVER)
      +            y = alloc.height - priv->mode_transition.end_surface_allocation.height;
      +        }
      +
               cairo_rectangle (cr,
                                priv->mode_transition.end_surface_clip.x,
                                priv->mode_transition.end_surface_clip.y,
                                priv->mode_transition.end_surface_clip.width,
                                priv->mode_transition.end_surface_clip.height);
               cairo_clip (cr);
      -        cairo_set_source_surface (cr, priv->mode_transition.end_surface,
      -                                  priv->mode_transition.end_surface_allocation.x,
      -                                  priv->mode_transition.end_surface_allocation.y);
      +        cairo_set_source_surface (cr, priv->mode_transition.end_surface, x, y);
               cairo_paint (cr);
             }
             cairo_restore (cr);
  • Alexander Mikhaylenko mentioned in merge request !324 (closed)

    mentioned in merge request !324 (closed)

  • Adrien Plazas added 129 commits

    added 129 commits

    • 37ce1b9c...9ecbf214 - 126 commits from branch Librem5:master
    • cb9b8d6a - leaflet: Clip children when drawing unfolded
    • e474eafa - leaflet: Clip the end surface when drawing folded
    • 19baf6a5 - leaflet: Add the over and under mode transition animations

    Compare with previous version

  • Rebased.

  • Adrien Plazas added 2 commits

    added 2 commits

    • 8573f56d - leaflet: Fix the folding sliding children padding
    • 886be959 - leaflet: Add the over and under mode transition animations

    Compare with previous version

  • @exalm: I applied your patch as a separate commit, what do you think? I'd be happy to merge it that way. :)

  • Adrien Plazas added 2 commits

    added 2 commits

    • 7af1ad3d - leaflet: Fix the folding sliding children padding
    • 9c6e1b76 - leaflet: Add the over and under mode transition animations

    Compare with previous version

  • Alexander Mikhaylenko resolved all threads

    resolved all threads

  • merged

  • Please register or sign in to reply
    Loading