Skip to content

Commit

Permalink
New icons. (#1230)
Browse files Browse the repository at this point in the history
* Remove unused icons.

* Support icon sequences in the theme.

* Update the icons to the new version.

Also changes the color channel icon into a sheet with a different
icon for each channel combination.

* Change the geometry color to better match the icon theme.

* Add a small margin to the device reload button.

* Flatten the icon resource file hierarchy.

* Match the background color preview with the new icons.

* gapic: Update histogram icons.
  • Loading branch information
pmuetschard authored and ben-clayton committed Oct 23, 2017
1 parent 6c16bc9 commit 795f3a1
Show file tree
Hide file tree
Showing 216 changed files with 135 additions and 88 deletions.
Binary file added gapic/res/icons/android.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed gapic/res/icons/android/android.png
Binary file not shown.
Binary file removed gapic/res/icons/android/[email protected]
Binary file not shown.
Binary file removed gapic/res/icons/android/zoom_actual.png
Binary file not shown.
Binary file removed gapic/res/icons/android/[email protected]
Binary file not shown.
Binary file removed gapic/res/icons/android/zoom_fit.png
Binary file not shown.
Binary file removed gapic/res/icons/android/[email protected]
Binary file not shown.
Binary file removed gapic/res/icons/android/zoom_in.png
Binary file not shown.
Binary file removed gapic/res/icons/android/[email protected]
Binary file not shown.
Binary file removed gapic/res/icons/android/zoom_out.png
Binary file not shown.
Binary file removed gapic/res/icons/android/[email protected]
Binary file not shown.
Binary file added gapic/res/icons/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gapic/res/icons/arrow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gapic/res/icons/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gapic/res/icons/color_buffer0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gapic/res/icons/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gapic/res/icons/color_buffer1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gapic/res/icons/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gapic/res/icons/color_buffer2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gapic/res/icons/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gapic/res/icons/color_buffer3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gapic/res/icons/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gapic/res/icons/color_channels_00.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gapic/res/icons/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gapic/res/icons/color_channels_01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gapic/res/icons/[email protected]
Binary file added gapic/res/icons/color_channels_02.png
Binary file added gapic/res/icons/[email protected]
Binary file added gapic/res/icons/color_channels_03.png
Binary file added gapic/res/icons/[email protected]
Binary file added gapic/res/icons/color_channels_04.png
Binary file added gapic/res/icons/[email protected]
Binary file added gapic/res/icons/color_channels_05.png
Binary file added gapic/res/icons/[email protected]
Binary file added gapic/res/icons/color_channels_06.png
Binary file added gapic/res/icons/[email protected]
Binary file added gapic/res/icons/color_channels_07.png
Binary file added gapic/res/icons/[email protected]
Binary file added gapic/res/icons/color_channels_08.png
Binary file added gapic/res/icons/[email protected]
Binary file added gapic/res/icons/color_channels_09.png
Binary file added gapic/res/icons/[email protected]
Binary file added gapic/res/icons/color_channels_10.png
Binary file added gapic/res/icons/[email protected]
Binary file added gapic/res/icons/color_channels_11.png
Binary file added gapic/res/icons/[email protected]
Binary file added gapic/res/icons/color_channels_12.png
Binary file added gapic/res/icons/[email protected]
Binary file added gapic/res/icons/color_channels_13.png
Binary file added gapic/res/icons/[email protected]
Binary file added gapic/res/icons/color_channels_14.png
Binary file added gapic/res/icons/[email protected]
Binary file added gapic/res/icons/color_channels_15.png
Binary file added gapic/res/icons/[email protected]
Binary file added gapic/res/icons/culling_disabled.png
Binary file added gapic/res/icons/[email protected]
Binary file added gapic/res/icons/culling_enabled.png
Binary file added gapic/res/icons/[email protected]
Binary file added gapic/res/icons/depth_buffer.png
Binary file added gapic/res/icons/[email protected]
File renamed without changes
File renamed without changes
Binary file added gapic/res/icons/faceted.png
Binary file added gapic/res/icons/[email protected]
Binary file added gapic/res/icons/flat.png
Binary file added gapic/res/icons/[email protected]
Binary file added gapic/res/icons/flip_vertically.png
Binary file added gapic/res/icons/[email protected]
Binary file removed gapic/res/icons/gapid/arrow.png
Diff not rendered.
Binary file removed gapic/res/icons/gapid/[email protected]
Diff not rendered.
Binary file removed gapic/res/icons/gapid/color_buffer0.png
Diff not rendered.
Binary file removed gapic/res/icons/gapid/[email protected]
Diff not rendered.
Binary file removed gapic/res/icons/gapid/color_buffer1.png
Diff not rendered.
Binary file removed gapic/res/icons/gapid/[email protected]
Diff not rendered.
Binary file removed gapic/res/icons/gapid/color_buffer2.png
Diff not rendered.
Binary file removed gapic/res/icons/gapid/[email protected]
Diff not rendered.
Binary file removed gapic/res/icons/gapid/color_buffer3.png
Diff not rendered.
Binary file removed gapic/res/icons/gapid/[email protected]
Diff not rendered.
Binary file removed gapic/res/icons/gapid/color_channels.png
Diff not rendered.
Binary file removed gapic/res/icons/gapid/[email protected]
Diff not rendered.
Binary file removed gapic/res/icons/gapid/culling_disabled.png
Diff not rendered.
Binary file removed gapic/res/icons/gapid/[email protected]
Diff not rendered.
Binary file removed gapic/res/icons/gapid/culling_enabled.png
Diff not rendered.
Binary file removed gapic/res/icons/gapid/[email protected]
Diff not rendered.
Binary file removed gapic/res/icons/gapid/depth_buffer.png
Diff not rendered.
Binary file removed gapic/res/icons/gapid/[email protected]
Diff not rendered.
Binary file removed gapic/res/icons/gapid/faceted.png
Diff not rendered.
Binary file removed gapic/res/icons/gapid/[email protected]
Diff not rendered.
Binary file removed gapic/res/icons/gapid/flat.png
Diff not rendered.
Binary file removed gapic/res/icons/gapid/[email protected]
Diff not rendered.
Binary file removed gapic/res/icons/gapid/flip_vertically.png
Diff not rendered.
Binary file removed gapic/res/icons/gapid/[email protected]
Diff not rendered.
Binary file removed gapic/res/icons/gapid/[email protected]
Diff not rendered.
Binary file removed gapic/res/icons/gapid/inject_spy.png
Diff not rendered.
Binary file removed gapic/res/icons/gapid/[email protected]
Diff not rendered.
Binary file removed gapic/res/icons/gapid/jump.png
Diff not rendered.
Binary file removed gapic/res/icons/gapid/listen_for_trace.png
Diff not rendered.
Binary file removed gapic/res/icons/gapid/[email protected]
Diff not rendered.
Binary file removed gapic/res/icons/gapid/lit.png
Diff not rendered.
Binary file removed gapic/res/icons/gapid/[email protected]
Diff not rendered.
Binary file removed gapic/res/icons/gapid/normals.png
Diff not rendered.
Binary file removed gapic/res/icons/gapid/[email protected]
Diff not rendered.
Binary file removed gapic/res/icons/gapid/opacity.png
Diff not rendered.
Binary file removed gapic/res/icons/gapid/[email protected]
Diff not rendered.
Binary file removed gapic/res/icons/gapid/point_cloud.png
Diff not rendered.
Binary file removed gapic/res/icons/gapid/[email protected]
Diff not rendered.
Binary file removed gapic/res/icons/gapid/refresh.png
Diff not rendered.
Binary file removed gapic/res/icons/gapid/[email protected]
Diff not rendered.
Binary file removed gapic/res/icons/gapid/save.png
Diff not rendered.
Binary file removed gapic/res/icons/gapid/[email protected]
Diff not rendered.
Binary file removed gapic/res/icons/gapid/smile.png
Diff not rendered.
Binary file removed gapic/res/icons/gapid/[email protected]
Diff not rendered.
Binary file removed gapic/res/icons/gapid/smooth.png
Diff not rendered.
Binary file removed gapic/res/icons/gapid/[email protected]
Diff not rendered.
Binary file removed gapic/res/icons/gapid/trace_file.png
Diff not rendered.
Binary file removed gapic/res/icons/gapid/[email protected]
Diff not rendered.
Binary file removed gapic/res/icons/gapid/transparency.png
Diff not rendered.
Binary file removed gapic/res/icons/gapid/[email protected]
Diff not rendered.
Binary file removed gapic/res/icons/gapid/winding_ccw.png
Diff not rendered.
Binary file removed gapic/res/icons/gapid/[email protected]
Diff not rendered.
Binary file removed gapic/res/icons/gapid/winding_cw.png
Diff not rendered.
Binary file removed gapic/res/icons/gapid/[email protected]
Diff not rendered.
Binary file removed gapic/res/icons/gapid/wireframe_all.png
Diff not rendered.
Binary file removed gapic/res/icons/gapid/[email protected]
Diff not rendered.
Binary file removed gapic/res/icons/gapid/wireframe_none.png
Diff not rendered.
Binary file removed gapic/res/icons/gapid/[email protected]
Diff not rendered.
Binary file removed gapic/res/icons/gapid/wireframe_overlay.png
Diff not rendered.
Binary file removed gapic/res/icons/gapid/[email protected]
Diff not rendered.
Binary file removed gapic/res/icons/gapid/yup.png
Diff not rendered.
Binary file removed gapic/res/icons/gapid/[email protected]
Diff not rendered.
Binary file removed gapic/res/icons/gapid/zup.png
Diff not rendered.
Binary file removed gapic/res/icons/gapid/[email protected]
Diff not rendered.
Binary file added gapic/res/icons/jump.png
Binary file added gapic/res/icons/[email protected]
Binary file added gapic/res/icons/lit.png
Binary file added gapic/res/icons/[email protected]
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Binary file added gapic/res/icons/normals.png
Binary file added gapic/res/icons/[email protected]
Binary file added gapic/res/icons/point_cloud.png
Binary file added gapic/res/icons/[email protected]
Binary file added gapic/res/icons/refresh.png
Binary file added gapic/res/icons/[email protected]
Binary file added gapic/res/icons/save.png
Binary file added gapic/res/icons/[email protected]
Binary file added gapic/res/icons/smile.png
Binary file added gapic/res/icons/[email protected]
Binary file added gapic/res/icons/smooth.png
Binary file added gapic/res/icons/[email protected]
Binary file added gapic/res/icons/transparency.png
Binary file added gapic/res/icons/[email protected]
Binary file added gapic/res/icons/winding_ccw.png
Binary file added gapic/res/icons/[email protected]
Binary file added gapic/res/icons/winding_cw.png
Binary file added gapic/res/icons/[email protected]
Binary file added gapic/res/icons/wireframe_all.png
Binary file added gapic/res/icons/[email protected]
Binary file added gapic/res/icons/wireframe_none.png
Binary file added gapic/res/icons/[email protected]
Binary file added gapic/res/icons/wireframe_overlay.png
Binary file added gapic/res/icons/[email protected]
Binary file added gapic/res/icons/yup.png
Binary file added gapic/res/icons/[email protected]
Binary file added gapic/res/icons/zoom_actual.png
Binary file added gapic/res/icons/[email protected]
Binary file added gapic/res/icons/zoom_fit.png
Binary file added gapic/res/icons/[email protected]
Binary file added gapic/res/icons/zoom_in.png
Binary file added gapic/res/icons/[email protected]
Binary file added gapic/res/icons/zoom_out.png
Binary file added gapic/res/icons/[email protected]
Binary file added gapic/res/icons/zup.png
Binary file added gapic/res/icons/[email protected]
4 changes: 2 additions & 2 deletions gapic/src/main/com/google/gapid/glviewer/GeometryScene.java
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ public Renderable.State getState(Shaders shaders, boolean invertNormals) {
0f, 0.05f, 0.05f, 0f
});
state.shader.setUniform("uDiffuseColor",
new float[] { 0.37868f, 0.56050f, 0.03703f }); // #A4C639 in linear.
new float[] { 0, 0.48777f, 0.66612f, }); // #00B8D4 in linear.
state.shader.setUniform("uSpecularColor", new float[] { 0.3f, 0.3f, 0.3f });
state.shader.setUniform("uRoughness", 0.25f);
return state;
Expand All @@ -241,7 +241,7 @@ public Renderable.State getState(Shaders shaders, boolean invertNormals) {
public Renderable.State getState(Shaders shaders, boolean invertNormals) {
Renderable.State state = new Renderable.State(shaders.flatShader, false);
state.shader.setUniform("uDiffuseColor",
new float[] { 0.640625f, 0.7734375f, 0.22265625f }); // #A4C639 in sRGB.
new float[] { 0, 0.721568627f, 0.831372549f }); // #00B8D4 in sRGB.
return state;
}
},
Expand Down
4 changes: 3 additions & 1 deletion gapic/src/main/com/google/gapid/views/TracerDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import static com.google.gapid.widgets.Widgets.createTextarea;
import static com.google.gapid.widgets.Widgets.createTextbox;
import static com.google.gapid.widgets.Widgets.ifNotDisposed;
import static com.google.gapid.widgets.Widgets.withIndents;
import static com.google.gapid.widgets.Widgets.withLayoutData;
import static com.google.gapid.widgets.Widgets.withMargin;
import static com.google.gapid.widgets.Widgets.withSpans;
Expand Down Expand Up @@ -446,7 +447,8 @@ protected void buildTargetSelection(Settings settings, Widgets widgets) {
device = createDeviceDropDown(deviceComposite);
deviceLoader = widgets.loading.createWidgetWithRefresh(deviceComposite);
device.getCombo().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
deviceLoader.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
deviceLoader.setLayoutData(
withIndents(new GridData(SWT.RIGHT, SWT.CENTER, false, false), 5, 0));
// TODO: Make this a true button to allow keyboard use.
deviceLoader.addListener(SWT.MouseDown, e -> {
deviceLoader.startLoading();
Expand Down
55 changes: 39 additions & 16 deletions gapic/src/main/com/google/gapid/widgets/ImagePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,18 +111,20 @@ public class ImagePanel extends Composite {
private static final float ALPHA_WARNING_THRESHOLD = 2 / 255f;
private static final Image[] NO_LAYERS = new Image[] { Image.EMPTY };

private final Widgets widgets;
private final SingleInFlight imageRequestController = new SingleInFlight();
protected final LoadablePanel<ImageComponent> loading;
private final StatusBar status;
protected final ImageComponent imageComponent;
private final BackgroundSelection backgroundSelection;
private ToolItem zoomFitItem, backgroundItem, saveItem;
private ToolItem zoomFitItem, backgroundItem, saveItem, colorChanelsItem;
private MultiLayerAndLevelImage image = MultiLayerAndLevelImage.EMPTY;
private Image[] layers = NO_LAYERS;

public ImagePanel(Composite parent, Widgets widgets, boolean naturallyFlipped) {
super(parent, SWT.NONE);
backgroundSelection = new BackgroundSelection(getDisplay());
this.widgets = widgets;
this.backgroundSelection = new BackgroundSelection(getDisplay());

setLayout(Widgets.withMargin(new GridLayout(1, false), 5, 2));

Expand Down Expand Up @@ -310,6 +312,7 @@ private void showAlphaWarning(AlphaWarning message) {

private void setAlphaEnabled(boolean enabled) {
imageComponent.autoToggleAlphaChannel(enabled);
updateColorChannelsIcon();
}

public void createToolbar(ToolBar bar, Theme theme) {
Expand All @@ -322,17 +325,27 @@ public void createToolbar(ToolBar bar, Theme theme) {
createSeparator(bar);
createToggleToolItem(bar, theme.toggleHistogram(),
e -> setShowHistogram(((ToolItem)e.widget).getSelection()), "Toggle histogram");
createBaloonToolItem(bar, theme.colorChannels(), shell -> {
saveItem = createToolItem(bar, theme.save(), e -> save(), "Save image to file");
saveItem.setEnabled(false);
colorChanelsItem = createBaloonToolItem(bar, theme.colorChannels()[15], shell -> {
Composite c = createComposite(shell, new RowLayout(SWT.HORIZONTAL), SWT.BORDER);
final ImageComponent i = imageComponent;
createCheckbox(c, "Red", i.isChannelEnabled(CHANNEL_RED),
e -> i.setChannelEnabled(CHANNEL_RED, ((Button)e.widget).getSelection()));
createCheckbox(c, "Green", i.isChannelEnabled(CHANNEL_GREEN),
e -> i.setChannelEnabled(CHANNEL_GREEN, ((Button)e.widget).getSelection()));
createCheckbox(c, "Blue", i.isChannelEnabled(CHANNEL_BLUE),
e -> i.setChannelEnabled(CHANNEL_BLUE, ((Button)e.widget).getSelection()));
createCheckbox(c, "Alpha", i.isChannelEnabled(CHANNEL_ALPHA),
e -> i.setChannelEnabled(CHANNEL_ALPHA, ((Button)e.widget).getSelection()));
createCheckbox(c, "Red", i.isChannelEnabled(CHANNEL_RED), e -> {
i.setChannelEnabled(CHANNEL_RED, ((Button)e.widget).getSelection());
updateColorChannelsIcon();
});
createCheckbox(c, "Green", i.isChannelEnabled(CHANNEL_GREEN), e -> {
i.setChannelEnabled(CHANNEL_GREEN, ((Button)e.widget).getSelection());
updateColorChannelsIcon();
});
createCheckbox(c, "Blue", i.isChannelEnabled(CHANNEL_BLUE), e -> {
i.setChannelEnabled(CHANNEL_BLUE, ((Button)e.widget).getSelection());
updateColorChannelsIcon();
});
createCheckbox(c, "Alpha", i.isChannelEnabled(CHANNEL_ALPHA), e -> {
i.setChannelEnabled(CHANNEL_ALPHA, ((Button)e.widget).getSelection());
updateColorChannelsIcon();
});
}, "Color channel selection");
backgroundItem = createBaloonToolItem(bar, theme.transparency(),
shell -> backgroundSelection.createBaloonContents(shell, theme,
Expand All @@ -344,6 +357,14 @@ public void createToolbar(ToolBar bar, Theme theme) {
saveItem.setEnabled(false);
}

private void updateColorChannelsIcon() {
colorChanelsItem.setImage(widgets.theme.colorChannels()[
(imageComponent.isChannelEnabled(CHANNEL_RED) ? 1 : 0) |
(imageComponent.isChannelEnabled(CHANNEL_GREEN) ? 2 : 0) |
(imageComponent.isChannelEnabled(CHANNEL_BLUE) ? 4 : 0) |
(imageComponent.isChannelEnabled(CHANNEL_ALPHA) ? 8 : 0)]);
}

protected void setZoomToFit(boolean enabled) {
zoomFitItem.setSelection(enabled);
imageComponent.setZoomToFit(enabled);
Expand Down Expand Up @@ -1330,8 +1351,8 @@ private static class BackgroundSelection {
public Color color;

public BackgroundSelection(Display display) {
image = new org.eclipse.swt.graphics.Image(display, 16, 16);
updateImage(new RGB(0, 0, 0));
image = new org.eclipse.swt.graphics.Image(display, 24, 24);
updateImage(new RGB(0, 0, 0), display);
}

public void createBaloonContents(Shell shell, Theme theme, Listener listener) {
Expand All @@ -1346,23 +1367,25 @@ public void createBaloonContents(Shell shell, Theme theme, Listener listener) {
e -> listener.onBackgroundSelectionChanged(BackgroundMode.SolidColor),
"Show solid color background"));
new QuickColorPiker(container, 128, newColor -> {
updateImage(newColor);
updateImage(newColor, shell.getDisplay());
transparency.setSelection(false);
backgroundColor.setSelection(true);
backgroundColor.setImage(image);
listener.onBackgroundSelectionChanged(BackgroundMode.SolidColor);
});
}

protected void updateImage(RGB newColor) {
protected void updateImage(RGB newColor, Display display) {
if (color != null) {
color.dispose();
}

GC gc = new GC(image);
gc.setBackground(display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
gc.fillRectangle(image.getBounds());
color = new Color(image.getDevice(), newColor);
gc.setBackground(color);
gc.fillRectangle(image.getBounds());
gc.fillRoundRectangle(2, 2, 20, 20, 4, 4);
gc.dispose();
}

Expand Down
10 changes: 2 additions & 8 deletions gapic/src/main/com/google/gapid/widgets/LoadingIndicator.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,8 @@ public class LoadingIndicator {

public LoadingIndicator(Display display, Theme theme) {
this.display = display;
this.icons = new Image[] {
theme.loading0large(), theme.loading1large(), theme.loading2large(), theme.loading3large(),
theme.loading4large(), theme.loading5large(), theme.loading6large(), theme.loading7large()
};
this.smallIcons = new Image[] {
theme.loading0small(), theme.loading1small(), theme.loading2small(), theme.loading3small(),
theme.loading4small(), theme.loading5small(), theme.loading6small(), theme.loading7small()
};
this.icons = theme.loadingLarge();
this.smallIcons = theme.loadingSmall();
this.refresh = theme.refresh();
}

Expand Down
144 changes: 83 additions & 61 deletions gapic/src/main/com/google/gapid/widgets/Theme.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,64 +45,46 @@
* {@link Color colors}, etc.).
*/
public interface Theme {
@Icon("gapid/arrow.png") public Image arrow();
@Icon("gapid/color_buffer0.png") public Image colorBuffer0();
@Icon("gapid/color_buffer1.png") public Image colorBuffer1();
@Icon("gapid/color_buffer2.png") public Image colorBuffer2();
@Icon("gapid/color_buffer3.png") public Image colorBuffer3();
@Icon("gapid/color_channels.png") public Image colorChannels();
@Icon("gapid/culling_disabled.png") public Image cullingDisabled();
@Icon("gapid/culling_enabled.png") public Image cullingEnabled();
@Icon("gapid/depth_buffer.png") public Image depthBuffer();
@Icon("gapid/error.png") public Image error();
@Icon("gapid/faceted.png") public Image faceted();
@Icon("gapid/flat.png") public Image flat();
@Icon("gapid/flip_vertically.png") public Image flipVertically();
@Icon("gapid/inject_spy.png") public Image injectSpy();
@Icon("gapid/jump.png") public Image jump();
@Icon("gapid/listen_for_trace.png") public Image listenForTrace();
@Icon("gapid/lit.png") public Image lit();
@Icon("gapid/logo.png") public Image logo();
@Icon("gapid/logo_big.png") public Image logoBig();
@Icon("gapid/normals.png") public Image normals();
@Icon("gapid/opacity.png") public Image opacity();
@Icon("gapid/point_cloud.png") public Image pointCloud();
@Icon("gapid/refresh.png") public Image refresh();
@Icon("gapid/save.png") public Image save();
@Icon("gapid/smile.png") public Image smile();
@Icon("gapid/smooth.png") public Image smooth();
@Icon("gapid/trace_file.png") public Image traceFile();
@Icon("gapid/transparency.png") public Image transparency();
@Icon("gapid/winding_ccw.png") public Image windingCCW();
@Icon("gapid/winding_cw.png") public Image windingCW();
@Icon("gapid/wireframe_all.png") public Image wireframeAll();
@Icon("gapid/wireframe_none.png") public Image wireframeNone();
@Icon("gapid/wireframe_overlay.png") public Image wireframeOverlay();
@Icon("gapid/yup.png") public Image yUp();
@Icon("gapid/zup.png") public Image zUp();
@Icon("gapid/loading_0_small.png") public Image loading0small();
@Icon("gapid/loading_1_small.png") public Image loading1small();
@Icon("gapid/loading_2_small.png") public Image loading2small();
@Icon("gapid/loading_3_small.png") public Image loading3small();
@Icon("gapid/loading_4_small.png") public Image loading4small();
@Icon("gapid/loading_5_small.png") public Image loading5small();
@Icon("gapid/loading_6_small.png") public Image loading6small();
@Icon("gapid/loading_7_small.png") public Image loading7small();
@Icon("gapid/loading_0_large.png") public Image loading0large();
@Icon("gapid/loading_1_large.png") public Image loading1large();
@Icon("gapid/loading_2_large.png") public Image loading2large();
@Icon("gapid/loading_3_large.png") public Image loading3large();
@Icon("gapid/loading_4_large.png") public Image loading4large();
@Icon("gapid/loading_5_large.png") public Image loading5large();
@Icon("gapid/loading_6_large.png") public Image loading6large();
@Icon("gapid/loading_7_large.png") public Image loading7large();
@Icon("gapid/histogram.png") public Image toggleHistogram();

@Icon("android/zoom_actual.png") public Image zoomActual();
@Icon("android/zoom_fit.png") public Image zoomFit();
@Icon("android/zoom_in.png") public Image zoomIn();
@Icon("android/zoom_out.png") public Image zoomOut();
@Icon("android/android.png") public Image androidLogo();
@Icon("android.png") public Image androidLogo();
@Icon("arrow.png") public Image arrow();
@Icon("color_buffer0.png") public Image colorBuffer0();
@Icon("color_buffer1.png") public Image colorBuffer1();
@Icon("color_buffer2.png") public Image colorBuffer2();
@Icon("color_buffer3.png") public Image colorBuffer3();
@Icon("culling_disabled.png") public Image cullingDisabled();
@Icon("culling_enabled.png") public Image cullingEnabled();
@Icon("depth_buffer.png") public Image depthBuffer();
@Icon("error.png") public Image error();
@Icon("faceted.png") public Image faceted();
@Icon("flat.png") public Image flat();
@Icon("flip_vertically.png") public Image flipVertically();
@Icon("jump.png") public Image jump();
@Icon("histogram.png") public Image toggleHistogram();
@Icon("lit.png") public Image lit();
@Icon("logo.png") public Image logo();
@Icon("logo_big.png") public Image logoBig();
@Icon("normals.png") public Image normals();
@Icon("point_cloud.png") public Image pointCloud();
@Icon("refresh.png") public Image refresh();
@Icon("save.png") public Image save();
@Icon("smile.png") public Image smile();
@Icon("smooth.png") public Image smooth();
@Icon("transparency.png") public Image transparency();
@Icon("winding_ccw.png") public Image windingCCW();
@Icon("winding_cw.png") public Image windingCW();
@Icon("wireframe_all.png") public Image wireframeAll();
@Icon("wireframe_none.png") public Image wireframeNone();
@Icon("wireframe_overlay.png") public Image wireframeOverlay();
@Icon("yup.png") public Image yUp();
@Icon("zup.png") public Image zUp();
@Icon("zoom_actual.png") public Image zoomActual();
@Icon("zoom_fit.png") public Image zoomFit();
@Icon("zoom_in.png") public Image zoomIn();
@Icon("zoom_out.png") public Image zoomOut();

@IconSequence(pattern = "color_channels_%02d.png", count = 16) public Image[] colorChannels();
@IconSequence(pattern = "loading_%d_small.png", count = 8) public Image[] loadingSmall();
@IconSequence(pattern = "loading_%d_large.png", count = 8) public Image[] loadingLarge();

// Shader source highlight colors.
@RGB(argb = 0xff808080) public Color commentColor();
Expand Down Expand Up @@ -170,6 +152,10 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl
((Resource)resource).dispose();
} else if (resource instanceof DisposableStyler) {
((DisposableStyler)resource).dispose();
} else if (resource instanceof Image[]) {
for (Image image : (Image[])resource) {
image.dispose();
}
}
}
resources.clear();
Expand All @@ -193,6 +179,24 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl
public String value();
}

/**
* Annotation for an icon sheet image resource.
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public static @interface IconSequence {
/**
* @return a {@link String#format(String, Object...)} pattern given a sequence number, i, to
* format the file name of the ith image in the sequence.
*/
public String pattern();

/**
* @return the number of images in the sequence.
*/
public int count();
}

/**
* Annotation for a color resource.
*/
Expand Down Expand Up @@ -284,19 +288,37 @@ public Map<String, Object> load() {
}

private boolean loadResource(Method method) {
return loadIcon(method) || loadColor(method) || loadTextStyle(method) || loadFont(method);
return loadIcon(method) || loadIconSequence(method) || loadColor(method) ||
loadTextStyle(method) || loadFont(method);
}

private boolean loadIcon(Method method) {
Icon icon = method.getDeclaredAnnotation(Icon.class);
if (icon != null) {
resources.put(method.getName(), ImageDescriptor.createFromURL(
Resources.getResource("icons/" + icon.value())).createImage(display));
resources.put(method.getName(), loadImage(icon.value()));
return true;
}
return false;
}

private boolean loadIconSequence(Method method) {
IconSequence seq = method.getDeclaredAnnotation(IconSequence.class);
if (seq != null) {
Image[] icons = new Image[seq.count()];
for (int i = 0; i < icons.length; i++) {
icons[i] = loadImage(String.format(seq.pattern(), i));
}
resources.put(method.getName(), icons);
return true;
}
return false;
}

private Image loadImage(String img) {
return
ImageDescriptor.createFromURL(Resources.getResource("icons/" + img)).createImage(display);
}

private boolean loadColor(Method method) {
RGB rgb = method.getDeclaredAnnotation(RGB.class);
if (rgb != null) {
Expand Down
6 changes: 6 additions & 0 deletions gapic/src/main/com/google/gapid/widgets/Widgets.java
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,12 @@ public static GridData withSizeHints(GridData data, int widthHint, int heightHin
return data;
}

public static GridData withIndents(GridData data, int horizontalIndent, int verticalIndent) {
data.horizontalIndent = horizontalIndent;
data.verticalIndent = verticalIndent;
return data;
}

public static FillLayout withMargin(FillLayout layout, int marginWidth, int marginHeight) {
layout.marginWidth = marginWidth;
layout.marginHeight = marginHeight;
Expand Down

0 comments on commit 795f3a1

Please sign in to comment.