From: giwoong.kim Date: Mon, 10 Jun 2013 12:45:31 +0000 (+0900) Subject: skin: added thumb to CustomScrollbar X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.1~961^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2025fa3e3775cfdce2cb2265023d5187bf7e2814;p=sdk%2Femulator%2Fqemu.git skin: added thumb to CustomScrollbar added thumb to CustomScrollbar Change-Id: I8c94f825691ab7c45a1b3e40d0292fb21b7074b5 Signed-off-by: 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 index 1ce54a8008..c6eedd89f6 100644 --- 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 @@ -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(); } }