Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

11855 Posts in 1569 Topics- by 3058 Members - Latest Member: xynewhand

12. February 2012, 01:42:18 AM
Xith3D CommunityGeneral CategoryFeature Requests & Brilliant Ideas (Moderators: Marvin Fröhlich, 'n ddrylliog)Slider improvements
Pages: [1]
Print
Author Topic: Slider improvements  (Read 1218 times)
elijah
Enjoying the stay
*
Offline Offline

Posts: 72


View Profile
« on: 22. June 2010, 09:03:52 AM »

I have done some improvement on the slider class and hope it can be included in the next released. Basically it controls the display of the ticks and the offset of the ticks in the slider.

Code:
public class Slider extends Widget {
 
        private boolean showMarking = true;
private int     MarkingOffset = 1;

@Override
protected void drawWidget(Texture2DCanvas texCanvas, int offsetX,
int offsetY, int width, int height, boolean drawsSelf) {
if (drawsSelf)
texCanvas.getImage().clear(offsetX, offsetY, width, height, true,
null);

int leftWidth = HUDTextureUtils.getTextureWidth(leftTex);
int rightWidth = HUDTextureUtils.getTextureWidth(rightTex);
int bodyWidth = width - leftWidth - rightWidth;

DrawUtils.drawImage(null, leftTex, null, texCanvas, offsetX, offsetY,
width, height);
DrawUtils.drawImage(null, bodyTex, TileMode.TILE_X, texCanvas, offsetX
+ leftWidth, offsetY, bodyWidth, height);
DrawUtils.drawImage(null, rightTex, null, texCanvas, offsetX + width
- rightWidth, offsetY, rightWidth, height);

if (showMarking == true) {
if (valueMarkTex != null) {
int valueMarkWidth = HUDTextureUtils
.getTextureWidth(valueMarkTex);
int valueMarkHeight = HUDTextureUtils
.getTextureHeight(valueMarkTex);

/* Eltekon
int n = getMaxValue() - getMinValue();
for (int i = 0; i <= n; i++) {
int pos = bodyWidth * i / n;

DrawUtils.drawImage(null, valueMarkTex, null, texCanvas,
offsetX + leftWidth + pos - (valueMarkWidth / 2)
- 1, offsetY + height - valueMarkHeight,
valueMarkWidth, valueMarkHeight);
}
*/

[color=red]int n = ( getMaxValue() - getMinValue() )/ MarkingOffset;[/color]
for (int i = 0; i <= n; i++) {
int pos = bodyWidth * i / n;

DrawUtils.drawImage(null, valueMarkTex, null, texCanvas,
offsetX + leftWidth + pos - (valueMarkWidth / 2)
- 1, offsetY + height - valueMarkHeight,
valueMarkWidth, valueMarkHeight);
}
}
}

if (getMaxValue() > getMinValue()) {
this.currentHandlePosPx = leftWidth
+ drawHandle(texCanvas, offsetX + leftWidth, offsetY, width
- leftWidth - rightWidth, height, handleTex,
isSliding ? forcedHandlePosPx - leftWidth : -1);
}
}



public void showMarking(boolean flag) {
showMarking = flag;
}

public void setMarkingDivider( int nDivider ){
MarkingOffset = nDivider;
}
}
« Last Edit: 22. June 2010, 09:06:52 AM by elijah » Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4337


May the 4th, be with you...


View Profile
« Reply #1 on: 30. July 2010, 07:51:41 AM »

Sorry. I forgot about this. I will apply it to the current source this weekend.

Do you want SVN dev access, if you don't already have?

Marvin
Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4337


May the 4th, be with you...


View Profile
« Reply #2 on: 23. September 2010, 08:08:39 PM »

Sorry for being "a little" late. But I have just applied your patch.

Marvin
Logged
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic