--- /dev/null
+/**
+ * Display
+ *
+ * Copyright (C) 2011 - 2014 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * GiWoong Kim <giwoong.kim@samsung.com>
+ * SangHo Park <sangho1206.park@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;
+
+import java.util.logging.Logger;
+
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Canvas;
+import org.eclipse.swt.widgets.Shell;
+import org.tizen.emulator.skin.log.SkinLogger;
+
+public class DisplayCanvas extends Canvas {
+ private Image maskImage;
+
+ private static Logger logger = SkinLogger.getSkinLogger(
+ DisplayCanvas.class).getLogger();
+
+ /**
+ * Constructor
+ */
+ public DisplayCanvas(Shell parent, int style) {
+ super(parent, style);
+ }
+
+ public Image getMaskImage() {
+ return maskImage;
+ }
+
+ public void setMaskImage(Image image) {
+ logger.info("set mask image : " +
+ image.getImageData().width + "x" + image.getImageData().height);
+
+ maskImage = image;
+ }
+}
\ No newline at end of file
/* org.eclipse.swt.widgets.Widget */
if (SwtUtil.isLinuxPlatform()) {
try {
- Field field = lcdCanvas.getClass().getField("embeddedHandle");
- windowHandleId = field.getLong(lcdCanvas);
- logger.info("lcdCanvas.embeddedHandle:" + windowHandleId);
+ Field field = displayCanvas.getClass().getField("embeddedHandle");
+ windowHandleId = field.getLong(displayCanvas);
+ logger.info("displayCanvas.embeddedHandle:" + windowHandleId);
} catch (IllegalArgumentException e) {
logger.log(Level.SEVERE, e.getMessage(), e);
shutdown();
}
} else if (SwtUtil.isWindowsPlatform()) {
try {
- Field field = lcdCanvas.getClass().getField("handle");
- windowHandleId = field.getLong(lcdCanvas);
- logger.info("lcdCanvas.handle:" + windowHandleId);
+ Field field = displayCanvas.getClass().getField("handle");
+ windowHandleId = field.getLong(displayCanvas);
+ logger.info("displayCanvas.handle:" + windowHandleId);
} catch (IllegalArgumentException e) {
logger.log(Level.SEVERE, e.getMessage(), e);
shutdown();
this.runnable = new Runnable() {
@Override
public void run() {
- if (lcdCanvas.isDisposed() == false) {
- lcdCanvas.redraw();
+ if (displayCanvas.isDisposed() == false) {
+ displayCanvas.redraw();
}
}
};
currentState.getCurrentResolutionWidth(),
currentState.getCurrentResolutionHeight());
- lcdCanvas.addPaintListener(new PaintListener() {
+ displayCanvas.addPaintListener(new PaintListener() {
public void paintControl(PaintEvent e) {
/* e.gc.setAdvanced(true);
if (!e.gc.getAdvanced()) {
logger.info("Advanced graphics not supported");
} */
- final int screen_width = lcdCanvas.getSize().x;
- final int screen_height = lcdCanvas.getSize().y;
+ final int screen_width = displayCanvas.getSize().x;
+ final int screen_height = displayCanvas.getSize().y;
/* blank guide */
if (imageCover != null) {
public void run() {
imageCover = image;
- lcdCanvas.redraw();
+ displayCanvas.redraw();
}
});
}
finger.maruFingerProcessing1(eventType,
e.x, e.y, geometry[0], geometry[1]);
- lcdCanvas.redraw();
+ displayCanvas.redraw();
return;
} else if (finger.getMultiTouchEnable() == 2) {
finger.maruFingerProcessing2(eventType,
e.x, e.y, geometry[0], geometry[1]);
- lcdCanvas.redraw();
+ displayCanvas.redraw();
return;
}
finger.maruFingerProcessing1(MouseEventType.RELEASE.value(),
e.x, e.y, geometry[0], geometry[1]);
- lcdCanvas.redraw();
+ displayCanvas.redraw();
return;
} else if (finger.getMultiTouchEnable() == 2) {
logger.info("maruFingerProcessing 2");
finger.maruFingerProcessing2(MouseEventType.RELEASE.value(),
e.x, e.y, geometry[0], geometry[1]);
- lcdCanvas.redraw();
+ displayCanvas.redraw();
return;
}
finger.maruFingerProcessing1(MouseEventType.PRESS.value(),
e.x, e.y, geometry[0], geometry[1]);
- lcdCanvas.redraw();
+ displayCanvas.redraw();
return;
} else if (finger.getMultiTouchEnable() == 2) {
logger.info("maruFingerProcessing 2");
finger.maruFingerProcessing2(MouseEventType.PRESS.value(),
e.x, e.y, geometry[0], geometry[1]);
- lcdCanvas.redraw();
+ displayCanvas.redraw();
return;
}
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.graphics.Region;
import org.eclipse.swt.graphics.Transform;
-import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
public EmulatorConfig config;
protected Shell shell;
protected ImageRegistry imageRegistry;
- protected Canvas lcdCanvas;
+ protected DisplayCanvas displayCanvas;
private int displayCanvasStyle;
public Transform displayTransform;
public SkinInformation skinInfo;
skinComposer = new GeneralPurposeSkinComposer(config, this);
}
- lcdCanvas = skinComposer.compose(displayCanvasStyle);
+ displayCanvas = skinComposer.compose(displayCanvasStyle);
/* */
//TODO: move
if (config.getArgBoolean(ArgsConstants.INPUT_MOUSE, false) == true) {
- prev_x = lcdCanvas.getSize().x / 2;
- prev_y = lcdCanvas.getSize().y / 2;
+ prev_x = displayCanvas.getSize().x / 2;
+ prev_y = displayCanvas.getSize().y / 2;
logger.info("prev_x : " + prev_x + " prev_y : " + prev_y);
isDisplayOn = false;
}
addMainWindowListeners();
addCanvasListeners();
- lcdCanvas.setFocus();
+ displayCanvas.setFocus();
return 0;
}
return shell;
}
+ public DisplayCanvas getDisplayCanvas() {
+ return displayCanvas;
+ }
+
public EmulatorSkinState getEmulatorSkinState() {
return currentState;
}
public void mouseMove(MouseEvent e) {
if (true == isDisplayDragging) {
int eventType = MouseEventType.DRAG.value();
- Point canvasSize = lcdCanvas.getSize();
+ Point canvasSize = displayCanvas.getSize();
if (e.x < 0) {
e.x = 0;
}
/* filtering for display mask */
- Region displayRegion = lcdCanvas.getRegion();
+ Region displayRegion = displayCanvas.getRegion();
if (displayRegion != null &&
displayRegion.contains(e.x, e.y) == false) {
logger.info("out of range touch event : " + e.x + ", " + e.y);
- int angle = SkinUtil.getAngleFromVector(lcdCanvas, e.x, e.y);
+ int angle = SkinUtil.getAngleFromVector(displayCanvas, e.x, e.y);
if (angle < 0) {
angle += 360;
}
- final int displayCenterX = lcdCanvas.getSize().x / 2;
- final int displayCenterY = lcdCanvas.getSize().y / 2;
+ final int displayCenterX = displayCanvas.getSize().x / 2;
+ final int displayCenterY = displayCanvas.getSize().y / 2;
if (angle >= 45 && angle < 135) { /* down side */
do {
int diff_y = e.y - prev_y;
int final_x = e.x;
int final_y = e.y;
- Point canvasSize = lcdCanvas.getSize();
+ Point canvasSize = displayCanvas.getSize();
/* caculate maximum relative point */
if (final_x >= canvasSize.x) {
int eventType = MouseEventType.MOVE.value();
if (true == isDisplayDragging) {
- Point canvasSize = lcdCanvas.getSize();
+ Point canvasSize = displayCanvas.getSize();
eventType = MouseEventType.DRAG.value();
if (e.x < 0) {
e.x = 0;
if (menu != null) {
keyForceRelease(false);
- lcdCanvas.setMenu(menu);
+ displayCanvas.setMenu(menu);
menu.setVisible(true);
e.doit = false;
} else {
- lcdCanvas.setMenu(null);
+ displayCanvas.setMenu(null);
}
}
};
/* remove 'input method' menu item (avoid bug) */
- lcdCanvas.addMenuDetectListener(canvasMenuDetectListener);
+ displayCanvas.addMenuDetectListener(canvasMenuDetectListener);
/* focus */
canvasFocusListener = new FocusListener() {
}
};
- lcdCanvas.addFocusListener(canvasFocusListener);
+ displayCanvas.addFocusListener(canvasFocusListener);
/* host mouse event */
if (config.getArgBoolean(ArgsConstants.INPUT_MOUSE, false) == true) {
canvasMouseListener = makeDisplayMouseClickListener();
canvasMouseWheelListener = makeDisplayMouseWheelListener();
- lcdCanvas.addMouseWheelListener(canvasMouseWheelListener);
+ displayCanvas.addMouseWheelListener(canvasMouseWheelListener);
} else {
/* mapping to virtual touch screen */
canvasMouseMoveListener = makeDisplayTouchMoveListener();
canvasMouseListener = makeDisplayTouchClickListener();
}
- lcdCanvas.addMouseMoveListener(canvasMouseMoveListener);
- lcdCanvas.addMouseListener(canvasMouseListener);
+ displayCanvas.addMouseMoveListener(canvasMouseMoveListener);
+ displayCanvas.addMouseListener(canvasMouseListener);
/* host keyboard event */
canvasKeyListener = new KeyListener() {
}
};
- lcdCanvas.addKeyListener(canvasKeyListener);
+ displayCanvas.addKeyListener(canvasKeyListener);
}
/* for display */
private void removeCanvasListeners() {
if (null != canvasMouseMoveListener) {
- lcdCanvas.removeMouseMoveListener(canvasMouseMoveListener);
+ displayCanvas.removeMouseMoveListener(canvasMouseMoveListener);
}
if (null != canvasMouseListener) {
- lcdCanvas.removeMouseListener(canvasMouseListener);
+ displayCanvas.removeMouseListener(canvasMouseListener);
}
if (null != canvasKeyListener) {
- lcdCanvas.removeKeyListener(canvasKeyListener);
+ displayCanvas.removeKeyListener(canvasKeyListener);
}
if (null != canvasMenuDetectListener) {
- lcdCanvas.removeMenuDetectListener(canvasMenuDetectListener);
+ displayCanvas.removeMenuDetectListener(canvasMenuDetectListener);
}
if (null != canvasFocusListener) {
- lcdCanvas.removeFocusListener(canvasFocusListener);
+ displayCanvas.removeFocusListener(canvasFocusListener);
}
if (null != canvasMouseWheelListener) {
- lcdCanvas.removeMouseWheelListener(canvasMouseWheelListener);
+ displayCanvas.removeMouseWheelListener(canvasMouseWheelListener);
}
}
displayTransform.dispose();
}
- displayTransform = new Transform(lcdCanvas.getDisplay());
+ displayTransform = new Transform(displayCanvas.getDisplay());
short rotationId = currentState.getCurrentRotationId();
displayTransform.rotate(SkinRotations.getAngle(rotationId));
if (rotationId == SkinRotations.LANDSCAPE_ID) {
/* landscape */
- displayTransform.translate(
- lcdCanvas.getSize().y * -1, 0);
+ displayTransform.translate(displayCanvas.getSize().y * -1, 0);
} else if (rotationId == SkinRotations.REVERSE_PORTRAIT_ID) {
/* reverse-portrait */
displayTransform.translate(
- lcdCanvas.getSize().x * -1,
- lcdCanvas.getSize().y * -1);
+ displayCanvas.getSize().x * -1,
+ displayCanvas.getSize().y * -1);
} else if (rotationId == SkinRotations.REVERSE_LANDSCAPE_ID) {
/* reverse-landscape */
- displayTransform.translate(
- 0, lcdCanvas.getSize().x * -1);
+ displayTransform.translate(0, displayCanvas.getSize().x * -1);
}
}
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
+import org.tizen.emulator.skin.DisplayCanvas;
import org.tizen.emulator.skin.EmulatorSkin;
import org.tizen.emulator.skin.EmulatorSkinMain;
import org.tizen.emulator.skin.config.EmulatorConfig;
private EmulatorConfig config;
private EmulatorSkin skin;
private Shell shell;
- private Canvas displayCanvas;
+ private DisplayCanvas displayCanvas;
private Color backgroundColor;
private CustomButton toggleButton;
private ColorTag pairTag;
}
@Override
- public Canvas compose(int style) {
+ public DisplayCanvas compose(int style) {
shell.setBackground(backgroundColor);
- displayCanvas = new Canvas(shell, style);
+ displayCanvas = new DisplayCanvas(shell, style);
int x = config.getValidWindowX();
int y = config.getValidWindowY();
}
@Override
- public void composeInternal(Canvas displayCanvas,
+ public void composeInternal(DisplayCanvas displayCanvas,
final int x, final int y, int scale, short rotationId) {
shell.setLocation(x, y);
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Canvas;
+import org.tizen.emulator.skin.DisplayCanvas;
public interface ISkinComposer {
- public abstract Canvas compose(int style);
+ public abstract DisplayCanvas compose(int style);
- public abstract void composeInternal(Canvas lcdCanvas,
+ public abstract void composeInternal(DisplayCanvas DisplayCanvas,
int x, int y, int scale, short rotationId);
public abstract void arrangeSkin(int scale, short rotationId);
import org.eclipse.swt.graphics.Region;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Shell;
+import org.tizen.emulator.skin.DisplayCanvas;
import org.tizen.emulator.skin.EmulatorSkin;
import org.tizen.emulator.skin.EmulatorSkinMain;
import org.tizen.emulator.skin.comm.ICommunicator.KeyEventType;
private Logger logger = SkinLogger.getSkinLogger(
ProfileSpecificSkinComposer.class).getLogger();
- private EmulatorConfig config;
- private EmulatorSkin skin;
- private Shell shell;
- private Canvas lcdCanvas;
- private EmulatorSkinState currentState;
- private SocketCommunicator communicator;
+ protected EmulatorConfig config;
+ protected EmulatorSkin skin;
+ protected Shell shell;
+ protected DisplayCanvas displayCanvas;
+ protected EmulatorSkinState currentState;
+ protected SocketCommunicator communicator;
private PaintListener shellPaintListener;
private MouseTrackListener shellMouseTrackListener;
}
@Override
- public Canvas compose(int style) {
- lcdCanvas = new Canvas(shell, style);
+ public DisplayCanvas compose(int style) {
+ displayCanvas = new DisplayCanvas(shell, style);
+ displayCanvas.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
int x = config.getValidWindowX();
int y = config.getValidWindowY();
int scale = currentState.getCurrentScale();
short rotationId = currentState.getCurrentRotationId();
- composeInternal(lcdCanvas, x, y, scale, rotationId);
+ composeInternal(displayCanvas, x, y, scale, rotationId);
logger.info("resolution : " + currentState.getCurrentResolution() +
", scale : " + scale);
- return lcdCanvas;
+ return displayCanvas;
}
@Override
- public void composeInternal(Canvas lcdCanvas,
+ public void composeInternal(DisplayCanvas displayCanvas,
int x, int y, int scale, short rotationId) {
shell.setLocation(x, y);
String emulatorName = SkinUtil.makeEmulatorName(config);
shell.setText(SkinUtil.EMULATOR_PREFIX + " - " + emulatorName);
- lcdCanvas.setBackground(
+ displayCanvas.setBackground(
shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
shell.setImage(skin.getImageRegistry().getIcon(
//TODO: eject the calculation from UI thread
/* calculate display bounds */
- Rectangle displayBounds = adjustDisplayGeometry(lcdCanvas,
+ Rectangle displayBounds = adjustDisplayGeometry(displayCanvas,
currentState.getCurrentResolutionWidth(),
currentState.getCurrentResolutionHeight(), scale, rotationId);
Image mask = imageRegistry.getSkinImage(rotationId, SkinImageType.DISPLAY_MASK_IMAGE);
if (mask != null) {
+ displayCanvas.setMaskImage(mask);
+
logger.info("display masking");
mask = SkinUtil.createScaledImage(
shell.getDisplay(), mask, rotationId, scale);
- lcdCanvas.setRegion(SkinUtil.getTrimmedRegion(mask));
+ displayCanvas.setRegion(SkinUtil.getTrimmedRegion(mask));
mask.dispose();
} else {
- lcdCanvas.setRegion(null);
+ displayCanvas.setRegion(null);
}
/* make profile skin */
/* arrange the display */
if (SwtUtil.isMacPlatform() == true) {
- lcdCanvas.setBounds(currentState.getDisplayBounds());
+ displayCanvas.setBounds(currentState.getDisplayBounds());
}
/* arrange the progress bar */
logger.info("shell transform was changed");
if (SwtUtil.isMacPlatform() == false) {
- lcdCanvas.setBounds(currentState.getDisplayBounds());
+ displayCanvas.setBounds(currentState.getDisplayBounds());
}
skin.setSuitableTransform();