> home > Custom Layer Boundary API

buffer_pos_at_relative_xy

January 19th 2020
Compute a byte position at a particular point relative to the top left corner of a particular line

Signature

C++
i64
buffer_pos_at_relative_xy(Application_Links* app,
                          Buffer_ID buffer_id,
                          f32 width,
                          Face_ID face_id,
                          i64 base_line,
                          Vec2_f32 relative_xy);

Parameters

app

the standard custom layer context pointer

buffer_id

the id of the buffer who's layout will be measured

width

the width parameter of the layout, passed to layout rules as a recommended wrap point

face_id

the face parameter of the layout, passed to layout rules as a recommended face

base_line

the line number of the line that serves as the relative starting point of the measurement

relative_xy

the point, in pixels, interpreted relative to the line's top left corner, that will serve as the query point

Return

the byte index associated as the first byte of a character in the layout that is the closest to containing the query point on success, when the buffer exists and contains the line, zero otherwise

Details

Line numbers are 1 based.