use of limelight.ui.text.TypedLayout in project limelight by slagyr.
the class SingleLineTextModel method getLocationAt.
@Override
public TextLocation getLocationAt(Point point) {
TypedLayout layout = getLine();
int index = layout.getIndexAt(point.x - getXOffset());
return TextLocation.at(0, index);
}
use of limelight.ui.text.TypedLayout in project limelight by slagyr.
the class TextModel method getAbsoluteY.
public int getAbsoluteY(TextLocation location) {
int height = 0;
for (int i = 0; i < location.line; i++) {
TypedLayout layout = getLines().get(i);
height += layout.getHeightWithLeading();
}
return height;
}
use of limelight.ui.text.TypedLayout in project limelight by slagyr.
the class MultiLineTextModel method getCaretShape.
@Override
public Box getCaretShape() {
TextLocation caretLocation = getCaretLocation();
TypedLayout line = getLines().get(caretLocation.line);
Box caretShape = line.getCaretShape(caretLocation.index);
caretShape.translate(getXOffset(line), getY(caretLocation));
return caretShape;
}
use of limelight.ui.text.TypedLayout in project limelight by slagyr.
the class MultiLineTextModel method getSelectionRegions.
@Override
public ArrayList<Box> getSelectionRegions() {
ArrayList<Box> regions = new ArrayList<Box>();
boolean startsAtCaret = getCaretLocation().before(getSelectionLocation());
TextLocation start = startsAtCaret ? getCaretLocation() : getSelectionLocation();
TextLocation end = startsAtCaret ? getSelectionLocation() : getCaretLocation();
ArrayList<TypedLayout> lines = getLines();
int y = getY(start);
for (int i = start.line; i <= end.line; i++) {
TypedLayout line = lines.get(i);
int startX = i == start.line ? line.getX(start.index) + getXOffset(line) : 0;
int endX = i == end.line ? line.getX(end.index) + getXOffset(line) : getContainer().getWidth();
regions.add(new Box(startX, y, endX - startX, line.getHeight()));
y += line.getHeight() + line.getLeading();
}
return regions;
}
use of limelight.ui.text.TypedLayout in project limelight by slagyr.
the class MultiLineTextModel method getLocationAt.
@Override
public TextLocation getLocationAt(Point point) {
int remainingY = point.y - getYOffset();
ArrayList<TypedLayout> lines = getLines();
for (int lineNumber = 0; lineNumber < lines.size(); lineNumber++) {
TypedLayout line = lines.get(lineNumber);
int lineHeight = line.getHeight();
if (lineHeight > remainingY) {
int lineIndex = line.getIndexAt(point.x - getXOffset(line));
return TextLocation.at(lineNumber, lineIndex);
} else {
remainingY -= lineHeight;
}
}
return TextLocation.fromIndex(lines, getText().length());
}
Aggregations