static void
mpl_panel_background_allocate (ClutterActor          *actor,
                               const ClutterActorBox *box,
                               ClutterAllocationFlags flags)
{
  MplPanelBackgroundPrivate *priv = MPL_PANEL_BACKGROUND (actor)->priv;
#if 0
  ClutterActor              *border;

  border = mx_widget_get_border_image (MX_WIDGET (actor));

  /*
   * We need to use different background asset based on the size allocated to us
   * -- basically, the panel cannot be smaller than the size of the borders of
   * its border image (see MB#702), so if it is smaller than the current asset
   * allows, we change the asset to simpler one.
   *
   * The code here assumes that we either have no name, or are called
   * 'too-small', but since this is a private widget of libmeego-panel, we can
   * enforce this assumption.
   */
  if (border)
    {
      const gchar *name = clutter_actor_get_name (actor);
      gboolean     too_small = FALSE;

      /*
       * Get the dimensions of the base texture (we are guaranteed to be called
       * first with name == NULL, so this works).
       */
      if (!priv->base_geom_known && !name)
        {
          mx_texture_frame_get_border_values (/*MX_TEXTURE_FRAME*/ (border),
                                              &priv->base_t,
                                              &priv->base_r,
                                              &priv->base_b,
                                              &priv->base_l);

          priv->base_geom_known = TRUE;
        }

      if (priv->base_l + priv->base_r > box->x2 - box->x1 ||
          priv->base_t + priv->base_b > box->y2 - box->y1)
        {
          too_small = TRUE;
        }

      if (!name && too_small)
        {
          clutter_actor_set_name (actor, "too-small");
        }
      else if (name && !too_small)
        {
          clutter_actor_set_name (actor, NULL);
        }
    }
#endif //DV
  CLUTTER_ACTOR_CLASS (
             mpl_panel_background_parent_class)->allocate (actor, box, flags);
}
Example #2
0
static void
mnb_toolbar_property_changed (MnbToolbarShadow *self,
                              GParamSpec       *param,
                              gpointer          data)
{
  MxTextureFrame *texture = MX_TEXTURE_FRAME (self);
  MnbToolbarShadowPrivate *priv = self->priv;

  priv->parent_texture =
    mx_texture_frame_get_parent_texture (texture);
  mx_texture_frame_get_border_values (texture,
                                      &priv->top,
                                      &priv->right,
                                      &priv->bottom,
                                      &priv->left);
}
static void
mnb_toolbar_background_border_changed (MnbToolbarBackground *self,
                                       GParamSpec           *param,
                                       gpointer              data)
{
  MxTextureFrame *texture;
  MnbToolbarBackgroundPrivate *priv = self->priv;

  texture = (MxTextureFrame *) mx_widget_get_border_image (MX_WIDGET (self));
  if (!texture)
    return;

  priv->parent_texture =
    mx_texture_frame_get_parent_texture (texture);
  mx_texture_frame_get_border_values (texture,
                                      &priv->top,
                                      &priv->right,
                                      &priv->bottom,
                                      &priv->left);
}
/*
 * Paints the provided texture frame trimming to the area indicated by padding.
 *
 * (Basically, we have one asset that gets split into two parts: an border area
 * that matches the padding, and the inside; MplPanelBackground paints the
 * latter, while the border is painted by the compositor as the window shadow.)
 */
static void
mpl_panel_background_paint_border_image (CoglHandle *frame,
                                         MxPadding      *padding)
{
  CoglHandle cogl_texture = COGL_INVALID_HANDLE;
  CoglHandle cogl_material = COGL_INVALID_HANDLE;
  ClutterActorBox box = { 0, };
  gfloat width, height;
  gfloat tex_width, tex_height;
  gfloat ex, ey;
  gfloat tx1, ty1, tx2, ty2;
  gfloat left = 4, right = 4 , top = 4, bottom =4;
  guint8 opacity;
  ClutterTexture *parent_texture;
  gfloat margin_l, margin_r, margin_t, margin_b;

  parent_texture = mx_texture_frame_get_parent_texture (frame);
  mx_texture_frame_get_border_values (frame, &top, &right, &bottom, &left);

  /* no need to paint stuff if we don't have a texture */
  if (G_UNLIKELY (parent_texture == NULL))
    return;

  /* parent texture may have been hidden, so need to make sure it gets
   * realized
   */
  if (!CLUTTER_ACTOR_IS_REALIZED (parent_texture))
    clutter_actor_realize (CLUTTER_ACTOR (parent_texture));

  cogl_texture = clutter_texture_get_cogl_texture (parent_texture);

  if (cogl_texture == COGL_INVALID_HANDLE)
    return;

  cogl_material = clutter_texture_get_cogl_material (parent_texture);

  if (cogl_material == COGL_INVALID_HANDLE)
    return;

  tex_width  = cogl_texture_get_width (cogl_texture);
  tex_height = cogl_texture_get_height (cogl_texture);

  clutter_actor_get_allocation_box ((ClutterActor*) frame, &box);

  width  = box.x2 - box.x1;
  height = box.y2 - box.y1;

  /*
   * These are the margins we are to trim expressed in texture coordinates.
   */
  margin_l = padding->left / tex_width;
  margin_r = padding->right / tex_width;
  margin_t = padding->top / tex_height;
  margin_b = padding->bottom / tex_height;

  tx1 = left / tex_width;
  tx2 = (tex_width - right) / tex_width;
  ty1 = top / tex_height;
  ty2 = (tex_height - bottom) / tex_height;

  ex = width - right;
  if (ex < 0)
    ex = right;

  ey = height - bottom;
  if (ey < 0)
    ey = bottom;

  opacity = clutter_actor_get_paint_opacity ((ClutterActor*)frame);

  cogl_material_set_color4ub (cogl_material,
                              opacity, opacity, opacity, opacity);
  cogl_set_source (cogl_material);

  cogl_material_set_layer_filters (cogl_material,
                                   0,
                                   COGL_MATERIAL_FILTER_NEAREST,
                                   COGL_MATERIAL_FILTER_NEAREST);

  {
    GLfloat rectangles[] =
    {
      /* top left corner */
      0.0, 0.0, left, top,
      margin_l, margin_t,
      tx1, ty1,

      /* top middle */
      left, 0.0, ex, top,
      tx1, margin_t,
      tx2, ty1,

      /* top right */
      ex, 0.0, width, top,
      tx2, margin_t,
      1.0 - margin_r, ty1,

      /* mid left */
      0.0, top, left, ey,
      margin_l, ty1,
      tx1, ty2,

      /* center */
      left, top, ex, ey,
      tx1, ty1,
      tx2, ty2,

      /* mid right */
      ex, top, width, ey,
      tx2, ty1,
      1.0 - margin_r, ty2,

      /* bottom left */
      0.0, ey, left, height,
      margin_l, ty2,
      tx1, 1.0 - margin_b,

      /* bottom center */
      left, ey, ex, height,
      tx1, ty2,
      tx2, 1.0 - margin_b,

      /* bottom right */
      ex, ey, width, height,
      tx2, ty2,
      1.0 - margin_r, 1.0 - margin_b
    };

    cogl_rectangles_with_texture_coords (rectangles, 9);
  }
}