Skip to content

Commit 637a824

Browse files
committed
Allow images to be labeld in the ImagePanel.
And label textures in the texture list and pinned texture view.
1 parent 4cf2689 commit 637a824

File tree

3 files changed

+34
-7
lines changed

3 files changed

+34
-7
lines changed

gapic/src/main/com/google/gapid/views/FramebufferView.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public FramebufferView(Composite parent, Models models, Widgets widgets) {
133133
picker = withLayoutData(new AttachmentPicker(content, widgets, this::updateBuffer),
134134
new GridData(SWT.FILL, SWT.TOP, true, false));
135135
imagePanel = withLayoutData(
136-
new ImagePanel(content, View.Framebuffer, models.analytics, widgets),
136+
new ImagePanel(content, false, View.Framebuffer, models.analytics, widgets),
137137
new GridData(SWT.FILL, SWT.FILL, true, true));
138138

139139
imagePanel.createToolbar(toolBar, widgets.theme);

gapic/src/main/com/google/gapid/views/TextureView.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ public TextureWidget(Composite parent, boolean pinned, Models models, Widgets wi
100100
setLayout(new FillLayout(SWT.VERTICAL));
101101
Composite imageAndToolbar = createComposite(this, new GridLayout(2, false));
102102
ToolBar toolBar = new ToolBar(imageAndToolbar, SWT.VERTICAL | SWT.FLAT);
103-
imagePanel = new ImagePanel(imageAndToolbar, View.TextureView, models.analytics, widgets);
103+
imagePanel =
104+
new ImagePanel(imageAndToolbar, true, View.TextureView, models.analytics, widgets);
104105

105106
toolBar.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, true));
106107
imagePanel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
@@ -166,10 +167,22 @@ protected void onUiThreadError(String error) {
166167
}
167168

168169
protected void setImage(FetchedImage result) {
170+
imagePanel.setLabel(getLabel(textureResource));
169171
imagePanel.setImage(result);
170172
pinItem.setEnabled(!pinned);
171173
}
172174

175+
private static String getLabel(Service.Resource resource) {
176+
if (resource == null) {
177+
return "Texture";
178+
}
179+
String label = resource.getHandle();
180+
if (!resource.getLabel().isEmpty()) {
181+
label += " " + resource.getLabel();
182+
}
183+
return label;
184+
}
185+
173186
/**
174187
* Action for the {@link ToolItem} that allows the user to jump to references of the currently
175188
* displayed texture.

gapic/src/main/com/google/gapid/widgets/ImagePanel.java

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import static com.google.gapid.widgets.Widgets.createBaloonToolItem;
2424
import static com.google.gapid.widgets.Widgets.createCheckbox;
2525
import static com.google.gapid.widgets.Widgets.createComposite;
26+
import static com.google.gapid.widgets.Widgets.createGroup;
2627
import static com.google.gapid.widgets.Widgets.createLabel;
2728
import static com.google.gapid.widgets.Widgets.createSeparator;
2829
import static com.google.gapid.widgets.Widgets.createToggleToolItem;
@@ -83,6 +84,7 @@
8384
import org.eclipse.swt.widgets.Composite;
8485
import org.eclipse.swt.widgets.Display;
8586
import org.eclipse.swt.widgets.FileDialog;
87+
import org.eclipse.swt.widgets.Group;
8688
import org.eclipse.swt.widgets.Label;
8789
import org.eclipse.swt.widgets.Scale;
8890
import org.eclipse.swt.widgets.ScrollBar;
@@ -127,8 +129,9 @@ public class ImagePanel extends Composite implements Loadable {
127129
private final Analytics analytics;
128130
private final Widgets widgets;
129131
private final SingleInFlight imageRequestController = new SingleInFlight();
130-
protected final LoadablePanel<ImageComponent> loading;
132+
protected final LoadablePanel<Composite> loading;
131133
private final StatusBar status;
134+
private final Group group;
132135
protected final ImageComponent imageComponent;
133136
private final BackgroundSelection backgroundSelection;
134137
private ToolItem zoomFitItem, zoomActualItem, backgroundItem, saveItem, colorChanelsItem;
@@ -141,7 +144,8 @@ public enum ZoomMode {
141144
ZOOM_MANUAL
142145
}
143146

144-
public ImagePanel(Composite parent, View view, Analytics analytics, Widgets widgets) {
147+
public ImagePanel(
148+
Composite parent, boolean labeled, View view, Analytics analytics, Widgets widgets) {
145149
super(parent, SWT.NONE);
146150
this.analyticsView = view;
147151
this.analytics = analytics;
@@ -150,10 +154,16 @@ public ImagePanel(Composite parent, View view, Analytics analytics, Widgets widg
150154

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

153-
loading = LoadablePanel.create(this, widgets, panel ->
154-
new ImageComponent(panel, widgets.theme, this::showAlphaWarning));
157+
loading = LoadablePanel.create(this, widgets, p -> createComposite(p, new FillLayout()));
155158
status = new StatusBar(this, widgets.theme, this::loadLevel, this::setAlphaEnabled);
156-
imageComponent = loading.getContents();
159+
160+
Composite container = loading.getContents();
161+
if (labeled) {
162+
container = group = createGroup(container, "Image");
163+
} else {
164+
group = null;
165+
}
166+
imageComponent = new ImageComponent(container, widgets.theme, this::showAlphaWarning);
157167

158168
loading.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
159169
status.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, true, false));
@@ -504,6 +514,10 @@ public void clearImage() {
504514
imageComponent.setImages(layers);
505515
}
506516

517+
public void setLabel(String label) {
518+
group.setText(label);
519+
}
520+
507521
private void loadLevel(int requestedLecel) {
508522
if (image.getLevelCount() == 0) {
509523
clearImage();

0 commit comments

Comments
 (0)