Commit 59870574 authored by Mark Sherman's avatar Mark Sherman Committed by Jeffrey Schiller

Sidebar tutorial images now scale to fit the window. (#1209)

parent 61ae55dd
...@@ -8,6 +8,7 @@ package com.google.appinventor.client.editor.youngandroid; ...@@ -8,6 +8,7 @@ package com.google.appinventor.client.editor.youngandroid;
import com.google.gwt.event.dom.client.LoadEvent; import com.google.gwt.event.dom.client.LoadEvent;
import com.google.gwt.event.dom.client.LoadHandler; import com.google.gwt.event.dom.client.LoadHandler;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Button; import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.ClickListener; import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.DialogBox; import com.google.gwt.user.client.ui.DialogBox;
...@@ -74,9 +75,27 @@ public class TutorialPanel extends Frame { ...@@ -74,9 +75,27 @@ public class TutorialPanel extends Frame {
ok.setStyleName("DialogBox-button"); ok.setStyleName("DialogBox-button");
// Adds Image // Adds Image
Image image = new Image(img); final Image image = new Image(img);
image.addLoadHandler(new LoadHandler() { image.addLoadHandler(new LoadHandler() {
public void onLoad(LoadEvent evt) { public void onLoad(LoadEvent evt) {
final int imageWidth = image.getWidth();
final int imageHeight = image.getHeight();
final int windowWidth = (int) ((float) Window.getClientWidth() * 0.8);
final int windowHeight = (int) ((float) Window.getClientHeight() * 0.9);
int effectiveWidth = imageWidth;
int effectiveHeight = imageHeight;
if (imageWidth > windowWidth) {
effectiveWidth = windowWidth;
effectiveHeight = (int)(imageHeight * ((float)effectiveWidth / imageWidth));
}
if (effectiveHeight > windowHeight) {
effectiveHeight = windowHeight;
effectiveWidth = (int)(imageWidth * ((float)effectiveHeight / imageHeight));
}
image.setPixelSize(effectiveWidth, effectiveHeight);
dialogBox.center(); dialogBox.center();
} }
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment