skin: make a dual mode progressbar 60/10860/1
authorGiWoong Kim <giwoong.kim@samsung.com>
Mon, 14 Oct 2013 10:19:24 +0000 (19:19 +0900)
committerGiWoong Kim <giwoong.kim@samsung.com>
Mon, 14 Oct 2013 10:20:37 +0000 (19:20 +0900)
Change-Id: I835d9038c7b4d5f4895e624214491a17e706b48f
Signed-off-by: GiWoong Kim <giwoong.kim@samsung.com>
tizen/src/hw/maru_virtio_esm.c
tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java
tizen/src/skin/client/src/org/tizen/emulator/skin/comm/sock/SocketCommunicator.java
tizen/src/skin/client/src/org/tizen/emulator/skin/custom/CustomProgressBar.java
tizen/src/skin/client/src/org/tizen/emulator/skin/layout/GeneralPurposeSkinComposer.java
tizen/src/skin/client/src/org/tizen/emulator/skin/layout/ProfileSpecificSkinComposer.java
tizen/src/skin/maruskin_server.c
tizen/src/skin/maruskin_server.h

index 863b818bce3a3bfe85d842fc72dbf1a37a755f86..1f54d7eb2a15cb7c7460d2d988424b9e406fa56e 100644 (file)
@@ -68,8 +68,8 @@ static void virtio_esm_handle(VirtIODevice *vdev, VirtQueue *vq)
         else {
             progress.percentage = *((uint16_t*)elem.out_sg[0].iov_base);
             INFO("boot up progress is [%u] percent done.\n", progress.percentage);
-            // notify to skin
-            notify_booting_progress(progress.percentage);
+            /* notify to skin */
+            //notify_booting_progress(0, progress.percentage);
         }
     }
 
index 458b01d46bd96b94728040aca0b54c0550d9bcfa..a5f4ca523cd03ccb7932972ec07d8d3047bc521a 100755 (executable)
@@ -1185,19 +1185,12 @@ public class EmulatorSkin {
                /* abstract */
        }
 
-       public void updateProgressBar(final int progress) {
+       public void updateProgressBar(final int idxLayer, final int progress) {
                getShell().getDisplay().asyncExec(new Runnable() {
                        @Override
                        public void run() {
                                if (bootingProgress != null) {
-                                       bootingProgress.setSelection(progress);
-
-                                       if (progress == 100 | progress == 0) {
-                                               /* this means progressbar will be disposed */
-                                               if (bootingProgress != null) {
-                                                       bootingProgress = null;
-                                               }
-                                       }
+                                       bootingProgress.setSelection(idxLayer, progress);
                                }
                        }
                });
index ddb86ac47097278e96037291d7b2f317e3fb3604..8d806d0de73d220f27dd52cf231d93dab83619cf 100755 (executable)
@@ -334,17 +334,20 @@ public class SocketCommunicator implements ICommunicator {
 
                                        byte[] receivedData = getReceivedData(progressDataTransfer);
                                        if (null != receivedData) {
-                                               String strValue = new String(receivedData, 0, length - 1);
+                                               String strLayer = new String(receivedData, 0, 1);
+                                               String strValue = new String(receivedData, 1, length - 2);
 
+                                               int layer = 0;
                                                int value = 0;
                                                try {
+                                                       layer = Integer.parseInt(strLayer);
                                                        value = Integer.parseInt(strValue);
                                                } catch (NumberFormatException e) {
                                                        e.printStackTrace();
                                                }
 
                                                /* draw progress bar */
-                                               skin.updateProgressBar(value);
+                                               skin.updateProgressBar(layer, value);
                                        }
 
                                        break;
index c3b79ffbfb039e1430fe9d73f4e17c0f84eb0bbd..ab53bf509f25e434c7fef5a439d78af21e19f08c 100644 (file)
@@ -39,27 +39,42 @@ import org.eclipse.swt.graphics.RGB;
 import org.eclipse.swt.graphics.Rectangle;
 import org.eclipse.swt.widgets.Canvas;
 import org.eclipse.swt.widgets.Composite;
+import org.tizen.emulator.skin.EmulatorSkin;
 import org.tizen.emulator.skin.log.SkinLogger;
 
 public class CustomProgressBar extends Canvas {
-       public static final RGB PROGRESS_COLOR = new RGB(0, 173, 239);
+       public static final RGB PROGRESS_COLOR_0 = new RGB(0, 174, 239);
+       public static final RGB PROGRESS_COLOR_1 = new RGB(179, 246, 0);
 
        private Logger logger =
                        SkinLogger.getSkinLogger(CustomProgressBar.class).getLogger();
 
+       private EmulatorSkin skin;
        private Composite parent;
-       private int selection;
-       private Color colorProgress;
+       private boolean isDual;
+       private int[] selection;
+       private Color[] colorProgress;
 
        /**
         *  Constructor
         */
-       public CustomProgressBar(final Composite parent, int style) {
-               super(parent, style);
-
-               this.parent = parent;
-               this.selection = 0;
-               this.colorProgress = new Color(parent.getDisplay(), PROGRESS_COLOR);
+       public CustomProgressBar(EmulatorSkin skin, int style, boolean isDual) {
+               super(skin.getShell(), style);
+
+               this.skin = skin;
+               this.parent = skin.getShell();
+               this.isDual = isDual;
+               this.selection = new int[2];
+               this.selection[0] = this.selection[1] = 0;
+
+               this.colorProgress = new Color[2];
+               this.colorProgress[0] = new Color(parent.getDisplay(), PROGRESS_COLOR_0);
+               if (isDual == true) {
+                       logger.info("dual progress bar is created");
+                       this.colorProgress[1] = new Color(parent.getDisplay(), PROGRESS_COLOR_1);
+               } else {
+                       logger.info("single progress bar is created");
+               }
 
                addProgressBarListener();
 
@@ -76,13 +91,24 @@ public class CustomProgressBar extends Canvas {
                addPaintListener(new PaintListener() {
                        @Override
                        public void paintControl(PaintEvent e) {
-                               e.gc.setBackground(colorProgress);
+                               if (isDual == true) {
+                                       /* draw layer1 */
+                                       e.gc.setBackground(colorProgress[1]);
+                                       Rectangle bounds = getBounds();
+                                       int width = (bounds.width * selection[1]) / 100;
+                                       e.gc.fillRectangle(0, 0,
+                                                       Math.min(bounds.width, width), bounds.height);
+                               }
 
+                               /* draw layer0 */
+                               e.gc.setBackground(colorProgress[0]);
                                Rectangle bounds = getBounds();
-                               int width = (bounds.width * selection) / 100; 
-                               e.gc.fillRectangle(0, 0, width, bounds.height);
+                               int width = (bounds.width * selection[0]) / 100;
+                               e.gc.fillRectangle(0, 0,
+                                               Math.min(bounds.width, width), bounds.height);
 
-                               if (selection == -1) {
+                               if (selection[0] == 101 &&
+                                               (isDual == false || selection[1] == 101)) {
                                        logger.info("progress : complete!");
 
                                        parent.getDisplay().asyncExec(new Runnable() {
@@ -100,12 +126,17 @@ public class CustomProgressBar extends Canvas {
                        public void widgetDisposed(DisposeEvent e) {
                                logger.info("progress bar is disposed");
 
-                               colorProgress.dispose();
+                               colorProgress[0].dispose();
+                               if (isDual == true) {
+                                       colorProgress[1].dispose();
+                               }
+
+                               skin.bootingProgress = null;
                        }
                });
        }
 
-       public void setSelection(int value) {
+       public void setSelection(int idxLayer, int value) {
                if (isDisposed() == true) {
                        return;
                }
@@ -119,28 +150,35 @@ public class CustomProgressBar extends Canvas {
                        });
                }
 
+               if (idxLayer < 0 || isDual == false) {
+                       idxLayer = 0;
+               } else if (idxLayer > 1) {
+                       idxLayer = 1;
+               }
+
                if (value < 0) {
                        value = 0;
                } else if (value > 100) {
                        value = 100;
                }
 
-               selection = value;
-               logger.info("progress : " + selection);
+               selection[idxLayer] = value;
+               logger.info("layer" + idxLayer + " progress : " + selection[idxLayer]);
 
+               final int index = idxLayer;
                parent.getDisplay().asyncExec(new Runnable() {
                        @Override
                        public void run() {
                                redraw();
 
-                               if (selection == 100) {
-                                       selection = -1;
+                               if (selection[index] == 100) {
+                                       selection[index] = 101;
                                }
                        }
                });
        }
 
-       public int getSelection() {
-               return selection;
+       public int getSelection(int idxLayer) {
+               return selection[idxLayer];
        }
 }
index 5f37efdae66cb5cdb903f1634016bdda1839d239..819b3d84405e35af9dfdbdd05f3d871f1598caf8 100644 (file)
@@ -191,7 +191,7 @@ public class GeneralPurposeSkinComposer implements ISkinComposer {
                skin.pairTag.setVisible(false);
 
                /* create a progress bar for booting status */
-               skin.bootingProgress = new CustomProgressBar(shell, SWT.NONE);
+               skin.bootingProgress = new CustomProgressBar(skin, SWT.NONE, true);
                skin.bootingProgress.setBackground(backgroundColor);
 
                arrangeSkin(scale, rotationId);
index 94f1025fe4681e672420aeb1aec050a1f8dd5a42..379e379a52d6a4c37df3c879a5b7a941c9268c57 100644 (file)
@@ -146,7 +146,7 @@ public class ProfileSpecificSkinComposer implements ISkinComposer {
                }
 
                /* create a progress bar for booting status */
-               skin.bootingProgress = new CustomProgressBar(shell, SWT.NONE);
+               skin.bootingProgress = new CustomProgressBar(skin, SWT.NONE, true);
                skin.bootingProgress.setBackground(
                                new Color(shell.getDisplay(), new RGB(38, 38, 38)));
 
index dabad9a257c122b2ba87399b45fec91ef70e2e0d..d2723810ba3a5243ba9ec705f22cec7fe26ac263 100644 (file)
@@ -386,16 +386,16 @@ void notify_ramdump_completed(void)
     }
 }
 
-void notify_booting_progress(int progress_value)
+void notify_booting_progress(unsigned int layer, int progress_value)
 {
-#define PROGRESS_DATA_LENGTH 4
+#define PROGRESS_DATA_LENGTH 5
     char progress_data[PROGRESS_DATA_LENGTH] = { 0, };
 
     TRACE("notify_booting_progress\n");
 
     snprintf(progress_data,
-        PROGRESS_DATA_LENGTH, "%03d", progress_value);
-    TRACE("booting...%s\%\n", progress_data);
+        PROGRESS_DATA_LENGTH, "%d%03d", layer % 10, progress_value);
+    INFO("booting...%s\%\n", progress_data);
 
     if (client_sock) {
         if (0 > send_skin_data(client_sock,
index 76e3d60c6047a37d50501ea3ef66004aaadecc5c..c1cea1149de373f57afaac7478aad10fc5072683 100644 (file)
@@ -41,7 +41,7 @@ void notify_sensor_daemon_start(void);
 void notify_sdb_daemon_start(void);
 void notify_ecs_server_start(void);
 void notify_ramdump_completed(void);
-void notify_booting_progress(int progress_value);
+void notify_booting_progress(unsigned int layer, int progress_value);
 void notify_brightness(bool on);
 
 int is_ready_skin_server(void);