skin: added CustomProgressbar file
authorgiwoong.kim <giwoong.kim@samsung.com>
Tue, 11 Dec 2012 07:55:51 +0000 (16:55 +0900)
committergiwoong.kim <giwoong.kim@samsung.com>
Tue, 11 Dec 2012 07:55:51 +0000 (16:55 +0900)
Add CustomProgressBar for booting status.

Signed-off-by: GiWoong Kim <giwoong.kim@samsung.com>
tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java
tizen/src/skin/client/src/org/tizen/emulator/skin/layout/GeneralPurposeSkinComposer.java
tizen/src/skin/client/src/org/tizen/emulator/skin/layout/PhoneShapeSkinComposer.java
tizen/src/skin/client/src/org/tizen/emulator/skin/window/CustomProgressBar.java [new file with mode: 0644]

index 1fa28a5..4e3586d 100644 (file)
@@ -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 */
index 2e09e7d..48280b8 100644 (file)
@@ -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());
 
index 948e92b..3f7b708 100644 (file)
@@ -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 (file)
index 0000000..abc523b
--- /dev/null
@@ -0,0 +1,72 @@
+/**
+ *
+ *
+ * Copyright ( C ) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * GiWoong Kim <giwoong.kim@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ *
+ * 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;
+       }
+}