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();
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() {
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;
}
});
}
+ 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];
}
}