From: GiWoong Kim Date: Mon, 14 Oct 2013 10:19:24 +0000 (+0900) Subject: skin: make a dual mode progressbar X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.1~693^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d2935ce2cf71ea2d53474df7537f36ad951eb115;p=sdk%2Femulator%2Fqemu.git skin: make a dual mode progressbar Change-Id: I835d9038c7b4d5f4895e624214491a17e706b48f Signed-off-by: GiWoong Kim --- diff --git a/tizen/src/hw/maru_virtio_esm.c b/tizen/src/hw/maru_virtio_esm.c index 863b818bce..1f54d7eb2a 100644 --- a/tizen/src/hw/maru_virtio_esm.c +++ b/tizen/src/hw/maru_virtio_esm.c @@ -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); } } 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 458b01d46b..a5f4ca523c 100755 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java @@ -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); } } }); diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/comm/sock/SocketCommunicator.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/comm/sock/SocketCommunicator.java index ddb86ac470..8d806d0de7 100755 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/comm/sock/SocketCommunicator.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/comm/sock/SocketCommunicator.java @@ -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; diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/custom/CustomProgressBar.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/custom/CustomProgressBar.java index c3b79ffbfb..ab53bf509f 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/custom/CustomProgressBar.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/custom/CustomProgressBar.java @@ -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]; } } 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 5f37efdae6..819b3d8440 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 @@ -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); diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/ProfileSpecificSkinComposer.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/ProfileSpecificSkinComposer.java index 94f1025fe4..379e379a52 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/ProfileSpecificSkinComposer.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/ProfileSpecificSkinComposer.java @@ -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))); diff --git a/tizen/src/skin/maruskin_server.c b/tizen/src/skin/maruskin_server.c index dabad9a257..d2723810ba 100644 --- a/tizen/src/skin/maruskin_server.c +++ b/tizen/src/skin/maruskin_server.c @@ -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, diff --git a/tizen/src/skin/maruskin_server.h b/tizen/src/skin/maruskin_server.h index 76e3d60c60..c1cea1149d 100644 --- a/tizen/src/skin/maruskin_server.h +++ b/tizen/src/skin/maruskin_server.h @@ -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);