<commit_before>/*
 * mx-box-layout.h: box layout actor
 *
 * Copyright 2009 Intel Corporation.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms and conditions of the GNU Lesser General Public License,
 * version 2.1, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for
 * more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * Written by: <NAME> <<EMAIL>>
 *
 */

/**
 * SECTION:mx-box-layout
 * @short_description: a layout container arranging children in a single line
 *
 * The #MxBoxLayout arranges its children along a single line, where each
 * child can be allocated either its preferred size or larger if the expand
 * option is set. If the fill option is set, the actor will be allocated more
 * than its requested size. If the fill option is not set, but the expand option
 * is enabled, then the position of the actor within the available space can
 * be determined by the alignment child property.
 *
 * <figure id="mx-box-layout-horizontal">
 *   <title>Box layout with horizontal flow</title>
 *   <para>The image shows an #MxBoxLayout with the
 *   #MxBoxLayout:vertical property set to
 *   #FALSE.</para>
 *   <graphic fileref="MxBoxLayout-horizontal.png" format="PNG"/>
 * </figure>
 *
 * <figure id="mx-box-layout-vertical">
 *   <title>Box layout with vertical flow</title>
 *   <para>The image shows an #MxBoxLayout with the
 *   #MxBoxLayout:vertical property set to
 *   #TRUE.</para>
 *   <graphic fileref="MxBoxLayout-vertical.png" format="PNG"/>
 * </figure>
 */

#include "mx-box-layout.h"

#include "mx-private.h"
#include "mx-scrollable.h"
#include "mx-box-layout-child.h"



static void mx_box_container_iface_init (ClutterContainerIface *iface);
static void mx_box_scrollable_interface_init (MxScrollableInterface *iface);

G_DEFINE_TYPE_WITH_CODE (MxBoxLayout, mx_box_layout, MX_TYPE_WIDGET,
                         G_IMPLEMENT_INTERFACE (CLUTTER_TYPE_CONTAINER,
                                                mx_box_container_iface_init)
                         G_IMPLEMENT_INTERFACE (MX_TYPE_SCROLLABLE,
                                                mx_box_scrollable_interface_init));

#define BOX_LAYOUT_PRIVATE(o) \
  (G_TYPE_INSTANCE_GET_PRIVATE ((o), MX_TYPE_BOX_LAYOUT, MxBoxLayoutPrivate))

enum {
  PROP_0,

  PROP_VERTICAL,
  PROP_PACK_START,
  PROP_SPACING,

  PROP_HADJUST,
  PROP_VADJUST,

  PROP_ENABLE_ANIMATIONS
};

struct _MxBoxLayoutPrivate
{
  GList        *children;

  guint         spacing;

  guint         is_vertical : 1;
  guint         is_pack_start : 1;

  MxAdjustment *hadjustment;
  MxAdjustment *vadjustment;

  GHashTable      *start_allocations;
  ClutterTimeline *timeline;
  ClutterAlpha    *alpha;
  guint            is_animating : 1;
  guint            enable_animations : 1;
};

void _mx_box_layout_finish_animation (MxBoxLayout *box);

void
_mx_box_layout_start_animation (MxBoxLayout *box)
{
  MxBoxLayoutPrivate *priv = box->priv;

  if (priv->is_animating || !priv->enable_animations)
      return;

  if (!CLUTTER_ACTOR_IS_MAPPED (CLUTTER_ACTOR (box)))
    return;

  priv->is_animating = TRUE;

  priv->timeline = clutter_timeline_new (500);
  g_signal_connect_swapped (priv->timeline, "new-frame",
                            G_CALLBACK (clutter_actor_queue_relayout), box);
  g_signal_connect_swapped (priv->timeline, "completed",
                            G_CALLBACK (_mx_box_layout_finish_animation), box);

  priv->alpha = clutter_alpha_new_full (priv->timeline,
                                        CLUTTER_EASE_OUT_CUBIC);

  clutter_timeline_start (priv->timeline);
}

void
_mx_box_layout_finish_animation (MxBoxLayout *box)
{
  MxBoxLayoutPrivate *priv = box->priv;<commit_msg>[box-layout] reduce the default animation timeline length<commit_after>/*
 * mx-box-layout.h: box layout actor
 *
 * Copyright 2009 Intel Corporation.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms and conditions of the GNU Lesser General Public License,
 * version 2.1, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for
 * more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * Written by: <NAME> <<EMAIL>>
 *
 */

/**
 * SECTION:mx-box-layout
 * @short_description: a layout container arranging children in a single line
 *
 * The #MxBoxLayout arranges its children along a single line, where each
 * child can be allocated either its preferred size or larger if the expand
 * option is set. If the fill option is set, the actor will be allocated more
 * than its requested size. If the fill option is not set, but the expand option
 * is enabled, then the position of the actor within the available space can
 * be determined by the alignment child property.
 *
 * <figure id="mx-box-layout-horizontal">
 *   <title>Box layout with horizontal flow</title>
 *   <para>The image shows an #MxBoxLayout with the
 *   #MxBoxLayout:vertical property set to
 *   #FALSE.</para>
 *   <graphic fileref="MxBoxLayout-horizontal.png" format="PNG"/>
 * </figure>
 *
 * <figure id="mx-box-layout-vertical">
 *   <title>Box layout with vertical flow</title>
 *   <para>The image shows an #MxBoxLayout with the
 *   #MxBoxLayout:vertical property set to
 *   #TRUE.</para>
 *   <graphic fileref="MxBoxLayout-vertical.png" format="PNG"/>
 * </figure>
 */

#include "mx-box-layout.h"

#include "mx-private.h"
#include "mx-scrollable.h"
#include "mx-box-layout-child.h"



static void mx_box_container_iface_init (ClutterContainerIface *iface);
static void mx_box_scrollable_interface_init (MxScrollableInterface *iface);

G_DEFINE_TYPE_WITH_CODE (MxBoxLayout, mx_box_layout, MX_TYPE_WIDGET,
                         G_IMPLEMENT_INTERFACE (CLUTTER_TYPE_CONTAINER,
                                                mx_box_container_iface_init)
                         G_IMPLEMENT_INTERFACE (MX_TYPE_SCROLLABLE,
                                                mx_box_scrollable_interface_init));

#define BOX_LAYOUT_PRIVATE(o) \
  (G_TYPE_INSTANCE_GET_PRIVATE ((o), MX_TYPE_BOX_LAYOUT, MxBoxLayoutPrivate))

enum {
  PROP_0,

  PROP_VERTICAL,
  PROP_PACK_START,
  PROP_SPACING,

  PROP_HADJUST,
  PROP_VADJUST,

  PROP_ENABLE_ANIMATIONS
};

struct _MxBoxLayoutPrivate
{
  GList        *children;

  guint         spacing;

  guint         is_vertical : 1;
  guint         is_pack_start : 1;

  MxAdjustment *hadjustment;
  MxAdjustment *vadjustment;

  GHashTable      *start_allocations;
  ClutterTimeline *timeline;
  ClutterAlpha    *alpha;
  guint            is_animating : 1;
  guint            enable_animations : 1;
};

void _mx_box_layout_finish_animation (MxBoxLayout *box);

void
_mx_box_layout_start_animation (MxBoxLayout *box)
{
  MxBoxLayoutPrivate *priv = box->priv;

  if (priv->is_animating || !priv->enable_animations)
      return;

  if (!CLUTTER_ACTOR_IS_MAPPED (CLUTTER_ACTOR (box)))
    return;

  priv->is_animating = TRUE;

  priv->timeline = clutter_timeline_new (300);
  g_signal_connect_swapped (priv->timeline, "new-frame",
                            G_CALLBACK (clutter_actor_queue_relayout), box);
  g_signal_connect_swapped (priv->timeline, "completed",
                            G_CALLBACK (_mx_box_layout_finish_animation), box);

  priv->alpha = clutter_alpha_new_full (priv->timeline,
                                        CLUTTER_EASE_OUT_CUBIC);

  clutter_timeline_start (priv->timeline);
}

void
_mx_box_layout_finish_animation (MxBoxLayout *box)
{
  MxBoxLayoutPrivate *priv = box->priv;
{'fraction_non_alphanumeric': 0.08527784459947077, 'fraction_numerical': 0.0060139523694972335, 'mean_word_length': 3.2905056759545923, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 59, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2712560', 'n_tokens_mistral': 2642, 'n_tokens_neox': 2550, 'n_words': 745}