Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make two UI modifications in Welcoming window and Help-About dialog. #2752

Merged
merged 7 commits into from
Jun 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 added 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 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/help.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/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.
95 changes: 93 additions & 2 deletions gapic/src/main/com/google/gapid/LoadingScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,25 @@
*/
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.createComposite;
import static com.google.gapid.widgets.Widgets.createLabel;
import static com.google.gapid.widgets.Widgets.createLink;
import static com.google.gapid.widgets.Widgets.createMenuItem;
import static com.google.gapid.widgets.Widgets.scheduleIfNotDisposed;
import static com.google.gapid.widgets.Widgets.withMargin;

import com.google.gapid.models.Analytics.View;
import com.google.gapid.models.Models;
import com.google.gapid.proto.service.Service.ClientAction;
import com.google.gapid.server.Client;
import com.google.gapid.util.Messages;
import com.google.gapid.util.OS;
import com.google.gapid.widgets.CenteringLayout;
import com.google.gapid.widgets.Theme;
import com.google.gapid.widgets.Widgets;
Expand All @@ -27,31 +43,106 @@
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Link;
import org.eclipse.swt.widgets.Menu;

import java.io.File;

/**
* The loading screen is a minimal view shown while the UI is loading, looking for gapis, etc.
*/
public class LoadingScreen extends Composite {
private final Theme theme;
private final Label statusLabel;
private final Composite optionsContainer;
private Link recentLink;
private Models models;
private Client client;
private Widgets widgets;

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

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

Label titleLabel = createLabel(container, Messages.WINDOW_TITLE);
titleLabel.setFont(theme.bigBoldFont());
titleLabel.setLayoutData(new GridData(SWT.CENTER, SWT.TOP, true, false));

Label versionLabel = createLabel(container, "Version " + GAPID_VERSION.toFriendlyString());
versionLabel.setForeground(theme.welcomeVersionColor());
versionLabel.setLayoutData(new GridData(SWT.CENTER, SWT.TOP, true, false));

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

optionsContainer = createComposite(container, withMargin(new GridLayout(3, false), 15, 5));
optionsContainer.setLayoutData(new GridData(SWT.CENTER, SWT.TOP, true, false));
createOptions();
}

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

/**
* Hide the messaging box and display the links after server set up.
*/
public void showOptions(Client newClient, Models newModels, Widgets newWidgets) {
this.client = newClient;
this.models = newModels;
this.widgets = newWidgets;

statusLabel.setVisible(false);
optionsContainer.setVisible(true);
if (models.settings.getRecent().length <= 0) {
recentLink.setEnabled(false);
}
}

/**
* Initialize the links for layout settings. Hide them until server set up.
*/
private void createOptions() {
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, (OS.isMac ? "\u2318" : "Ctrl") + " + T");
captureHint.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false));
captureHint.setForeground(theme.shortcutKeyHintColor());

createLabel(optionsContainer, "", theme.open());
createLink(optionsContainer, "<a>Open an existing trace</a>", e -> {
showOpenTraceDialog(getShell(), checkNotNull(this.models));
});
Label openHint = createLabel(optionsContainer, (OS.isMac ? "\u2318" : "Ctrl") + " + O");
openHint.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false));
openHint.setForeground(theme.shortcutKeyHintColor());

createLabel(optionsContainer, "", theme.recent());
recentLink = createLink(optionsContainer, "<a>Open 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);
});
recentLink.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 2, 1));

createLabel(optionsContainer, "", theme.help());
createLink(optionsContainer, "<a>Help</a>", e -> showHelp(models.analytics));

optionsContainer.setVisible(false);
}
}
6 changes: 3 additions & 3 deletions gapic/src/main/com/google/gapid/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import static com.google.gapid.util.GapidVersion.GAPID_VERSION;
import static com.google.gapid.views.ErrorDialog.showErrorDialog;
import static com.google.gapid.views.WelcomeDialog.showFirstTimeDialog;
import static com.google.gapid.views.WelcomeDialog.showWelcomeDialog;
import static com.google.gapid.widgets.Widgets.scheduleIfNotDisposed;

import com.google.common.base.Throwables;
Expand Down Expand Up @@ -147,8 +146,6 @@ private void uiStartup(Shell shell) {
Runnable onStart = () -> {
if (args.length == 1) {
models.capture.loadCapture(new File(args[0]));
} else if (!models.settings.skipWelcomeScreen) {
showWelcomeDialog(server.getClient(), window.getShell(), models, widgets);
}
};

Expand All @@ -158,6 +155,9 @@ private void uiStartup(Shell shell) {
} else {
shell.getDisplay().asyncExec(() -> showFirstTimeDialog(shell, models, widgets, onStart));
}

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

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

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

public void initMainUi(Client client, Models models, Widgets widgets) {
Shell shell = getShell();

Expand Down Expand Up @@ -130,7 +134,7 @@ public void onCaptureLoaded(Message error) {

if (OS.isMac) {
MacApplication.init(shell.getDisplay(),
() -> showAbout(shell, models.analytics, widgets.theme),
() -> showAbout(shell, models.analytics, widgets),
() -> showSettingsDialog(shell, models, widgets.theme),
file -> models.capture.loadCapture(new File(file)));
}
Expand Down Expand Up @@ -347,7 +351,7 @@ private MenuManager createHelpMenu(Client client, Models models, Widgets widgets
MenuManager manager = new MenuManager("&Help");
manager.add(MenuItems.HelpOnlineHelp.create(() -> showHelp(models.analytics)));
manager.add(MenuItems.HelpAbout.create(
() -> showAbout(getShell(), models.analytics, widgets.theme)));
() -> showAbout(getShell(), models.analytics, widgets)));
manager.add(MenuItems.HelpShowLogs.create(() -> showLogDir(models.analytics)));
manager.add(MenuItems.HelpLicenses.create(
() -> showLicensesDialog(getShell(), models.analytics, widgets.theme)));
Expand Down
31 changes: 23 additions & 8 deletions gapic/src/main/com/google/gapid/views/AboutDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
package com.google.gapid.views;

import static com.google.gapid.util.GapidVersion.GAPID_VERSION;
import static com.google.gapid.widgets.Widgets.centered;
import static com.google.gapid.widgets.Widgets.createComposite;
import static com.google.gapid.widgets.Widgets.createLabel;
import static com.google.gapid.widgets.Widgets.createTextbox;
import static com.google.gapid.widgets.Widgets.withMargin;
import static java.util.logging.Level.SEVERE;

import com.google.gapid.models.Analytics;
Expand All @@ -30,15 +30,17 @@
import com.google.gapid.util.Messages;
import com.google.gapid.util.OS;
import com.google.gapid.widgets.DialogBase;
import com.google.gapid.widgets.Theme;
import com.google.gapid.widgets.Widgets;

import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.RowLayout;
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.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;

Expand Down Expand Up @@ -69,9 +71,9 @@ public static void showLogDir(Analytics analytics) {
}
}

public static void showAbout(Shell shell, Analytics analytics, Theme theme) {
public static void showAbout(Shell shell, Analytics analytics, Widgets widgets) {
analytics.postInteraction(View.About, ClientAction.Show);
new DialogBase(shell, theme) {
new DialogBase(shell, widgets.theme) {
@Override
public String getTitle() {
return Messages.ABOUT_TITLE;
Expand All @@ -81,12 +83,25 @@ public String getTitle() {
protected Control createDialogArea(Composite parent) {
Composite area = (Composite)super.createDialogArea(parent);

Composite container = createComposite(area, centered(new RowLayout(SWT.VERTICAL)));
container.setLayoutData(new GridData(SWT.CENTER, SWT.FILL, true, true));
Composite container = createComposite(area, withMargin(new GridLayout(2, false), 20, 5));
container.setLayoutData(new GridData(SWT.CENTER, SWT.FILL, true, false));

Label logo = createLabel(container, "", theme.dialogLogo());
logo.setLayoutData(new GridData(SWT.CENTER, SWT.FILL, true, false, 2, 1));

createLabel(container, "", theme.dialogLogo());
Text title = createForegroundLabel(container, Messages.WINDOW_TITLE);
title.setFont(theme.bigBoldFont());
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));
Button clipboard = Widgets.createButton(container, "", e -> {
String textData = "Version " + GAPID_VERSION;
widgets.copypaste.setContents(textData);
});

clipboard.setImage(theme.clipboard());
clipboard.setLayoutData(new GridData(SWT.CENTER, SWT.BEGINNING, true, true, 1, 3));

createForegroundLabel(container, "Version " + GAPID_VERSION);
createForegroundLabel(
container, "Server: " + Info.getServerName() + ", Version: " + Info.getServerVersion());
Expand Down
4 changes: 4 additions & 0 deletions gapic/src/main/com/google/gapid/widgets/CopyPaste.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ protected void doCopy(CopySource source) {
clipboard.setContents(objs, transfers);
}

public void setContents(String s) {
clipboard.setContents(new Object[]{s}, new Transfer[]{TextTransfer.getInstance()});
}

public void addListener(Listener listener) {
listeners.addListener(listener);
}
Expand Down
6 changes: 6 additions & 0 deletions gapic/src/main/com/google/gapid/widgets/Theme.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,14 @@
* {@link Color colors}, etc.).
*/
public interface Theme {
@Icon(file = "add.png") public Image add();
@Icon(file = "android.png", color = 0x335577) public Image androidLogo();
@Icon(file = "arrow.png") public Image arrow();
@Icon(file = "arrow_drop_down.png") public Image arrowDropDownLight();
@Icon(file = "arrow_drop_right.png") public Image arrowDropRightLight();
@Icon(file = "arrow_drop_down.png", color = 0xFFFFFF) public Image arrowDropDownDark();
@Icon(file = "arrow_drop_right.png", color = 0xFFFFFF) public Image arrowDropRightDark();
@Icon(file = "clipboard.png") public Image clipboard();
@Icon(file = "color_buffer0.png") public Image colorBuffer0();
@Icon(file = "color_buffer1.png") public Image colorBuffer1();
@Icon(file = "color_buffer2.png") public Image colorBuffer2();
Expand All @@ -72,16 +74,19 @@ public interface Theme {
@Icon(file = "flat.png") public Image flat();
@Icon(file = "flip_vertically.png") public Image flipVertically();
@Icon(file = "jump.png") public Image jump();
@Icon(file = "help.png") public Image help();
@Icon(file = "histogram.png") public Image toggleHistogram();
@Icon(file = "lit.png") public Image lit();
@Icon(file = "logo_128.png") public Image dialogLogo();
@Icon(file = "normals.png") public Image normals();
@Icon(file = "open.png") public Image open();
@Icon(file = "overdraw.png") public Image overdraw();
@Icon(file = "point_cloud.png") public Image pointCloud();
@Icon(file = "range_start.png") public Image rangeStartLight();
@Icon(file = "range_end.png") public Image rangeEndLight();
@Icon(file = "range_start.png", color = 0xFFFFFF) public Image rangeStartDark();
@Icon(file = "range_end.png", color = 0xFFFFFF) public Image rangeEndDark();
@Icon(file = "recent.png") public Image recent();
@Icon(file = "refresh.png") public Image refresh();
@Icon(file = "save.png") public Image save();
@Icon(file = "settings.png") public Image settings();
Expand Down Expand Up @@ -125,6 +130,7 @@ public interface Theme {

// About & Welcome dialog text colors
@RGB(argb = 0xffa9a9a9) public Color welcomeVersionColor();
@RGB(argb = 0xffa9a9a9) public Color shortcutKeyHintColor();

// Logging view colors by log level.
@RGB(argb = 0xbb000000) public Color logVerboseForeground();
Expand Down