Search in sources :

Example 6 with TypedLayout

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);
}
Also used : TypedLayout(limelight.ui.text.TypedLayout)

Example 7 with TypedLayout

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;
}
Also used : TypedLayout(limelight.ui.text.TypedLayout)

Example 8 with TypedLayout

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;
}
Also used : TypedLayout(limelight.ui.text.TypedLayout) Box(limelight.util.Box) TextLocation(limelight.ui.text.TextLocation)

Example 9 with TypedLayout

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;
}
Also used : TypedLayout(limelight.ui.text.TypedLayout) ArrayList(java.util.ArrayList) Box(limelight.util.Box) TextLocation(limelight.ui.text.TextLocation)

Example 10 with TypedLayout

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());
}
Also used : TypedLayout(limelight.ui.text.TypedLayout)

Aggregations

TypedLayout (limelight.ui.text.TypedLayout)13 TextLocation (limelight.ui.text.TextLocation)7 Box (limelight.util.Box)3 ArrayList (java.util.ArrayList)1 Style (limelight.styles.Style)1