skin: added thumb to CustomScrollbar
authorgiwoong.kim <giwoong.kim@samsung.com>
Mon, 10 Jun 2013 12:45:31 +0000 (21:45 +0900)
committergiwoong.kim <giwoong.kim@samsung.com>
Mon, 10 Jun 2013 12:45:31 +0000 (21:45 +0900)
added thumb to CustomScrollbar

Change-Id: I8c94f825691ab7c45a1b3e40d0292fb21b7074b5
Signed-off-by: GiWoong Kim <giwoong.kim@samsung.com>
tizen/src/skin/client/src/org/tizen/emulator/skin/custom/CustomScrollBar.java

index 1ce54a80081f6401a23a076de61979053453749a..c6eedd89f608a6a5cd60af3ca5cca6a0542fc65d 100644 (file)
@@ -38,11 +38,14 @@ import org.eclipse.swt.events.MouseListener;
 import org.eclipse.swt.events.MouseWheelListener;
 import org.eclipse.swt.events.PaintEvent;
 import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.graphics.Color;
 import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.RGB;
 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.eclipse.swt.widgets.Display;
 import org.tizen.emulator.skin.log.SkinLogger;
 
 
@@ -129,6 +132,21 @@ public class CustomScrollBar {
                                                        imageShaft.getImageData().width,
                                                        imageShaft.getImageData().height,
                                                        0, 0, widthShaft, heightShaft);
+
+                                       /* draw a thumb */
+                                       e.gc.setBackground(new Color(Display.getDefault(), new RGB(80, 80, 80)));
+
+                                       int heightScrollGap = compositeScroll.getMinHeight() - heightScrollBar;
+
+                                       float tempHeightThumb = (compositeScroll.getMinHeight() - heightScrollGap) *
+                                                       heightShaft / compositeScroll.getMinHeight();
+                                       int heightThumb = Math.max(1, (int)tempHeightThumb);
+
+                                       int xThumb = 2;
+                                       int yThumb = getSelection() * (heightShaft - heightThumb) / heightScrollGap;
+
+                                       e.gc.fillRectangle(xThumb, yThumb,
+                                                       widthShaft - (xThumb * 2), heightThumb);
                                }
                        }
                });
@@ -165,18 +183,18 @@ public class CustomScrollBar {
                if (amountRemaining > 0) {
                        setSelection(getSelection() - Math.min(amount, amountRemaining));
                        compositeScroll.vScroll();
+                       canvasShaft.redraw();
                }
        }
 
        private void scrollDown(int amount) {
-               int minHeightContents =
-                               ((CustomScrolledComposite) parent.getParent()).getMinHeight();
-
+               int minHeightContents = compositeScroll.getMinHeight();
                int amountRemaining = (minHeightContents - heightScrollBar) - getSelection();
 
                if (amountRemaining > 0) {
                        setSelection(getSelection() + Math.min(amount, amountRemaining));
                        compositeScroll.vScroll();
+                       canvasShaft.redraw();
                }
        }