new MenuItem(menu, SWT.SEPARATOR);
- /* HW Key Window menu */
+ /* Key Window menu */
final MenuItem panelItem = new MenuItem(menu, SWT.CHECK);
- panelItem.setText("&HW Key Window");
+ panelItem.setText("&Key Window");
panelItem.setSelection(isControlPanel);
panelItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
final boolean isControlPanel = panelItem.getSelection();
- logger.info("Select HW Key Window : " + isControlPanel);
+ logger.info("Select Key Window : " + isControlPanel);
if (isControlPanel == true) {
if (controlPanel != null) {
return;
}
- /* create a HW key window */
+ /* create a key window */
List<KeyMapType> keyMapList =
SkinUtil.getHWKeyMapList(currentState.getCurrentRotationId());
import org.tizen.emulator.skin.util.SwtUtil;
public class GeneralPurposeSkinComposer implements ISkinComposer {
+ private static final String PATCH_IMAGES_PATH = "images/emul-window/";
+
private Logger logger = SkinLogger.getSkinLogger(
GeneralPurposeSkinComposer.class).getLogger();
private EmulatorSkinState currentState;
private ImageRegistry imageRegistry;
- private SkinPatches frame;
+ private SkinPatches frameMaker;
private SocketCommunicator communicator;
private PaintListener shellPaintListener;
this.isGrabbedShell= false;
this.grabPosition = new Point(0, 0);
- this.frame = new SkinPatches("images/emul-window/");
+ this.frameMaker = new SkinPatches(PATCH_IMAGES_PATH);
}
@Override
}
currentState.setCurrentImage(
- frame.getPatchedImage(lcdBounds.width, lcdBounds.height));
+ frameMaker.getPatchedImage(lcdBounds.width, lcdBounds.height));
if (tempImage != null) {
tempImage.dispose();
int scale, short rotationId) {
Rectangle lcdBounds = new Rectangle(
- frame.getPatchWidth(), frame.getPatchHeight(), 0, 0);
+ frameMaker.getPatchWidth(), frameMaker.getPatchHeight(), 0, 0);
float convertedScale = SkinUtil.convertScale(scale);
RotationInfo rotation = RotationInfo.getValue(rotationId);
shellMouseMoveListener = new MouseMoveListener() {
@Override
public void mouseMove(MouseEvent e) {
- if (isGrabbedShell == true && e.button == 0/* left button */ &&
- currentState.getCurrentPressedHWKey() == null) {
+ if (isGrabbedShell == true && e.button == 0/* left button */) {
/* move a window */
Point previousLocation = shell.getLocation();
int x = previousLocation.x + (e.x - grabPosition.x);
shell.removeMouseListener(shellMouseListener);
}
- frame.freePatches();
+ frameMaker.freePatches();
}
}
private Logger logger =
SkinLogger.getSkinLogger(SkinPatches.class).getLogger();
+ private Display display;
private String pathImage;
private int patchWidth;
private int patchHeight;
private static final String filenameRB = "RB.png";
public SkinPatches(String path) {
+ this.display = Display.getCurrent();
this.pathImage = path;
loadPatches(pathImage);
}
public Image getPatchedImage(int centerPatchWidth, int centerPatchHeight) {
- Image patchedImage = new Image(Display.getCurrent(),
+ Image patchedImage = new Image(display,
(patchWidth * 2) + centerPatchWidth,
(patchHeight * 2) + centerPatchHeight);
private void loadPatches(String path) {
ClassLoader loader = this.getClass().getClassLoader();
- imageLT = new Image(Display.getCurrent(),
+ imageLT = new Image(display,
loader.getResourceAsStream(path + filenameLT));
logger.info("left-top image is loaded from " + path + filenameLT);
- imageT = new Image(Display.getCurrent(),
+ imageT = new Image(display,
loader.getResourceAsStream(path + filenameT));
- imageRT = new Image(Display.getCurrent(),
+ imageRT = new Image(display,
loader.getResourceAsStream(path + filenameRT));
- imageL = new Image(Display.getCurrent(),
+ imageL = new Image(display,
loader.getResourceAsStream(path + filenameL));
- imageR = new Image(Display.getCurrent(),
+ imageR = new Image(display,
loader.getResourceAsStream(path + filenameR));
- imageLB = new Image(Display.getCurrent(),
+ imageLB = new Image(display,
loader.getResourceAsStream(path + filenameLB));
- imageB = new Image(Display.getCurrent(),
+ imageB = new Image(display,
loader.getResourceAsStream(path + filenameB));
- imageRB = new Image(Display.getCurrent(),
+ imageRB = new Image(display,
loader.getResourceAsStream(path + filenameRB));
}
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseListener;
import org.eclipse.swt.events.MouseMoveListener;
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.tizen.emulator.skin.comm.sock.SocketCommunicator;
import org.tizen.emulator.skin.comm.sock.data.KeyEventData;
import org.tizen.emulator.skin.dbi.KeyMapType;
+import org.tizen.emulator.skin.layout.SkinPatches;
public class ControlPanel extends SkinWindow {
+ private static final String PATCH_IMAGES_PATH = "images/key-window/";
+
+ private SkinPatches frameMaker;
+ private Image imageFrame;
private SocketCommunicator communicator;
private List<KeyMapType> keyMapList;
+
+ private PaintListener shellPaintListener;
+ private MouseMoveListener shellMouseMoveListener;
+ private MouseListener shellMouseListener;
+
private boolean isGrabbedShell;
private Point grabPosition;
super(parent);
this.shell = new Shell(Display.getDefault(), SWT.NO_TRIM);
+ this.frameMaker = new SkinPatches(PATCH_IMAGES_PATH); //TODO: freePatches
+ this.imageFrame = frameMaker.getPatchedImage(136, 140);
this.keyMapList = keyMapList;
this.communicator = communicator;
this.grabPosition = new Point(0, 0);
createContents();
- addControlPanelListener();
+ addControlPanelListener(); //TODO: remove
- shell.setSize(160, 100);
+ shell.setSize((frameMaker.getPatchWidth() * 2) + 136,
+ (frameMaker.getPatchHeight() * 2) + 140);
}
protected void createContents() {
GridLayout gridLayout = new GridLayout(1, true);
- gridLayout.marginLeft = gridLayout.marginRight = 0;
- gridLayout.marginTop = gridLayout.marginBottom = 0;
+ gridLayout.marginLeft = gridLayout.marginRight = frameMaker.getPatchWidth() + 6;
+ gridLayout.marginTop = frameMaker.getPatchHeight() + 20;
+ gridLayout.marginBottom = frameMaker.getPatchHeight() + 6;
gridLayout.marginWidth = gridLayout.marginHeight = 0;
gridLayout.horizontalSpacing = gridLayout.verticalSpacing = 0;
}
private void addControlPanelListener() {
- MouseMoveListener shellMouseMoveListener = new MouseMoveListener() {
+ shellPaintListener = new PaintListener() {
+ @Override
+ public void paintControl(final PaintEvent e) {
+ if (imageFrame != null) {
+ e.gc.drawImage(imageFrame, 0, 0);
+ }
+ }
+ };
+
+ shell.addPaintListener(shellPaintListener);
+
+ shellMouseMoveListener = new MouseMoveListener() {
@Override
public void mouseMove(MouseEvent e) {
- if (isGrabbedShell == true && e.button == 0) {
+ if (isGrabbedShell == true && e.button == 0/* left button */) {
/* move a window */
Point previousLocation = shell.getLocation();
int x = previousLocation.x + (e.x - grabPosition.x);
}
}
};
+
shell.addMouseMoveListener(shellMouseMoveListener);
- MouseListener shellMouseListener = new MouseListener() {
+ shellMouseListener = new MouseListener() {
+ @Override
+ public void mouseUp(MouseEvent e) {
+ if (e.button == 1) { /* left button */
+ isGrabbedShell = false;
+ grabPosition.x = grabPosition.y = 0;
+ }
+ }
+
@Override
public void mouseDown(MouseEvent e) {
if (1 == e.button) { /* left button */
}
}
- @Override
- public void mouseUp(MouseEvent e) {
- if (e.button == 1) { /* left button */
- isGrabbedShell = false;
- grabPosition.x = grabPosition.y = 0;
- }
- }
-
@Override
public void mouseDoubleClick(MouseEvent e) {
/* do nothing */
}
};
+
shell.addMouseListener(shellMouseListener);
}
}