Revision: 2532
http://sourceforge.net/p/swingme/code/2532
Author: yuranet
Date: 2021-07-09 15:36:46 +0000 (Fri, 09 Jul 2021)
Log Message:
-----------
allow drawing of thinner slider track
Modified Paths:
--------------
SwingME/src/net/yura/mobile/gui/components/Slider.java
Modified: SwingME/src/net/yura/mobile/gui/components/Slider.java
===================================================================
--- SwingME/src/net/yura/mobile/gui/components/Slider.java 2021-07-09 15:26:45 UTC (rev 2531)
+++ SwingME/src/net/yura/mobile/gui/components/Slider.java 2021-07-09 15:36:46 UTC (rev 2532)
@@ -382,8 +382,14 @@
protected void workoutMinimumSize() {
Border track = getTrack();
+ int thickness = (track != null) ? track.getTop() + track.getBottom() : 0;
- int thickness = (track != null) ? track.getTop() + track.getBottom() : 0;
+ Border thumb = getThumb();
+ // if we do have a track, but thumb is bigger, take size of thumb
+ if (thickness > 1 && (thumb.getTop() + thumb.getBottom()) > thickness) {
+ thickness = thumb.getTop() + thumb.getBottom();
+ }
+
if (paintTicks) {
thickness = thickness + tickSpace;
}
@@ -519,6 +525,7 @@
}
}
+ int thumbHeight = thumb == null ? 0 : thumb.getTop() + thumb.getBottom();
// DRAW ARROWS
//,\xB8\xB8,\xF8\xA4\xBA\xB0``\xB0\xBA\xA4\xF8,\xB8\xB8,\xF8\xA4\xBA\xB0``\xB0\xBA\xA4\xF8,\xB8\xB8,\xF8\xA4\xBA\xB0``\xB0\xBA\xA4\xF8,\xB8\xB8,\xF8\xA4\xBA\xB0``\xB0\xBA\xA4\xF8,\xB8\xB8,\xF8\xA4\xBA\xB0``\xB0\xBA\xA4\xF8,\xB8\xB8,
@@ -525,9 +532,20 @@
if (track!=null) {
- g.translate(x+track.getLeft(), y+track.getTop());
- track.paintBorder(this, g, w-track.getLeft()-track.getRight(), h-track.getTop()-track.getBottom());
- g.translate(-x-track.getLeft(), -y-track.getTop());
+ int trackHeight = track.getTop() + track.getBottom();
+
+ // if the thumb is bigger then the track, just draw track in the middle
+ if (thumbHeight > trackHeight) {
+ int offset = (h - trackHeight) / 2;
+ g.translate(x + track.getLeft(), y + track.getTop() + offset);
+ track.paintBorder(this, g, w - track.getLeft() - track.getRight(), 0);
+ g.translate(-x - track.getLeft(), -y - track.getTop() - offset);
+ }
+ else {
+ g.translate(x + track.getLeft(), y + track.getTop());
+ track.paintBorder(this, g, w - track.getLeft() - track.getRight(), h - trackHeight);
+ g.translate(-x - track.getLeft(), -y - track.getTop());
+ }
/*
int x1 = x + (w-trackTop.getIconWidth())/2;
trackTop.paintIcon(this, g, x1, y);
@@ -546,11 +564,11 @@
if (thumb!=null) {
- int y1 = y + (h-thumb.getTop()-thumb.getBottom())/2;
+ int y1 = y + (h-thumbHeight)/2;
// this does the floating scrollbars
- if (y1+thumb.getTop()+thumb.getBottom() > y+h) {
- y1 = y+h -thumb.getTop()-thumb.getBottom();
+ if (y1+thumbHeight > y+h) {
+ y1 = y+h -thumbHeight;
}
g.translate(startX+thumb.getLeft(), y1+thumb.getTop());
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|