Пример #1
0
static void
mex_epg_grid_get_preferred_width (ClutterActor *actor,
                                  gfloat        for_height,
                                  gfloat       *min_width_p,
                                  gfloat       *nat_width_p)
{
  MexEpgGrid *grid = MEX_EPG_GRID (actor);
  MexEpgGridPrivate *priv = grid->priv;
  MxPadding padding;
  GTimeSpan diff;

  mx_widget_get_padding (MX_WIDGET (actor), &padding);

  if (priv->first_date == NULL || priv->last_date == NULL)
    diff = 0;
  else
    diff = g_date_time_difference (priv->last_date, priv->first_date);

  if (min_width_p)
    *min_width_p = 0;

  if (nat_width_p)
    *nat_width_p = time_span_to_pixels (grid, diff) + padding.left +
                   padding.right;
}
Пример #2
0
static void
mex_clock_bin_get_preferred_height (ClutterActor *actor,
                                    gfloat        for_width,
                                    gfloat       *min_height_p,
                                    gfloat       *nat_height_p)
{
  MxPadding padding;
  gfloat min_height, nat_height;

  MexClockBinPrivate *priv = MEX_CLOCK_BIN (actor)->priv;

  CLUTTER_ACTOR_CLASS (mex_clock_bin_parent_class)->
    get_preferred_height (actor, for_width, min_height_p, nat_height_p);

  mx_widget_get_padding (MX_WIDGET (actor), &padding);
  if (for_width >= 0)
    for_width = MAX (0, for_width - padding.left - padding.right);

  clutter_actor_get_preferred_height (priv->clock_hbox,
                                      for_width,
                                      &min_height,
                                      &nat_height);

  min_height += padding.top + padding.bottom;
  nat_height += padding.top + padding.bottom;

  if (min_height_p && (*min_height_p < min_height))
    *min_height_p = min_height;
  if (nat_height_p && (*nat_height_p < nat_height))
    *nat_height_p = nat_height;
}
Пример #3
0
static void
mex_column_paint (ClutterActor *actor)
{
  GList *c;
  MxPadding padding;
  ClutterActorBox box;

  MexColumn *self = MEX_COLUMN (actor);
  MexColumnPrivate *priv = self->priv;

  CLUTTER_ACTOR_CLASS (mex_column_parent_class)->paint (actor);

  mx_widget_get_padding (MX_WIDGET (actor), &padding);
  clutter_actor_get_allocation_box (actor, &box);

  cogl_clip_push_rectangle (padding.left,
                            padding.top + priv->adjustment_value,
                            box.x2 - box.x1 - padding.right,
                            box.y2 - box.y1 - padding.bottom +
                            priv->adjustment_value);

  for (c = priv->children; c; c = c->next)
    {
      /* skip the current focus and paint it last*/
      if (priv->current_focus != c->data)
        clutter_actor_paint (c->data);
    }

  /* paint the current focused actor last to ensure any shadow is drawn
   * on top of other items */
  if (priv->current_focus)
    clutter_actor_paint (priv->current_focus);

  cogl_clip_pop ();
}
Пример #4
0
static void
mpl_entry_get_preferred_height (ClutterActor *actor,
                                gfloat        for_width,
                                gfloat       *min_height_p,
                                gfloat       *natural_height_p)
{
  MplEntryPrivate *priv = MPL_ENTRY (actor)->priv;
  MxPadding padding = { 0, 0, 0, 0 };
  gfloat min_height_entry, min_height_button;
  gfloat natural_height_entry, natural_height_button;

  mx_widget_get_padding (MX_WIDGET (actor), &padding);

  clutter_actor_get_preferred_height (priv->entry, for_width,
                                      &min_height_entry,
                                      &natural_height_entry);

  clutter_actor_get_preferred_height (priv->table, for_width,
                                     &min_height_button,
                                     &natural_height_button);

  if (min_height_p)
    *min_height_p = padding.top +
                    MAX (min_height_entry, min_height_button) +
                    padding.bottom;

  if (natural_height_p)
    *natural_height_p = padding.top +
                        MAX (natural_height_entry, natural_height_button) +
                        padding.bottom;
}
Пример #5
0
static void
mpl_entry_get_preferred_width (ClutterActor *actor,
                               gfloat        for_height,
                               gfloat       *min_width_p,
                               gfloat       *natural_width_p)
{
  MplEntryPrivate *priv = MPL_ENTRY (actor)->priv;
  MxPadding padding = { 0, 0, 0, 0 };
  gfloat min_width_entry, min_width_button;
  gfloat natural_width_entry, natural_width_button;

  mx_widget_get_padding (MX_WIDGET (actor), &padding);

  clutter_actor_get_preferred_width (priv->entry, for_height,
                                     &min_width_entry,
                                     &natural_width_entry);

  clutter_actor_get_preferred_width (priv->table, for_height,
                                     &min_width_button,
                                     &natural_width_button);

  if (min_width_p)
    *min_width_p = padding.left +
                   min_width_entry +
                   min_width_button +
                   padding.right;

  if (natural_width_p)
    *natural_width_p = padding.left +
                       natural_width_entry +
                       natural_width_button +
                       padding.right;
}
Пример #6
0
static void
mex_music_player_allocate (ClutterActor           *actor,
                           const ClutterActorBox  *box,
                           ClutterAllocationFlags  flags)
{
  MexMusicPlayerPrivate *priv = MEX_MUSIC_PLAYER (actor)->priv;
  ClutterActorBox child_box;
  ClutterActor *child;
  gfloat w, h;
  MxPadding padding;

  CLUTTER_ACTOR_CLASS (mex_music_player_parent_class)->allocate (actor, box,
                                                                 flags);

  mx_widget_get_padding (MX_WIDGET (actor), &padding);

  child = mex_script_get_actor (priv->script, "box");
  clutter_actor_get_preferred_size (child, NULL, NULL, &w, &h);

  child_box.x1 = padding.left + (box->x2 - box->x1 - padding.left - padding.right) / 2 - w / 2;
  child_box.y1 = (box->y2 - box->y1 - padding.bottom) - h;
  child_box.x2 = child_box.x1 + w;
  child_box.y2 = child_box.y1 + h;
  clutter_actor_allocate (child, &child_box, flags);
}
Пример #7
0
static void
mx_frame_get_preferred_height (ClutterActor *actor,
                               gfloat        for_width,
                               gfloat       *min_height,
                               gfloat       *pref_height)
{
    MxFramePrivate *priv = ((MxFrame *) actor)->priv;
    MxPadding padding;

    mx_widget_get_padding (MX_WIDGET (actor), &padding);

    if (min_height)
        *min_height = 0;

    if (pref_height)
        *pref_height = 0;

    if (priv->child)
    {
        clutter_actor_get_preferred_height (priv->child,
                                            for_width - padding.left - padding.right,
                                            min_height, pref_height);
    }

    if (min_height)
        *min_height += padding.top + padding.bottom;

    if (pref_height)
        *pref_height += padding.top + padding.bottom;
}
Пример #8
0
/**
 * mx_bin_allocate_child:
 * @bin: An #MxBin
 * @box: The allocation box of the parent actor.
 * @flags: #ClutterAllocationFlags, usually provided by the.
 * clutter_actor_allocate function.
 *
 * Allocates the child of an #MxBin using the width and height from @box.
 * This function should usually only be called by subclasses of #MxBin.
 *
 * This function can be used to allocate the child of an #MxBin if no special
 * allocation requirements are needed. It is similar to
 * #mx_allocate_align_fill, except that it reads the alignment, padding and
 * fill values from the #MxBin, and will call #clutter_actor_allocate on the
 * child.
 *
 */
void
mx_bin_allocate_child (MxBin                  *bin,
                       const ClutterActorBox  *box,
                       ClutterAllocationFlags  flags)
{
  MxBinPrivate *priv;

  g_return_if_fail (MX_IS_BIN (bin));

  priv = bin->priv;

  if (priv->child)
    {
      MxPadding padding;
      ClutterActorBox allocation = { 0, };

      mx_widget_get_padding (MX_WIDGET (bin), &padding);

      allocation.x1 = padding.left;
      allocation.x2 = box->x2 - box->x1 - padding.right;
      allocation.y1 = padding.top;
      allocation.y2 = box->y2 - box->y1 - padding.bottom;

      mx_allocate_align_fill (priv->child,
                              &allocation,
                              priv->x_align,
                              priv->y_align,
                              priv->x_fill,
                              priv->y_fill);

      clutter_actor_allocate (priv->child, &allocation, flags);
    }
}
Пример #9
0
static void
mx_scroll_view_allocate (ClutterActor          *actor,
                         const ClutterActorBox *box,
                         ClutterAllocationFlags flags)
{
  MxPadding padding;
  ClutterActorBox child_box;
  gfloat avail_width, avail_height, sb_width, sb_height;

  MxScrollViewPrivate *priv = MX_SCROLL_VIEW (actor)->priv;

  CLUTTER_ACTOR_CLASS (mx_scroll_view_parent_class)->
    allocate (actor, box, flags);

  mx_widget_get_padding (MX_WIDGET (actor), &padding);

  avail_width = (box->x2 - box->x1) - padding.left - padding.right;
  avail_height = (box->y2 - box->y1) - padding.top - padding.bottom;

  sb_width = priv->scrollbar_width;
  sb_height = priv->scrollbar_height;

  if (!CLUTTER_ACTOR_IS_VISIBLE (priv->vscroll))
    sb_width = 0;

  if (!CLUTTER_ACTOR_IS_VISIBLE (priv->hscroll))
    sb_height = 0;

  /* Vertical scrollbar */
  if (CLUTTER_ACTOR_IS_VISIBLE (priv->vscroll))
    {
      child_box.x1 = avail_width - sb_width;
      child_box.y1 = padding.top;
      child_box.x2 = avail_width;
      child_box.y2 = child_box.y1 + avail_height - sb_height;

      clutter_actor_allocate (priv->vscroll, &child_box, flags);
    }

  /* Horizontal scrollbar */
  if (CLUTTER_ACTOR_IS_VISIBLE (priv->hscroll))
    {
      child_box.x1 = padding.left;
      child_box.x2 = child_box.x1 + avail_width - sb_width;
      child_box.y1 = avail_height - sb_height;
      child_box.y2 = avail_height;

      clutter_actor_allocate (priv->hscroll, &child_box, flags);
    }


  /* Child */
  child_box.x1 = padding.left;
  child_box.x2 = avail_width - sb_width;
  child_box.y1 = padding.top;
  child_box.y2 = avail_height - sb_height;

  if (priv->child)
    clutter_actor_allocate (priv->child, &child_box, flags);
}
Пример #10
0
static void
mx_progress_bar_allocate_fill (MxProgressBar         *self,
                               const ClutterActorBox *box,
                               ClutterAllocationFlags flags)
{
  ClutterActorBox box_data;
  MxProgressBarPrivate *priv = self->priv;

  if (!box)
    {
      clutter_actor_get_allocation_box (CLUTTER_ACTOR (self), &box_data);
      box = &box_data;
    }

  if (priv->progress)
    {
      ClutterActorBox child_box;
      MxPadding padding;

      mx_widget_get_padding (MX_WIDGET (self), &padding);

      child_box.x1 = padding.left;
      child_box.y1 = padding.top;
      child_box.y2 = (box->y2 - box->y1) - padding.bottom;
      child_box.x2 = ((box->x2 - box->x1 - padding.left - padding.right) *
                      priv->progress) + padding.left;

      clutter_actor_allocate (priv->fill, &child_box, flags);
    }
}
Пример #11
0
static void
mx_notebook_allocate (ClutterActor          *actor,
                      const ClutterActorBox *box,
                      ClutterAllocationFlags flags)
{
  MxNotebookPrivate *priv = MX_NOTEBOOK (actor)->priv;
  GList *l;
  MxPadding padding;
  ClutterActorBox childbox;

  CLUTTER_ACTOR_CLASS (mx_notebook_parent_class)->allocate (actor, box, flags);

  mx_widget_get_padding (MX_WIDGET (actor), &padding);

  childbox.x1 = 0 + padding.left;
  childbox.x2 = box->x2 - box->x1 - padding.right;

  childbox.y1 = 0 + padding.top;
  childbox.y2 = box->y2 - box->y1 - padding.bottom;

  for (l = priv->children; l; l = l->next)
    {
      ClutterActor *child;

      child = CLUTTER_ACTOR (l->data);

      if (CLUTTER_ACTOR_IS_VISIBLE (l->data))
        clutter_actor_allocate (child, &childbox, flags);
    }
}
Пример #12
0
static void
mx_progress_bar_get_preferred_width (ClutterActor *actor,
                                     gfloat        for_height,
                                     gfloat       *min_width_p,
                                     gfloat       *nat_width_p)
{
  MxPadding padding;
  MxProgressBarPrivate *priv = MX_PROGRESS_BAR (actor)->priv;
  gfloat height;

  clutter_actor_get_preferred_width (priv->fill,
                                     for_height,
                                     min_width_p,
                                     nat_width_p);

  clutter_actor_get_preferred_height (priv->fill,
                                      -1,
                                      &height,
                                      NULL);

  mx_widget_get_padding (MX_WIDGET (actor), &padding);

  if (min_width_p)
    *min_width_p += padding.left + padding.right;

  /* Add an arbitrary amount to the width for preferred width, so that the
   * indicator is visible and can display some values */
  if (nat_width_p)
    *nat_width_p += padding.left + padding.right + height * 4;
}
static void
mx_label_get_preferred_width (ClutterActor *actor,
                              gfloat        for_height,
                              gfloat       *min_width_p,
                              gfloat       *natural_width_p)
{
  MxLabelPrivate *priv = MX_LABEL (actor)->priv;
  MxPadding padding = { 0, };

  mx_widget_get_padding (MX_WIDGET (actor), &padding);

  for_height -= padding.top + padding.bottom;

  clutter_actor_get_preferred_width (priv->label, for_height,
                                     min_width_p,
                                     natural_width_p);

  /* If we're fading out, make sure our minimum width is zero */
  if (priv->fade_out && min_width_p)
    *min_width_p = 0;

  if (min_width_p)
    *min_width_p += padding.left + padding.right;

  if (natural_width_p)
    *natural_width_p += padding.left + padding.right;
}
static void
mnb_fancy_bin_allocate (ClutterActor          *actor,
                        const ClutterActorBox *box,
                        ClutterAllocationFlags flags)
{
  MxPadding padding;
  ClutterActorBox child_box;

  MnbFancyBinPrivate *priv = MNB_FANCY_BIN (actor)->priv;

  mx_widget_get_padding (MX_WIDGET (actor), &padding);

  if (priv->real_child)
    clutter_actor_allocate_preferred_size (priv->real_child, flags);

  child_box.x1 = padding.left;
  child_box.x2 = box->x2 - box->x1 - padding.right;
  child_box.y1 = padding.top;
  child_box.y2 = box->y2 - box->y1 - padding.bottom;

  if (priv->child)
    clutter_actor_allocate (priv->child, &child_box, flags);

  if (priv->clone)
    clutter_actor_allocate (priv->clone, &child_box, flags);

  CLUTTER_ACTOR_CLASS (mnb_fancy_bin_parent_class)->
    allocate (actor, box, flags);
}
static void
mnb_fancy_bin_get_preferred_height (ClutterActor *actor,
                                    gfloat        for_width,
                                    gfloat       *min_height_p,
                                    gfloat       *nat_height_p)
{
  MxPadding padding;
  MnbFancyBinPrivate *priv = MNB_FANCY_BIN (actor)->priv;

  if (min_height_p)
    *min_height_p = 0;
  if (nat_height_p)
    *nat_height_p = 0;

  if (priv->real_child)
    clutter_actor_get_preferred_height (priv->real_child,
                                        for_width,
                                        min_height_p,
                                        nat_height_p);

  mx_widget_get_padding (MX_WIDGET (actor), &padding);

  if (min_height_p)
    *min_height_p += padding.top + padding.bottom;
  if (nat_height_p)
    *nat_height_p += padding.top + padding.bottom;
}
Пример #16
0
static void
mex_column_pick (ClutterActor *actor, const ClutterColor *color)
{
  GList *c;
  gdouble value;
  MxPadding padding;
  ClutterActorBox box;

  MexColumn *self = MEX_COLUMN (actor);
  MexColumnPrivate *priv = self->priv;

  CLUTTER_ACTOR_CLASS (mex_column_parent_class)->pick (actor, color);

  /* Don't pick children when we don't have focus */
  if (!priv->has_focus)
    return;

  mx_widget_get_padding (MX_WIDGET (actor), &padding);
  clutter_actor_get_allocation_box (actor, &box);
  if (priv->adjustment)
    value = priv->adjustment_value;
  else
    value = 0;

  cogl_clip_push_rectangle (padding.left,
                            padding.top + value,
                            box.x2 - box.x1 - padding.right,
                            box.y2 - box.y1 - padding.bottom + value);

  for (c = priv->children; c; c = c->next)
    clutter_actor_paint (c->data);

  cogl_clip_pop ();
}
Пример #17
0
static void
mex_tile_get_preferred_height (ClutterActor *actor,
                               gfloat        for_width,
                               gfloat       *min_height_p,
                               gfloat       *nat_height_p)
{
  MxPadding padding;
  gfloat box_height, label_h, icon1_h, icon2_h;

  MexTilePrivate *priv = MEX_TILE (actor)->priv;

  CLUTTER_ACTOR_CLASS (mex_tile_parent_class)->
    get_preferred_height (actor, for_width, NULL, nat_height_p);

  mx_widget_get_padding (MX_WIDGET (actor), &padding);
  for_width -= padding.left + padding.right;

  /* Header */
  clutter_actor_get_preferred_height (priv->box_layout, for_width, NULL, &label_h);

  if (priv->icon1)
    clutter_actor_get_preferred_height (priv->icon1, for_width, NULL, &icon1_h);
  else
    icon1_h = 0;

  if (priv->icon2)
    clutter_actor_get_preferred_height (priv->icon2, for_width, NULL, &icon2_h);
  else
    icon2_h = 0;

  box_height = MAX (label_h, MAX (icon1_h, icon2_h)) +
    ((priv->header_padding) ? priv->header_padding->top + priv->header_padding->bottom : 0);


  /* Override the minimum height with the height of the box */
  if (min_height_p)
    *min_height_p = box_height;

  if (nat_height_p)
    {
      gdouble progress;

      /* When the timeline is at 0.5, the actor isn't visible - this is
       * the time where we switch sizes between the natural height and the
       * box height.
       */
      if (clutter_alpha_get_alpha (priv->important_alpha) < 0.5)
        progress = 0.0;
      else
        progress = 1.0;

      if (*nat_height_p < box_height)
        *nat_height_p = box_height;
      else if (progress == 0.0)
        *nat_height_p = box_height;
      else if (progress < 1.0)
        *nat_height_p = (box_height * (1.0 - progress)) +
                        (*nat_height_p * progress);
    }
}
Пример #18
0
static void
mx_slider_allocate (ClutterActor           *actor,
                    const ClutterActorBox  *box,
                    ClutterAllocationFlags  flags)
{
  MxSlider          *self = MX_SLIDER (actor);
  MxSliderPrivate   *priv = self->priv;
  MxPadding          padding;
  ClutterActorClass *actor_class;
  ClutterActorBox    bar_box;
  ClutterActorBox    trough_box;
  guint              handle_width_2;

  actor_class = CLUTTER_ACTOR_CLASS (mx_slider_parent_class);
  actor_class->allocate (actor, box, flags);

  if (box == NULL)
    {
      clutter_actor_get_allocation_box (CLUTTER_ACTOR (self), &bar_box);
      box = &bar_box;
    }

  handle_width_2 = priv->handle_width >> 1;

  mx_widget_get_padding (MX_WIDGET (self), &padding);

  /* save the min/max position of the middle of the handle */
  priv->handle_middle_start = padding.left + handle_width_2 + 1;
  priv->handle_middle_end   = box->x2 - box->x1 - padding.right -
    handle_width_2 - 1;

  if (priv->trough_height < 0)
    {
      /* trough-height has not been specified, take the whole height */
      trough_box.x1 = padding.left;
      trough_box.y1 = padding.top;
      trough_box.x2 = (box->x2 - box->x1) - padding.right;
      trough_box.y2 = (box->y2 - box->y1) - padding.bottom;
    }
  else
    {
      trough_box.x1 = padding.left;
      trough_box.y1 = (int) ((box->y2 - box->y1 - padding.bottom - padding.top -
                       priv->trough_height) / 2);
      trough_box.x2 = (box->x2 - box->x1) - padding.right;
      trough_box.y2 = trough_box.y1 + priv->trough_height;
    }

  clutter_actor_allocate (priv->trough_bg, &trough_box, flags);

  /* save trough_box.y1 and trough_box.y2 so we don't have the duplicate
   * the logic above in ::allocate_fill() */
  priv->trough_box_y1 = trough_box.y1;
  priv->trough_box_y2 = trough_box.y2;

  mx_slider_allocate_fill_handle (self, box, flags);

  clutter_actor_allocate (priv->trough, &trough_box, flags);
}
Пример #19
0
static void
mex_column_view_get_preferred_width (ClutterActor *actor,
                                     gfloat        for_height,
                                     gfloat       *min_width_p,
                                     gfloat       *nat_width_p)
{
  MxPadding padding;
  gfloat min_width, nat_width;
  gfloat min_header, nat_header;
  gfloat min_placeholder, nat_placeholder;
  gfloat height;

  MexColumnView *self = MEX_COLUMN_VIEW (actor);
  MexColumnViewPrivate *priv = self->priv;

  clutter_actor_get_preferred_width (priv->header,
                                     -1,
                                     &min_header,
                                     &nat_header);

  clutter_actor_get_preferred_height (priv->header, -1, NULL, &height);
  for_height = MAX (0, for_height - height);

  if (mex_column_is_empty (MEX_COLUMN (priv->column)))
    {
      if (priv->placeholder_actor)
        {
          clutter_actor_get_preferred_width (priv->placeholder_actor,
                                             for_height,
                                             &min_placeholder,
                                             &nat_placeholder);

          min_width = MAX (min_header, min_placeholder);
          nat_width = MAX (min_header, nat_placeholder);
        }
      else
        {
          min_width = min_header;
          nat_width = nat_header;
        }
    }
  else
    {
      clutter_actor_get_preferred_width (priv->scroll,
                                         for_height,
                                         &min_placeholder,
                                         &nat_placeholder);

      min_width = MAX (min_header, min_placeholder);
      nat_width = MAX (min_header, nat_placeholder);
    }

  mx_widget_get_padding (MX_WIDGET (actor), &padding);

  if (min_width_p)
    *min_width_p = min_width + padding.left + padding.right;
  if (nat_width_p)
    *nat_width_p = nat_width + padding.left + padding.right;
}
Пример #20
0
static void
mx_tooltip_get_preferred_height (ClutterActor *self,
                                 gfloat        for_width,
                                 gfloat       *min_height_p,
                                 gfloat       *natural_height_p)
{
  MxTooltipPrivate *priv = MX_TOOLTIP (self)->priv;
  gfloat arrow_height;
  gfloat min_label_h, natural_label_h;
  gfloat label_width;
  CoglHandle arrow_image;
  MxPadding padding;

  arrow_image = mx_widget_get_background_texture (MX_WIDGET (self));

  if (arrow_image && !priv->actor_below)
    {
      arrow_height = cogl_texture_get_height (arrow_image);
    }
  else
    {
      arrow_height = 0;
    }
  mx_widget_get_padding (MX_WIDGET (self), &padding);

  if (for_width > -1)
    {
      label_width = for_width - padding.left - padding.right;
    }
  else
    {
      label_width = -1;
    }

  if (priv->label)
    {
      clutter_actor_get_preferred_height (priv->label,
                                          label_width,
                                          &min_label_h,
                                          &natural_label_h);
    }
  else
    {
      min_label_h = 0;
      natural_label_h = 0;
    }

  if (min_height_p)
    {
      *min_height_p = padding.top + padding.bottom
                      + arrow_height + min_label_h;
    }

  if (natural_height_p)
    {
      *natural_height_p = padding.top + padding.bottom
                          + arrow_height + natural_label_h;
    }
}
Пример #21
0
static void
mx_expander_get_preferred_height (ClutterActor *actor,
                                  gfloat        for_width,
                                  gfloat       *min_height,
                                  gfloat       *pref_height)
{
  MxExpanderPrivate *priv = MX_EXPANDER (actor)->priv;
  ClutterActor *child;
  MxPadding padding;
  gfloat min_child_h, pref_child_h, min_label_h, pref_label_h, arrow_h;
  gfloat available_w;

  child = mx_bin_get_child (MX_BIN (actor));

  mx_widget_get_padding (MX_WIDGET (actor), &padding);
  available_w = for_width - padding.left - padding.right;

  if (child)
    {
      clutter_actor_get_preferred_height (child,
                                          available_w,
                                          &min_child_h,
                                          &pref_child_h);
      min_child_h += priv->spacing;
      pref_child_h += priv->spacing;

      /* allocate the space multiplied by the progress of the "expansion"
       * animation */
      min_child_h *= priv->progress;
      pref_child_h *= priv->progress;
    }
  else
    {
      min_child_h = 0;
      pref_child_h = 0;
    }

  clutter_actor_get_preferred_height (priv->label,
                                      available_w,
                                      &min_label_h,
                                      &pref_label_h);

  clutter_actor_get_preferred_height (priv->arrow, -1, NULL, &arrow_h);

  min_label_h = MAX (min_label_h, arrow_h);
  pref_label_h = MAX (pref_label_h, arrow_h);

  if (min_height)
    *min_height = padding.top
                  + min_child_h + min_label_h
                  + padding.bottom;

  if (pref_height)
    *pref_height = padding.top
                   + pref_child_h + pref_label_h
                   + padding.bottom;

}
Пример #22
0
static void
mx_tooltip_get_preferred_width (ClutterActor *self,
                                gfloat        for_height,
                                gfloat       *min_width_p,
                                gfloat       *natural_width_p)
{
  MxTooltipPrivate *priv = MX_TOOLTIP (self)->priv;
  gfloat min_label_w, natural_label_w;
  gfloat label_height, arrow_height;
  CoglHandle arrow_image;
  MxPadding padding;

  mx_widget_get_padding (MX_WIDGET (self), &padding);

  arrow_image = mx_widget_get_background_texture (MX_WIDGET (self));
  if (arrow_image)
    {
      arrow_height = cogl_texture_get_height (arrow_image);
    }
  else
    {
      arrow_height = 0;
    }

  if (for_height > -1)
    {
      label_height = for_height - arrow_height - padding.top - padding.bottom;
    }
  else
    {
      label_height = -1;
    }

  if (priv->label)
    {
      clutter_actor_get_preferred_width (priv->label,
                                         label_height,
                                         &min_label_w,
                                         &natural_label_w);
    }
  else
    {
      min_label_w = 0;
      natural_label_w = 0;
    }


  if (min_width_p)
    {
      *min_width_p = padding.left + padding.right + min_label_w;
    }

  if (natural_width_p)
    {
      *natural_width_p = padding.left + padding.right + natural_label_w;
    }
}
Пример #23
0
static void
mpl_application_view_allocate (ClutterActor          *actor,
                               const ClutterActorBox *box,
                               ClutterAllocationFlags flags)
{
  MplApplicationViewPrivate *priv = ((MplApplicationView *) actor)->priv;
  MxPadding padding;
  ClutterActorBox child_box;
  gfloat icon_width = 0, icon_height = 0, button_width, button_height;

  CLUTTER_ACTOR_CLASS (mpl_application_view_parent_class)->allocate (actor,
                                                                     box,
                                                                     flags);

  mx_widget_get_padding (MX_WIDGET (actor), &padding);

  /* Icon */
  child_box.x1 = padding.left;
  child_box.y1 = padding.top;

  if (priv->icon)
    {
      clutter_actor_get_preferred_width (priv->icon, -1, NULL, &icon_width);
      clutter_actor_get_preferred_height (priv->icon, -1, NULL, &icon_height);

      child_box.x2 = child_box.x1 + icon_width;
      child_box.y2 = child_box.y1 + icon_height;

      clutter_actor_allocate (priv->icon, &child_box, flags);
    }

  /* Close button */
  clutter_actor_get_preferred_width (priv->close_button, -1, NULL, &button_width);
  clutter_actor_get_preferred_height (priv->close_button, -1, NULL, &button_height);

  child_box.x2 = box->x2 - box->x1 - padding.right;
  child_box.y2 = child_box.y1 + button_height;
  child_box.x1 = child_box.x2 - button_width;

  clutter_actor_allocate (priv->close_button, &child_box, flags);

  /* Titles */
  child_box.x1 = padding.left + icon_width;
  child_box.x2 = box->x2 - box->x1 - padding.right - button_width;
  child_box.y2 = padding.top + icon_height;

  clutter_actor_allocate (priv->title_box, &child_box, flags);

  /* App frame */
  child_box.x1 = padding.left;
  child_box.x2 = box->x2 - box->x1 - padding.right;
  child_box.y1 = padding.top + icon_width;
  child_box.y2 = box->y2 - box->y1 - padding.bottom;

  clutter_actor_allocate (priv->app_frame, &child_box, flags);
}
Пример #24
0
static void
mex_tile_paint (ClutterActor *actor)
{
  MexTilePrivate *priv = MEX_TILE (actor)->priv;
  MxPadding padding;
  ClutterActorBox box;

  CLUTTER_ACTOR_CLASS (mex_tile_parent_class)->paint (actor);

  clutter_actor_paint (priv->child);

  mx_widget_get_padding (MX_WIDGET (actor), &padding);

  if (priv->header_visible)
    {
      clutter_actor_get_allocation_box (actor, &box);


      if (priv->header_background_color)
        {
          cogl_set_source_color4ub (priv->header_background_color->red,
                                    priv->header_background_color->green,
                                    priv->header_background_color->blue,
                                    priv->header_background_color->alpha);

          cogl_rectangle (padding.left, padding.top,
                          box.x2 - box.x1 - padding.right,
                          priv->header_height);
        }


      if (cogl_material_get_n_layers (priv->material) > 0)
        {
          guint8 opacity;

          opacity = clutter_actor_get_paint_opacity (actor);

          cogl_material_set_color4ub (priv->material, opacity, opacity, opacity,
                                      opacity);
          cogl_set_source (priv->material);

          cogl_rectangle (padding.left, padding.top,
                          box.x2 - box.x1 - padding.right,
                          priv->header_height);
        }

      clutter_actor_paint (priv->box_layout);

      if (priv->icon1)
        clutter_actor_paint (priv->icon1);

      if (priv->icon2)
        clutter_actor_paint (priv->icon2);
    }
}
Пример #25
0
static void
mx_tooltip_allocate (ClutterActor          *self,
                     const ClutterActorBox *box,
                     ClutterAllocationFlags flags)
{
  MxTooltipPrivate *priv = MX_TOOLTIP (self)->priv;
  ClutterActorBox child_box;
  gfloat arrow_height, arrow_width;
  CoglHandle arrow_image;
  MxPadding padding;

  CLUTTER_ACTOR_CLASS (mx_tooltip_parent_class)->allocate (self,
                                                           box,
                                                           flags);

  mx_widget_get_padding (MX_WIDGET (self), &padding);

  arrow_image = mx_widget_get_background_texture (MX_WIDGET (self));

  if (arrow_image && !priv->actor_below)
    {
      arrow_height = cogl_texture_get_height (arrow_image);
      arrow_width = cogl_texture_get_width (arrow_image);

      priv->arrow_box.x1 = (float)(priv->arrow_offset) - (int)(arrow_width / 2);
      priv->arrow_box.y1 = 0;
      priv->arrow_box.x2 = priv->arrow_box.x1 + arrow_width;
      priv->arrow_box.y2 = arrow_height;
    }
  else
    {
      arrow_height = 0;
      arrow_width = 0;
    }

  child_box.x1 = child_box.y1 = 0;
  child_box.x2 = (box->x2 - box->x1);
  child_box.y2 = (box->y2 - box->y1);

  /* remove the space that is used by the arrow */
  child_box.y1 += arrow_height;

  priv->text_allocation = child_box;

  if (priv->label)
    {
      /* now remove the padding */
      child_box.y1 += padding.top;
      child_box.x1 += padding.left;
      child_box.x2 -= padding.right;
      child_box.y2 -= padding.bottom;

      clutter_actor_allocate (priv->label, &child_box, flags);
    }
}
Пример #26
0
static void
mx_scroll_view_get_preferred_width (ClutterActor *actor,
                                    gfloat        for_height,
                                    gfloat       *min_width_p,
                                    gfloat       *natural_width_p)
{
  MxPadding padding;
  gfloat child_min_w, child_nat_w;
  gfloat vscroll_w;

  MxScrollViewPrivate *priv = MX_SCROLL_VIEW (actor)->priv;

  if (!priv->child)
    return;

  mx_widget_get_padding (MX_WIDGET (actor), &padding);

  /* Our natural width is the natural width of the child */
  clutter_actor_get_preferred_width (priv->child,
                                     for_height,
                                     &child_min_w,
                                     &child_nat_w);

  /* Add space for the scroll-bar if we can determine it will be necessary */
  vscroll_w = 0;
  if (for_height >= 0)
    {
      gfloat natural_height;

      clutter_actor_get_preferred_height (priv->child, -1.0,
                                          NULL,
                                          &natural_height);
      if (for_height < natural_height)
        vscroll_w = priv->scrollbar_width;
    }

  if (min_width_p)
    {
      *min_width_p = padding.left + padding.right + vscroll_w;

      /* if the scroll policy is not set to always or horizontal, then the
       * minimum size of the scroll view is the minimum size of the child */

      if (!(priv->scroll_policy == MX_SCROLL_POLICY_BOTH
            || priv->scroll_policy == MX_SCROLL_POLICY_HORIZONTAL))
        {
          *min_width_p += child_min_w;
        }
    }

  /* Add space for padding */
  if (natural_width_p)
    *natural_width_p = padding.left + padding.right + child_nat_w + vscroll_w;
}
Пример #27
0
static void
mex_column_view_get_preferred_height (ClutterActor *actor,
                                      gfloat        for_width,
                                      gfloat       *min_height_p,
                                      gfloat       *nat_height_p)
{
  gfloat min_height, nat_height;
  gfloat min_placeholder, nat_placeholder;
  MxPadding padding;

  MexColumnView *self = MEX_COLUMN_VIEW (actor);
  MexColumnViewPrivate *priv = self->priv;

  mx_widget_get_padding (MX_WIDGET (actor), &padding);

  if (for_width >= 0)
    for_width = MAX (0, for_width - padding.left - padding.right);

  clutter_actor_get_preferred_height (priv->header,
                                      for_width,
                                      NULL,
                                      &min_height);
  nat_height = min_height;

  if (mex_column_is_empty (MEX_COLUMN (priv->column)))
    {
      if (priv->placeholder_actor)
        {
          clutter_actor_get_preferred_height (priv->placeholder_actor,
                                              for_width,
                                              &min_placeholder,
                                              &nat_placeholder);

          min_height += min_placeholder;
          nat_height += nat_placeholder;
        }
    }
  else
    {
      clutter_actor_get_preferred_height (priv->scroll,
                                          for_width,
                                          &min_placeholder,
                                          &nat_placeholder);

      min_height += min_placeholder;
      nat_height += nat_placeholder;
    }

  if (min_height_p)
    *min_height_p = min_height + padding.top + padding.bottom;
  if (nat_height_p)
    *nat_height_p += nat_height + padding.top + padding.bottom;
}
Пример #28
0
static void
mex_column_view_allocate (ClutterActor          *actor,
                          const ClutterActorBox *box,
                          ClutterAllocationFlags flags)
{
  gfloat header_pref_height, pref_h, pref_w;
  ClutterActorBox child_box;
  MxPadding padding;

  MexColumnView *column = MEX_COLUMN_VIEW (actor);
  MexColumnViewPrivate *priv = column->priv;

  CLUTTER_ACTOR_CLASS (mex_column_view_parent_class)->allocate (actor,
                                                                box,
                                                                flags);

  mx_widget_get_padding (MX_WIDGET (actor), &padding);

  /* Allocate header */
  child_box.x1 = padding.left;
  child_box.x2 = box->x2 - box->x1 - padding.right;
  child_box.y1 = padding.top;

  clutter_actor_get_preferred_height (priv->header,
                                      child_box.x2 - child_box.x1,
                                      NULL,
                                      &header_pref_height);

  child_box.y2 = child_box.y1 + header_pref_height;

  clutter_actor_allocate (priv->header, &child_box, flags);

  /* Allocate placeholder/column actor */
  child_box.y1 = padding.top + header_pref_height;

  /* scroll view */
  child_box.y2 = box->y2 - box->y1 - padding.bottom;
  clutter_actor_allocate (priv->scroll, &child_box, flags);


  /* placeholder */
  if (mex_column_is_empty (MEX_COLUMN (priv->column)) &&
      priv->placeholder_actor)
    {
      /* keep the aspect ratio of the placeholder actor */
      clutter_actor_get_preferred_size (priv->placeholder_actor, NULL, NULL,
                                        &pref_w, &pref_h);
      pref_h = pref_h * ((child_box.x2 - child_box.x1) / pref_w);
      child_box.y2 = child_box.y1 + pref_h;

      clutter_actor_allocate (priv->placeholder_actor, &child_box, flags);
    }
}
Пример #29
0
static void
mex_epg_grid_allocate (ClutterActor           *actor,
                       const ClutterActorBox  *box,
                       ClutterAllocationFlags  flags)
{
  MexEpgGrid *grid = MEX_EPG_GRID (actor);
  MexEpgGridPrivate *priv = grid->priv;
  ClutterActorBox tile_box, header_box;
  MxPadding padding;
  guint i, j;

  CLUTTER_ACTOR_CLASS (mex_epg_grid_parent_class)->allocate (actor, box, flags);

  mx_widget_get_padding (MX_WIDGET (actor), &padding);

  /* header */
  for (i = 0; i < priv->header->len; i++)
    {
      ClutterActor *header = g_ptr_array_index (priv->header, i);

      header_box.x1 = padding.left + i * 6 * priv->pixels_for_5_mins;
      header_box.y1 = padding.top;
      header_box.x2 = header_box.x1 + 6 * priv->pixels_for_5_mins;
      header_box.y2 = header_box.y1 + HEADER_HEIGHT;

#if 0
      g_message ("Allocating header (%f,%f) (%f,%f)",
                 header_box.x1, header_box.y1,
                 header_box.x2, header_box.y2);
#endif

      clutter_actor_allocate (header, &header_box, flags);
    }

  /* tiles */
  for (i = 0; i < priv->rows->len; i++)
    {
      GPtrArray *tiles = g_ptr_array_index (priv->rows, i);

      if (tiles == NULL)
        continue;

      for (j = 0; j < tiles->len; j++)
        {
          MexEpgTile *tile = g_ptr_array_index (tiles, j);

          get_tile_box (grid, tile, i, &padding, &tile_box);
          clutter_actor_allocate (CLUTTER_ACTOR (tile), &tile_box, flags);
        }
    }
}
Пример #30
0
static void
mx_scroll_view_get_preferred_height (ClutterActor *actor,
                                     gfloat        for_width,
                                     gfloat       *min_height_p,
                                     gfloat       *natural_height_p)
{
  MxPadding padding;
  gfloat min_child_h, nat_child_h;
  gfloat scroll_h;

  MxScrollViewPrivate *priv = MX_SCROLL_VIEW (actor)->priv;

  if (!priv->child)
    return;

  mx_widget_get_padding (MX_WIDGET (actor), &padding);

  /* Our natural height is the natural height of the child */
  clutter_actor_get_preferred_height (priv->child,
                                      for_width,
                                      &min_child_h,
                                      &nat_child_h);

  /* Add space for the scroll-bar if we can determine it will be necessary */
  scroll_h = 0;
  if (for_width >= 0)
    {
      gfloat natural_width;

      clutter_actor_get_preferred_width (priv->child, -1.0,
                                         NULL,
                                         &natural_width);
      if (for_width < natural_width)
        scroll_h = priv->scrollbar_height;
    }

  /* Add space for padding */
  if (min_height_p)
    {
      *min_height_p = padding.top + padding.bottom + scroll_h;

      if (!(priv->scroll_policy == MX_SCROLL_POLICY_BOTH
            || priv->scroll_policy == MX_SCROLL_POLICY_VERTICAL))
        {
          *min_height_p += min_child_h;
        }
    }

  if (natural_height_p)
    *natural_height_p = padding.top + nat_child_h + padding.bottom + scroll_h;
}