コード例 #1
0
  /** @brief polaroid color setting function */
  public void setElementPolaroidFrameColor(PDEColor color) {
    float red, green, blue, alpha, red2, green2, blue2, alpha2;

    // validation
    if (color == null) return;

    red = color.getRed();
    green = color.getGreen();
    blue = color.getBlue();
    alpha = color.getAlpha();
    red2 = mElementPolaroidFrameColor.getRed();
    green2 = mElementPolaroidFrameColor.getGreen();
    blue2 = mElementPolaroidFrameColor.getBlue();
    alpha2 = mElementPolaroidFrameColor.getAlpha();

    // changed?
    if (red == red2 && green == green2 && blue == blue2 && alpha == alpha2) return;

    // remember new value
    mElementPolaroidFrameColor = color;
    // mElementPolaroidDrawable.setElementBackgroundColor(mElementPolaroidFrameColor);

    // update
    invalidateSelf();
  }
コード例 #2
0
  /** @brief update helper function for the polaroid bg layer */
  private void updatePolaroidDrawable(Rect bounds) {
    PDEColor highColor;
    PDEColor lowColor;
    float red, green, blue;
    Rect frameRect = new Rect(0, 0, bounds.width(), bounds.height());

    mElementCornerRadius = bounds.width() * 0.07f;
    // update Frame
    mElementPolaroidDrawable.setBounds(frameRect);
    mElementPolaroidDrawable.setElementCornerRadius(mElementCornerRadius);
    mElementPolaroidDrawable.setElementBorderColor(mElementPolaroidFrameColor);
    // todo: this border stuff does not work properly!!! So we take a workaround.
    // mElementPolaroidDrawable.setElementBorderWidth(polaroidRelativeValue(2.5f));
    int border = Math.round(polaroidRelativeValue(2.5f));
    mElementGradientDrawable.setBounds(
        frameRect.left + border,
        frameRect.top + border,
        frameRect.right - border,
        frameRect.bottom - border);

    red = mElementPolaroidFrameColor.getRed();
    blue = mElementPolaroidFrameColor.getBlue();
    green = mElementPolaroidFrameColor.getGreen();

    highColor = new PDEColor(red, green, blue, 0.0f);
    lowColor = new PDEColor(red - 0.33f, green - 0.33f, blue - 0.33f, 0.75f);
    mElementGradientDrawable.setElementBackgroundGradientColors(highColor, highColor, lowColor);
    mElementGradientDrawable.setElementGradientDistributionPositions(0.0f, 0.85f, 1.0f);

    // set other layer data
    mElementPolaroidDrawable.setElementBackgroundColor(mElementPolaroidFrameColor);
    mElementGradientDrawable.setElementCornerRadius(mElementCornerRadius);
    mElementGradientDrawable.setElementBorderColor(PDEColor.valueOf("DTTransparentBlack"));
  }