Skip to content

Commit

Permalink
Further UI modifications based on comments in pull request #2752.
Browse files Browse the repository at this point in the history
  • Loading branch information
stellama0208 committed May 21, 2019
1 parent 5a92729 commit 5009659
Show file tree
Hide file tree
Showing 13 changed files with 75 additions and 41 deletions.
Binary file added gapic/res/icons/add.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 modified gapic/res/icons/clipboard.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 modified 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/open.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/recent.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.
88 changes: 61 additions & 27 deletions gapic/src/main/com/google/gapid/LoadingScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
*/
package com.google.gapid;

import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.gapid.util.GapidVersion.GAPID_VERSION;
import static com.google.gapid.util.GeoUtils.bottomLeft;
import static com.google.gapid.views.AboutDialog.showHelp;
import static com.google.gapid.views.TracerDialog.showOpenTraceDialog;
import static com.google.gapid.views.TracerDialog.showTracingDialog;
import static com.google.gapid.widgets.Widgets.createLabel;
Expand All @@ -41,7 +41,6 @@
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Link;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.Shell;

import java.io.File;

Expand All @@ -50,13 +49,18 @@
*/
public class LoadingScreen extends Composite {
private final Label statusLabel;
private final Composite container;
private final Composite optionsContainer;
private Label recentIcon;
private Link recentLink;
private Models models;
private Client client;
private Widgets widgets;

public LoadingScreen(Composite parent, Theme theme) {
super(parent, SWT.NONE);
setLayout(CenteringLayout.goldenRatio());

container = Widgets.createComposite(this, new GridLayout(1, false));
Composite container = Widgets.createComposite(this, new GridLayout(1, false));
createLabel(container, "", theme.dialogLogo())
.setLayoutData(new GridData(SWT.CENTER, SWT.TOP, true, false));

Expand All @@ -70,40 +74,70 @@ public LoadingScreen(Composite parent, Theme theme) {

statusLabel = createLabel(container, "Starting up...");
statusLabel.setLayoutData(new GridData(SWT.CENTER, SWT.TOP, true, false));
statusLabel.setVisible(false);

GridLayout gridLayout = new GridLayout(3, false);
gridLayout.horizontalSpacing = 15;
optionsContainer = Widgets.createComposite(container, gridLayout);
optionsContainer.setLayoutData(new GridData(SWT.CENTER, SWT.TOP, true, false));
this.createOptions(theme);
}

public void setText(String status) {
statusLabel.setText(status);
statusLabel.requestLayout();
}

public void createLinks(Client client, Shell shell, Models models, Widgets widgets) {
createLink(container, "<a>Open Trace...</a>", e -> {
showOpenTraceDialog(getShell(), models);
});
/**
* Hide the messaging box and display the links after server set up.
*/
@SuppressWarnings("hiding")
public void showOptions(Client client, Models models, Widgets widgets) {
this.client = client;
this.models = models;
this.widgets = widgets;

String[] files = models.settings.getRecent();
if (files.length > 0) {
createLink(container, "<a>Open Recent...</a>", e -> {
Menu popup = new Menu(container);
for (String file : models.settings.recentFiles) {
createMenuItem(popup, file, 0, ev -> {
models.analytics.postInteraction(View.Welcome, ClientAction.OpenRecent);
models.capture.loadCapture(new File(file));
});
}
popup.addListener(SWT.Hide, ev -> scheduleIfNotDisposed(popup, popup::dispose));

popup.setLocation(container.toDisplay(bottomLeft(((Link)e.widget).getBounds())));
popup.setVisible(true);
});
statusLabel.setVisible(false);
optionsContainer.setVisible(true);
if (models.settings.getRecent().length <= 0) {
recentLink.setVisible(false);
recentIcon.setVisible(false);
}
}

/**
* Initialize the links for layout settings. Hide them until server set up.
*/
private void createOptions(Theme theme) {
createLabel(optionsContainer, "", theme.add());
createLink(optionsContainer, "<a>Capture a new trace</a>", e -> {
showTracingDialog(checkNotNull(client), getShell(), checkNotNull(models), checkNotNull(widgets));
});
Label captureHint = createLabel(optionsContainer, "Ctrl + T");
captureHint.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, false));
captureHint.setForeground(theme.welcomeVersionColor());

createLink(container, "<a>Capture Trace...</a>", e -> {
showTracingDialog(client, shell, models, widgets);
createLabel(optionsContainer, "", theme.open());
createLink(optionsContainer, "<a>Open an existing trace</a>", e -> {
showOpenTraceDialog(getShell(), checkNotNull(this.models));
});
Label openHint = createLabel(optionsContainer, "Ctrl + O");
openHint.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, false));
openHint.setForeground(theme.welcomeVersionColor());

recentIcon = createLabel(optionsContainer, "", theme.recent());
recentLink = createLink(optionsContainer, "<a>Recent traces</a>", e -> {
Menu popup = new Menu(optionsContainer);
for (String file : checkNotNull(models).settings.recentFiles) {
createMenuItem(popup, file, 0, ev -> {
checkNotNull(models).analytics.postInteraction(View.Welcome, ClientAction.OpenRecent);
checkNotNull(models).capture.loadCapture(new File(file));
});
}
popup.addListener(SWT.Hide, ev -> scheduleIfNotDisposed(popup, popup::dispose));
popup.setLocation(optionsContainer.toDisplay(bottomLeft(((Link)e.widget).getBounds())));
popup.setVisible(true);
});

createLink(container, "<a>Help...</a>", e -> showHelp(models.analytics));
optionsContainer.setVisible(false);
}
}
2 changes: 1 addition & 1 deletion gapic/src/main/com/google/gapid/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ private void uiStartup(Shell shell) {
}

// Add the links on Loading Screen after the server set up.
window.updateLoadingScreen(server.getClient(), window.getShell(), models, widgets);
window.updateLoadingScreen(server.getClient(), models, widgets);
}

@Override
Expand Down
4 changes: 2 additions & 2 deletions gapic/src/main/com/google/gapid/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ public void showLoadingMessage(String status) {
loadingScreen.setText(status);
}

public void updateLoadingScreen(Client client, Shell shell, Models models, Widgets widgets) {
this.loadingScreen.createLinks(client, shell, models, widgets);
public void updateLoadingScreen(Client client, Models models, Widgets widgets) {
this.loadingScreen.showOptions(client, models, widgets);
}

public void initMainUi(Client client, Models models, Widgets widgets) {
Expand Down
19 changes: 8 additions & 11 deletions gapic/src/main/com/google/gapid/views/AboutDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import com.google.gapid.proto.service.Service.ClientAction;
import com.google.gapid.util.Logging;
import com.google.gapid.util.Messages;
import com.google.gapid.util.MouseAdapter;
import com.google.gapid.util.OS;
import com.google.gapid.widgets.DialogBase;
import com.google.gapid.widgets.Theme;
Expand All @@ -37,10 +36,10 @@
import org.eclipse.swt.dnd.Clipboard;
import org.eclipse.swt.dnd.TextTransfer;
import org.eclipse.swt.dnd.Transfer;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.program.Program;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
Expand Down Expand Up @@ -89,7 +88,8 @@ protected Control createDialogArea(Composite parent) {
Composite area = (Composite)super.createDialogArea(parent);

GridLayout gridLayout = new GridLayout(2, false);
gridLayout.horizontalSpacing = 30;
gridLayout.horizontalSpacing = 20;
gridLayout.verticalSpacing = 5;
Composite container = createComposite(area, gridLayout);
container.setLayoutData(new GridData(SWT.CENTER, SWT.FILL, true, false));

Expand All @@ -101,15 +101,12 @@ protected Control createDialogArea(Composite parent) {
title.setLayoutData(new GridData(SWT.CENTER, SWT.FILL, true, false, 2, 1));

createLabel(container, "").setLayoutData(new GridData(SWT.CENTER, SWT.FILL, true, true, 2, 1));
Label clipboard = createLabel(container, "", theme.clipboard());
clipboard.addMouseListener(new MouseAdapter() {
@Override
public void mouseDown (MouseEvent e) {
String textData = "Version " + GAPID_VERSION;
TextTransfer textTransfer = TextTransfer.getInstance();
cb.setContents(new Object[]{textData}, new Transfer[]{textTransfer});
}
Button clipboard = com.google.gapid.widgets.Widgets.createButton(container, "", e -> {
String textData = "Version " + GAPID_VERSION;
TextTransfer textTransfer = TextTransfer.getInstance();
cb.setContents(new Object[]{textData}, new Transfer[]{textTransfer});
});
clipboard.setImage(theme.clipboard());
clipboard.setLayoutData(new GridData(SWT.CENTER, SWT.BEGINNING, true, true, 1, 3));

createForegroundLabel(container, "Version " + GAPID_VERSION);
Expand Down
3 changes: 3 additions & 0 deletions gapic/src/main/com/google/gapid/widgets/Theme.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
* {@link Color colors}, etc.).
*/
public interface Theme {
@Icon("add.png") public Image add();
@Icon("android.png") public Image androidLogo();
@Icon("arrow.png") public Image arrow();
@Icon("clipboard.png") public Image clipboard();
Expand All @@ -65,8 +66,10 @@ public interface Theme {
@Icon("lit.png") public Image lit();
@Icon("logo_128.png") public Image dialogLogo();
@Icon("normals.png") public Image normals();
@Icon("open.png") public Image open();
@Icon("overdraw.png") public Image overdraw();
@Icon("point_cloud.png") public Image pointCloud();
@Icon("recent.png") public Image recent();
@Icon("refresh.png") public Image refresh();
@Icon("save.png") public Image save();
@Icon("settings.png") public Image settings();
Expand Down

0 comments on commit 5009659

Please sign in to comment.