OSDN Git Service

Palette previews with custom themes and other palette fixes
authorTor Norbye <tnorbye@google.com>
Sun, 6 Feb 2011 23:58:18 +0000 (15:58 -0800)
committerTor Norbye <tnorbye@google.com>
Mon, 7 Feb 2011 02:38:59 +0000 (18:38 -0800)
commit1c1c1c869f489b6ee42b7998a6d6e889e12ac4ed
tree5db302d1e135945191615b0c08b0d88d94e4069e
parentfd22f8ba39772c6553d95d07c44bde023db1848f
Palette previews with custom themes and other palette fixes

Palette previews are rendered on top of the default theme
background. For certain custom themes, where a gradient or image is
used, this can look terrible, since the preview images will include
portions of the gradient or image.

This changeset improves this situation by taking advantage of
layoutlib 5's ability to override the background. It now uses theme
resolution to find the background color, and paints the previews with
the custom background override to force this color. In addition, if
the theme background is not a color (but a gradient etc), it uses
layoutlib5's new render-drawable support to generate the background,
and it extracts a suitable color from it (currently, the center
pixel.)

This fix also ensures that the foreground color (used to paint labels
for the widgets that cannot be rendered, such as layouts) has a
suitable contrast with the background. After computing the background,
it computes the brightness, and if the foreground and background
differ less than 25% in brightness, then the foreground color is
forced to white or black depending on whether the background is light
or dark.

This changeset also contains a bugfix for a palette initialization
problem where in some cases the palette could come up empty (because
the code which attempts to avoid doing extra work when reloadPalette
is called repeatedly could be tricked by a scenario where the SDK
target does not change but its "have target data" status did.)

The open palette category is now preserved across palette refreshes
(which occur when you change palette modes or category/sorting
options, along with theme and render target changes).

Finally, the changeset also turns off the new window decorations
(system bar, action bar, etc) when generating preview images for both
palette previews and for drag & drop.

Change-Id: I8b8766ad45f2cb6a4a6b79a24c31ed0f08d1e826
eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/AccordionControl.java
eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/GraphicalEditorPart.java
eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/ImageUtils.java
eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/PaletteControl.java
eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/PreviewIconFactory.java
eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/layout/gle2/ImageUtilsTest.java