mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-11 06:27:13 -06:00
right-to-left fixes:
-Slider: colored track (if ticks and labels are hidden) was on the left side of the thumb - ToolTip: multi-line text was not aligned to the right (issue #18)
This commit is contained in:
@@ -170,9 +170,15 @@ public class FlatSliderUI
|
||||
if( slider.getOrientation() == JSlider.HORIZONTAL ) {
|
||||
float y = trackRect.y + (trackRect.height - tw) / 2f;
|
||||
if( enabled && isRoundThumb() ) {
|
||||
int cw = thumbRect.x + (thumbRect.width / 2) - trackRect.x;
|
||||
coloredTrack = new RoundRectangle2D.Float( trackRect.x, y, cw, tw, arc, arc );
|
||||
track = new RoundRectangle2D.Float( trackRect.x + cw, y, trackRect.width - cw, tw, arc, arc );
|
||||
if( slider.getComponentOrientation().isLeftToRight() ) {
|
||||
int cw = thumbRect.x + (thumbRect.width / 2) - trackRect.x;
|
||||
coloredTrack = new RoundRectangle2D.Float( trackRect.x, y, cw, tw, arc, arc );
|
||||
track = new RoundRectangle2D.Float( trackRect.x + cw, y, trackRect.width - cw, tw, arc, arc );
|
||||
} else {
|
||||
int cw = trackRect.x + trackRect.width - thumbRect.x - (thumbRect.width / 2);
|
||||
coloredTrack = new RoundRectangle2D.Float( trackRect.x + trackRect.width - cw, y, cw, tw, arc, arc );
|
||||
track = new RoundRectangle2D.Float( trackRect.x, y, trackRect.width - cw, tw, arc, arc );
|
||||
}
|
||||
} else
|
||||
track = new RoundRectangle2D.Float( trackRect.x, y, trackRect.width, tw, arc, arc );
|
||||
} else {
|
||||
|
||||
@@ -74,11 +74,14 @@ public class FlatToolTipUI
|
||||
List<String> lines = FlatLaf.split( ((JToolTip)c).getTipText(), '\n' );
|
||||
|
||||
int x = insets.left;
|
||||
int x2 = c.getWidth() - insets.right;
|
||||
int y = insets.top - fm.getDescent();
|
||||
int lineHeight = fm.getHeight();
|
||||
JComponent comp = ((JToolTip)c).getComponent();
|
||||
boolean leftToRight = (comp != null ? comp : c).getComponentOrientation().isLeftToRight();
|
||||
for( String line : lines ) {
|
||||
y += lineHeight;
|
||||
g.drawString( line, x, y );
|
||||
g.drawString( line, leftToRight ? x : x2 - SwingUtilities.computeStringWidth( fm, line ), y );
|
||||
}
|
||||
} else
|
||||
super.paint( g, c );
|
||||
|
||||
Reference in New Issue
Block a user