From: giwoong.kim Date: Tue, 11 Dec 2012 07:55:51 +0000 (+0900) Subject: skin: added CustomProgressbar file X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.1~1299 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8f9cea1281854547b1826c089b801e83273ac427;p=sdk%2Femulator%2Fqemu.git skin: added CustomProgressbar file Add CustomProgressBar for booting status. Signed-off-by: GiWoong Kim --- diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java index 1fa28a5956..4e3586d5ca 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java @@ -94,6 +94,7 @@ import org.tizen.emulator.skin.util.SkinRotation; import org.tizen.emulator.skin.util.SkinUtil; import org.tizen.emulator.skin.util.SwtUtil; import org.tizen.emulator.skin.window.ControlPanel; +import org.tizen.emulator.skin.window.CustomProgressBar; /** * @@ -146,6 +147,7 @@ public class EmulatorSkin { public ControlPanel controlPanel; public Color colorPairTag; public Canvas pairTagCanvas; + public CustomProgressBar bootingProgress; protected ScreenShotDialog screenShotDialog; protected SocketCommunicator communicator; @@ -204,8 +206,8 @@ public class EmulatorSkin { imageRegistry = ImageRegistry.getInstance(); if (skinInfo.isPhoneShape() == true) { /* phone shape skin */ - skinComposer = new PhoneShapeSkinComposer(config, shell, - currentState, imageRegistry, communicator); + skinComposer = new PhoneShapeSkinComposer(config, this, + shell, currentState, imageRegistry, communicator); ((PhoneShapeSkinComposer) skinComposer).addPhoneShapeListener(shell); } else { /* general purpose skin */ diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/GeneralPurposeSkinComposer.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/GeneralPurposeSkinComposer.java index 2e09e7dfe3..48280b8aad 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/GeneralPurposeSkinComposer.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/GeneralPurposeSkinComposer.java @@ -57,6 +57,7 @@ import org.tizen.emulator.skin.log.SkinLogger; import org.tizen.emulator.skin.util.SkinRotation; import org.tizen.emulator.skin.util.SkinUtil; import org.tizen.emulator.skin.util.SwtUtil; +import org.tizen.emulator.skin.window.CustomProgressBar; import org.tizen.emulator.skin.window.ImageButton; public class GeneralPurposeSkinComposer implements ISkinComposer { @@ -200,6 +201,11 @@ public class GeneralPurposeSkinComposer implements ISkinComposer { }); skin.pairTagCanvas.setVisible(false); + /* create a progress bar for booting status */ + skin.bootingProgress = new CustomProgressBar(shell, SWT.NONE); + skin.bootingProgress.setBackground( + new Color(shell.getDisplay(), new RGB(38, 38, 38))); + arrangeSkin(scale, rotationId); /* open the key window */ @@ -218,7 +224,7 @@ public class GeneralPurposeSkinComposer implements ISkinComposer { currentState.setCurrentRotationId(rotationId); currentState.setCurrentAngle(SkinRotation.getAngle(rotationId)); - /* arrange the lcd */ + /* arrange the display */ Rectangle lcdBounds = adjustLcdGeometry(lcdCanvas, currentState.getCurrentResolutionWidth(), currentState.getCurrentResolutionHeight(), scale, rotationId); @@ -254,6 +260,15 @@ public class GeneralPurposeSkinComposer implements ISkinComposer { lcdBounds.y + (lcdBounds.height / 2) - (toggleButton.getImageSize().y / 2), toggleButton.getImageSize().x, toggleButton.getImageSize().y); + /* arrange the progress bar */ + if (skin.bootingProgress != null) { + skin.bootingProgress.setBounds(lcdBounds.x, + lcdBounds.y + lcdBounds.height + 1, lcdBounds.width, 2); + + skin.bootingProgress.dispose(); //TODO + skin.bootingProgress = null; + } + /* custom window shape */ trimPatchedShell(shell, currentState.getCurrentImage()); diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/PhoneShapeSkinComposer.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/PhoneShapeSkinComposer.java index 948e92bc74..3f7b708a26 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/PhoneShapeSkinComposer.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/PhoneShapeSkinComposer.java @@ -38,13 +38,16 @@ import org.eclipse.swt.events.MouseTrackAdapter; import org.eclipse.swt.events.MouseTrackListener; import org.eclipse.swt.events.PaintEvent; import org.eclipse.swt.events.PaintListener; +import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.ImageData; import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.widgets.Canvas; import org.eclipse.swt.widgets.Shell; +import org.tizen.emulator.skin.EmulatorSkin; import org.tizen.emulator.skin.EmulatorSkinState; import org.tizen.emulator.skin.comm.ICommunicator.KeyEventType; import org.tizen.emulator.skin.comm.ICommunicator.SendCommand; @@ -63,12 +66,14 @@ import org.tizen.emulator.skin.log.SkinLogger; import org.tizen.emulator.skin.util.SkinRotation; import org.tizen.emulator.skin.util.SkinUtil; import org.tizen.emulator.skin.util.SwtUtil; +import org.tizen.emulator.skin.window.CustomProgressBar; public class PhoneShapeSkinComposer implements ISkinComposer { private Logger logger = SkinLogger.getSkinLogger( PhoneShapeSkinComposer.class).getLogger(); private EmulatorConfig config; + private EmulatorSkin skin; private Shell shell; private Canvas lcdCanvas; private EmulatorSkinState currentState; @@ -83,10 +88,11 @@ public class PhoneShapeSkinComposer implements ISkinComposer { private boolean isGrabbedShell; private Point grabPosition; - public PhoneShapeSkinComposer(EmulatorConfig config, Shell shell, - EmulatorSkinState currentState, ImageRegistry imageRegistry, - SocketCommunicator communicator) { + public PhoneShapeSkinComposer(EmulatorConfig config, EmulatorSkin skin, + Shell shell, EmulatorSkinState currentState, + ImageRegistry imageRegistry, SocketCommunicator communicator) { this.config = config; + this.skin = skin; this.shell = shell; this.currentState = currentState; this.imageRegistry = imageRegistry; @@ -140,6 +146,11 @@ public class PhoneShapeSkinComposer implements ISkinComposer { shell.setImage(imageRegistry.getIcon(IconName.EMULATOR_TITLE)); } + /* create a progress bar for booting status */ + skin.bootingProgress = new CustomProgressBar(shell, SWT.NONE); + skin.bootingProgress.setBackground( + new Color(shell.getDisplay(), new RGB(38, 38, 38))); + arrangeSkin(scale, rotationId); if (currentState.getCurrentImage() == null) { @@ -156,7 +167,7 @@ public class PhoneShapeSkinComposer implements ISkinComposer { currentState.setCurrentRotationId(rotationId); currentState.setCurrentAngle(SkinRotation.getAngle(rotationId)); - /* arrange the lcd */ + /* arrange the display */ Rectangle lcdBounds = adjustLcdGeometry(lcdCanvas, currentState.getCurrentResolutionWidth(), currentState.getCurrentResolutionHeight(), scale, rotationId); @@ -196,6 +207,15 @@ public class PhoneShapeSkinComposer implements ISkinComposer { tempKeyPressedImage.dispose(); } + /* arrange the progress bar */ + if (skin.bootingProgress != null) { + skin.bootingProgress.setBounds(lcdBounds.x, + lcdBounds.y + lcdBounds.height + 1, lcdBounds.width, 2); + + skin.bootingProgress.dispose(); //TODO: + skin.bootingProgress = null; + } + /* custom window shape */ SkinUtil.trimShell(shell, currentState.getCurrentImage()); diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/window/CustomProgressBar.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/window/CustomProgressBar.java new file mode 100644 index 0000000000..abc523b8be --- /dev/null +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/window/CustomProgressBar.java @@ -0,0 +1,72 @@ +/** + * + * + * Copyright ( C ) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * GiWoong Kim + * YeongKyoon Lee + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or ( at your option ) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +package org.tizen.emulator.skin.window; + +import org.eclipse.swt.events.PaintEvent; +import org.eclipse.swt.events.PaintListener; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.RGB; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.widgets.Canvas; +import org.eclipse.swt.widgets.Composite; + +public class CustomProgressBar extends Canvas { + private int selection = 0; + + public CustomProgressBar(final Composite parent, int style) { + super(parent, style); + + this.addPaintListener(new PaintListener() { + @Override + public void paintControl(PaintEvent e) { + e.gc.setBackground( + new Color(parent.getDisplay(), new RGB(0, 173, 239))); + + Rectangle bounds = getBounds(); + int width = (bounds.width * selection) / 100; + e.gc.fillRectangle(0, 0, width, bounds.height); + } + }); + } + + public void setSelection(int value) { + if (value < 0) { + value = 0; + } else if (value > 100) { + value = 100; + } + + selection = value; + redraw(); + } + + public int getSelection() { + return selection; + } +}