> home > Custom Layer Boundary API

view_pos_at_relative_xy

September 8th 2024
Compute a byte position at a particular point relative to the top left corner of a particular line

Signature

C++
i64
view_pos_at_relative_xy(Application_Links* app,
                        View_ID view_id,
                        i64 base_line,
                        Vec2_f32 relative_xy);

Parameters

app

the standard custom layer context pointer

view_id

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

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 view exists and contains the line, zero otherwise

Details

Line numbers are 1 based.
Equivalent to calling the buffer related function of the same name by deriving the buffer, width, and face from the view.