2323import static com .google .gapid .widgets .Widgets .createBaloonToolItem ;
2424import static com .google .gapid .widgets .Widgets .createCheckbox ;
2525import static com .google .gapid .widgets .Widgets .createComposite ;
26+ import static com .google .gapid .widgets .Widgets .createGroup ;
2627import static com .google .gapid .widgets .Widgets .createLabel ;
2728import static com .google .gapid .widgets .Widgets .createSeparator ;
2829import static com .google .gapid .widgets .Widgets .createToggleToolItem ;
8384import org .eclipse .swt .widgets .Composite ;
8485import org .eclipse .swt .widgets .Display ;
8586import org .eclipse .swt .widgets .FileDialog ;
87+ import org .eclipse .swt .widgets .Group ;
8688import org .eclipse .swt .widgets .Label ;
8789import org .eclipse .swt .widgets .Scale ;
8890import 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