mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-15 16: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 ) {
|
if( slider.getOrientation() == JSlider.HORIZONTAL ) {
|
||||||
float y = trackRect.y + (trackRect.height - tw) / 2f;
|
float y = trackRect.y + (trackRect.height - tw) / 2f;
|
||||||
if( enabled && isRoundThumb() ) {
|
if( enabled && isRoundThumb() ) {
|
||||||
|
if( slider.getComponentOrientation().isLeftToRight() ) {
|
||||||
int cw = thumbRect.x + (thumbRect.width / 2) - trackRect.x;
|
int cw = thumbRect.x + (thumbRect.width / 2) - trackRect.x;
|
||||||
coloredTrack = new RoundRectangle2D.Float( trackRect.x, y, cw, tw, arc, arc );
|
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 );
|
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
|
} else
|
||||||
track = new RoundRectangle2D.Float( trackRect.x, y, trackRect.width, tw, arc, arc );
|
track = new RoundRectangle2D.Float( trackRect.x, y, trackRect.width, tw, arc, arc );
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -74,11 +74,14 @@ public class FlatToolTipUI
|
|||||||
List<String> lines = FlatLaf.split( ((JToolTip)c).getTipText(), '\n' );
|
List<String> lines = FlatLaf.split( ((JToolTip)c).getTipText(), '\n' );
|
||||||
|
|
||||||
int x = insets.left;
|
int x = insets.left;
|
||||||
|
int x2 = c.getWidth() - insets.right;
|
||||||
int y = insets.top - fm.getDescent();
|
int y = insets.top - fm.getDescent();
|
||||||
int lineHeight = fm.getHeight();
|
int lineHeight = fm.getHeight();
|
||||||
|
JComponent comp = ((JToolTip)c).getComponent();
|
||||||
|
boolean leftToRight = (comp != null ? comp : c).getComponentOrientation().isLeftToRight();
|
||||||
for( String line : lines ) {
|
for( String line : lines ) {
|
||||||
y += lineHeight;
|
y += lineHeight;
|
||||||
g.drawString( line, x, y );
|
g.drawString( line, leftToRight ? x : x2 - SwingUtilities.computeStringWidth( fm, line ), y );
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
super.paint( g, c );
|
super.paint( g, c );
|
||||||
|
|||||||
Reference in New Issue
Block a user