Exemple #1
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;
}
Exemple #2
0
static void
ntf_overlay_allocate (ClutterActor          *actor,
                      const ClutterActorBox *box,
                      ClutterAllocationFlags flags)
{
    NtfOverlayPrivate *priv = NTF_OVERLAY (actor)->priv;
    ClutterActorClass *klass;
    gfloat             my_width, my_height;
    ClutterActor      *tna = CLUTTER_ACTOR (priv->tray_normal);
    ClutterActor      *tua = CLUTTER_ACTOR (priv->tray_urgent);
    ClutterActor      *lowlight = priv->lowlight;

    klass = CLUTTER_ACTOR_CLASS (ntf_overlay_parent_class);

    klass->allocate (actor, box, flags);

    my_width  = box->x2 - box->x1;
    my_height = box->y2 - box->y1;

    {
        ClutterActorBox tray_box;
        gfloat p_width, p_height, m_width, m_height;

        clutter_actor_get_preferred_width  (tna, -1.0, &m_width, &p_width);
        clutter_actor_get_preferred_height (tna, p_width, &m_height, &p_height);

        tray_box.x1 = my_width  - p_width;
        tray_box.y1 = my_height - p_height;
        tray_box.x2 = tray_box.x1 + p_width;
        tray_box.y2 = tray_box.y1 + p_height;

        clutter_actor_allocate (tna, &tray_box, flags);
    }

    {
        ClutterActorBox tray_box;
        gfloat p_width, p_height, m_width, m_height;

        clutter_actor_get_preferred_width  (tua, -1.0, &m_width, &p_width);
        clutter_actor_get_preferred_height (tua, p_width, &m_height, &p_height);

        tray_box.x1 = (gint)((my_width  - p_width)  / 2.0);
        tray_box.y1 = (gint)((my_height - p_height) / 2.0);
        tray_box.x2 = tray_box.x1 + p_width;
        tray_box.y2 = tray_box.y1 + p_height;

        clutter_actor_allocate (tua, &tray_box, flags);
    }

    {
        ClutterActorBox lowlight_box;

        lowlight_box.x1 = 0.0;
        lowlight_box.y1 = 0.0;
        lowlight_box.x2 = my_width;
        lowlight_box.y2 = my_height;

        clutter_actor_allocate (lowlight, &lowlight_box, flags);
    }
}
static void
mex_content_box_get_preferred_width (ClutterActor *actor,
                                     gfloat        for_height,
                                     gfloat       *min_width,
                                     gfloat       *pref_width)
{
  MexContentBoxPrivate *priv = MEX_CONTENT_BOX (actor)->priv;
  gfloat list_w;

  clutter_actor_get_preferred_width (priv->tile, for_height, min_width,
                                     pref_width);
  if (!priv->extras_visible)
    return;

  if (pref_width)
    {
      clutter_actor_get_preferred_width (priv->action_list, for_height, NULL,
                                         &list_w);

      if (clutter_timeline_is_playing (priv->timeline))
        *pref_width = *pref_width +
          (list_w * clutter_alpha_get_alpha (priv->alpha));
      else
        *pref_width = *pref_width + list_w;
    }
}
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;
}
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);
}
static void
mex_content_box_allocate (ClutterActor           *actor,
                          const ClutterActorBox  *box,
                          ClutterAllocationFlags  flags)
{
  MexContentBoxPrivate *priv = MEX_CONTENT_BOX (actor)->priv;
  ClutterActorBox child_box;
  gfloat pref_w = 0, pref_h = 0, tile_w, tile_h;

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

  tile_w = box->x2 - box->x1;
  clutter_actor_get_preferred_width (priv->tile, -1, NULL, &tile_w);
  if (tile_w > box->x2 - box->x1)
    tile_w = box->x2 - box->x1;

  clutter_actor_get_preferred_height (priv->tile, tile_w, NULL, &tile_h);
  child_box.x1 = 0;
  child_box.x2 = child_box.x1 + tile_w;
  child_box.y1 = 0;
  child_box.y2 = child_box.y1 + tile_h;

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

  if (G_UNLIKELY (priv->extras_visible))
    {
      /* action list */
      clutter_actor_get_preferred_width (priv->action_list, -1, NULL, &pref_w);
      clutter_actor_get_preferred_height (priv->info_panel, -1, NULL, &pref_h);

      child_box.x1 = tile_w;
      child_box.x2 = tile_w + pref_w;
      child_box.y1 = 0;
      child_box.y2 = tile_h;
      clutter_actor_allocate (priv->action_list, &child_box, flags);


      child_box.x1 = 0;
      child_box.x2 = tile_w + pref_w;
      child_box.y1 = tile_h;
      child_box.y2 = tile_h + pref_h;
      clutter_actor_allocate (priv->info_panel, &child_box, flags);
    }

  /* enable clip-to-allocation if the children will extend beyond the allocated
   * box */
  if ((tile_w + pref_w) > (box->x2 - box->x1)
      || (tile_h + pref_h) > (box->y2 - box->y1))
    priv->clip_to_allocation = TRUE;
  else
    priv->clip_to_allocation = FALSE;
}
/* Get width of a child of this actor */
static void _xfdashboard_workspace_selector_get_preferred_width_for_child(XfdashboardWorkspaceSelector *self,
																			ClutterActor *inChild,
																			gfloat inForHeight,
																			gfloat *outMinWidth,
																			gfloat *outNaturalWidth)
{
	XfdashboardWorkspaceSelectorPrivate		*priv;
	gfloat									minWidth, naturalWidth;
	gfloat									maxSize;

	g_return_if_fail(XFDASHBOARD_IS_WORKSPACE_SELECTOR(self));

	priv=self->priv;

	/* Set up default values */
	minWidth=naturalWidth=0.0f;

	/* Determine width for horizontal orientation ... */
	if(priv->orientation==CLUTTER_ORIENTATION_HORIZONTAL)
	{
		/* Adjust requested height to maximum height */
		maxSize=_xfdashboard_workspace_selector_get_max_size_internal(self)-(2*priv->spacing);
		if(maxSize>=0.0f && inForHeight>maxSize) inForHeight=maxSize;

		/* Get width of child */
		clutter_actor_get_preferred_width(inChild, inForHeight, &minWidth, &naturalWidth);
	}
		/* ... otherwise determine height for vertical orientation */
		else
		{
			/* Get width of child */
			clutter_actor_get_preferred_width(inChild, inForHeight, &minWidth, &naturalWidth);

			/* Adjust child's width to maximum width */
			maxSize=_xfdashboard_workspace_selector_get_max_size_internal(self)-(2*priv->spacing);
			if(maxSize>=0.0)
			{
				/* Adjust minimum width if it exceed limit */
				if(minWidth>maxSize) minWidth=maxSize;

				/* Adjust natural width if it exceed limit */
				if(naturalWidth>maxSize) naturalWidth=maxSize;
			}
		}

	/* Store sizes computed */
	if(outMinWidth) *outMinWidth=minWidth;
	if(outNaturalWidth) *outNaturalWidth=naturalWidth;
}
Exemple #8
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_get_preferred_width (ClutterActor *actor,
                                   gfloat        for_height,
                                   gfloat       *min_width_p,
                                   gfloat       *nat_width_p)
{
  MxPadding padding;
  MnbFancyBinPrivate *priv = MNB_FANCY_BIN (actor)->priv;

  if (min_width_p)
    *min_width_p = 0;
  if (nat_width_p)
    *nat_width_p = 0;

  if (priv->real_child)
    clutter_actor_get_preferred_width (priv->real_child,
                                       for_height,
                                       min_width_p,
                                       nat_width_p);

  mx_widget_get_padding (MX_WIDGET (actor), &padding);

  if (min_width_p)
    *min_width_p += padding.left + padding.right;
  if (nat_width_p)
    *nat_width_p += padding.left + padding.right;
}
Exemple #11
0
static void
mx_toggle_get_preferred_width (ClutterActor *actor,
                               gfloat        for_height,
                               gfloat       *min_width_p,
                               gfloat       *pref_width_p)
{
  ClutterActor *background;
  gfloat pref_w;

  background = mx_widget_get_background_image (MX_WIDGET (actor));

  if (!background)
    {
      if (min_width_p)
        *min_width_p = 0;
      if (pref_width_p)
        *pref_width_p = 0;

      return;
    }

  clutter_actor_get_preferred_width (background, -1, NULL, &pref_w);

  if (min_width_p)
    *min_width_p = pref_w;

  if (pref_width_p)
    *pref_width_p = pref_w;
}
static void
clutter_bin_layout_get_preferred_width (ClutterLayoutManager *manager,
                                        ClutterContainer     *container,
                                        gfloat                for_height,
                                        gfloat               *min_width_p,
                                        gfloat               *nat_width_p)
{
  ClutterActor *actor = CLUTTER_ACTOR (container);
  ClutterActorIter iter;
  ClutterActor *child;
  gfloat min_width, nat_width;

  min_width = nat_width = 0.0;

  clutter_actor_iter_init (&iter, actor);
  while (clutter_actor_iter_next (&iter, &child))
    {
      gfloat minimum, natural;

      clutter_actor_get_preferred_width (child, for_height,
                                         &minimum,
                                         &natural);

      min_width = MAX (min_width, minimum);
      nat_width = MAX (nat_width, natural);
    }

  if (min_width_p)
    *min_width_p = min_width;

  if (nat_width_p)
    *nat_width_p = nat_width;
}
Exemple #13
0
static void
ntf_tray_get_preferred_width (ClutterActor *actor,
                              gfloat        for_height,
                              gfloat       *min_width,
                              gfloat       *nat_width)
{
  NtfTrayPrivate *priv = NTF_TRAY (actor)->priv;

  if (min_width)
    *min_width = CLUSTER_WIDTH;
  if (nat_width)
    {
      if (priv->urgent)
        {
          gfloat nat_notif;
          MetaPlugin *plugin = dawati_netbook_get_plugin_singleton ();
          MetaScreen *screen = meta_plugin_get_screen (plugin);
          gint screen_width, screen_height;

          meta_screen_get_size (screen, &screen_width, &screen_height);

          clutter_actor_get_preferred_width (priv->notifiers, for_height,
                                             NULL, &nat_notif);

          *nat_width = MIN ((2 * screen_width) / 3, nat_notif);
        }
      else
        *nat_width = CLUSTER_WIDTH;
    }
}
Exemple #14
0
static void
clutter_bin_layout_get_preferred_width (ClutterLayoutManager *manager,
                                        ClutterContainer     *container,
                                        gfloat                for_height,
                                        gfloat               *min_width_p,
                                        gfloat               *nat_width_p)
{
  GList *children = clutter_container_get_children (container);
  GList *l;
  gfloat min_width, nat_width;

  min_width = nat_width = 0.0;

  for (l = children; l != NULL; l = l->next)
    {
      ClutterActor *child = l->data;
      gfloat minimum, natural;

      clutter_actor_get_preferred_width (child, for_height,
                                         &minimum,
                                         &natural);

      min_width = MAX (min_width, minimum);
      nat_width = MAX (nat_width, natural);
    }

  if (min_width_p)
    *min_width_p = min_width;

  if (nat_width_p)
    *nat_width_p = nat_width;
}
static void
mex_clock_bin_get_preferred_width (ClutterActor *actor,
                                   gfloat        for_height,
                                   gfloat       *min_width_p,
                                   gfloat       *nat_width_p)
{
  MxPadding padding;
  gfloat min_width, nat_width;

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

  CLUTTER_ACTOR_CLASS (mex_clock_bin_parent_class)->
    get_preferred_width (actor, for_height, min_width_p, nat_width_p);

  mx_widget_get_padding (MX_WIDGET (actor), &padding);
  if (for_height >= 0)
    for_height = MAX (0, for_height - padding.top - padding.bottom);

  clutter_actor_get_preferred_width (priv->clock_hbox,
                                     for_height,
                                     &min_width,
                                     &nat_width);

  min_width += padding.left + padding.right;
  nat_width += padding.left + padding.right;

  if (min_width_p && (*min_width_p < min_width))
    *min_width_p = min_width;
  if (nat_width_p && (*nat_width_p < nat_width))
    *nat_width_p = nat_width;
}
Exemple #16
0
static void
mx_button_get_preferred_width (ClutterActor *actor,
                               gfloat        for_height,
                               gfloat       *min_width,
                               gfloat       *pref_width)
{
  MxButtonPrivate *priv = MX_BUTTON (actor)->priv;

  if (priv->content_image)
    {
      gfloat width;

      clutter_actor_get_preferred_width (priv->content_image, for_height,
                                         NULL, &width);
      if (min_width)
        *min_width = width;
      if (pref_width)
        *pref_width = width;

      return;
    }

  CLUTTER_ACTOR_CLASS (mx_button_parent_class)->get_preferred_width (actor,
                                                                     for_height,
                                                                     min_width,
                                                                     pref_width);
}
Exemple #17
0
static void
mx_frame_get_preferred_width (ClutterActor *actor,
                              gfloat        for_height,
                              gfloat       *min_width,
                              gfloat       *pref_width)
{
    MxFramePrivate *priv = ((MxFrame *) actor)->priv;
    MxPadding padding;

    mx_widget_get_padding (MX_WIDGET (actor), &padding);

    if (min_width)
        *min_width = 0;

    if (pref_width)
        *pref_width = 0;

    if (priv->child)
    {
        clutter_actor_get_preferred_width (priv->child,
                                           for_height - padding.top - padding.bottom,
                                           min_width, pref_width);
    }

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

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

}
Exemple #18
0
static void
mx_toolbar_get_preferred_width (ClutterActor *actor,
                                gfloat        for_height,
                                gfloat       *min_width,
                                gfloat       *pref_width)
{
  MxToolbarPrivate *priv = MX_TOOLBAR (actor)->priv;
  MxPadding padding;
  gfloat min_child, pref_child, min_close, pref_close;

  mx_widget_get_padding (MX_WIDGET (actor), &padding);

  for_height = for_height - padding.top - padding.bottom;

  if (priv->has_close_button && priv->close_button)
    {
      clutter_actor_get_preferred_width (priv->close_button,
                                         for_height,
                                         &min_close,
                                         &pref_close);
    }
  else
    {
      min_close = 0;
      pref_close = 0;
    }

  if (priv->child)
    {
      clutter_actor_get_preferred_width (priv->child,
                                         for_height,
                                         &min_child,
                                         &pref_child);
    }
  else
    {
      min_child = 0;
      pref_child = 0;
    }

  if (min_width)
    *min_width = padding.left + padding.right + min_close + min_child + SPACING;

  if (pref_width)
    *pref_width = padding.left + padding.right + pref_close + pref_child + SPACING;
}
Exemple #19
0
static void
mx_toggle_allocate (ClutterActor          *actor,
                    const ClutterActorBox *box,
                    ClutterAllocationFlags flags)
{
  MxTogglePrivate *priv = MX_TOGGLE (actor)->priv;
  ClutterActorBox handle_box, child_box;
  ClutterActor *background;
  gfloat handle_w;
  gfloat toggle_pos;

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

  mx_widget_get_available_area (MX_WIDGET (actor), box, &child_box);

  /* background-image don't get stretched, so adjust the child box so that the
   * handle appears in the correct place.
   */
  background = mx_widget_get_background_image (MX_WIDGET (actor));
  if (background)
    {
      gfloat width;
      MxPadding padding;

      mx_widget_get_padding (MX_WIDGET (actor), &padding);
      clutter_actor_get_preferred_width (background, -1, NULL, &width);
      width -= padding.left + padding.right;

      child_box.x1 += (child_box.x2 - child_box.x1) / 2.f;
      child_box.x1 -= width / 2.f;
      child_box.x2 = child_box.x1 + width;
    }

  clutter_actor_get_preferred_width (priv->handle, -1, NULL, &handle_w);
  toggle_pos = child_box.x2 - handle_w - child_box.x1;
  priv->slide_length = toggle_pos;

  toggle_pos = toggle_pos * priv->position;

  handle_box.x1 = (gint) (child_box.x1 + toggle_pos);
  handle_box.y1 = child_box.y1;
  handle_box.x2 = handle_box.x1 + handle_w;
  handle_box.y2 = child_box.y2;

  clutter_actor_allocate (priv->handle, &handle_box, flags);
}
Exemple #20
0
static void
mx_expander_get_preferred_width (ClutterActor *actor,
                                 gfloat        for_height,
                                 gfloat       *min_width,
                                 gfloat       *pref_width)
{
  MxExpanderPrivate *priv = MX_EXPANDER (actor)->priv;
  ClutterActor *child;
  MxPadding padding;
  gfloat min_child_w, pref_child_w, min_label_w, pref_label_w, arrow_w;

  child = mx_bin_get_child (MX_BIN (actor));
  mx_widget_get_padding (MX_WIDGET (actor), &padding);

  if (child)
    {
      clutter_actor_get_preferred_width (child,
                                         -1,
                                         &min_child_w,
                                         &pref_child_w);
    }
  else
    {
      min_child_w = 0;
      pref_child_w = 0;
    }

  clutter_actor_get_preferred_width (priv->label,
                                     -1, &min_label_w, &pref_label_w);
  clutter_actor_get_preferred_width (priv->arrow,
                                     -1, NULL, &arrow_w);

  /* TODO: create a style property for this padding between arrow and label */
  if (arrow_w)
    arrow_w += 6.0f;

  if (min_width)
    *min_width = padding.left
                 + MAX (min_child_w, min_label_w + arrow_w)
                 + padding.right;

  if (pref_width)
    *pref_width = padding.left
                  + MAX (pref_child_w, pref_label_w + arrow_w)
                  + padding.right;
}
Exemple #21
0
static void
ckd_slide_get_preferred_width (ClutterActor *a, gfloat for_h, gfloat *min_w, gfloat *natural_w)
{
        CkdSlide *self = CKD_SLIDE (a);
        CkdSlidePriv *priv = CKD_SLIDE_GET_PRIVATE (self);

        clutter_actor_get_preferred_width (priv->content, for_h, min_w, natural_w);
}
Exemple #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;
    }
}
Exemple #23
0
static void
st_table_get_preferred_height (ClutterActor *self,
                               gfloat        for_width,
                               gfloat       *min_height_p,
                               gfloat       *natural_height_p)
{
  gfloat total_min_height, total_pref_height;
  StTablePrivate *priv = ST_TABLE (self)->priv;
  StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (self));
  gint i;
  DimensionData *rows;

  /* We only support height-for-width allocation. So if we are called
   * width-for-height, calculate heights based on our natural width
   */
  if (for_width < 0)
    {
      float natural_width;

      clutter_actor_get_preferred_width (self, -1, NULL, &natural_width);
      for_width = natural_width;
    }

  if (priv->n_rows < 1)
    {
      *min_height_p = 0;
      *natural_height_p = 0;
      return;
    }

  st_theme_node_adjust_for_width (theme_node, &for_width);

  /* use min_widths to help allocation of height-for-width widgets */
  st_table_calculate_dimensions (ST_TABLE (self), for_width, -1);

  rows = &g_array_index (priv->rows, DimensionData, 0);

  /* start off with row spacing */
  total_min_height = (priv->visible_rows - 1) * (float)(priv->row_spacing);
  total_pref_height = total_min_height;

  for (i = 0; i < priv->n_rows; i++)
    {
      total_min_height += rows[i].min_size;
      total_pref_height += rows[i].pref_size;
    }

  if (min_height_p)
    *min_height_p = total_min_height;
  if (natural_height_p)
    *natural_height_p = total_pref_height;

  st_theme_node_adjust_preferred_height (theme_node, min_height_p, natural_height_p);
}
Exemple #24
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;
}
Exemple #25
0
static void
st_scroll_view_get_preferred_width (ClutterActor *actor,
                                    gfloat        for_height,
                                    gfloat       *min_width_p,
                                    gfloat       *natural_width_p)
{
  StScrollViewPrivate *priv = ST_SCROLL_VIEW (actor)->priv;
  StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (actor));
  gfloat min_width = 0, natural_width;
  gfloat child_min_width, child_natural_width;

  if (!priv->child)
    return;

  st_theme_node_adjust_for_height (theme_node, &for_height);

  clutter_actor_get_preferred_width (priv->child, -1,
                                     &child_min_width, &child_natural_width);

  natural_width = child_natural_width;

  switch (priv->hscrollbar_policy)
    {
    case GTK_POLICY_NEVER:
      min_width = child_min_width;
      break;
    case GTK_POLICY_ALWAYS:
    case GTK_POLICY_AUTOMATIC:
    case GTK_POLICY_EXTERNAL:
      /* Should theoretically use the min width of the hscrollbar,
       * but that's not cleanly defined at the moment */
      min_width = 0;
      break;
    default:
      g_warn_if_reached();
      break;
    }

  if (priv->vscrollbar_policy != GTK_POLICY_NEVER)
    {
      float sb_width = get_scrollbar_width (ST_SCROLL_VIEW (actor), for_height);

      min_width += sb_width;
      natural_width += sb_width;
    }

  if (min_width_p)
    *min_width_p = min_width;

  if (natural_width_p)
    *natural_width_p = natural_width;

  st_theme_node_adjust_preferred_width (theme_node, min_width_p, natural_width_p);
}
Exemple #26
0
static void
st_entry_get_preferred_width (ClutterActor *actor,
                              gfloat        for_height,
                              gfloat       *min_width_p,
                              gfloat       *natural_width_p)
{
  StEntryPrivate *priv = ST_ENTRY_PRIV (actor);
  StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (actor));
  gfloat icon_w;

  st_theme_node_adjust_for_height (theme_node, &for_height);

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

  if (priv->primary_icon)
    {
      clutter_actor_get_preferred_width (priv->primary_icon, -1, NULL, &icon_w);

      if (min_width_p)
        *min_width_p += icon_w + priv->spacing;

      if (natural_width_p)
        *natural_width_p += icon_w + priv->spacing;
    }

  if (priv->secondary_icon)
    {
      clutter_actor_get_preferred_width (priv->secondary_icon,
                                         -1, NULL, &icon_w);

      if (min_width_p)
        *min_width_p += icon_w + priv->spacing;

      if (natural_width_p)
        *natural_width_p += icon_w + priv->spacing;
    }

  st_theme_node_adjust_preferred_width (theme_node, min_width_p, natural_width_p);
}
/* Allocate position and size of actor and its children */
static void _xfdashboard_workspace_selector_allocate(ClutterActor *inActor,
														const ClutterActorBox *inBox,
														ClutterAllocationFlags inFlags)
{
	XfdashboardWorkspaceSelector			*self=XFDASHBOARD_WORKSPACE_SELECTOR(inActor);
	XfdashboardWorkspaceSelectorPrivate		*priv=self->priv;
	gfloat									availableWidth, availableHeight;
	gfloat									childWidth, childHeight;
	ClutterActor							*child;
	ClutterActorIter						iter;
	ClutterActorBox							childAllocation={ 0, };

	/* Chain up to store the allocation of the actor */
	CLUTTER_ACTOR_CLASS(xfdashboard_workspace_selector_parent_class)->allocate(inActor, inBox, inFlags);

	/* Get available size */
	clutter_actor_box_get_size(inBox, &availableWidth, &availableHeight);

	/* Calculate new position and size of visible children */
	childAllocation.x1=childAllocation.y1=priv->spacing;
	clutter_actor_iter_init(&iter, CLUTTER_ACTOR(inActor));
	while(clutter_actor_iter_next(&iter, &child))
	{
		/* Is child visible? */
		if(!CLUTTER_ACTOR_IS_VISIBLE(child)) continue;

		/* Calculate new position and size of child */
		if(priv->orientation==CLUTTER_ORIENTATION_HORIZONTAL)
		{
			childHeight=availableHeight-(2*priv->spacing);
			clutter_actor_get_preferred_width(child, childHeight, NULL, &childWidth);

			childAllocation.y1=ceil(MAX(((availableHeight-childHeight))/2.0f, priv->spacing));
			childAllocation.y2=floor(childAllocation.y1+childHeight);
			childAllocation.x2=floor(childAllocation.x1+childWidth);
		}
			else
			{
				childWidth=availableWidth-(2*priv->spacing);
				clutter_actor_get_preferred_height(child, childWidth, NULL, &childHeight);

				childAllocation.x1=ceil(MAX(((availableWidth-childWidth))/2.0f, priv->spacing));
				childAllocation.x2=floor(childAllocation.x1+childWidth);
				childAllocation.y2=floor(childAllocation.y1+childHeight);
			}

		clutter_actor_allocate(child, &childAllocation, inFlags);

		/* Set up for next child */
		if(priv->orientation==CLUTTER_ORIENTATION_HORIZONTAL) childAllocation.x1=floor(childAllocation.x1+childWidth+priv->spacing);
			else childAllocation.y1=floor(childAllocation.y1+childHeight+priv->spacing);
	}
}
void
mex_telepathy_channel_set_tool_mode (MexTelepathyChannel *self,
                                    MexToolMode mode,
                                    guint duration)
{
  MexTelepathyChannelPrivate *priv = self->priv;

  gfloat height;
  gfloat width;
  gfloat pref_height;
  gfloat pref_width;

  /* Get natural width and height to calculate aspect ratio */
  clutter_actor_get_preferred_height (priv->full_frame,
                                      -1,
                                      NULL,
                                      &pref_height);
  clutter_actor_get_preferred_width (priv->full_frame,
                                     -1,
                                     NULL,
                                     &pref_width);

  if (mode == TOOL_MODE_PIP)
    {
      width = priv->scene_width * 0.25;
      height = width * (pref_height / pref_width);
      /* Hide the toolbar and preview areas */
      clutter_actor_hide (priv->toolbar_area);
      clutter_actor_hide (priv->preview_area);
    }
  else if (mode == TOOL_MODE_FULL)
    {
      height = priv->scene_height * 0.90;
      width = height * (pref_width / pref_height);
      /* Show the toolbar and preview areas */
      clutter_actor_show (priv->toolbar_area);
      clutter_actor_show (priv->preview_area);
    }
  else if (mode == TOOL_MODE_SBS)
    {
      width = priv->scene_width * 0.50;
      height = width * (pref_height / pref_width);
      /* Show the toolbar and preview areas */
      clutter_actor_hide (priv->toolbar_area);
      clutter_actor_hide (priv->preview_area);
    }

  clutter_actor_animate (priv->full_frame, CLUTTER_EASE_IN_CUBIC,
                         duration,
                         "width", width,
                         "height", height,
                         NULL);
}
static void
get_preferred_width (ClutterActor *self,
    gfloat for_height,
    gfloat *min_width_p,
    gfloat *natural_width_p)
{
  ChamplainTilePrivate *priv = GET_PRIVATE (self);

  clutter_actor_get_preferred_width (CLUTTER_ACTOR (priv->content_group),
      for_height,
      min_width_p,
      natural_width_p);
}
Exemple #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;
}