From: giwoong.kim Date: Mon, 25 Feb 2013 08:34:18 +0000 (+0900) Subject: skin: added CustomScrolledComposite X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.1~1065 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7cf6dd25b27515c03bf90eb4f927123bb246c507;p=sdk%2Femulator%2Fqemu.git skin: added CustomScrolledComposite added CustomScrolledComposite for key window of general skin. Signed-off-by: GiWoong Kim --- diff --git a/tizen/src/skin/client/resource/images/key-window/scroll_back.png b/tizen/src/skin/client/resource/images/key-window/scroll_back.png new file mode 100644 index 0000000000..5f8c377805 Binary files /dev/null and b/tizen/src/skin/client/resource/images/key-window/scroll_back.png differ diff --git a/tizen/src/skin/client/resource/images/key-window/scroll_button_down_hover.png b/tizen/src/skin/client/resource/images/key-window/scroll_button_down_hover.png new file mode 100644 index 0000000000..62f58d14b5 Binary files /dev/null and b/tizen/src/skin/client/resource/images/key-window/scroll_button_down_hover.png differ diff --git a/tizen/src/skin/client/resource/images/key-window/scroll_button_down_nml.png b/tizen/src/skin/client/resource/images/key-window/scroll_button_down_nml.png new file mode 100644 index 0000000000..7ced278fc8 Binary files /dev/null and b/tizen/src/skin/client/resource/images/key-window/scroll_button_down_nml.png differ diff --git a/tizen/src/skin/client/resource/images/key-window/scroll_button_down_pushed.png b/tizen/src/skin/client/resource/images/key-window/scroll_button_down_pushed.png new file mode 100644 index 0000000000..68cc7f2afc Binary files /dev/null and b/tizen/src/skin/client/resource/images/key-window/scroll_button_down_pushed.png differ diff --git a/tizen/src/skin/client/resource/images/key-window/scroll_button_up_hover.png b/tizen/src/skin/client/resource/images/key-window/scroll_button_up_hover.png new file mode 100644 index 0000000000..a362b4e7f1 Binary files /dev/null and b/tizen/src/skin/client/resource/images/key-window/scroll_button_up_hover.png differ diff --git a/tizen/src/skin/client/resource/images/key-window/scroll_button_up_nml.png b/tizen/src/skin/client/resource/images/key-window/scroll_button_up_nml.png new file mode 100644 index 0000000000..29882e087b Binary files /dev/null and b/tizen/src/skin/client/resource/images/key-window/scroll_button_up_nml.png differ diff --git a/tizen/src/skin/client/resource/images/key-window/scroll_button_up_pushed.png b/tizen/src/skin/client/resource/images/key-window/scroll_button_up_pushed.png new file mode 100644 index 0000000000..6c510c132e Binary files /dev/null and b/tizen/src/skin/client/resource/images/key-window/scroll_button_up_pushed.png differ diff --git a/tizen/src/skin/client/resource/images/key-window/scroll_thumb.png b/tizen/src/skin/client/resource/images/key-window/scroll_thumb.png new file mode 100644 index 0000000000..b33ca1fbdf Binary files /dev/null and b/tizen/src/skin/client/resource/images/key-window/scroll_thumb.png differ diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/custom/CustomButton.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/custom/CustomButton.java index aad16e1760..4627f5fb72 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/custom/CustomButton.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/custom/CustomButton.java @@ -1,7 +1,7 @@ /** + * Image Button * - * - * Copyright ( C ) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved. + * Copyright ( C ) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved. * * Contact: * GiWoong Kim diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/custom/CustomScrollBar.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/custom/CustomScrollBar.java new file mode 100644 index 0000000000..12d73a1ea7 --- /dev/null +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/custom/CustomScrollBar.java @@ -0,0 +1,226 @@ +/** + * + * + * Copyright ( C ) 2013 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * GiWoong Kim + * YeongKyoon Lee + * + * 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.custom; + +import java.util.Timer; +import java.util.TimerTask; +import java.util.logging.Logger; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.MouseEvent; +import org.eclipse.swt.events.MouseListener; +import org.eclipse.swt.events.PaintEvent; +import org.eclipse.swt.events.PaintListener; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.layout.RowData; +import org.eclipse.swt.layout.RowLayout; +import org.eclipse.swt.widgets.Canvas; +import org.eclipse.swt.widgets.Composite; +import org.tizen.emulator.skin.log.SkinLogger; + + +public class CustomScrollBar { + static final int SCROLL_SHIFT_LENGTH = 10; + + private Logger logger = SkinLogger.getSkinLogger( + CustomScrollBar.class).getLogger(); + + private Composite parent; + private Composite composite; + CustomScrolledComposite compositeScroll; + + private int heightScrollBar; + private int maxShift; + + private Image[] imagesArrowUp; + private Image[] imagesArrowDown; + private Image imageThumb; + private Image imageShaft; + + private CustomButton buttonArrowUp; + private CustomButton buttonArrowDown; + private Canvas canvasShaft; + private CustomButton buttonThumb; + + private int valueSelection; + private Timer timerScroller; + private TimerTask scroller; + + CustomScrollBar(Composite parent, int style, int heightScrollBar, + Image[] imagesArrowUp, Image[] imagesArrowDown, + Image imageThumb, Image imageShaft) { + this.parent = parent; + this.composite = new Composite(parent, SWT.NONE); + this.compositeScroll = ((CustomScrolledComposite) parent.getParent()); + + RowLayout rowLayout = new RowLayout(SWT.VERTICAL); + rowLayout.marginLeft = rowLayout.marginRight = 0; + rowLayout.marginTop = rowLayout.marginBottom = 0; + rowLayout.marginWidth = rowLayout.marginHeight = 0; + rowLayout.spacing = 0; + + composite.setLayout(rowLayout); + + this.heightScrollBar = heightScrollBar; + this.maxShift = SCROLL_SHIFT_LENGTH; + + this.imagesArrowUp = imagesArrowUp; + this.imagesArrowDown = imagesArrowDown; + this.imageThumb = imageThumb; + this.imageShaft = imageShaft; + + //this.timerScroller = new Timer(); + + createContents(); + + addScrollBarListener(); + } + + protected void createContents() { + /* arrow up */ + buttonArrowUp = new CustomButton(composite, SWT.NONE, + imagesArrowUp[0], imagesArrowUp[1], imagesArrowUp[2]); + + int width = buttonArrowUp.getImageSize().x; + int height = buttonArrowUp.getImageSize().y; + + buttonArrowUp.setBackground(parent.getBackground()); + buttonArrowUp.setLayoutData(new RowData(width, height)); + + /* shaft */ + canvasShaft = new Canvas(composite, SWT.NONE); + + final int widthShaft = width; + final int heightShaft = heightScrollBar - (height * 2); + canvasShaft.setLayoutData(new RowData(widthShaft, heightShaft)); + + canvasShaft.addPaintListener(new PaintListener() { + @Override + public void paintControl(PaintEvent e) { + if (imageShaft != null) { + e.gc.drawImage(imageShaft, 0, 0, + imageShaft.getImageData().width, + imageShaft.getImageData().height, + 0, 0, widthShaft, heightShaft); + } + } + }); + + /* arrow down */ + buttonArrowDown = new CustomButton(composite, SWT.NONE, + imagesArrowDown[0], imagesArrowDown[1], imagesArrowDown[2]); + + buttonArrowDown.setBackground(parent.getBackground()); + buttonArrowDown.setLayoutData(new RowData(width, height)); + } + + class ScrollerTask extends TimerTask { + @Override + public void run() { + int vSelection = getSelection(); + if (vSelection <= (173 - heightScrollBar - 1)) { + setSelection(getSelection() + 1); + logger.info("" + getSelection()); + +// Display.getCurrent().asyncExec(new Runnable() { +// @Override +// public void run() { + //compositeScroll.vScroll(); +// } +// }); + } + } + } + + protected void addScrollBarListener() { + buttonArrowUp.addMouseListener(new MouseListener() { + @Override + public void mouseDown(MouseEvent e) { + int shift = getSelection(); + + if (shift > 0) { + setSelection(getSelection() - Math.min(maxShift, shift)); + ((CustomScrolledComposite) parent.getParent()).vScroll(); + } + } + + @Override + public void mouseUp(MouseEvent e) { + /* do nothing */ + } + + @Override + public void mouseDoubleClick(MouseEvent e) { + /* do nothing */ + } + }); + + buttonArrowDown.addMouseListener(new MouseListener() { + @Override + public void mouseDown(MouseEvent e) { + int minHeightContents = + ((CustomScrolledComposite) parent.getParent()).getMinHeight(); + + int shift = (minHeightContents - heightScrollBar) - getSelection(); + + if (shift > 0) { + setSelection(getSelection() + Math.min(maxShift, shift)); + ((CustomScrolledComposite) parent.getParent()).vScroll(); + } + } + + @Override + public void mouseUp(MouseEvent e) { + timerScroller.cancel(); + timerScroller = new Timer(); + } + + @Override + public void mouseDoubleClick(MouseEvent e) { + /* do nothing */ + } + }); + +// buttonArrowDown.addDragDetectListener(new DragDetectListener() { +// @Override +// public void dragDetected( DragDetectEvent e ) { +// logger.info( "dragDetected:" + e.button ); +// timerScroller.schedule(new ScrollerTask(), 1, 100); +// } +// }); + } + + public int getSelection() { + return valueSelection; + } + + public void setSelection(int selection) { + valueSelection = selection; + } +} diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/custom/CustomScrolledComposite.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/custom/CustomScrolledComposite.java new file mode 100644 index 0000000000..fc8abbcf63 --- /dev/null +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/custom/CustomScrolledComposite.java @@ -0,0 +1,178 @@ +/** + * + * + * Copyright ( C ) 2013 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * GiWoong Kim + * YeongKyoon Lee + * + * 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.custom; + +import java.util.logging.Logger; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Listener; +import org.tizen.emulator.skin.log.SkinLogger; + +public class CustomScrolledComposite extends Composite { + + private Logger logger = + SkinLogger.getSkinLogger(CustomScrolledComposite.class).getLogger(); + + Control content; + Listener contentListener; + Listener filter; + Point sizeContent; + + Composite compositeRight; + CustomScrollBar vBar; + + private Image[] imagesArrowUp; + private Image[] imagesArrowDown; + private Image imageThumb; + private Image imageShaft; + + public int minHeight = 0; + public int minWidth = 0; + public boolean expandHorizontal = false; + public boolean expandVertical = false; + + private int value; + + public CustomScrolledComposite(Composite parent, int style, + Image[] imagesArrowUp, Image[] imagesArrowDown, + Image imageThumb, Image imageShaft) { + super(parent, style); + super.setLayout(new ScrolledCompositeLayout()); + + compositeRight = new Composite(this, SWT.NONE); + compositeRight.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_YELLOW)); + + GridLayout compositeGridLayout = new GridLayout(1, false); + compositeGridLayout.marginLeft = compositeGridLayout.marginRight = 0; + compositeGridLayout.marginTop = compositeGridLayout.marginBottom = 0; + compositeGridLayout.marginWidth = compositeGridLayout.marginHeight = 0; + compositeGridLayout.horizontalSpacing = compositeGridLayout.verticalSpacing = 0; + compositeRight.setLayout(compositeGridLayout); + + this.imagesArrowUp = imagesArrowUp; + this.imagesArrowDown = imagesArrowDown; + this.imageThumb = imageThumb; + this.imageShaft = imageShaft; + + value = 0; + } + + public CustomScrollBar getScrollBar() { + return vBar; + } + + public void setContent(Control content, Point sizeContent) { + checkWidget(); + if (this.content != null && !this.content.isDisposed()) { + this.content.removeListener(SWT.Resize, contentListener); + this.content.setBounds(new Rectangle(-200, -200, 0, 0)); + } + + this.content = content; + this.sizeContent = sizeContent; + + if (this.content != null) { + if (vBar == null) { + compositeRight.setBackground(this.content.getBackground()); + vBar = new CustomScrollBar(compositeRight, SWT.NONE, sizeContent.y, + imagesArrowUp, imagesArrowDown, imageThumb, imageShaft); + } + + content.setLocation(0, 0); + + layout(false); + + } + } + + public void setExpandHorizontal(boolean expand) { + checkWidget(); + if (expand == expandHorizontal) return; + expandHorizontal = expand; + layout(false); + } + + public void setExpandVertical(boolean expand) { + checkWidget(); + if (expand == expandVertical) return; + expandVertical = expand; + layout(false); + } + + public void setMinSize(Point size) { + if (size == null) { + setMinSize(0, 0); + } else { + setMinSize(size.x, size.y); + } + } + + public void setMinSize(int width, int height) { + checkWidget(); + if (width == minWidth && height == minHeight) { + return; + } + + minWidth = Math.max(0, width); + minHeight = Math.max(0, height); + + logger.info("composite minWidth : " + minWidth + + ", minHeight : " + minHeight); + + layout(false); + } + + public int getMinWidth() { + checkWidget(); + return minWidth; + } + + public int getMinHeight() { + checkWidget(); + return minHeight; + } + + public void vScroll() { + if (content == null) { + return; + } + + Point location = content.getLocation(); + int vSelection = vBar.getSelection(); + + content.setLocation(location.x, -vSelection); + } +} \ No newline at end of file diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/custom/CustomScrolledCompositeLayout.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/custom/CustomScrolledCompositeLayout.java new file mode 100644 index 0000000000..c63ced2c7f --- /dev/null +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/custom/CustomScrolledCompositeLayout.java @@ -0,0 +1,101 @@ +/** + * + * + * Copyright ( C ) 2013 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * GiWoong Kim + * YeongKyoon Lee + * + * 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.custom; + +import java.util.logging.Logger; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Layout; +import org.tizen.emulator.skin.log.SkinLogger; + +class ScrolledCompositeLayout extends Layout { + static final int DEFAULT_WIDTH = 64; + static final int DEFAULT_HEIGHT = 64; + + private Logger logger = SkinLogger.getSkinLogger( + ScrolledCompositeLayout.class).getLogger(); + + private boolean inLayout = false; + + protected Point computeSize(Composite composite, int wHint, int hHint, boolean flushCache) { + CustomScrolledComposite sc = (CustomScrolledComposite)composite; + Point size = new Point(DEFAULT_WIDTH, DEFAULT_HEIGHT); + + if (sc.content != null) { + Point preferredSize = sc.content.computeSize(wHint, hHint, flushCache); + size.x = preferredSize.x; + size.y = preferredSize.y; + } + size.x = Math.max(size.x, sc.minWidth); + size.y = Math.max(size.y, sc.minHeight); + + if (wHint != SWT.DEFAULT) size.x = wHint; + if (hHint != SWT.DEFAULT) size.y = hHint; + + return size; + } + + protected boolean flushCache(Control control) { + return true; + } + + protected void layout(Composite composite, boolean flushCache) { + if (inLayout) { + return; + } + + CustomScrolledComposite sc = (CustomScrolledComposite)composite; + if (sc.content == null) { + return; + } + + inLayout = true; + Rectangle contentRect = sc.content.getBounds(); + + Rectangle hostRect = sc.getClientArea(); + if (sc.expandHorizontal) { + contentRect.width = Math.max(sc.minWidth, hostRect.width); + } + if (sc.expandVertical) { + contentRect.height = Math.max(sc.minHeight, hostRect.height); + } + + sc.content.setBounds(contentRect); + + Point size = sc.compositeRight.computeSize(SWT.DEFAULT, SWT.DEFAULT); + sc.compositeRight.setBounds( + contentRect.width - size.x, 0, size.x, contentRect.height); + + inLayout = false; + } +} diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/custom/KeyWindow.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/custom/KeyWindow.java index 02c8227382..ee1f86ce92 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/custom/KeyWindow.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/custom/KeyWindow.java @@ -69,13 +69,22 @@ public class KeyWindow extends SkinWindow { private static final int PAIRTAG_MARGIN_BOTTOM = 6; private static final int BUTTON_DEFAULT_CNT = 4; private static final int BUTTON_VERTICAL_SPACING = 7; + private static final int SCROLLBAR_HORIZONTAL_SPACING = 4; + private static final int SCROLLBAR_SIZE_WIDTH = 14; private EmulatorSkin skin; private SkinPatches frameMaker; + + private int widthBase; + private int heightBase; + private int widthScrollbar; + private int cntHiddenButton; + private Image imageNormal; /* ImageButton image */ private Image imageHover; /* hovered ImageButton image */ private Image imagePushed; /* pushed ImageButton image */ private Image imageFrame; /* nine-patch image */ + private Color colorFrame; private Color colorPairTag; private SocketCommunicator communicator; @@ -98,7 +107,7 @@ public class KeyWindow extends SkinWindow { this.frameMaker = new SkinPatches(PATCH_IMAGES_PATH); this.colorPairTag = colorPairTag; - this.keyMapList = keyMapList; + this.keyMapList = keyMapList; //TODO: null this.communicator = communicator; this.grabPosition = new Point(0, 0); @@ -114,25 +123,27 @@ public class KeyWindow extends SkinWindow { KeyWindowImageName.KEYBUTTON_PUSHED); /* calculate the key window size */ - int width = imageNormal.getImageData().width; - int height = (imageNormal.getImageData().height * BUTTON_DEFAULT_CNT) + - (BUTTON_VERTICAL_SPACING * (BUTTON_DEFAULT_CNT - 1)) + - (PAIRTAG_CIRCLE_SIZE + PAIRTAG_MARGIN_BOTTOM) + - SHELL_MARGIN_BOTTOM; + widthBase = imageNormal.getImageData().width; + heightBase = (imageNormal.getImageData().height * BUTTON_DEFAULT_CNT) + + (BUTTON_VERTICAL_SPACING * (BUTTON_DEFAULT_CNT - 1)); + + widthScrollbar = SCROLLBAR_SIZE_WIDTH + SCROLLBAR_HORIZONTAL_SPACING; + int heightHeaderPart = (PAIRTAG_CIRCLE_SIZE + PAIRTAG_MARGIN_BOTTOM); + int heightTailPart = SHELL_MARGIN_BOTTOM; /* make a frame image */ - this.imageFrame = frameMaker.getPatchedImage(width, height); + this.cntHiddenButton = 0; //keyMapList.size() - BUTTON_DEFAULT_CNT; + + this.imageFrame = frameMaker.getPatchedImage( + widthBase + ((cntHiddenButton > 0) ? widthScrollbar : 0), + heightBase + heightHeaderPart + heightTailPart); this.colorFrame = new Color(shell.getDisplay(), new RGB(38, 38, 38)); -// /* generate a pair tag color of key window */ -// int red = (int) (Math.random() * 256); -// int green = (int) (Math.random() * 256); -// int blue = (int) (Math.random() * 256); -// this.colorPairTag = new Color(shell.getDisplay(), new RGB(red, green, blue)); this.colorPairTag = colorPairTag; createContents(); trimPatchedShell(shell, imageFrame); + addKeyWindowListener(); shell.setBackground(colorFrame); @@ -143,7 +154,8 @@ public class KeyWindow extends SkinWindow { protected void createContents() { GridLayout shellGridLayout = new GridLayout(1, false); shellGridLayout.marginLeft = shellGridLayout.marginRight = frameMaker.getPatchWidth(); - shellGridLayout.marginTop = shellGridLayout.marginBottom = frameMaker.getPatchHeight(); + shellGridLayout.marginTop = frameMaker.getPatchHeight(); + shellGridLayout.marginBottom = frameMaker.getPatchHeight() + SHELL_MARGIN_BOTTOM; shellGridLayout.marginWidth = shellGridLayout.marginHeight = 0; shellGridLayout.horizontalSpacing = shellGridLayout.verticalSpacing = 0; @@ -166,12 +178,65 @@ public class KeyWindow extends SkinWindow { } }); - /* */ - ScrolledComposite compositeScroll = new ScrolledComposite(shell, SWT.V_SCROLL); - compositeScroll.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, true, true, 1, 1)); + /* make a region of HW keys */ + if (cntHiddenButton > 0) { + /* added custom scrollbar */ + + Image imagesScrollArrowUp[] = new Image[3]; + Image imagesScrollArrowDown[] = new Image[3]; + + imagesScrollArrowUp[0] = skin.getImageRegistry().getKeyWindowImageData( + KeyWindowImageName.SCROLL_UPBUTTON_NORMAL); + imagesScrollArrowUp[1] = skin.getImageRegistry().getKeyWindowImageData( + KeyWindowImageName.SCROLL_UPBUTTON_HOVER); + imagesScrollArrowUp[2] = skin.getImageRegistry().getKeyWindowImageData( + KeyWindowImageName.SCROLL_UPBUTTON_PUSHED); + + imagesScrollArrowDown[0] = skin.getImageRegistry().getKeyWindowImageData( + KeyWindowImageName.SCROLL_DOWNBUTTON_NORMAL); + imagesScrollArrowDown[1] = skin.getImageRegistry().getKeyWindowImageData( + KeyWindowImageName.SCROLL_DOWNBUTTON_HOVER); + imagesScrollArrowDown[2] = skin.getImageRegistry().getKeyWindowImageData( + KeyWindowImageName.SCROLL_DOWNBUTTON_PUSHED); + + CustomScrolledComposite compositeScroll = + new CustomScrolledComposite(shell, SWT.NONE, + imagesScrollArrowUp, imagesScrollArrowDown, + skin.getImageRegistry().getKeyWindowImageData( + KeyWindowImageName.SCROLL_THUMB), + skin.getImageRegistry().getKeyWindowImageData( + KeyWindowImageName.SCROLL_SHAFT)); + compositeScroll.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, true, true, 1, 1)); + + Composite compositeBase = new Composite(compositeScroll, SWT.NONE); + + createHwKeys(compositeBase); + + Point sizeContent = compositeBase.computeSize( + widthBase + widthScrollbar, heightBase); + compositeScroll.setContent(compositeBase, sizeContent); + compositeScroll.setExpandHorizontal(true); + compositeScroll.setExpandVertical(true); + + sizeContent.y += (imageNormal.getImageData().height * cntHiddenButton) + + (BUTTON_VERTICAL_SPACING * cntHiddenButton); + compositeScroll.setMinSize(sizeContent); + } else { + ScrolledComposite compositeScroll = new ScrolledComposite(shell, SWT.V_SCROLL); + compositeScroll.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, true, true, 1, 1)); + + Composite compositeBase = new Composite(compositeScroll, SWT.NONE); + createHwKeys(compositeBase); + + compositeScroll.setContent(compositeBase); + compositeScroll.setExpandHorizontal(true); + compositeScroll.setExpandVertical(true); + compositeScroll.setMinSize(compositeBase.computeSize(SWT.DEFAULT, SWT.DEFAULT)); + } + } - Composite compositeBase = new Composite(compositeScroll, SWT.NONE); - compositeBase.setBackground(colorFrame); + protected void createHwKeys(Composite composite) { + composite.setBackground(colorFrame); GridLayout compositeGridLayout = new GridLayout(1, false); compositeGridLayout.marginLeft = compositeGridLayout.marginRight = 0; @@ -179,12 +244,12 @@ public class KeyWindow extends SkinWindow { compositeGridLayout.marginWidth = compositeGridLayout.marginHeight = 0; compositeGridLayout.horizontalSpacing = 0; compositeGridLayout.verticalSpacing = BUTTON_VERTICAL_SPACING; - compositeBase.setLayout(compositeGridLayout); + composite.setLayout(compositeGridLayout); /* attach HW keys */ if (keyMapList != null && keyMapList.isEmpty() == false) { for (KeyMapType keyEntry : keyMapList) { - CustomButton HWKeyButton = new CustomButton(compositeBase, + CustomButton HWKeyButton = new CustomButton(composite, SWT.NO_FOCUS, imageNormal, imageHover, imagePushed); HWKeyButton.setText(keyEntry.getEventInfo().getKeyName()); HWKeyButton.setToolTipText(keyEntry.getTooltip()); @@ -215,11 +280,6 @@ public class KeyWindow extends SkinWindow { }); } } - - compositeScroll.setContent(compositeBase); - compositeScroll.setExpandHorizontal(true); - compositeScroll.setExpandVertical(true); - compositeScroll.setMinSize(compositeBase.computeSize(SWT.DEFAULT, SWT.DEFAULT)); } public static void trimPatchedShell(Shell shell, Image image) { diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/image/ImageRegistry.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/image/ImageRegistry.java index 2eab2be061..d7623f82ed 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/image/ImageRegistry.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/image/ImageRegistry.java @@ -109,7 +109,16 @@ public class ImageRegistry { public enum KeyWindowImageName { KEYBUTTON_NORMAL("keybutton_nml.png"), KEYBUTTON_HOVER("keybutton_hover.png"), - KEYBUTTON_PUSHED("keybutton_pushed.png"); + KEYBUTTON_PUSHED("keybutton_pushed.png"), + + SCROLL_UPBUTTON_NORMAL("scroll_button_up_nml.png"), + SCROLL_UPBUTTON_HOVER("scroll_button_up_hover.png"), + SCROLL_UPBUTTON_PUSHED("scroll_button_up_pushed.png"), + SCROLL_DOWNBUTTON_NORMAL("scroll_button_down_nml.png"), + SCROLL_DOWNBUTTON_HOVER("scroll_button_down_hover.png"), + SCROLL_DOWNBUTTON_PUSHED("scroll_button_down_pushed.png"), + SCROLL_THUMB("scroll_thumb.png"), + SCROLL_SHAFT("scroll_back.png"); private String name;